chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1470570 - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench: ./ model/ swing/
Date Mon, 22 Apr 2013 15:10:52 GMT
Author: fmui
Date: Mon Apr 22 15:10:51 2013
New Revision: 1470570

URL: http://svn.apache.org/r1470570
Log:
CMIS-506: Workbench: added mandatory property fields to create dialogs

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateFolderDialog.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateItemDialog.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateRelationshipDialog.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CreateDialog.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java?rev=1470570&r1=1470569&r2=1470570&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java
Mon Apr 22 15:10:51 2013
@@ -125,9 +125,13 @@ public class CreateDocumentDialog extend
                 } else {
                     versioningStateNoneButton.setSelected(true);
                 }
+                updateMandatoryFields(type);
             }
         });
 
+        ObjectTypeItem type = (ObjectTypeItem) typeBox.getSelectedItem();
+        updateMandatoryFields(type.getObjectType());
+
         createRow("Type:", typeBox, 2);
 
         JPanel filePanel = new JPanel(new BorderLayout());
@@ -175,7 +179,7 @@ public class CreateDocumentDialog extend
         });
         filePanel.add(browseButton, BorderLayout.LINE_END);
 
-        createRow("File:", filePanel, 3);
+        createRow("File:", filePanel, 4);
 
         JPanel generateContentPanel = new JPanel();
         generateContentPanel.setLayout(new BoxLayout(generateContentPanel, BoxLayout.X_AXIS));
@@ -194,7 +198,7 @@ public class CreateDocumentDialog extend
 
         generateContentPanel.add(Box.createHorizontalGlue());
 
-        createRow("Generate content:", generateContentPanel, 4);
+        createRow("Generate content:", generateContentPanel, 5);
 
         versioningStateNoneButton = new JRadioButton("none");
         versioningStateMajorButton = new JRadioButton("major");
@@ -218,10 +222,10 @@ public class CreateDocumentDialog extend
         } else {
             versioningStateNoneButton.setSelected(true);
         }
-        createRow("Versioning State:", versioningStatePanel, 5);
+        createRow("Versioning State:", versioningStatePanel, 6);
 
         verifyAfterUploadButton = new JCheckBox("Verify content after upload");
-        createRow("", verifyAfterUploadButton, 6);
+        createRow("", verifyAfterUploadButton, 7);
 
         JButton createButton = new JButton("Create Document", ClientHelper.getIcon("newdocument.png"));
         createButton.addActionListener(new ActionListener() {
@@ -245,8 +249,8 @@ public class CreateDocumentDialog extend
                     ObjectId objectId = null;
                     if (filename.length() > 0) {
                         // create a document from a file
-                        objectId = getClientModel().createDocument(name, type, filename,
versioningState,
-                                unfiledButton.isSelected());
+                        objectId = getClientModel().createDocument(name, type, filename,
getMandatoryPropertyValues(),
+                                versioningState, unfiledButton.isSelected());
 
                         if (verifyAfterUploadButton.isSelected()) {
                             ContentStream contentStream = getClientModel().createContentStream(filename);
@@ -264,8 +268,8 @@ public class CreateDocumentDialog extend
                             }
                         }
 
-                        objectId = getClientModel().createDocument(name, type, length, seed,
versioningState,
-                                unfiledButton.isSelected());
+                        objectId = getClientModel().createDocument(name, type, getMandatoryPropertyValues(),
length,
+                                seed, versioningState, unfiledButton.isSelected());
 
                         if (verifyAfterUploadButton.isSelected()) {
                             ContentStream contentStream = getClientModel().createContentStream("",
length, seed);
@@ -292,7 +296,7 @@ public class CreateDocumentDialog extend
                 }
             }
         });
-        createRow("", createButton, 7);
+        createActionRow("", createButton, 7);
 
         if (file != null) {
             setFile(file);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateFolderDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateFolderDialog.java?rev=1470570&r1=1470569&r2=1470570&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateFolderDialog.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateFolderDialog.java
Mon Apr 22 15:10:51 2013
@@ -22,6 +22,8 @@ import java.awt.Cursor;
 import java.awt.Frame;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 
 import javax.swing.JButton;
 import javax.swing.JComboBox;
@@ -29,6 +31,7 @@ import javax.swing.JOptionPane;
 import javax.swing.JTextField;
 
 import org.apache.chemistry.opencmis.client.api.ObjectId;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
 import org.apache.chemistry.opencmis.workbench.swing.CreateDialog;
@@ -60,6 +63,16 @@ public class CreateFolderDialog extends 
 
         typeBox = new JComboBox(types);
         typeBox.setSelectedIndex(0);
+        typeBox.addItemListener(new ItemListener() {
+            public void itemStateChanged(ItemEvent e) {
+                TypeDefinition type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType();
+                updateMandatoryFields(type);
+            }
+        });
+
+        ObjectTypeItem type = (ObjectTypeItem) typeBox.getSelectedItem();
+        updateMandatoryFields(type.getObjectType());
+
         createRow("Type:", typeBox, 1);
 
         JButton createButton = new JButton("Create Folder", ClientHelper.getIcon("newfolder.png"));
@@ -71,7 +84,7 @@ public class CreateFolderDialog extends 
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
-                    ObjectId objectId = getClientModel().createFolder(name, type);
+                    ObjectId objectId = getClientModel().createFolder(name, type, getMandatoryPropertyValues());
 
                     if (objectId != null) {
                         getClientModel().loadObject(objectId.getId());
@@ -92,7 +105,7 @@ public class CreateFolderDialog extends 
                 }
             }
         });
