Anonymous avatar Anonymous committed d2b3b98

- added switch view button to the toolbar - resolved a few warnings

Comments (0)

Files changed (13)

src/messages.properties

 SetLocationCommand_Label_Location=Move Object
 SetLocationCommand_Label_Resize=Resize Object
 ViewMenu_LabelText=&View
-Wire_LabelText=Wire
 LimeEditor_outline_show_outline=Show Outline
 LimeEditor_outline_show_overview=Show Overview
 #########
Add a comment to this file

src/modelicons/others/switchview.gif

Added
New image

src/nl/tudelft/lime/LimeEditor.java

 package nl.tudelft.lime;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.EventObject;
+import java.util.List;
+
 import nl.tudelft.lime.actions.LimePasteTemplateAction;
 import nl.tudelft.lime.constants.LimeMessages;
 import nl.tudelft.lime.dnd.TextTransferDropTargetListener;
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-
+import org.eclipse.core.runtime.SafeRunner;
 import org.eclipse.draw2d.FigureCanvas;
 import org.eclipse.draw2d.LightweightSystem;
 import org.eclipse.draw2d.MarginBorder;
 import org.eclipse.draw2d.Viewport;
 import org.eclipse.draw2d.parts.ScrollableThumbnail;
 import org.eclipse.draw2d.parts.Thumbnail;
-
 import org.eclipse.gef.ContextMenuProvider;
 import org.eclipse.gef.DefaultEditDomain;
 import org.eclipse.gef.EditPartViewer;
 import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
 import org.eclipse.gef.ui.parts.TreeViewer;
 import org.eclipse.gef.ui.rulers.RulerComposite;
-
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IMenuListener;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.util.SafeRunnable;
 import org.eclipse.jface.util.TransferDropTargetListener;
-
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.dnd.TextTransfer;
 import org.eclipse.swt.events.DisposeEvent;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Shell;
-
 import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.part.FileEditorInput;
 import org.eclipse.ui.part.IPageSite;
 import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.services.IServiceLocator;
 import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-
