Skip to content
Snippets Groups Projects
Commit 532a4693 authored by Jens Bendisposto's avatar Jens Bendisposto
Browse files

Merge remote-tracking branch 'origin/develop' into feature/newcore

parents 5920737d 2313c826
No related branches found
No related tags found
No related merge requests found
Showing
with 250 additions and 180 deletions
de.bmotionstudio.gef.editor/icons/eclipse16/updated_co.gif

105 B

de.bmotionstudio.gef.editor/icons/eclipse16/updated_col.gif

113 B

...@@ -290,6 +290,10 @@ ...@@ -290,6 +290,10 @@
class="de.bmotionstudio.gef.editor.observer.ExternalObserverScript" class="de.bmotionstudio.gef.editor.observer.ExternalObserverScript"
name="External Observer Script"> name="External Observer Script">
</observer> </observer>
<observer
class="de.bmotionstudio.gef.editor.observer.TableObserver"
name="Table Observer">
</observer>
<observer <observer
class="de.bmotionstudio.gef.editor.observer.ColumnObserver" class="de.bmotionstudio.gef.editor.observer.ColumnObserver"
name="Column Observer"> name="Column Observer">
...@@ -380,6 +384,9 @@ ...@@ -380,6 +384,9 @@
<control <control
id="de.bmotionstudio.gef.editor.table"> id="de.bmotionstudio.gef.editor.table">
</control> </control>
<control
id="de.bmotionstudio.gef.editor.tablecolumn">
</control>
</observer> </observer>
<observer <observer
id="de.bmotionstudio.gef.editor.observer.SwitchCoordinates"> id="de.bmotionstudio.gef.editor.observer.SwitchCoordinates">
...@@ -470,6 +477,9 @@ ...@@ -470,6 +477,9 @@
<control <control
id="de.bmotionstudio.gef.editor.table"> id="de.bmotionstudio.gef.editor.table">
</control> </control>
<control
id="de.bmotionstudio.gef.editor.tablecolumn">
</control>
</observer> </observer>
<observer <observer
id="de.bmotionstudio.gef.editor.observer.SwitchChildCoordinates"> id="de.bmotionstudio.gef.editor.observer.SwitchChildCoordinates">
...@@ -518,6 +528,9 @@ ...@@ -518,6 +528,9 @@
<control <control
id="de.bmotionstudio.gef.editor.table"> id="de.bmotionstudio.gef.editor.table">
</control> </control>
<control
id="de.bmotionstudio.gef.editor.tablecolumn">
</control>
</observer> </observer>
<observer <observer
id="de.bmotionstudio.gef.editor.observer.SwitchImage"> id="de.bmotionstudio.gef.editor.observer.SwitchImage">
...@@ -540,6 +553,12 @@ ...@@ -540,6 +553,12 @@
id="de.bmotionstudio.gef.editor.tablecolumn"> id="de.bmotionstudio.gef.editor.tablecolumn">
</control> </control>
</observer> </observer>
<observer
id="de.bmotionstudio.gef.editor.observer.TableObserver">
<control
id="de.bmotionstudio.gef.editor.table">
</control>
</observer>
</include> </include>
</extension> </extension>
</plugin> </plugin>
...@@ -13,6 +13,8 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; ...@@ -13,6 +13,8 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
import de.bmotionstudio.gef.editor.internal.BControlTemplate; import de.bmotionstudio.gef.editor.internal.BControlTemplate;
import de.bmotionstudio.gef.editor.model.Visualization; import de.bmotionstudio.gef.editor.model.Visualization;
import de.bmotionstudio.gef.editor.part.BControlTreeEditPart;
import de.bmotionstudio.gef.editor.part.BMSAbstractTreeEditPart;
/** /**
* @author Lukas Ladenberger * @author Lukas Ladenberger
...@@ -40,4 +42,8 @@ public abstract class AbstractBControlService { ...@@ -40,4 +42,8 @@ public abstract class AbstractBControlService {
return true; return true;
} }
public BMSAbstractTreeEditPart createTreeEditPart() {
return new BControlTreeEditPart();
}
} }
...@@ -51,6 +51,7 @@ public final class AttributeConstants { ...@@ -51,6 +51,7 @@ public final class AttributeConstants {
public static final String ATTRIBUTE_COORDINATES = "de.bmotionstudio.gef.editor.attribute.BAttributeCoordinates"; public static final String ATTRIBUTE_COORDINATES = "de.bmotionstudio.gef.editor.attribute.BAttributeCoordinates";
public static final String ATTRIBUTE_MISC = "de.bmotionstudio.gef.editor.attribute.BAttributeMisc"; public static final String ATTRIBUTE_MISC = "de.bmotionstudio.gef.editor.attribute.BAttributeMisc";
public static final String ATTRIBUTE_MAIN = "de.bmotionstudio.gef.editor.attribute.BAttributeMain"; public static final String ATTRIBUTE_MAIN = "de.bmotionstudio.gef.editor.attribute.BAttributeMain";
public static final String ATTRIBUTE_CONNECTION = "de.bmotionstudio.gef.editor.attribute.BAttributeConnection";
public static final String EVENT_MOUSECLICK = "de.bmotionstudio.gef.editor.event.OnClickEvent"; public static final String EVENT_MOUSECLICK = "de.bmotionstudio.gef.editor.event.OnClickEvent";
public static final String EVENT_MOUSEDBLCLICK = "de.bmotionstudio.gef.editor.event.OnDblClickEvent"; public static final String EVENT_MOUSEDBLCLICK = "de.bmotionstudio.gef.editor.event.OnDblClickEvent";
......
...@@ -14,6 +14,7 @@ import org.eclipse.core.runtime.IExtensionRegistry; ...@@ -14,6 +14,7 @@ import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.gef.ContextMenuProvider; import org.eclipse.gef.ContextMenuProvider;
import org.eclipse.gef.EditPartViewer; import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.editparts.AbstractEditPart;
import org.eclipse.gef.ui.actions.ActionRegistry; import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.gef.ui.actions.GEFActionConstants; import org.eclipse.gef.ui.actions.GEFActionConstants;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
...@@ -24,11 +25,11 @@ import org.eclipse.ui.actions.ActionFactory; ...@@ -24,11 +25,11 @@ import org.eclipse.ui.actions.ActionFactory;
import de.bmotionstudio.gef.editor.action.OpenSchedulerEventAction; import de.bmotionstudio.gef.editor.action.OpenSchedulerEventAction;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.part.AppAbstractEditPart; import de.bmotionstudio.gef.editor.model.ObserverRootVirtualTreeNode;
import de.bmotionstudio.gef.editor.part.VisualizationPart; import de.bmotionstudio.gef.editor.model.Visualization;
import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent; import de.bmotionstudio.gef.editor.scheduler.SchedulerEvent;
public class AppContextMenuProvider extends ContextMenuProvider { public class BMSContextMenuProvider extends ContextMenuProvider {
private ActionRegistry actionRegistry; private ActionRegistry actionRegistry;
...@@ -36,7 +37,7 @@ public class AppContextMenuProvider extends ContextMenuProvider { ...@@ -36,7 +37,7 @@ public class AppContextMenuProvider extends ContextMenuProvider {
private String[] eventIDs = { AttributeConstants.EVENT_MOUSECLICK }; private String[] eventIDs = { AttributeConstants.EVENT_MOUSECLICK };
public AppContextMenuProvider(EditPartViewer viewer, ActionRegistry registry) { public BMSContextMenuProvider(EditPartViewer viewer, ActionRegistry registry) {
super(viewer); super(viewer);
setActionRegistry(registry); setActionRegistry(registry);
} }
...@@ -54,24 +55,32 @@ public class AppContextMenuProvider extends ContextMenuProvider { ...@@ -54,24 +55,32 @@ public class AppContextMenuProvider extends ContextMenuProvider {
action = getActionRegistry().getAction(ActionFactory.REDO.getId()); action = getActionRegistry().getAction(ActionFactory.REDO.getId());
menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action); menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
action = actionRegistry.getAction(ActionFactory.COPY.getId()); action = getActionRegistry().getAction(ActionFactory.COPY.getId());
menu.appendToGroup(GEFActionConstants.GROUP_COPY, action); menu.appendToGroup(GEFActionConstants.GROUP_COPY, action);
action = actionRegistry.getAction(ActionFactory.PASTE.getId()); action = getActionRegistry().getAction(ActionFactory.PASTE.getId());
menu.appendToGroup(GEFActionConstants.GROUP_COPY, action); menu.appendToGroup(GEFActionConstants.GROUP_COPY, action);
action = getActionRegistry().getAction(ActionFactory.DELETE.getId()); action = getActionRegistry().getAction(ActionFactory.DELETE.getId());
menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action); menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
buildCustomMenu(menu); Object sel = ((IStructuredSelection) getViewer().getSelection())
.getFirstElement();
buildObserverMenu(menu); if (sel instanceof AbstractEditPart) {
AbstractEditPart editPart = (AbstractEditPart) sel;
buildEventMenu(menu); buildCustomMenu(menu, editPart);
buildObserverMenu(menu, editPart);
buildEventMenu(menu, editPart);
}
} }
private void buildCustomMenu(IMenuManager menu) { private void buildCustomMenu(IMenuManager menu, AbstractEditPart editPart) {
Object model = editPart.getModel();
if (model instanceof BControl) {
IExtensionPoint extensionPoint = registry IExtensionPoint extensionPoint = registry
.getExtensionPoint("de.bmotionstudio.gef.editor.installMenu"); .getExtensionPoint("de.bmotionstudio.gef.editor.installMenu");
...@@ -86,7 +95,8 @@ public class AppContextMenuProvider extends ContextMenuProvider { ...@@ -86,7 +95,8 @@ public class AppContextMenuProvider extends ContextMenuProvider {
IInstallMenu installMenuClass = (IInstallMenu) configurationElement IInstallMenu installMenuClass = (IInstallMenu) configurationElement
.createExecutableExtension("class"); .createExecutableExtension("class");
installMenuClass.installMenu(menu, getActionRegistry()); installMenuClass.installMenu(menu,
getActionRegistry());
} catch (final CoreException e) { } catch (final CoreException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -100,23 +110,27 @@ public class AppContextMenuProvider extends ContextMenuProvider { ...@@ -100,23 +110,27 @@ public class AppContextMenuProvider extends ContextMenuProvider {
} }
private void buildObserverMenu(IMenuManager menu) { }
private void buildObserverMenu(IMenuManager menu, AbstractEditPart editPart) {
Object model = editPart.getModel();
BControl bcontrol = null;
final MenuManager handleObserverMenu = new MenuManager("Observers", if (model instanceof BControl)
bcontrol = (BControl) model;
else if (model instanceof ObserverRootVirtualTreeNode)
bcontrol = ((ObserverRootVirtualTreeNode) model).getControl();
else
return;
final MenuManager handleObserverMenu = new MenuManager("Observer",
BMotionStudioImage.getImageDescriptor( BMotionStudioImage.getImageDescriptor(
BMotionEditorPlugin.PLUGIN_ID, BMotionEditorPlugin.PLUGIN_ID,
"icons/icon_observer.gif"), "observerMenu"); "icons/icon_observer.gif"), "observerMenu");
menu.appendToGroup(GEFActionConstants.GROUP_ADD, handleObserverMenu); menu.appendToGroup(GEFActionConstants.GROUP_ADD, handleObserverMenu);
IStructuredSelection selection = (IStructuredSelection) BMotionEditorPlugin
.getActiveEditor().getEditorSite().getSelectionProvider()
.getSelection();
if (selection.getFirstElement() instanceof AppAbstractEditPart) {
BControl bcontrol = (BControl) ((AppAbstractEditPart) selection
.getFirstElement()).getModel();
IExtensionPoint extensionPoint = registry IExtensionPoint extensionPoint = registry
.getExtensionPoint("de.bmotionstudio.gef.editor.observer"); .getExtensionPoint("de.bmotionstudio.gef.editor.observer");
for (IExtension extension : extensionPoint.getExtensions()) { for (IExtension extension : extensionPoint.getExtensions()) {
...@@ -158,8 +172,6 @@ public class AppContextMenuProvider extends ContextMenuProvider { ...@@ -158,8 +172,6 @@ public class AppContextMenuProvider extends ContextMenuProvider {
} }
}
private boolean checkIncludeObserver(String observerID, BControl control) { private boolean checkIncludeObserver(String observerID, BControl control) {
IExtensionPoint extensionPoint = registry IExtensionPoint extensionPoint = registry
...@@ -212,23 +224,19 @@ public class AppContextMenuProvider extends ContextMenuProvider { ...@@ -212,23 +224,19 @@ public class AppContextMenuProvider extends ContextMenuProvider {
} }
private void buildEventMenu(IMenuManager menu) { private void buildEventMenu(IMenuManager menu, AbstractEditPart editPart) {
Object model = editPart.getModel();
if (model instanceof BControl && !(model instanceof Visualization)) {
MenuManager handleEventMenu = new MenuManager("Events", MenuManager handleEventMenu = new MenuManager("Events",
BMotionStudioImage.getImageDescriptor( BMotionStudioImage.getImageDescriptor(
BMotionEditorPlugin.PLUGIN_ID, "icons/icon_event.png"), BMotionEditorPlugin.PLUGIN_ID,
"eventMenu"); "icons/icon_event.png"), "eventMenu");
menu.appendToGroup(GEFActionConstants.GROUP_ADD, handleEventMenu); menu.appendToGroup(GEFActionConstants.GROUP_ADD, handleEventMenu);
IStructuredSelection selection = (IStructuredSelection) BMotionEditorPlugin BControl bcontrol = (BControl) model;
.getActiveEditor().getEditorSite().getSelectionProvider()
.getSelection();
if ((selection.getFirstElement() instanceof AppAbstractEditPart)
&& !(selection.getFirstElement() instanceof VisualizationPart)) {
BControl bcontrol = (BControl) ((AppAbstractEditPart) selection
.getFirstElement()).getModel();
// Has event // Has event
if (bcontrol.hasEvent(eventIDs[0])) { if (bcontrol.hasEvent(eventIDs[0])) {
...@@ -297,7 +305,6 @@ public class AppContextMenuProvider extends ContextMenuProvider { ...@@ -297,7 +305,6 @@ public class AppContextMenuProvider extends ContextMenuProvider {
} }
} }
} }
} }
......
...@@ -23,10 +23,12 @@ public class BMotionSelectionSynchronizer extends SelectionSynchronizer { ...@@ -23,10 +23,12 @@ public class BMotionSelectionSynchronizer extends SelectionSynchronizer {
} }
protected EditPart convert(EditPartViewer viewer, EditPart part) { protected EditPart convert(EditPartViewer viewer, EditPart part) {
EditPart p = super.convert(viewer, part);
if (viewer instanceof ScrollingGraphicalViewer if (viewer instanceof ScrollingGraphicalViewer
|| viewer instanceof TreeViewer) { || viewer instanceof TreeViewer) {
BControl control = (BControl) part.getModel(); Object model = part.getModel();
if (model instanceof BControl) {
BControl control = (BControl) model;
String id = control.getID(); String id = control.getID();
BControl editControl = editor.getEditPage().getVisualization() BControl editControl = editor.getEditPage().getVisualization()
.getBControl(id); .getBControl(id);
...@@ -36,10 +38,9 @@ public class BMotionSelectionSynchronizer extends SelectionSynchronizer { ...@@ -36,10 +38,9 @@ public class BMotionSelectionSynchronizer extends SelectionSynchronizer {
newPart = (EditPart) temp; newPart = (EditPart) temp;
} }
return newPart; return newPart;
} else {
return super.convert(viewer, part);
} }
}
return p;
} }
} }
...@@ -70,6 +70,7 @@ import org.eclipse.gef.ui.rulers.RulerComposite; ...@@ -70,6 +70,7 @@ import org.eclipse.gef.ui.rulers.RulerComposite;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeEvent;
...@@ -104,8 +105,10 @@ import de.bmotionstudio.gef.editor.library.AttributeTransferDropTargetListener; ...@@ -104,8 +105,10 @@ import de.bmotionstudio.gef.editor.library.AttributeTransferDropTargetListener;
import de.bmotionstudio.gef.editor.model.BMotionRuler; import de.bmotionstudio.gef.editor.model.BMotionRuler;
import de.bmotionstudio.gef.editor.model.BMotionRulerProvider; import de.bmotionstudio.gef.editor.model.BMotionRulerProvider;
import de.bmotionstudio.gef.editor.model.Visualization; import de.bmotionstudio.gef.editor.model.Visualization;
import de.bmotionstudio.gef.editor.part.AppEditPartFactory; import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart;
import de.bmotionstudio.gef.editor.part.AppTreeEditPartFactory; import de.bmotionstudio.gef.editor.part.BMSAbstractTreeEditPart;
import de.bmotionstudio.gef.editor.part.BMSEditPartFactory;
import de.bmotionstudio.gef.editor.part.BMSTreeEditPartFactory;
public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette { public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette {
...@@ -152,10 +155,18 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette { ...@@ -152,10 +155,18 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette {
@Override @Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) { public void selectionChanged(IWorkbenchPart part, ISelection selection) {
// If not the active editor, ignore selection changed. // If not the active editor, ignore selection changed.
if (getBMotionStudioEditor().equals( if (!getBMotionStudioEditor().equals(
getSite().getPage().getActiveEditor())) getSite().getPage().getActiveEditor()))
return;
Object selectedElement = ((IStructuredSelection) selection)
.getFirstElement();
if (selectedElement instanceof BMSAbstractEditPart
|| selectedElement instanceof BMSAbstractTreeEditPart)
updateActions(getSelectionActions()); updateActions(getSelectionActions());
} }
/** /**
...@@ -495,7 +506,7 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette { ...@@ -495,7 +506,7 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette {
super.configureGraphicalViewer(); super.configureGraphicalViewer();
ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer(); ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
viewer.setEditPartFactory(new AppEditPartFactory()); viewer.setEditPartFactory(new BMSEditPartFactory());
ScalableRootEditPart rootEditPart = new ScalableRootEditPart(); ScalableRootEditPart rootEditPart = new ScalableRootEditPart();
GridLayer gridLayer = (GridLayer) rootEditPart GridLayer gridLayer = (GridLayer) rootEditPart
...@@ -533,7 +544,7 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette { ...@@ -533,7 +544,7 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette {
getActionRegistry().registerAction( getActionRegistry().registerAction(
new ToggleGridAction(getGraphicalViewer())); new ToggleGridAction(getGraphicalViewer()));
ContextMenuProvider provider = new AppContextMenuProvider(viewer, ContextMenuProvider provider = new BMSContextMenuProvider(viewer,
getActionRegistry()); getActionRegistry());
viewer.setContextMenu(provider); viewer.setContextMenu(provider);
...@@ -670,8 +681,8 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette { ...@@ -670,8 +681,8 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette {
protected void configureOutlineViewer() { protected void configureOutlineViewer() {
getViewer().setEditDomain(getEditDomain()); getViewer().setEditDomain(getEditDomain());
getViewer().setEditPartFactory(new AppTreeEditPartFactory()); getViewer().setEditPartFactory(new BMSTreeEditPartFactory());
ContextMenuProvider provider = new AppContextMenuProvider( ContextMenuProvider provider = new BMSContextMenuProvider(
getViewer(), getActionRegistry()); getViewer(), getActionRegistry());
getViewer().setContextMenu(provider); getViewer().setContextMenu(provider);
getViewer().setKeyHandler(getCommonKeyHandler()); getViewer().setKeyHandler(getCommonKeyHandler());
...@@ -736,13 +747,6 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette { ...@@ -736,13 +747,6 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette {
} }
}; };
// collapseAllAction
// .setImageDescriptor(ImageDescriptor
// .createFromImage(PlatformUI
// .getWorkbench()
// .getSharedImages()
// .getImage(
// ISharedImages.IMG_ELCL_COLLAPSEALL)));
getSite().getActionBars().getMenuManager().add(expandAllAction); getSite().getActionBars().getMenuManager().add(expandAllAction);
getSite().getActionBars().getMenuManager().add(collapseAllAction); getSite().getActionBars().getMenuManager().add(collapseAllAction);
......
...@@ -31,7 +31,7 @@ import org.eclipse.ui.IWorkbenchPart; ...@@ -31,7 +31,7 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.actions.ActionFactory;
import de.bmotionstudio.gef.editor.model.Visualization; import de.bmotionstudio.gef.editor.model.Visualization;
import de.bmotionstudio.gef.editor.part.AppEditPartFactory; import de.bmotionstudio.gef.editor.part.BMSEditPartFactory;
public class BMotionStudioRunPage extends GraphicalEditor { public class BMotionStudioRunPage extends GraphicalEditor {
...@@ -125,7 +125,7 @@ public class BMotionStudioRunPage extends GraphicalEditor { ...@@ -125,7 +125,7 @@ public class BMotionStudioRunPage extends GraphicalEditor {
super.configureGraphicalViewer(); super.configureGraphicalViewer();
ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer(); ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
viewer.setEditPartFactory(new AppEditPartFactory()); viewer.setEditPartFactory(new BMSEditPartFactory());
ScalableRootEditPart rootEditPart = new ScalableRootEditPart(); ScalableRootEditPart rootEditPart = new ScalableRootEditPart();
viewer.setRootEditPart(rootEditPart); viewer.setRootEditPart(rootEditPart);
......
...@@ -25,6 +25,8 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry { ...@@ -25,6 +25,8 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry {
public static final String IMG_ICON_CONNECTION24 = "icon_connection24"; public static final String IMG_ICON_CONNECTION24 = "icon_connection24";
public static final String IMG_ICON_NEW_WIZ = "icon_new_wiz"; public static final String IMG_ICON_NEW_WIZ = "icon_new_wiz";
public static final String IMG_ICON_DELETE_EDIT = "icon_delete_edit"; public static final String IMG_ICON_DELETE_EDIT = "icon_delete_edit";
public static final String IMG_ICON_TR_UP = "icon_tr_up";
public static final String IMG_ICON_TR_LEFT = "icon_tr_left";
public static final String IMG_ICON_JPG = "icon_jpg"; public static final String IMG_ICON_JPG = "icon_jpg";
public static final String IMG_ICON_GIF = "icon_gif"; public static final String IMG_ICON_GIF = "icon_gif";
...@@ -66,6 +68,13 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry { ...@@ -66,6 +68,13 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry {
BMotionStudioImage.registerImage(IMG_ICON_DELETE_EDIT, BMotionStudioImage.registerImage(IMG_ICON_DELETE_EDIT,
"org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif"); "org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif");
BMotionStudioImage
.registerImage(IMG_ICON_TR_UP, BMotionEditorPlugin.PLUGIN_ID,
"icons/eclipse16/updated_co.gif");
BMotionStudioImage.registerImage(IMG_ICON_TR_LEFT,
BMotionEditorPlugin.PLUGIN_ID,
"icons/eclipse16/updated_col.gif");
BMotionStudioImage.registerImage(IMG_ICON_JPG, BMotionStudioImage.registerImage(IMG_ICON_JPG,
BMotionEditorPlugin.PLUGIN_ID, "icons/icon_jpg.gif"); BMotionEditorPlugin.PLUGIN_ID, "icons/icon_jpg.gif");
BMotionStudioImage.registerImage(IMG_ICON_GIF, BMotionStudioImage.registerImage(IMG_ICON_GIF,
......
...@@ -11,7 +11,8 @@ import org.eclipse.gef.palette.ToolEntry; ...@@ -11,7 +11,8 @@ import org.eclipse.gef.palette.ToolEntry;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.model.Visualization; import de.bmotionstudio.gef.editor.model.Visualization;
import de.bmotionstudio.gef.editor.part.AppAbstractEditPart; import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart;
import de.bmotionstudio.gef.editor.part.BMSAbstractTreeEditPart;
/** /**
* @author Lukas Ladenberger * @author Lukas Ladenberger
...@@ -21,7 +22,9 @@ public interface IBControlService { ...@@ -21,7 +22,9 @@ public interface IBControlService {
public BControl createControl(Visualization visualization); public BControl createControl(Visualization visualization);
public AppAbstractEditPart createEditPart(); public BMSAbstractEditPart createEditPart();
public BMSAbstractTreeEditPart createTreeEditPart();
public ToolEntry createToolEntry(Visualization visualization, public ToolEntry createToolEntry(Visualization visualization,
IConfigurationElement configurationElement); IConfigurationElement configurationElement);
......
...@@ -16,7 +16,7 @@ public class BMotionObserverWizardDialog extends BMotionAbstractWizardDialog { ...@@ -16,7 +16,7 @@ public class BMotionObserverWizardDialog extends BMotionAbstractWizardDialog {
public BMotionObserverWizardDialog(IWorkbenchPart workbenchPart, IWizard newWizard) { public BMotionObserverWizardDialog(IWorkbenchPart workbenchPart, IWizard newWizard) {
super(workbenchPart, newWizard); super(workbenchPart, newWizard);
setShellStyle(SWT.CLOSE); setShellStyle(SWT.CLOSE | SWT.RESIZE);
setDeleteToolTip("Delete Observer"); setDeleteToolTip("Delete Observer");
} }
......
...@@ -17,7 +17,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; ...@@ -17,7 +17,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
import de.bmotionstudio.gef.editor.BMotionEditorPlugin; import de.bmotionstudio.gef.editor.BMotionEditorPlugin;
import de.bmotionstudio.gef.editor.command.BringToBottomCommand; import de.bmotionstudio.gef.editor.command.BringToBottomCommand;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.part.AppAbstractEditPart; import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart;
import de.bmotionstudio.gef.editor.part.VisualizationPart; import de.bmotionstudio.gef.editor.part.VisualizationPart;
public class BringToBottomAction extends SelectionAction { public class BringToBottomAction extends SelectionAction {
...@@ -66,9 +66,9 @@ public class BringToBottomAction extends SelectionAction { ...@@ -66,9 +66,9 @@ public class BringToBottomAction extends SelectionAction {
List<?> selectedObjects = getSelectedObjects(); List<?> selectedObjects = getSelectedObjects();
for (Object obj : selectedObjects) { for (Object obj : selectedObjects) {
if (obj instanceof AppAbstractEditPart) { if (obj instanceof BMSAbstractEditPart) {
modelList modelList
.add((BControl) ((AppAbstractEditPart) obj).getModel()); .add((BControl) ((BMSAbstractEditPart) obj).getModel());
} }
} }
......
...@@ -17,7 +17,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; ...@@ -17,7 +17,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
import de.bmotionstudio.gef.editor.BMotionEditorPlugin; import de.bmotionstudio.gef.editor.BMotionEditorPlugin;
import de.bmotionstudio.gef.editor.command.BringToBottomStepCommand; import de.bmotionstudio.gef.editor.command.BringToBottomStepCommand;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.part.AppAbstractEditPart; import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart;
import de.bmotionstudio.gef.editor.part.VisualizationPart; import de.bmotionstudio.gef.editor.part.VisualizationPart;
public class BringToBottomStepAction extends SelectionAction { public class BringToBottomStepAction extends SelectionAction {
...@@ -67,9 +67,9 @@ public class BringToBottomStepAction extends SelectionAction { ...@@ -67,9 +67,9 @@ public class BringToBottomStepAction extends SelectionAction {
List<?> selectedObjects = getSelectedObjects(); List<?> selectedObjects = getSelectedObjects();
for (Object obj : selectedObjects) { for (Object obj : selectedObjects) {
if (obj instanceof AppAbstractEditPart) { if (obj instanceof BMSAbstractEditPart) {
modelList modelList
.add((BControl) ((AppAbstractEditPart) obj).getModel()); .add((BControl) ((BMSAbstractEditPart) obj).getModel());
} }
} }
......
...@@ -17,7 +17,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; ...@@ -17,7 +17,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
import de.bmotionstudio.gef.editor.BMotionEditorPlugin; import de.bmotionstudio.gef.editor.BMotionEditorPlugin;
import de.bmotionstudio.gef.editor.command.BringToTopCommand; import de.bmotionstudio.gef.editor.command.BringToTopCommand;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.part.AppAbstractEditPart; import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart;
import de.bmotionstudio.gef.editor.part.VisualizationPart; import de.bmotionstudio.gef.editor.part.VisualizationPart;
public class BringToTopAction extends SelectionAction { public class BringToTopAction extends SelectionAction {
...@@ -62,8 +62,8 @@ public class BringToTopAction extends SelectionAction { ...@@ -62,8 +62,8 @@ public class BringToTopAction extends SelectionAction {
List<BControl> controlList = new ArrayList<BControl>(); List<BControl> controlList = new ArrayList<BControl>();
List<?> selectedObjects = getSelectedObjects(); List<?> selectedObjects = getSelectedObjects();
for (Object obj : selectedObjects) { for (Object obj : selectedObjects) {
if (obj instanceof AppAbstractEditPart) { if (obj instanceof BMSAbstractEditPart) {
controlList.add((BControl) ((AppAbstractEditPart) obj) controlList.add((BControl) ((BMSAbstractEditPart) obj)
.getModel()); .getModel());
} }
} }
......
...@@ -17,7 +17,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; ...@@ -17,7 +17,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
import de.bmotionstudio.gef.editor.BMotionEditorPlugin; import de.bmotionstudio.gef.editor.BMotionEditorPlugin;
import de.bmotionstudio.gef.editor.command.BringToTopStepCommand; import de.bmotionstudio.gef.editor.command.BringToTopStepCommand;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.part.AppAbstractEditPart; import de.bmotionstudio.gef.editor.part.BMSAbstractEditPart;
import de.bmotionstudio.gef.editor.part.VisualizationPart; import de.bmotionstudio.gef.editor.part.VisualizationPart;
public class BringToTopStepAction extends SelectionAction { public class BringToTopStepAction extends SelectionAction {
...@@ -66,9 +66,9 @@ public class BringToTopStepAction extends SelectionAction { ...@@ -66,9 +66,9 @@ public class BringToTopStepAction extends SelectionAction {
List<?> selectedObjects = getSelectedObjects(); List<?> selectedObjects = getSelectedObjects();
for (Object obj : selectedObjects) { for (Object obj : selectedObjects) {
if (obj instanceof AppAbstractEditPart) { if (obj instanceof BMSAbstractEditPart) {
modelList modelList
.add((BControl) ((AppAbstractEditPart) obj).getModel()); .add((BControl) ((BMSAbstractEditPart) obj).getModel());
} }
} }
......
...@@ -53,11 +53,12 @@ public class CopyAction extends SelectionAction { ...@@ -53,11 +53,12 @@ public class CopyAction extends SelectionAction {
Object nextElement = it.next(); Object nextElement = it.next();
if (nextElement instanceof EditPart) { if (nextElement instanceof EditPart) {
EditPart ep = (EditPart) nextElement; EditPart ep = (EditPart) nextElement;
if (ep.getModel() instanceof BControl) {
BControl node = (BControl) ep.getModel(); BControl node = (BControl) ep.getModel();
if (!cmd.isCopyableControl(node)) if (cmd.isCopyableControl(node))
return null;
cmd.addElement(node); cmd.addElement(node);
} }
}
} }
return cmd; return cmd;
......
...@@ -54,6 +54,7 @@ public class FitImageAction extends SelectionAction { ...@@ -54,6 +54,7 @@ public class FitImageAction extends SelectionAction {
for (Object obj : selectedObjects) { for (Object obj : selectedObjects) {
if (obj instanceof EditPart) { if (obj instanceof EditPart) {
EditPart part = (EditPart) obj; EditPart part = (EditPart) obj;
if (part.getModel() instanceof BControl) {
BControl bcontrol = (BControl) part.getModel(); BControl bcontrol = (BControl) part.getModel();
if (bcontrol if (bcontrol
.getAttributeValue(AttributeConstants.ATTRIBUTE_IMAGE) != null) { .getAttributeValue(AttributeConstants.ATTRIBUTE_IMAGE) != null) {
...@@ -61,6 +62,7 @@ public class FitImageAction extends SelectionAction { ...@@ -61,6 +62,7 @@ public class FitImageAction extends SelectionAction {
} }
} }
} }
}
return false; return false;
} }
......
...@@ -14,11 +14,12 @@ import org.eclipse.gef.ui.actions.SelectionAction; ...@@ -14,11 +14,12 @@ import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPart;
import de.bmotionstudio.gef.editor.AttributeConstants;
import de.bmotionstudio.gef.editor.BMotionEditorPlugin; import de.bmotionstudio.gef.editor.BMotionEditorPlugin;
import de.bmotionstudio.gef.editor.BMotionStudioImage; import de.bmotionstudio.gef.editor.BMotionStudioImage;
import de.bmotionstudio.gef.editor.command.ObserverCommand; import de.bmotionstudio.gef.editor.command.RemoveObserverCommand;
import de.bmotionstudio.gef.editor.command.SetObserverCommand;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.model.ObserverRootVirtualTreeNode;
import de.bmotionstudio.gef.editor.observer.Observer; import de.bmotionstudio.gef.editor.observer.Observer;
import de.bmotionstudio.gef.editor.observer.ObserverWizard; import de.bmotionstudio.gef.editor.observer.ObserverWizard;
import de.prob.logging.Logger; import de.prob.logging.Logger;
...@@ -26,9 +27,6 @@ import de.prob.logging.Logger; ...@@ -26,9 +27,6 @@ import de.prob.logging.Logger;
public class OpenObserverAction extends SelectionAction { public class OpenObserverAction extends SelectionAction {
private String className; private String className;
private Observer clonedObserver;
private Observer newObserver;
private BControl actionControl;
public OpenObserverAction(IWorkbenchPart part) { public OpenObserverAction(IWorkbenchPart part) {
super(part); super(part);
...@@ -48,35 +46,35 @@ public class OpenObserverAction extends SelectionAction { ...@@ -48,35 +46,35 @@ public class OpenObserverAction extends SelectionAction {
@Override @Override
public void run() { public void run() {
clonedObserver = null; BControl actionControl = getControl();
actionControl = getControl();
if (actionControl != null) { if (actionControl != null) {
newObserver = getControl().getObserver(getClassName()); Observer oldObserver = null;
Observer observer = getControl().getObserver(getClassName());
// Add Observer // If an observer does not exist, add one
if (newObserver == null) { if (observer == null) {
try { try {
newObserver = (Observer) BMotionEditorPlugin observer = (Observer) BMotionEditorPlugin
.getObserverExtension(getClassName()) .getObserverExtension(getClassName())
.createExecutableExtension("class"); .createExecutableExtension("class");
} catch (CoreException e) { } catch (CoreException e) {
} }
} else { // Edit Observer } else { // else edit the current observer
// Clone Observer // therefore, clone the current observer, if the user aborts
// editing the current observer
try { try {
clonedObserver = newObserver.clone(); oldObserver = observer.clone();
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
} }
} }
ObserverWizard wizard = newObserver.getWizard(getControl()); ObserverWizard wizard = observer.getWizard(actionControl);
if (wizard != null) { if (wizard != null) {
...@@ -84,65 +82,76 @@ public class OpenObserverAction extends SelectionAction { ...@@ -84,65 +82,76 @@ public class OpenObserverAction extends SelectionAction {
getWorkbenchPart(), wizard); getWorkbenchPart(), wizard);
dialog.create(); dialog.create();
dialog.getShell().setSize(wizard.getSize()); dialog.getShell().setSize(wizard.getSize());
String title = "Observer: " String title = "Observer: " + observer.getName()
+ newObserver.getName() + " Control: " + getControl().getID();
+ " Control: "
+ getControl().getAttributeValue(
AttributeConstants.ATTRIBUTE_ID);
wizard.setWindowTitle("BMotion Studio Observer Wizard"); wizard.setWindowTitle("BMotion Studio Observer Wizard");
dialog.setTitle(title); dialog.setTitle(title);
dialog.setMessage(newObserver.getDescription()); dialog.setMessage(observer.getDescription());
dialog.setTitleImage(BMotionStudioImage dialog.setTitleImage(BMotionStudioImage
.getImage(BMotionStudioImage.IMG_LOGO_BMOTION64)); .getImage(BMotionStudioImage.IMG_LOGO_BMOTION64));
int status = dialog.open(); int status = dialog.open();
// The user clicked on the "OK" button in order to confirm his
// changes on the observer
if (status == WizardDialog.OK) { if (status == WizardDialog.OK) {
ObserverCommand observerCommand = createObserverCommandCommand(); // If the observer delete flag is set to true, delete the
observerCommand.setNewObserver(newObserver); // observer anyway
if (wizard.isObserverDelete()) { if (wizard.isObserverDelete()) {
RemoveObserverCommand cmd = createRemoveObserverCommand(
RemoveObserverAction action = new RemoveObserverAction( observer, actionControl);
getWorkbenchPart()); execute(cmd);
action.setControl(getControl());
action.setObserver(newObserver);
action.run();
} else { } else {
if (clonedObserver != null) { SetObserverCommand cmd = createObserverSetCommand(
observerCommand.setClonedObserver(clonedObserver); actionControl, observer, oldObserver);
} execute(cmd);
execute(observerCommand);
} }
// else the user canceled his changes on the observer
} else if (status == WizardDialog.CANCEL) { } else if (status == WizardDialog.CANCEL) {
if (clonedObserver != null) // Reset observer without using a command!
actionControl.addObserver(clonedObserver); if (oldObserver != null)
actionControl.getObservers().put(oldObserver.getID(),
oldObserver);
// else the user clicked on the delete button in order to
// delete the observer
} else if (status == BMotionObserverWizardDialog.DELETE) { } else if (status == BMotionObserverWizardDialog.DELETE) {
RemoveObserverAction action = new RemoveObserverAction( RemoveObserverCommand cmd = createRemoveObserverCommand(
getWorkbenchPart()); observer, actionControl);
action.setControl(getControl()); execute(cmd);
action.setObserver(newObserver);
action.run();
} }
} else { } else {
Logger.notifyUserWithoutBugreport("The Observer \"" Logger.notifyUserWithoutBugreport("The Observer \""
+ newObserver.getName() + observer.getName()
+ "\" does not support a wizard."); + "\" does not support a wizard.");
} }
} }
} }
public ObserverCommand createObserverCommandCommand() { private RemoveObserverCommand createRemoveObserverCommand(
ObserverCommand command = new ObserverCommand(); Observer observer, BControl control) {
command.setClassName(getClassName()); RemoveObserverCommand cmd = new RemoveObserverCommand();
command.setControl(actionControl); cmd.setControl(control);
return command; cmd.setObserver(observer);
return cmd;
}
public SetObserverCommand createObserverSetCommand(BControl control,
Observer newObserver, Observer oldObserver) {
SetObserverCommand cmd = new SetObserverCommand();
cmd.setNewObserver(newObserver);
cmd.setOldObserver(oldObserver);
cmd.setControl(control);
return cmd;
}
public SetObserverCommand createObserverSetCommand(BControl control,
Observer newObserver) {
return createObserverSetCommand(control, newObserver, null);
} }
public void setClassName(String className) { public void setClassName(String className) {
...@@ -162,8 +171,15 @@ public class OpenObserverAction extends SelectionAction { ...@@ -162,8 +171,15 @@ public class OpenObserverAction extends SelectionAction {
if ((objects.get(0) instanceof EditPart)) { if ((objects.get(0) instanceof EditPart)) {
EditPart part = (EditPart) objects.get(0); EditPart part = (EditPart) objects.get(0);
return (BControl) part.getModel(); BControl control = null;
if (part.getModel() instanceof ObserverRootVirtualTreeNode)
control = ((ObserverRootVirtualTreeNode) part.getModel())
.getControl();
else if (part.getModel() instanceof BControl)
control = (BControl) part.getModel();
return control;
} }
return null; return null;
} }
......
...@@ -52,12 +52,13 @@ public class PasteAction extends SelectionAction { ...@@ -52,12 +52,13 @@ public class PasteAction extends SelectionAction {
Object nextElement = it.next(); Object nextElement = it.next();
if (nextElement instanceof EditPart) { if (nextElement instanceof EditPart) {
EditPart ep = (EditPart) nextElement; EditPart ep = (EditPart) nextElement;
if (ep.getModel() instanceof BControl) {
BControl node = (BControl) ep.getModel(); BControl node = (BControl) ep.getModel();
if (!cmd.isContainer(node)) if (cmd.isContainer(node))
return null;
cmd.addElement(node); cmd.addElement(node);
} }
} }
}
return cmd; return cmd;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment