chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1696943 - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench: ./ swing/
Date Fri, 21 Aug 2015 11:31:22 GMT
Author: fmui
Date: Fri Aug 21 11:31:22 2015
New Revision: 1696943

URL: http://svn.apache.org/r1696943
Log:
CMIS-925: Workbench: added support for oncreate in 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/CreatePolicyDialog.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/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=1696943&r1=1696942&r2=1696943&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
Fri Aug 21 11:31:22 2015
@@ -50,6 +50,7 @@ import javax.swing.event.DocumentListene
 
 import org.apache.chemistry.opencmis.client.api.Document;
 import org.apache.chemistry.opencmis.client.api.ObjectId;
+import org.apache.chemistry.opencmis.client.api.ObjectType;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
@@ -129,12 +130,12 @@ public class CreateDocumentDialog extend
                 } else {
                     versioningStateNoneButton.setSelected(true);
                 }
-                updateMandatoryFields(type);
+                updateMandatoryOrOnCreateFields(type);
             }
         });
 
         ObjectTypeItem type = (ObjectTypeItem) typeBox.getSelectedItem();
-        updateMandatoryFields(type.getObjectType());
+        updateMandatoryOrOnCreateFields(type.getObjectType());
 
         createRow("Type:", typeBox, 2);
 
