]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/handlers/ToggleFocusabilityHandler.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / diagramEditor / handlers / ToggleFocusabilityHandler.java
index c40d2a10d27be8f44580471e8af4e821a3d34aa4..5c306b31f4bb5415b5b5ca6123667e005fb9a81a 100644 (file)
@@ -1,94 +1,94 @@
-/*******************************************************************************\r
- * Copyright (c) 2013 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
- *     Semantum Oy - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.modeling.ui.diagramEditor.handlers;\r
-\r
-import java.util.Map;\r
-\r
-import org.eclipse.core.commands.AbstractHandler;\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.ui.IEditorPart;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.eclipse.ui.commands.ICommandService;\r
-import org.eclipse.ui.commands.IElementUpdater;\r
-import org.eclipse.ui.menus.UIElement;\r
-import org.simantics.g2d.diagram.DiagramHints;\r
-import org.simantics.g2d.diagram.IDiagram;\r
-import org.simantics.g2d.layers.ILayersEditor;\r
-import org.simantics.modeling.ui.diagramEditor.DiagramEditor;\r
-import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class ToggleFocusabilityHandler extends AbstractHandler implements IElementUpdater {\r
-\r
-       @Override\r
-       public Object execute(ExecutionEvent event) throws ExecutionException {\r
-               ILayersEditor le = getLayers();\r
-               if (le != null) {\r
-                       boolean b = le.getIgnoreFocusSettings();\r
-                       le.setIgnoreFocusSettings( !b );\r
-\r
-                       ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
-                       service.refreshElements(event.getCommand().getId(), null);\r
-               }\r
-               return null;\r
-       }\r
-\r
-       @SuppressWarnings("rawtypes")\r
-       @Override\r
-       public void updateElement(UIElement element, Map parameters) {\r
-               //System.out.println("updateElement: " + element);\r
-               DiagramEditor editor = getEditor();\r
-               if (editor != null) {\r
-                       //System.out.println("updateElement2: " + editor);\r
-                       ILayersEditor le = getLayers(editor);\r
-                       if (le != null) {\r
-                               boolean bool = le.getIgnoreFocusSettings();\r
-                               //System.out.println("get ignore focus setting: " + bool);\r
-                               element.setChecked(bool);\r
-                               element.setTooltip((bool ? "Deny" : "Allow") + " Focusing and Editing of Images");\r
-                               return;\r
-                       }\r
-               }\r
-       }\r
-\r
-       protected ILayersEditor getLayers() {\r
-               DiagramEditor editor = getEditor();\r
-               if (editor == null)\r
-                       return null;\r
-               return getLayers(editor);\r
-       }\r
-\r
-       protected ILayersEditor getLayers(DiagramEditor editor) {\r
-               // The diagram might not be available since the diagram editor loads it asynchronously.\r
-               IDiagram diagram = (IDiagram) editor.getAdapter(IDiagram.class);\r
-               if (diagram == null)\r
-                       return null;\r
-               //System.out.println("getLayersEditor(" + diagram + ")");\r
-               ILayersEditor le = diagram.getHint(DiagramHints.KEY_LAYERS_EDITOR);\r
-               return le;\r
-       }\r
-\r
-       protected DiagramEditor getEditor() {\r
-               IEditorPart editorPart = WorkbenchUtils.getActiveEditor();\r
-               if (editorPart == null)\r
-                       return null;\r
-               if (editorPart instanceof DiagramEditor) {\r
-                       DiagramEditor editor = (DiagramEditor) editorPart;\r
-                       return editor;\r
-               }\r
-               return null;\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.modeling.ui.diagramEditor.handlers;
+
+import java.util.Map;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.commands.IElementUpdater;
+import org.eclipse.ui.menus.UIElement;
+import org.simantics.g2d.diagram.DiagramHints;
+import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.g2d.layers.ILayersEditor;
+import org.simantics.modeling.ui.diagramEditor.DiagramEditor;
+import org.simantics.utils.ui.workbench.WorkbenchUtils;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ToggleFocusabilityHandler extends AbstractHandler implements IElementUpdater {
+
+       @Override
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               ILayersEditor le = getLayers();
+               if (le != null) {
+                       boolean b = le.getIgnoreFocusSettings();
+                       le.setIgnoreFocusSettings( !b );
+
+                       ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
+                       service.refreshElements(event.getCommand().getId(), null);
+               }
+               return null;
+       }
+
+       @SuppressWarnings("rawtypes")
+       @Override
+       public void updateElement(UIElement element, Map parameters) {
+               //System.out.println("updateElement: " + element);
+               DiagramEditor editor = getEditor();
+               if (editor != null) {
+                       //System.out.println("updateElement2: " + editor);
+                       ILayersEditor le = getLayers(editor);
+                       if (le != null) {
+                               boolean bool = le.getIgnoreFocusSettings();
+                               //System.out.println("get ignore focus setting: " + bool);
+                               element.setChecked(bool);
+                               element.setTooltip((bool ? "Deny" : "Allow") + " Focusing and Editing of Images");
+                               return;
+                       }
+               }
+       }
+
+       protected ILayersEditor getLayers() {
+               DiagramEditor editor = getEditor();
+               if (editor == null)
+                       return null;
+               return getLayers(editor);
+       }
+
+       protected ILayersEditor getLayers(DiagramEditor editor) {
+               // The diagram might not be available since the diagram editor loads it asynchronously.
+               IDiagram diagram = (IDiagram) editor.getAdapter(IDiagram.class);
+               if (diagram == null)
+                       return null;
+               //System.out.println("getLayersEditor(" + diagram + ")");
+               ILayersEditor le = diagram.getHint(DiagramHints.KEY_LAYERS_EDITOR);
+               return le;
+       }
+
+       protected DiagramEditor getEditor() {
+               IEditorPart editorPart = WorkbenchUtils.getActiveEditor();
+               if (editorPart == null)
+                       return null;
+               if (editorPart instanceof DiagramEditor) {
+                       DiagramEditor editor = (DiagramEditor) editorPart;
+                       return editor;
+               }
+               return null;
+       }
+
+}