]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.ui/src/org/simantics/ui/contribution/NameLabelButtonTrim.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / contribution / NameLabelButtonTrim.java
index c0e8f7394495f0637af1aa2111068f3f3b15ca47..af12150f27467bff708aa9e2749fed2b7797e6b7 100644 (file)
@@ -1,76 +1,76 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in 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.ui.contribution;\r
-\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.eclipse.jface.resource.JFaceResources;\r
-import org.eclipse.jface.resource.LocalResourceManager;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.SelectionAdapter;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.layout.FillLayout;\r
-import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.simantics.NameLabelMode;\r
-import org.simantics.NameLabelUtil;\r
-import org.simantics.Simantics;\r
-import org.simantics.utils.ui.BundleUtils;\r
-\r
-/**\r
- * @author Antti Villberg\r
- */\r
-public class NameLabelButtonTrim extends Composite {\r
-\r
-    LocalResourceManager resourceManager;\r
-\r
-    public NameLabelButtonTrim(Composite parent) {\r
-        super(parent, SWT.NONE);\r
-\r
-        setLayout(new FillLayout());\r
-\r
-        final NameLabelMode initialMode = NameLabelUtil.getNameLabelMode(Simantics.getSession());\r
-\r
-        final Button b = new Button(this, SWT.PUSH);\r
-        this.resourceManager = new LocalResourceManager(JFaceResources.getResources(), b);\r
-\r
-        b.setToolTipText(tooltip(initialMode));\r
-        b.setImage(resourceManager.createImage(getDescriptor(initialMode)));\r
-        b.addSelectionListener(new SelectionAdapter() {\r
-\r
-            NameLabelMode mode = initialMode; \r
-\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                mode = mode.cycle();\r
-                b.setImage(resourceManager.createImage(getDescriptor(mode)));\r
-                b.setToolTipText(tooltip(mode));\r
-                NameLabelUtil.setNameLabelMode(Simantics.getSession(), mode);\r
-            }\r
-        });\r
-\r
-    }\r
-\r
-    private String tooltip(NameLabelMode currentMode) {\r
-        return "Switch Name/Label Visualization Mode from " + currentMode.getLabel() + " to " + currentMode.cycle().getLabel();\r
-    }\r
-\r
-    private ImageDescriptor getDescriptor(NameLabelMode mode) {\r
-        switch (mode) {\r
-        case NAME: return BundleUtils.getImageDescriptorFromPlugin("org.simantics.ui", "/icons/N.png");\r
-        case LABEL: return BundleUtils.getImageDescriptorFromPlugin("org.simantics.ui", "/icons/L.png");\r
-        case NAME_AND_LABEL: return BundleUtils.getImageDescriptorFromPlugin("org.simantics.ui", "/icons/N+L.png");\r
-        case LABEL_AND_NAME: return BundleUtils.getImageDescriptorFromPlugin("org.simantics.ui", "/icons/L+N.png");\r
-        default: throw new IllegalArgumentException("unrecognized name/label mode: " + mode);\r
-        }\r
-    }\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 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.ui.contribution;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.resource.LocalResourceManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.simantics.NameLabelMode;
+import org.simantics.NameLabelUtil;
+import org.simantics.Simantics;
+import org.simantics.utils.ui.BundleUtils;
+
+/**
+ * @author Antti Villberg
+ */
+public class NameLabelButtonTrim extends Composite {
+
+    LocalResourceManager resourceManager;
+
+    public NameLabelButtonTrim(Composite parent) {
+        super(parent, SWT.NONE);
+
+        setLayout(new FillLayout());
+
+        final NameLabelMode initialMode = NameLabelUtil.getNameLabelMode(Simantics.getSession());
+
+        final Button b = new Button(this, SWT.PUSH);
+        this.resourceManager = new LocalResourceManager(JFaceResources.getResources(), b);
+
+        b.setToolTipText(tooltip(initialMode));
+        b.setImage(resourceManager.createImage(getDescriptor(initialMode)));
+        b.addSelectionListener(new SelectionAdapter() {
+
+            NameLabelMode mode = initialMode; 
+
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                mode = mode.cycle();
+                b.setImage(resourceManager.createImage(getDescriptor(mode)));
+                b.setToolTipText(tooltip(mode));
+                NameLabelUtil.setNameLabelMode(Simantics.getSession(), mode);
+            }
+        });
+
+    }
+
+    private String tooltip(NameLabelMode currentMode) {
+        return "Switch Name/Label Visualization Mode from " + currentMode.getLabel() + " to " + currentMode.cycle().getLabel();
+    }
+
+    private ImageDescriptor getDescriptor(NameLabelMode mode) {
+        switch (mode) {
+        case NAME: return BundleUtils.getImageDescriptorFromPlugin("org.simantics.ui", "/icons/N.png");
+        case LABEL: return BundleUtils.getImageDescriptorFromPlugin("org.simantics.ui", "/icons/L.png");
+        case NAME_AND_LABEL: return BundleUtils.getImageDescriptorFromPlugin("org.simantics.ui", "/icons/N+L.png");
+        case LABEL_AND_NAME: return BundleUtils.getImageDescriptorFromPlugin("org.simantics.ui", "/icons/L+N.png");
+        default: throw new IllegalArgumentException("unrecognized name/label mode: " + mode);
+        }
+    }
+
 }
\ No newline at end of file