]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/forms/DataboardDialog.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / forms / DataboardDialog.java
index ea2efd97050d53f8148bf1d5f2c56e27c6fda265..ee780c4373bbdc3acf6df88ef15d8d93aaf0de74 100644 (file)
-package org.simantics.databoard.forms;\r
-\r
-import org.eclipse.jface.dialogs.Dialog;\r
-import org.eclipse.jface.dialogs.IDialogConstants;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.custom.ScrolledComposite;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.simantics.databoard.accessor.error.AccessorConstructionException;\r
-import org.simantics.databoard.accessor.error.AccessorException;\r
-import org.simantics.databoard.binding.RecordBinding;\r
-import org.simantics.databoard.binding.error.BindingException;\r
-\r
-public class DataboardDialog extends Dialog {\r
-       \r
-       RecordBinding formBinding;\r
-       Object initialValues;\r
-       String title;\r
-       Object result;\r
-    DataboardForm form;\r
-    Composite composite;\r
-    \r
-    /**\r
-     * Create dialog window\r
-     * \r
-     * @param parentShell\r
-     * @param title\r
-     * @param formBinding\r
-     * @param initialValues values according to formBinding or null\r
-     */\r
-       public DataboardDialog(Shell parentShell, String title, RecordBinding formBinding, Object initialValues) {              \r
-               super(parentShell);\r
-               this.formBinding = formBinding;\r
-               this.initialValues = initialValues;\r
-               this.title = title;\r
-               \r
-               setBlockOnOpen(true);\r
-               setShellStyle(SWT.RESIZE | SWT.TITLE | SWT.CLOSE | SWT.BORDER);\r
-       }\r
-\r
-       @Override\r
-       protected void createButtonsForButtonBar(Composite parent) {\r
-               createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);\r
-               createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);\r
-       }\r
-\r
-       @Override\r
-       protected Control createDialogArea(Composite parent) {\r
-           ScrolledComposite scroll = new ScrolledComposite(parent, SWT.V_SCROLL);\r
-           composite = new Composite(scroll, 0);\r
-        scroll.setContent(composite);\r
-        scroll.setExpandHorizontal(true);\r
-        scroll.setExpandVertical(false);\r
-               form = new DataboardForm();\r
-           form.setFirstColumnWidth(0);\r
-           form.addFields(composite, formBinding.type());\r
-           \r
-               composite.setLayout( new GridLayout(3, false) );                        \r
-               composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));\r
-               \r
-               if ( initialValues != null ) {\r
-                       try {\r
-                               form.writeFields(composite, formBinding, initialValues);\r
-                       } catch (AccessorException e) {\r
-                               e.printStackTrace();\r
-                       } catch (BindingException e) {\r
-                               e.printStackTrace();\r
-                       } catch (AccessorConstructionException e) {\r
-                               e.printStackTrace();\r
-                       }                       \r
-               }\r
-               \r
-           composite.pack();\r
-               \r
-               return scroll;\r
-       }\r
-\r
-    protected void configureShell(Shell newShell) {\r
-        super.configureShell(newShell);\r
-        newShell.setText(title);\r
-    }\r
-    \r
-       @Override\r
-       protected void okPressed() {\r
-               try {\r
-                       result = formBinding.createDefault();\r
-                       form.readFields(composite, formBinding, result);\r
-               } catch (BindingException e) {\r
-                       e.printStackTrace();\r
-                       result = null;\r
-               } catch (AccessorConstructionException e) {\r
-                       e.printStackTrace();\r
-                       result = null;\r
-               } catch (AccessorException e) {\r
-                       e.printStackTrace();\r
-                       result = null;\r
-               }\r
-               super.okPressed();\r
-       }\r
-       \r
-       @Override\r
-       protected void cancelPressed() {\r
-               result = null;\r
-               super.cancelPressed();\r
-       }\r
-\r
-       public Object getResult() {\r
-               return result;\r
-       }\r
-       \r
+package org.simantics.databoard.forms;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.simantics.databoard.accessor.error.AccessorConstructionException;
+import org.simantics.databoard.accessor.error.AccessorException;
+import org.simantics.databoard.binding.RecordBinding;
+import org.simantics.databoard.binding.error.BindingException;
+
+public class DataboardDialog extends Dialog {
+       
+       RecordBinding formBinding;
+       Object initialValues;
+       String title;
+       Object result;
+    DataboardForm form;
+    Composite composite;
+    
+    /**
+     * Create dialog window
+     * 
+     * @param parentShell
+     * @param title
+     * @param formBinding
+     * @param initialValues values according to formBinding or null
+     */
+       public DataboardDialog(Shell parentShell, String title, RecordBinding formBinding, Object initialValues) {              
+               super(parentShell);
+               this.formBinding = formBinding;
+               this.initialValues = initialValues;
+               this.title = title;
+               
+               setBlockOnOpen(true);
+               setShellStyle(SWT.RESIZE | SWT.TITLE | SWT.CLOSE | SWT.BORDER);
+       }
+
+       @Override
+       protected void createButtonsForButtonBar(Composite parent) {
+               createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+               createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+       }
+
+       @Override
+       protected Control createDialogArea(Composite parent) {
+           ScrolledComposite scroll = new ScrolledComposite(parent, SWT.V_SCROLL);
+           composite = new Composite(scroll, 0);
+        scroll.setContent(composite);
+        scroll.setExpandHorizontal(true);
+        scroll.setExpandVertical(false);
+               form = new DataboardForm();
+           form.setFirstColumnWidth(0);
+           form.addFields(composite, formBinding.type());
+           
+               composite.setLayout( new GridLayout(3, false) );                        
+               composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));
+               
+               if ( initialValues != null ) {
+                       try {
+                               form.writeFields(composite, formBinding, initialValues);
+                       } catch (AccessorException e) {
+                               e.printStackTrace();
+                       } catch (BindingException e) {
+                               e.printStackTrace();
+                       } catch (AccessorConstructionException e) {
+                               e.printStackTrace();
+                       }                       
+               }
+               
+           composite.pack();
+               
+               return scroll;
+       }
+
+    protected void configureShell(Shell newShell) {
+        super.configureShell(newShell);
+        newShell.setText(title);
+    }
+    
+       @Override
+       protected void okPressed() {
+               try {
+                       result = formBinding.createDefault();
+                       form.readFields(composite, formBinding, result);
+               } catch (BindingException e) {
+                       e.printStackTrace();
+                       result = null;
+               } catch (AccessorConstructionException e) {
+                       e.printStackTrace();
+                       result = null;
+               } catch (AccessorException e) {
+                       e.printStackTrace();
+                       result = null;
+               }
+               super.okPressed();
+       }
+       
+       @Override
+       protected void cancelPressed() {
+               result = null;
+               super.cancelPressed();
+       }
+
+       public Object getResult() {
+               return result;
+       }
+       
 }
\ No newline at end of file