@@ -238,7 +239,7 @@ public class CreateDocumentDialog extend
             @Override
             public void actionPerformed(ActionEvent event) {
                 String name = nameField.getText();
-                String type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType().getId();
+                ObjectType type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType();
                 String filename = filenameField.getText();
 
                 try {
@@ -256,8 +257,10 @@ public class CreateDocumentDialog extend
                     ObjectId objectId = null;
                     if (filename.length() > 0) {
                         // create a document from a file
-                        objectId = getClientModel().createDocument(name, type, filename,
getMandatoryPropertyValues(),
-                                versioningState, unfiledButton.isSelected());
+                        objectId = getClientModel()
+                                .createDocument(name, type.getId(), filename,
+                                        getMandatoryOrOnCreatePropertyValues(type), versioningState,
+                                        unfiledButton.isSelected());
 
                         if (verifyAfterUploadButton.isSelected()) {
                             ContentStream contentStream = getClientModel().createContentStream(filename);
@@ -275,8 +278,9 @@ public class CreateDocumentDialog extend
                             }
                         }
 
-                        objectId = getClientModel().createDocument(name, type, getMandatoryPropertyValues(),
length,
-                                seed, versioningState, unfiledButton.isSelected());
+                        objectId = getClientModel().createDocument(name, type.getId(),
+                                getMandatoryOrOnCreatePropertyValues(type), length, seed,
versioningState,
+                                unfiledButton.isSelected());
 
                         if (verifyAfterUploadButton.isSelected()) {
                             ContentStream contentStream = getClientModel().createContentStream("",
length, seed);

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=1696943&r1=1696942&r2=1696943&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
Fri Aug 21 11:31:22 2015
@@ -31,6 +31,7 @@ import javax.swing.JOptionPane;
 import javax.swing.JTextField;
 
 import org.apache.chemistry.opencmis.client.api.ObjectId;
+import org.apache.chemistry.opencmis.client.api.ObjectType;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.workbench.icons.NewFolderIcon;
@@ -68,12 +69,12 @@ public class CreateFolderDialog extends
             @Override
             public void itemStateChanged(ItemEvent e) {
                 TypeDefinition type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType();
-                updateMandatoryFields(type);
+                updateMandatoryOrOnCreateFields(type);
             }
         });
 
         ObjectTypeItem type = (ObjectTypeItem) typeBox.getSelectedItem();
-        updateMandatoryFields(type.getObjectType());
+        updateMandatoryOrOnCreateFields(type.getObjectType());
 
         createRow("Type:", typeBox, 1);
 
@@ -83,12 +84,13 @@ public class CreateFolderDialog extends
             @Override
             public void actionPerformed(ActionEvent event) {
                 String name = nameField.getText();
-                String type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType().getId();
+                ObjectType type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType();
 
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
-                    ObjectId objectId = getClientModel().createFolder(name, type, getMandatoryPropertyValues());
+                    ObjectId objectId = getClientModel().createFolder(name, type.getId(),
+                            getMandatoryOrOnCreatePropertyValues(type));
 
                     if (objectId != null) {
                         getClientModel().loadObject(objectId.getId());

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=1696943&r1=1696942&r2=1696943&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
Fri Aug 21 11:31:22 2015
@@ -35,6 +35,7 @@ import javax.swing.JRadioButton;
 import javax.swing.JTextField;
 
 import org.apache.chemistry.opencmis.client.api.ObjectId;
+import org.apache.chemistry.opencmis.client.api.ObjectType;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.workbench.icons.NewItemIcon;
@@ -91,12 +92,12 @@ public class CreateItemDialog extends Cr
             @Override
             public void itemStateChanged(ItemEvent e) {
                 TypeDefinition type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType();
-                updateMandatoryFields(type);
+                updateMandatoryOrOnCreateFields(type);
             }
         });
 
         ObjectTypeItem type = (ObjectTypeItem) typeBox.getSelectedItem();
-        updateMandatoryFields(type.getObjectType());
+        updateMandatoryOrOnCreateFields(type.getObjectType());
 
         createRow("Type:", typeBox, 2);
 
@@ -106,13 +107,13 @@ public class CreateItemDialog extends Cr
             @Override
             public void actionPerformed(ActionEvent event) {
                 String name = nameField.getText();
-                String type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType().getId();
+                ObjectType type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType();
 
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
-                    ObjectId objectId = getClientModel().createItem(name, type, getMandatoryPropertyValues(),
-                            unfiledButton.isSelected());
+                    ObjectId objectId = getClientModel().createItem(name, type.getId(),
+                            getMandatoryOrOnCreatePropertyValues(type), unfiledButton.isSelected());
 
                     if (objectId != null) {
                         getClientModel().loadObject(objectId.getId());

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreatePolicyDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreatePolicyDialog.java?rev=1696943&r1=1696942&r2=1696943&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreatePolicyDialog.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreatePolicyDialog.java
Fri Aug 21 11:31:22 2015
@@ -35,6 +35,7 @@ import javax.swing.JRadioButton;
 import javax.swing.JTextField;
 
 import org.apache.chemistry.opencmis.client.api.ObjectId;
+import org.apache.chemistry.opencmis.client.api.ObjectType;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.workbench.icons.NewPolicyIcon;
@@ -92,12 +93,12 @@ public class CreatePolicyDialog extends
             @Override
             public void itemStateChanged(ItemEvent e) {
                 TypeDefinition type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType();
-                updateMandatoryFields(type);
+                updateMandatoryOrOnCreateFields(type);
             }
         });
 
         ObjectTypeItem type = (ObjectTypeItem) typeBox.getSelectedItem();
-        updateMandatoryFields(type.getObjectType());
+        updateMandatoryOrOnCreateFields(type.getObjectType());
 
         createRow("Type:", typeBox, 2);
 
@@ -111,13 +112,13 @@ public class CreatePolicyDialog extends
             public void actionPerformed(ActionEvent event) {
                 String name = nameField.getText();
                 String policyText = policyTextField.getText();
-                String type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType().getId();
+                ObjectType type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType();
 
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
-                    ObjectId objectId = getClientModel().createPolicy(name, type, policyText,
-                            getMandatoryPropertyValues(), unfiledButton.isSelected());
+                    ObjectId objectId = getClientModel().createPolicy(name, type.getId(),
policyText,
+                            getMandatoryOrOnCreatePropertyValues(type), unfiledButton.isSelected());
 
                     if (objectId != null) {
                         getClientModel().loadObject(objectId.getId());

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=1696943&r1=1696942&r2=1696943&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
Fri Aug 21 11:31:22 2015
@@ -31,6 +31,7 @@ import javax.swing.JOptionPane;
 import javax.swing.JTextField;
 
 import org.apache.chemistry.opencmis.client.api.ObjectId;
+import org.apache.chemistry.opencmis.client.api.ObjectType;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.workbench.icons.NewRelationshipIcon;
@@ -70,12 +71,12 @@ public class CreateRelationshipDialog ex
             @Override
             public void itemStateChanged(ItemEvent e) {
                 TypeDefinition type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType();
-                updateMandatoryFields(type);
+                updateMandatoryOrOnCreateFields(type);
             }
         });
 
         ObjectTypeItem type = (ObjectTypeItem) typeBox.getSelectedItem();
-        updateMandatoryFields(type.getObjectType());
+        updateMandatoryOrOnCreateFields(type.getObjectType());
 
         createRow("Type:", typeBox, 1);
 
@@ -94,15 +95,15 @@ public class CreateRelationshipDialog ex
             @Override
             public void actionPerformed(ActionEvent event) {
                 String name = nameField.getText();
-                String type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType().getId();
+                ObjectType type = ((ObjectTypeItem) typeBox.getSelectedItem()).getObjectType();
                 String sourceId = sourceIdField.getText();
                 String targetId = targetIdField.getText();
 
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
-                    ObjectId objectId = getClientModel().createRelationship(name, type, sourceId,
targetId,
-                            getMandatoryPropertyValues());
+                    ObjectId objectId = getClientModel().createRelationship(name, type.getId(),
sourceId, targetId,
+                            getMandatoryOrOnCreatePropertyValues(type));
 
                     if (objectId != null) {
                         getClientModel().loadObject(objectId.getId());

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=1696943&r1=1696942&r2=1696943&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
Fri Aug 21 11:31:22 2015
@@ -22,6 +22,9 @@ import java.awt.BorderLayout;
 import java.awt.Frame;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.text.DecimalFormat;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -30,6 +33,7 @@ import javax.swing.BorderFactory;
 import javax.swing.JCheckBox;
 import javax.swing.JComponent;
 import javax.swing.JDialog;
+import javax.swing.JFormattedTextField;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
@@ -40,6 +44,7 @@ import org.apache.chemistry.opencmis.com
 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.commons.enums.Updatability;
 import org.apache.chemistry.opencmis.workbench.ClientHelper;
 import org.apache.chemistry.opencmis.workbench.WorkbenchScale;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
@@ -50,9 +55,9 @@ public abstract class CreateDialog exten
 
     private final ClientModel model;
     private final JPanel panel;
-    private final JPanel mandatoryPropertiesPanel;
+    private final JPanel mandatoryOrOnCreatePropertiesPanel;
     private final JPanel actionPanel;
-    private final Map<String, JComponent> mandatoryProperties;
+    private final Map<String, JComponent> mandatoryOrOnCreateProperties;
 
     public CreateDialog(Frame owner, String title, ClientModel model) {
         super(owner, title, true);
@@ -63,11 +68,11 @@ public abstract class CreateDialog exten
         panel.setBorder(WorkbenchScale.scaleBorder(BorderFactory.createEmptyBorder(10, 10,
10, 10)));
         add(panel, BorderLayout.CENTER);
 
-        mandatoryProperties = new HashMap<String, JComponent>();
-        mandatoryPropertiesPanel = new JPanel(new GridBagLayout());
-        mandatoryPropertiesPanel.setBorder(WorkbenchScale.scaleBorder(BorderFactory.createCompoundBorder(
+        mandatoryOrOnCreateProperties = new HashMap<String, JComponent>();
+        mandatoryOrOnCreatePropertiesPanel = new JPanel(new GridBagLayout());
+        mandatoryOrOnCreatePropertiesPanel.setBorder(WorkbenchScale.scaleBorder(BorderFactory.createCompoundBorder(
                 WorkbenchScale.scaleBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)),
-                WorkbenchScale.scaleBorder(BorderFactory.createTitledBorder("Mandatory properties")))));
+                WorkbenchScale.scaleBorder(BorderFactory.createTitledBorder("Mandatory or
OnCreate properties")))));
 
         actionPanel = new JPanel();
         createRow(actionPanel, 10);
@@ -145,31 +150,32 @@ public abstract class CreateDialog exten
         return result;
     }
 
-    protected final void updateMandatoryFields(TypeDefinition type) {
-        mandatoryProperties.clear();
-        mandatoryPropertiesPanel.removeAll();
+    protected final void updateMandatoryOrOnCreateFields(TypeDefinition type) {
+        mandatoryOrOnCreateProperties.clear();
+        mandatoryOrOnCreatePropertiesPanel.removeAll();
 
         final Map<String, PropertyDefinition<?>> propertyDefinitions = type.getPropertyDefinitions();
         if (propertyDefinitions != null) {
             int row = 0;
             for (PropertyDefinition<?> definition : propertyDefinitions.values()) {
-                if (Boolean.TRUE.equals(definition.isRequired())
+                if ((Boolean.TRUE.equals(definition.isRequired()) || Updatability.ONCREATE.equals(definition
+                        .getUpdatability()))
                         && !(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);
+                    mandatoryOrOnCreateProperties.put(definition.getId(), child);
+                    createRow(mandatoryOrOnCreatePropertiesPanel, definition.getDisplayName()
+ ":", child, row);
                     row++;
                 }
             }
         }
 
-        if (mandatoryPropertiesPanel.getComponents().length > 0) {
-            createRow(mandatoryPropertiesPanel, 9);
+        if (mandatoryOrOnCreatePropertiesPanel.getComponents().length > 0) {
+            createRow(mandatoryOrOnCreatePropertiesPanel, 9);
         } else {
-            panel.remove(mandatoryPropertiesPanel);
+            panel.remove(mandatoryOrOnCreatePropertiesPanel);
         }
 
         pack();
@@ -183,6 +189,23 @@ public abstract class CreateDialog exten
         case BOOLEAN:
             result = new JCheckBox();
             break;
+        case INTEGER:
+            DecimalFormat intFormat = new DecimalFormat("#,##0");
+            intFormat.setParseBigDecimal(true);
+            intFormat.setParseIntegerOnly(true);
+            result = new JFormattedTextField(intFormat);
+            ((JFormattedTextField) result).setColumns(50);
+            break;
+        case DECIMAL:
+            DecimalFormat decFormat = new DecimalFormat("#,##0.#############################");
+            decFormat.setParseBigDecimal(true);
+            result = new JFormattedTextField(decFormat);
+            ((JFormattedTextField) result).setColumns(50);
+            break;
+        case DATETIME:
+            result = new JFormattedTextField(DateFormat.getDateTimeInstance());
+            ((JFormattedTextField) result).setColumns(50);
+            break;
         default:
             result = new JTextField("", 50);
             break;
@@ -191,22 +214,34 @@ public abstract class CreateDialog exten
         return result;
     }
 
-    protected Map<String, Object> getMandatoryPropertyValues() {
-        if (mandatoryProperties.isEmpty()) {
+    protected Map<String, Object> getMandatoryOrOnCreatePropertyValues(TypeDefinition
type) {
+        if (mandatoryOrOnCreateProperties.isEmpty()) {
             return null;
         }
 
         Map<String, Object> result = new HashMap<String, Object>();
 
-        for (Map.Entry<String, JComponent> component : mandatoryProperties.entrySet())
{
+        for (Map.Entry<String, JComponent> component : mandatoryOrOnCreateProperties.entrySet())
{
+            PropertyDefinition<?> propDef = type.getPropertyDefinitions().get(component.getKey());
+
             Object value = null;
-            if (component.getValue() instanceof JTextField) {
+            if (component.getValue() instanceof JFormattedTextField) {
+                value = ((JFormattedTextField) component.getValue()).getValue();
+
+                if (value != null) {
+                    if (propDef.getPropertyType() == PropertyType.INTEGER) {
+                        value = ((BigDecimal) value).toBigIntegerExact();
+                    }
+                }
+            } else 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);
+            if (value != null) {
+                result.put(component.getKey(), value);
+            }
         }
 
         return result;



Mime
View raw message