-        createRow("", createButton, 3);
+        createActionRow("", createButton, 3);
 
         getRootPane().setDefaultButton(createButton);
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateItemDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateItemDialog.java?rev=1470570&r1=1470569&r2=1470570&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateItemDialog.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateItemDialog.java
Mon Apr 22 15:10:51 2013
@@ -22,6 +22,8 @@ import java.awt.Cursor;
 import java.awt.Frame;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 
 import javax.swing.JButton;
 import javax.swing.JComboBox;
@@ -29,6 +31,7 @@ import javax.swing.JOptionPane;
 import javax.swing.JTextField;
 
 import org.apache.chemistry.opencmis.client.api.ObjectId;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
 import org.apache.chemistry.opencmis.workbench.swing.CreateDialog;
@@ -60,6 +63,16 @@ public class CreateItemDialog extends Cr
 
         typeBox = new JComboBox(types);
         typeBox.setSelectedIndex(0);
+        typeBox.addItemListener(new ItemListener() {
+            public void itemStateChanged(ItemEvent e) {
+                TypeDefinition type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType();
+                updateMandatoryFields(type);
+            }
+        });
+
+        ObjectTypeItem type = (ObjectTypeItem) typeBox.getSelectedItem();
+        updateMandatoryFields(type.getObjectType());
+
         createRow("Type:", typeBox, 1);
 
         JButton createButton = new JButton("Create Item", ClientHelper.getIcon("newfolder.png"));
@@ -71,7 +84,7 @@ public class CreateItemDialog extends Cr
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
-                    ObjectId objectId = getClientModel().createItem(name, type);
+                    ObjectId objectId = getClientModel().createItem(name, type, getMandatoryPropertyValues());
 
                     if (objectId != null) {
                         getClientModel().loadObject(objectId.getId());
@@ -92,7 +105,7 @@ public class CreateItemDialog extends Cr
                 }
             }
         });
-        createRow("", createButton, 3);
+        createActionRow("", createButton, 3);
 
         getRootPane().setDefaultButton(createButton);
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateRelationshipDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateRelationshipDialog.java?rev=1470570&r1=1470569&r2=1470570&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateRelationshipDialog.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateRelationshipDialog.java
Mon Apr 22 15:10:51 2013
@@ -22,6 +22,8 @@ import java.awt.Cursor;
 import java.awt.Frame;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 
 import javax.swing.JButton;
 import javax.swing.JComboBox;
@@ -29,6 +31,7 @@ import javax.swing.JOptionPane;
 import javax.swing.JTextField;
 
 import org.apache.chemistry.opencmis.client.api.ObjectId;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
 import org.apache.chemistry.opencmis.workbench.swing.CreateDialog;
@@ -62,6 +65,16 @@ public class CreateRelationshipDialog ex
 
         typeBox = new JComboBox(types);
         typeBox.setSelectedIndex(0);
+        typeBox.addItemListener(new ItemListener() {
+            public void itemStateChanged(ItemEvent e) {
+                TypeDefinition type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType();
+                updateMandatoryFields(type);
+            }
+        });
+
+        ObjectTypeItem type = (ObjectTypeItem) typeBox.getSelectedItem();
+        updateMandatoryFields(type.getObjectType());
+
         createRow("Type:", typeBox, 1);
 
         sourceIdField = new JTextField(60);
@@ -84,7 +97,8 @@ public class CreateRelationshipDialog ex
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
-                    ObjectId objectId = getClientModel().createRelationship(name, type, sourceId,
targetId);
+                    ObjectId objectId = getClientModel().createRelationship(name, type, sourceId,
targetId,
+                            getMandatoryPropertyValues());
 
                     if (objectId != null) {
                         getClientModel().loadObject(objectId.getId());
@@ -105,7 +119,7 @@ public class CreateRelationshipDialog ex
                 }
             }
         });
