]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/typicals/NewMasterTypicalDiagram.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / typicals / NewMasterTypicalDiagram.java
index 86926145ccffed8808c715c65f69ece3e9b6edc8..62c45447689142b71daccf3632a656d39f3ea7d4 100644 (file)
@@ -1,96 +1,96 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.modeling.ui.typicals;\r
-\r
-import java.lang.reflect.InvocationTargetException;\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.jface.operation.IRunnableWithProgress;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.ui.IWorkbenchWindow;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.simantics.Simantics;\r
-import org.simantics.browsing.ui.common.ErrorLogger;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Session;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.adapter.ActionFactory;\r
-import org.simantics.modeling.ModelingResources;\r
-import org.simantics.modeling.typicals.TypicalUtil;\r
-import org.simantics.ui.workbench.action.ChooseActionRequest;\r
-import org.simantics.utils.ui.SWTUtils;\r
-import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
-\r
-/**\r
- * Creates a new master typical diagram and its corresponding composites.\r
- * \r
- * <p>\r
- * The created typical composite and diagram type are specified by the model\r
- * using {@link ModelingResources#StructuralModel_HasTypicalCompositeBaseType}\r
- * and {@link ModelingResources#StructuralModel_HasTypicalDiagramBaseType}.\r
- * \r
- * <p>\r
- * Marks the created master composite with the model-specified master composite\r
- * type to support searching. The master type is specified by the model using\r
- * {@link ModelingResources#StructuralModel_HasMasterTypicalCompositeType}.\r
- * \r
- * <p>\r
- * Clones symbol contributions from the sources specified by the model through\r
- * {@link ModelingResources#StructuralModel_CloneTypicalDiagramSymbolContributionsFrom}\r
- * .\r
- * \r
- * @author Tuukka Lehtonen\r
- */\r
-public class NewMasterTypicalDiagram implements ActionFactory {\r
-\r
-    @Override\r
-    public Runnable create(Object target_) {\r
-        final Resource target = (Resource)target_;\r
-        return new Runnable() {\r
-            @Override\r
-            public void run() {\r
-               try {\r
-                       PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {\r
-                               @Override\r
-                        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {\r
-                                       try {\r
-                                               Resource composite = TypicalUtil.newMasterTypical(target);\r
-                                               \r
-                               // Perform default action on the newly created diagram\r
-                               performDefaultAction(Simantics.getSession(), composite);\r
-                                       } catch (DatabaseException e) {\r
-                                               throw new InvocationTargetException(e);\r
-                                       } finally {\r
-                                               monitor.done();\r
-                                       }\r
-                               }\r
-                       });\r
-               } catch (InvocationTargetException e) {\r
-                       ErrorLogger.defaultLogError(e.getCause());\r
-               } catch (InterruptedException e) {\r
-                       ErrorLogger.defaultLogError(e);\r
-               }\r
-            }\r
-        };\r
-    };\r
-\r
-    private static void performDefaultAction(final Session session, final Object input) {\r
-        SWTUtils.asyncExec(PlatformUI.getWorkbench().getDisplay(), new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();\r
-                Shell shell = window != null ? window.getShell() : null;\r
-                session.asyncRequest(new ChooseActionRequest(shell, null, input, WorkbenchUtils.getCurrentPerspectiveId(), false, false, true));\r
-            }\r
-        });\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.modeling.ui.typicals;
+
+import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.simantics.Simantics;
+import org.simantics.browsing.ui.common.ErrorLogger;
+import org.simantics.db.Resource;
+import org.simantics.db.Session;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.adapter.ActionFactory;
+import org.simantics.modeling.ModelingResources;
+import org.simantics.modeling.typicals.TypicalUtil;
+import org.simantics.ui.workbench.action.ChooseActionRequest;
+import org.simantics.utils.ui.SWTUtils;
+import org.simantics.utils.ui.workbench.WorkbenchUtils;
+
+/**
+ * Creates a new master typical diagram and its corresponding composites.
+ * 
+ * <p>
+ * The created typical composite and diagram type are specified by the model
+ * using {@link ModelingResources#StructuralModel_HasTypicalCompositeBaseType}
+ * and {@link ModelingResources#StructuralModel_HasTypicalDiagramBaseType}.
+ * 
+ * <p>
+ * Marks the created master composite with the model-specified master composite
+ * type to support searching. The master type is specified by the model using
+ * {@link ModelingResources#StructuralModel_HasMasterTypicalCompositeType}.
+ * 
+ * <p>
+ * Clones symbol contributions from the sources specified by the model through
+ * {@link ModelingResources#StructuralModel_CloneTypicalDiagramSymbolContributionsFrom}
+ * .
+ * 
+ * @author Tuukka Lehtonen
+ */
+public class NewMasterTypicalDiagram implements ActionFactory {
+
+    @Override
+    public Runnable create(Object target_) {
+        final Resource target = (Resource)target_;
+        return new Runnable() {
+            @Override
+            public void run() {
+               try {
+                       PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
+                               @Override
+                        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                                       try {
+                                               Resource composite = TypicalUtil.newMasterTypical(target);
+                                               
+                               // Perform default action on the newly created diagram
+                               performDefaultAction(Simantics.getSession(), composite);
+                                       } catch (DatabaseException e) {
+                                               throw new InvocationTargetException(e);
+                                       } finally {
+                                               monitor.done();
+                                       }
+                               }
+                       });
+               } catch (InvocationTargetException e) {
+                       ErrorLogger.defaultLogError(e.getCause());
+               } catch (InterruptedException e) {
+                       ErrorLogger.defaultLogError(e);
+               }
+            }
+        };
+    };
+
+    private static void performDefaultAction(final Session session, final Object input) {
+        SWTUtils.asyncExec(PlatformUI.getWorkbench().getDisplay(), new Runnable() {
+            @Override
+            public void run() {
+                IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+                Shell shell = window != null ? window.getShell() : null;
+                session.asyncRequest(new ChooseActionRequest(shell, null, input, WorkbenchUtils.getCurrentPerspectiveId(), false, false, true));
+            }
+        });
+    }
+
+}