-import java.util.ArrayList;
-import java.util.EventObject;
-import java.util.List;
-
 
 public class LimeEditor extends GraphicalEditorWithFlyoutPalette {
     protected static final String PALETTE_DOCK_LOCATION = "Dock location"; //$NON-NLS-1$
      */
     public void doSave(final IProgressMonitor progressMonitor) {
         editorSaving = true;
-        Platform.run(new SafeRunnable() {
+        SafeRunner.run(new SafeRunnable() {
                 public void run() throws Exception {
                     saveProperties();
 

src/nl/tudelft/lime/actions/LimeActionBarContributor.java

 import nl.tudelft.lime.model.component.LimeComponent;
 
 import org.eclipse.draw2d.PositionConstants;
-
 import org.eclipse.gef.editparts.ZoomManager;
 import org.eclipse.gef.internal.GEFMessages;
 import org.eclipse.gef.ui.actions.ActionBarContributor;
 import org.eclipse.gef.ui.actions.ZoomComboContributionItem;
 import org.eclipse.gef.ui.actions.ZoomInRetargetAction;
 import org.eclipse.gef.ui.actions.ZoomOutRetargetAction;
-
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.resource.ImageDescriptor;
-
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IWorkbenchActionConstants;
 import org.eclipse.ui.actions.ActionFactory;
 
 public class LimeActionBarContributor extends ActionBarContributor {
     private FlyoutChangeLayoutAction changeLayoutAction;
+    private SwitchViewAction switchViewAction;
     private IEditorPart editor;
 
     /**
         addRetargetAction(new RetargetAction(
                 GEFActionConstants.TOGGLE_GRID_VISIBILITY,
                 GEFMessages.ToggleGrid_Label, IAction.AS_CHECK_BOX));
+        //add switch layout button
         buildChangeLayoutAction();
         addAction(changeLayoutAction);
+        //add switch view button
+        buildSwitchViewAction();
+        addAction(switchViewAction);
     }
 
+    /**
+     * Creates switch view button on the toolbar. This button is used to 
+     * change view mode from 'Class' mode to 'instance' mode
+     */
+    private void buildSwitchViewAction() {
+        switchViewAction = new SwitchViewAction(editor);
+        switchViewAction.setToolTipText("Switch view mode (Class <--> Instance)");
+        switchViewAction.setId("nl.tudelft.action.SwtichViewAction");
+        switchViewAction.setImageDescriptor(ImageDescriptor.createFromFile(
+                LimeComponent.class, SystemSettings.SwitchView_Normal_Icon_Path));
+
+        switchViewAction.setDisabledImageDescriptor(ImageDescriptor.createFromFile(
+                LimeComponent.class, SystemSettings.SwitchView_Disabled_Icon_Path));
+    }
+
+    /**
+     * Creates change layout button on the toolbar. This button is used to 
+     * impose automatic layouting to a diagram
+     */
     private void buildChangeLayoutAction() {
         changeLayoutAction = new FlyoutChangeLayoutAction(editor);
         changeLayoutAction.setToolTipText("Automatic Layout");
     public void setActiveEditor(IEditorPart editor) {
         this.editor = editor;
         changeLayoutAction.setActiveEditor(editor);
+        switchViewAction.setActiveEditor(editor);
         super.setActiveEditor(editor);
     }
 
         toolbarManager.add(new ZoomComboContributionItem(getPage(), zoomStrings));
         toolbarManager.add(new Separator());
         toolbarManager.add(changeLayoutAction);
+        toolbarManager.add(switchViewAction);
     }
 
     /**

src/nl/tudelft/lime/actions/SwitchViewAction.java

+/*
+ * Created on Jul 23, 2004
+ */
+package nl.tudelft.lime.actions;
+
+import nl.tudelft.lime.LimeEditor;
+import nl.tudelft.lime.model.component.LimeDiagram;
+
+import org.eclipse.jface.action.Action;
+
+import org.eclipse.ui.IEditorPart;
+
+
+/**
+ * Action to toggle the layout between manual and automatic
+ *
+ * @author Phil Zoio
+ */
+public class SwitchViewAction extends Action {
+    IEditorPart editor;
+
+    public SwitchViewAction(IEditorPart editor) {
+        super("Switch View", Action.AS_PUSH_BUTTON);
+        this.editor = editor;
+    }
+
+    public void run() {
+        if (editor instanceof LimeEditor) {
+            LimeEditor schemaEditor = (LimeEditor) editor;
+            LimeDiagram limeDiagram = schemaEditor.getLimeDiagram();
+            //the name getOnlyInstances is a bit vague
+            Integer showOnlyInstances = limeDiagram.getShowOnlyInstances();
+            //reverse it
+            limeDiagram.setShowOnlyInstances(Math.abs(1 - showOnlyInstances));
+        }
+    }
+
+    public boolean isChecked() {
+        if (editor != null) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    public void setActiveEditor(IEditorPart editor) {
+        this.editor = editor;
+
+/*        boolean localChecked = isChecked(editor);
+
+        //there appears to be a bug in the framework which necessitates this
+        if (localChecked) {
+            firePropertyChange(CHECKED, Boolean.FALSE, Boolean.TRUE);
+        } else {
+            firePropertyChange(CHECKED, Boolean.TRUE, Boolean.FALSE);
+        }
+*/    }
+}

src/nl/tudelft/lime/constants/LimeMessages.java

     public static String LimeEditor_outline_show_outline;
     public static String LimeEditor_outline_show_overview;
     public static String LimeElementEditPolicy_OrphanCommandLabelText;
-    public static String LimePlugin_Category_ComplexParts_Label;
     public static String LimePlugin_Category_Components_Label;
     public static String LimePlugin_Category_ControlGroup_Label;
     public static String LimePlugin_Arc_Tool_Description;

src/nl/tudelft/lime/constants/SystemSettings.java

     public static String Component_Menu_Icon_Path;
     public static String Layout_Normal_Icon_Path;
     public static String Layout_Disabled_Icon_Path;
+    public static String SwitchView_Normal_Icon_Path;
+    public static String SwitchView_Disabled_Icon_Path;
 
     //XML
     public static String Default_XML_DTD_Entry;
Add a comment to this file

src/nl/tudelft/lime/icons/logic.gif

Removed
Old image
Add a comment to this file

src/nl/tudelft/lime/icons/minus.gif

Removed
Old image
Add a comment to this file

src/nl/tudelft/lime/icons/plus.gif

Removed
Old image

src/nl/tudelft/lime/model/component/LimeComponent.java

      * @param componentClassString
      */
     public void setComponentClass(String componentClassString) {
-        Integer oldOnlyInstances = getOnlyInstances();
-        setOnlyInstances(1);
+        Integer oldOnlyInstances = getShowOnlyInstances();
+        setShowOnlyInstances(1);
         this.componentClass = componentClassString;
 
         LimeComponent realComponentClass = findComponentClass(componentClassString);
             }
         }
 
-        setOnlyInstances(oldOnlyInstances);
+        setShowOnlyInstances(oldOnlyInstances);
         firePropertyChange(Property_ID_Component_InstanceOf, null,
             realComponentClass);
     }

src/nl/tudelft/lime/model/component/LimeDiagram.java

     private double zoom = 1.0;
 
     //in the default mode only instances should be visible
-    private Integer onlyInstances = 0;
+    private Integer ShowOnlyInstances = 0;
     private Map<String, LimeComponent> componentClassDictionary = new HashMap<String, LimeComponent>();
 
     public LimeDiagram() {
     }
 
     public Integer showOnlyInstances() {
-        return onlyInstances;
+        return ShowOnlyInstances;
     }
 
     /**
      * remember that diagram is the parent of a component
      * @param onlyInstances
      */
-    public void setOnlyInstances(Integer onlyInstances) {
-        Integer oldOnlyInstances = this.onlyInstances;
-        this.onlyInstances = onlyInstances;
+    public void setShowOnlyInstances(Integer onlyInstances) {
+        Integer oldOnlyInstances = this.ShowOnlyInstances;
+        this.ShowOnlyInstances = onlyInstances;
         firePropertyChange(Property_ID_DIAGRAM_ONLY_INSTANCES,
             oldOnlyInstances, onlyInstances);
     }
-
-    public Integer getOnlyInstances() {
-        return onlyInstances;
+    
+    /**
+     * The name is a bit vague get the value of 'OnlyInstances'
+     * @return
+     */
+    public Integer getShowOnlyInstances() {
+        return ShowOnlyInstances;
     }
 
     public void addChild(LimeElement child) {
      * @param isInstance
      */
     public void addChild(LimeElement child, boolean isInstance) {
-        this.onlyInstances = isInstance ? 1 : 0;
+        this.ShowOnlyInstances = isInstance ? 1 : 0;
         addChild(child);
     }
 
             //if this is a diagram
             if (this.getClass().getSimpleName()
                         .equals(LimeDiagram.class.getSimpleName())) {
-                ((LimeComponent) child).setInstance(this.onlyInstances == 1);
+                ((LimeComponent) child).setInstance(this.ShowOnlyInstances == 1);
             }
             //if it is a component set its child also to its instance condition
             else {
             }
 
             //if it is a component class then add it to dictionary
-            if ((this.onlyInstances != 1) &&
+            if ((this.ShowOnlyInstances != 1) &&
                     this.getClass().getSimpleName()
                             .equals(LimeDiagram.class.getSimpleName())) {
                 componentClassDictionary.put(((LimeComponent) child).getName(),
 
     public Object getPropertyValue(Object propName) {
         if (Property_ID_DIAGRAM_ONLY_INSTANCES.equals(propName)) {
-            return onlyInstances;
+            return ShowOnlyInstances;
         } else if (propName.equals(ID_ROUTER)) {
             return connectionRouter;
         }
 
     public void setPropertyValue(Object id, Object value) {
         if (Property_ID_DIAGRAM_ONLY_INSTANCES.equals(id)) {
-            setOnlyInstances((Integer) value);
+            setShowOnlyInstances((Integer) value);
         } else if (ID_ROUTER.equals(id)) {
             setConnectionRouter((Integer) value);
         } else {

src/system.properties

 Component_Menu_Icon_Path=/modelicons/others/comp.gif
 Layout_Normal_Icon_Path=/modelicons/others/layout.gif
 Layout_Disabled_Icon_Path=/modelicons/others/layout_disabled.gif
+SwitchView_Normal_Icon_Path=/modelicons/others/switchview.gif
+SwitchView_Disabled_Icon_Path=/modelicons/others/switchview.gif
 
 #XML
 Default_XML_DTD_Entry=gxf.dtd
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.