-        createRow("", createButton, 4);
+        createActionRow("", createButton, 4);
 
         getRootPane().setDefaultButton(createButton);
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java?rev=1470570&r1=1470569&r2=1470570&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
Mon Apr 22 15:10:51 2013
@@ -263,11 +263,16 @@ public class ClientModel {
     }
 
     public synchronized ObjectId createDocument(String name, String type, String filename,
-            VersioningState versioningState, boolean unfiled) throws Exception {
+            Map<String, Object> additionalProperties, VersioningState versioningState,
boolean unfiled)
+            throws Exception {
         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put(PropertyIds.NAME, name);
         properties.put(PropertyIds.OBJECT_TYPE_ID, type);
 
+        if (additionalProperties != null) {
+            properties.putAll(additionalProperties);
+        }
+
         ContentStream content = createContentStream(filename);
 
         try {
@@ -285,12 +290,16 @@ public class ClientModel {
                 .createContentStream(name, length, "application/octet-stream", new RandomInputStream(length,
seed));
     }
 
-    public synchronized ObjectId createDocument(String name, String type, long length, long
seed,
-            VersioningState versioningState, boolean unfiled) throws Exception {
+    public synchronized ObjectId createDocument(String name, String type, Map<String,
Object> additionalProperties,
+            long length, long seed, VersioningState versioningState, boolean unfiled) throws
Exception {
         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put(PropertyIds.NAME, name);
         properties.put(PropertyIds.OBJECT_TYPE_ID, type);
 
+        if (additionalProperties != null) {
+            properties.putAll(additionalProperties);
+        }
+
         ContentStream content = createContentStream(name, length, seed);
         try {
             return clientSession.getSession().createDocument(properties, (unfiled ? null
: currentFolder), content,
@@ -302,30 +311,44 @@ public class ClientModel {
         }
     }
 
-    public synchronized ObjectId createItem(String name, String type) throws Exception {
+    public synchronized ObjectId createItem(String name, String type, Map<String, Object>
additionalProperties)
+            throws Exception {
         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put(PropertyIds.NAME, name);
         properties.put(PropertyIds.OBJECT_TYPE_ID, type);
 
+        if (additionalProperties != null) {
+            properties.putAll(additionalProperties);
+        }
+
         return clientSession.getSession().createItem(properties, currentFolder, null, null,
null);
     }
 
-    public synchronized ObjectId createFolder(String name, String type) throws Exception
{
+    public synchronized ObjectId createFolder(String name, String type, Map<String, Object>
additionalProperties)
+            throws Exception {
         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put(PropertyIds.NAME, name);
         properties.put(PropertyIds.OBJECT_TYPE_ID, type);
 
+        if (additionalProperties != null) {
+            properties.putAll(additionalProperties);
+        }
+
         return clientSession.getSession().createFolder(properties, currentFolder, null, null,
null);
     }
 
-    public synchronized ObjectId createRelationship(String name, String type, String sourceId,
String targetId)
-            throws Exception {
+    public synchronized ObjectId createRelationship(String name, String type, String sourceId,
String targetId,
+            Map<String, Object> additionalProperties) throws Exception {
         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put(PropertyIds.NAME, name);
         properties.put(PropertyIds.OBJECT_TYPE_ID, type);
         properties.put(PropertyIds.SOURCE_ID, sourceId);
         properties.put(PropertyIds.TARGET_ID, targetId);
 
+        if (additionalProperties != null) {
+            properties.putAll(additionalProperties);
+        }
+
         return clientSession.getSession().createRelationship(properties, null, null, null);
     }
 
@@ -339,7 +362,7 @@ public class ClientModel {
             return result;
         }
 
-        List<Tree<ObjectType>> types = clientSession.getSession().getTypeDescendants(rootTypeId,
-1, false);
+        List<Tree<ObjectType>> types = clientSession.getSession().getTypeDescendants(rootTypeId,
-1, true);
         addType(types, result, creatableOnly);
 
         if (creatableOnly) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CreateDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CreateDialog.java?rev=1470570&r1=1470569&r2=1470570&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CreateDialog.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CreateDialog.java
Mon Apr 22 15:10:51 2013
@@ -22,16 +22,24 @@ import java.awt.BorderLayout;
 import java.awt.Frame;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.swing.BorderFactory;
+import javax.swing.JCheckBox;
 import javax.swing.JComponent;
 import javax.swing.JDialog;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
+import javax.swing.JTextField;
 
 import org.apache.chemistry.opencmis.client.api.ObjectType;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.PropertyType;
 import org.apache.chemistry.opencmis.workbench.ClientHelper;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
 
@@ -41,6 +49,9 @@ public abstract class CreateDialog exten
 
     private final ClientModel model;
     private final JPanel panel;
+    private final JPanel mandatoryPropertiesPanel;
+    private final JPanel actionPanel;
+    private final Map<String, JComponent> mandatoryProperties;
 
     public CreateDialog(Frame owner, String title, ClientModel model) {
         super(owner, title, true);
@@ -50,6 +61,15 @@ public abstract class CreateDialog exten
         panel = new JPanel(new GridBagLayout());
         panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
         add(panel, BorderLayout.CENTER);
+
+        mandatoryProperties = new HashMap<String, JComponent>();
+        mandatoryPropertiesPanel = new JPanel(new GridBagLayout());
+        mandatoryPropertiesPanel
+                .setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(10,
0, 0, 0),
+                        BorderFactory.createTitledBorder("Mandatory properties")));
+
+        actionPanel = new JPanel();
+        createRow(actionPanel, 10);
     }
 
     protected ClientModel getClientModel() {
@@ -57,6 +77,14 @@ public abstract class CreateDialog exten
     }
 
     protected void createRow(String label, JComponent comp, int row) {
+        createRow(panel, label, comp, row);
+    }
+
+    protected void createActionRow(String label, JComponent comp, int row) {
+        createRow(actionPanel, label, comp, row);
+    }
+
+    protected void createRow(JPanel panel, String label, JComponent comp, int row) {
         JLabel textLabel = new JLabel(label);
         textLabel.setLabelFor(comp);
 
@@ -70,6 +98,16 @@ public abstract class CreateDialog exten
         panel.add(comp, c);
     }
 
+    protected void createRow(JComponent comp, int row) {
+        GridBagConstraints c = new GridBagConstraints();
+        c.anchor = GridBagConstraints.LINE_START;
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 0;
+        c.gridy = row;
+        c.gridwidth = 2;
+        panel.add(comp, c);
+    }
+
     public void showDialog() {
         panel.invalidate();
 
@@ -105,6 +143,73 @@ public abstract class CreateDialog exten
         return result;
     }
 
+    protected void updateMandatoryFields(TypeDefinition type) {
+        mandatoryProperties.clear();
+        mandatoryPropertiesPanel.removeAll();
+
+        final Map<String, PropertyDefinition<?>> propertyDefinitions = type.getPropertyDefinitions();
+        if (propertyDefinitions != null) {
+            int row = 0;
+            for (PropertyDefinition<?> definition : propertyDefinitions.values()) {
+                if (definition.isRequired()
+                        && !(PropertyIds.NAME.equals(definition.getId())
+                                || PropertyIds.OBJECT_TYPE_ID.equals(definition.getId())
+                                || PropertyIds.SOURCE_ID.equals(definition.getId()) || PropertyIds.TARGET_ID
+                                    .equals(definition.getId()))) {
+                    JComponent child = createPropertyComponent(definition);
+                    mandatoryProperties.put(definition.getId(), child);
+                    createRow(mandatoryPropertiesPanel, definition.getDisplayName() + ":",
child, row);
+                    row++;
+                }
+            }
+        }
+
+        if (mandatoryPropertiesPanel.getComponents().length > 0) {
+            createRow(mandatoryPropertiesPanel, 9);
+        } else {
+            panel.remove(mandatoryPropertiesPanel);
+        }
+
+        pack();
+        repaint();
+    }
+
+    protected JComponent createPropertyComponent(PropertyDefinition<?> definition)
{
+        final PropertyType propertyType = definition.getPropertyType();
+        JComponent result;
+        switch (propertyType) {
+        case BOOLEAN:
+            result = new JCheckBox();
+            break;
+        default:
+            result = new JTextField("", 50);
+            break;
+        }
+
+        return result;
+    }
+
+    protected Map<String, Object> getMandatoryPropertyValues() {
+        if (mandatoryProperties.isEmpty()) {
+            return null;
+        }
+
+        Map<String, Object> result = new HashMap<String, Object>();
+
+        for (Map.Entry<String, JComponent> component : mandatoryProperties.entrySet())
{
+            Object value = null;
+            if (component.getValue() instanceof JTextField) {
+                value = ((JTextField) component.getValue()).getText();
+            } else if (component.getValue() instanceof JCheckBox) {
+                value = ((JCheckBox) component.getValue()).isSelected();
+            }
+
+            result.put(component.getKey(), value);
+        }
+
+        return result;
+    }
+
     public interface ObjectTypeItem {
         ObjectType getObjectType();
     }



Mime
View raw message