diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSPerspectiveFactory.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSPerspectiveFactory.java index 9582f0be2921741684ee7eb9edebdf5a6d53c6a8..70e960b63cec125bbfd8941517a019b65cfd4a9f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSPerspectiveFactory.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMSPerspectiveFactory.java @@ -16,44 +16,49 @@ public class BMSPerspectiveFactory implements IPerspectiveFactory { public void createInitialLayout(IPageLayout layout) { layout.setEditorAreaVisible(false); + layout.getViewLayout(VisualizationViewPart.ID).setCloseable(false); String editorArea = layout.getEditorArea(); - // ProB Event View (Top-Left) + // ProB Event View IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, 0.15f, editorArea); left.addView("de.prob.ui.OperationView"); + left.addView("de.prob.ui.HistoryView"); + left.addView("de.prob.ui.EventErrorView"); + // Event-B Explorer IFolderLayout leftb = layout.createFolder("leftb", IPageLayout.BOTTOM, - 0.4f, "left"); - leftb.addView("de.prob.ui.StateView"); - leftb.addView("de.prob.ui.HistoryView"); - leftb.addView("de.prob.ui.EventErrorView"); + 0.65f, "left"); + leftb.addView("fr.systerel.explorer.navigator.view"); + + // State View + IFolderLayout main1 = layout.createFolder("main1", IPageLayout.BOTTOM, + 0.20f, editorArea); + main1.addView("de.prob.ui.StateView"); // Outline View + Palette View + Library View (Right) - IFolderLayout right1 = layout.createFolder("right1", IPageLayout.RIGHT, - 0.80f, editorArea); - right1.addView(BMSPaletteView.ID); - right1.addView(BMotionOutlineView.ID); + IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, + 0.80f, "main1"); + right.addView(BMSPaletteView.ID); + right.addView(BMotionOutlineView.ID); - // Library View + Event-B Explorer - IFolderLayout right2 = layout.createFolder("right2", - IPageLayout.BOTTOM, 0.60f, "right1"); - right2.addView(LibraryView.ID); - right2.addView("fr.systerel.explorer.navigator.view"); - - // Placeholder for new visualization views - IFolderLayout top = layout.createFolder("bottom1", IPageLayout.BOTTOM, - 0.20f, IPageLayout.ID_EDITOR_AREA); - top.addPlaceholder(VisualizationViewPart.ID + ":*"); - layout.getViewLayout(VisualizationViewPart.ID).setCloseable(false); + // Library View + IFolderLayout rightb = layout.createFolder("rightb", + IPageLayout.BOTTOM, 0.65f, "right"); + rightb.addView(LibraryView.ID); // Properties view + observer view + control panel - IFolderLayout bottom = layout.createFolder("bottom2", - IPageLayout.BOTTOM, 0.65f, "bottom1"); - bottom.addView(ControlPanel.ID); - bottom.addView(IPageLayout.ID_PROP_SHEET); - bottom.addView(ObserverView.ID); + IFolderLayout bottom1 = layout.createFolder("bottom1", + IPageLayout.BOTTOM, 0.65f, "main1"); + bottom1.addView(ControlPanel.ID); + bottom1.addView(IPageLayout.ID_PROP_SHEET); + bottom1.addView(ObserverView.ID); + + // Placeholder for new visualization views + IFolderLayout main2 = layout.createFolder("main2", IPageLayout.RIGHT, + 0.50f, "main1"); + main2.addPlaceholder(VisualizationViewPart.ID + ":*"); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationViewPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationViewPart.java index 20d728051248e70211f312e24a07ec6b25055818..5e2c37fada187616d6dffd8cb2438dd990794666 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationViewPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/VisualizationViewPart.java @@ -1,5 +1,7 @@ package de.bmotionstudio.gef.editor; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.EventObject; import java.util.Iterator; @@ -66,7 +68,7 @@ import de.bmotionstudio.gef.editor.model.VisualizationView; import de.bmotionstudio.gef.editor.part.BMSEditPartFactory; public class VisualizationViewPart extends ViewPart implements - CommandStackListener { + CommandStackListener, PropertyChangeListener { public static String ID = "de.bmotionstudio.gef.editor.VisualizationView"; @@ -92,6 +94,8 @@ public class VisualizationViewPart extends ViewPart implements private boolean isInitialized = false; + private Composite parent; + private List<String> selectionActions = new ArrayList<String>(); private List<String> stackActions = new ArrayList<String>(); private List<String> propertyActions = new ArrayList<String>(); @@ -165,10 +169,6 @@ public class VisualizationViewPart extends ViewPart implements return visualizationView; } - public void setVisualizationView(VisualizationView visualizationView) { - this.visualizationView = visualizationView; - } - private void createActions() { ActionRegistry registry = getActionRegistry(); @@ -325,6 +325,8 @@ public class VisualizationViewPart extends ViewPart implements if (getActionRegistry() != null) getActionRegistry().dispose(); setInitialized(false); + if (getVisualizationView() != null) + getVisualizationView().removePropertyChangeListener(this); } @Override @@ -367,17 +369,19 @@ public class VisualizationViewPart extends ViewPart implements @Override public void createPartControl(Composite parent) { - container = new RulerComposite(parent, SWT.NONE); + this.parent = parent; + this.container = new RulerComposite(parent, SWT.NONE); } @Override public void setFocus() { - container.setFocus(); + this.container.setFocus(); } public void init(Simulation simulation, VisualizationView visualizationView) { this.simulation = simulation; this.visualizationView = visualizationView; + this.visualizationView.addPropertyChangeListener(this); this.visualization = visualizationView.getVisualization(); this.graphicalViewer = new ScrollingGraphicalViewer(); this.graphicalViewer.createControl(this.container); @@ -548,4 +552,14 @@ public class VisualizationViewPart extends ViewPart implements return this.visualization; } + public Composite getParent() { + return parent; + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getPropertyName().equals("name")) + setPartName(evt.getNewValue().toString()); + } + } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/controlpanel/ControlPanel.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/controlpanel/ControlPanel.java index 9d7e45ab6778ae0ce1b4d0b43d6943ed9233ff71..a280e50464d823db48fac6823633196472843a4a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/controlpanel/ControlPanel.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/controlpanel/ControlPanel.java @@ -12,13 +12,17 @@ import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; +import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITableColorProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.ITreeSelection; +import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewerColumn; import org.eclipse.jface.viewers.Viewer; @@ -65,36 +69,52 @@ public class ControlPanel extends ViewPart implements ISimulationListener, column1.getColumn().setAlignment(SWT.LEFT); column1.getColumn().setText("Name"); column1.getColumn().setWidth(300); - // column1.setEditingSupport(new EditingSupport(treeViewer) { - // - // @Override - // protected void setValue(Object element, Object value) { - // if (element instanceof VisualizationView) { - // ((VisualizationView) element).setName(String.valueOf(value)); - // treeViewer.update(element, null); - // } - // } - // - // @Override - // protected Object getValue(Object element) { - // if (element instanceof VisualizationView) - // return ((VisualizationView) element).getName(); - // return null; - // } - // - // @Override - // protected CellEditor getCellEditor(Object element) { - // return new TextCellEditor(treeViewer.getTree()); - // } - // - // @Override - // protected boolean canEdit(Object element) { - // if (element instanceof VisualizationView) - // return true; - // return false; - // } - // - // }); + column1.setEditingSupport(new EditingSupport(treeViewer) { + + @Override + protected void setValue(Object element, Object value) { + if (element instanceof VisualizationView) { + + VisualizationView visView = (VisualizationView) element; + visView.setName(String.valueOf(value)); + + ITreeSelection selection = ((ITreeSelection) treeViewer + .getSelection()); + Object parent = selection.getPaths()[0].getParentPath() + .getLastSegment(); + if (parent instanceof Simulation) + ((Simulation) parent).setDirty(true); + treeViewer.update(element, null); + + // IWorkbenchPage page = PlatformUI.getWorkbench() + // .getActiveWorkbenchWindow().getActivePage(); + // IViewReference viewReference = page.findViewReference( + // VisualizationViewPart.ID, visView.getViewId()); + // IViewPart view = viewReference.getView(true); + + } + } + + @Override + protected Object getValue(Object element) { + if (element instanceof VisualizationView) + return ((VisualizationView) element).getName(); + return null; + } + + @Override + protected CellEditor getCellEditor(Object element) { + return new TextCellEditor(treeViewer.getTree()); + } + + @Override + protected boolean canEdit(Object element) { + if (element instanceof VisualizationView) + return true; + return false; + } + + }); TreeViewerColumn column2 = new TreeViewerColumn(treeViewer, SWT.RIGHT); column2.getColumn().setAlignment(SWT.LEFT); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/VisualizationView.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/VisualizationView.java index 71cc970729e9a06439e0f3b943e27723ba0ab81b..98c22b80b7d1c4ff1e80aada825349aabbdd01ab 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/VisualizationView.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/VisualizationView.java @@ -1,11 +1,18 @@ package de.bmotionstudio.gef.editor.model; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + public class VisualizationView { private String name; + private Visualization visualization; + private String viewId; + private transient PropertyChangeSupport listeners; + public VisualizationView(String name, Visualization visualization, String viewId) { this.name = name; @@ -18,7 +25,9 @@ public class VisualizationView { } public void setName(String name) { + String oldVal = this.name; this.name = name; + listeners.firePropertyChange("name", oldVal, name); } public Visualization getVisualization() { @@ -37,4 +46,18 @@ public class VisualizationView { this.viewId = viewId; } + public void addPropertyChangeListener(PropertyChangeListener listener) { + getListeners().addPropertyChangeListener(listener); + } + + public PropertyChangeSupport getListeners() { + if (listeners == null) + listeners = new PropertyChangeSupport(this); + return listeners; + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + getListeners().removePropertyChangeListener(listener); + } + }