|
|
@@ -21,7 +21,9 @@ import org.eclipse.debug.ui.contexts.DebugContextEvent;
|
|
|
import org.eclipse.debug.ui.contexts.IDebugContextListener;
|
|
|
import org.eclipse.jface.action.IMenuManager;
|
|
|
import org.eclipse.jface.action.IToolBarManager;
|
|
|
+import org.eclipse.jface.viewers.ISelectionChangedListener;
|
|
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
|
+import org.eclipse.jface.viewers.SelectionChangedEvent;
|
|
|
import org.eclipse.jface.viewers.TreeViewer;
|
|
|
import org.eclipse.jface.viewers.TreeViewerColumn;
|
|
|
import org.eclipse.jface.viewers.Viewer;
|
|
|
@@ -31,7 +33,7 @@ import org.eclipse.swt.widgets.Display;
|
|
|
import org.yakindu.sct.simulation.core.debugmodel.SCTDebugTarget;
|
|
|
import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
|
|
|
import org.yakindu.sct.simulation.core.runtime.IExecutionFacade;
|
|
|
-import org.yakindu.sct.simulation.ui.model.presenter.IDynamicNotationHandler;
|
|
|
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionEvent;
|
|
|
import org.yakindu.sct.simulation.ui.view.editing.BooleanEditingSupport;
|
|
|
import org.yakindu.sct.simulation.ui.view.editing.IntegerEditingSupport;
|
|
|
import org.yakindu.sct.simulation.ui.view.editing.MultiEditingSupport;
|
|
|
@@ -61,7 +63,8 @@ public class DeclarationView extends AbstractDebugView implements
|
|
|
|
|
|
@Override
|
|
|
protected Viewer createViewer(Composite parent) {
|
|
|
- viewer = new TreeViewer(parent);
|
|
|
+ viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL
|
|
|
+ | SWT.FULL_SELECTION);
|
|
|
viewer.getTree().setHeaderVisible(true);
|
|
|
viewer.getTree().setLinesVisible(true);
|
|
|
TreeViewerColumn column = new TreeViewerColumn(viewer, SWT.DEFAULT);
|
|
|
@@ -78,15 +81,20 @@ public class DeclarationView extends AbstractDebugView implements
|
|
|
new BooleanEditingSupport(viewer), new IntegerEditingSupport(
|
|
|
viewer), new RealEditingSupport(viewer)));
|
|
|
valueColumn.setLabelProvider(new ExecutionContextLabelProvider(1));
|
|
|
-
|
|
|
- TreeViewerColumn raiseEventColumn = new TreeViewerColumn(viewer,
|
|
|
- SWT.DEFAULT);
|
|
|
- raiseEventColumn.getColumn().setText("Raise");
|
|
|
- raiseEventColumn.getColumn().setMoveable(true);
|
|
|
- raiseEventColumn.getColumn().setWidth(50);
|
|
|
- raiseEventColumn.setLabelProvider(new ExecutionContextLabelProvider(0));
|
|
|
-
|
|
|
viewer.setContentProvider(new ExecutionContextContentProvider());
|
|
|
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
|
|
+ public void selectionChanged(SelectionChangedEvent event) {
|
|
|
+ Object firstElement = ((IStructuredSelection) event
|
|
|
+ .getSelection()).getFirstElement();
|
|
|
+ if (firstElement instanceof ExecutionEvent) {
|
|
|
+ IExecutionContext input = (IExecutionContext) viewer
|
|
|
+ .getInput();
|
|
|
+ input.raiseEvent(((ExecutionEvent) firstElement).getName(),
|
|
|
+ null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
return viewer;
|
|
|
}
|
|
|
|
|
|
@@ -96,7 +104,7 @@ public class DeclarationView extends AbstractDebugView implements
|
|
|
.getContext()).getFirstElement();
|
|
|
SCTDebugTarget debugTarget = (SCTDebugTarget) object
|
|
|
.getAdapter(IDebugTarget.class);
|
|
|
- if (!debugTarget.isTerminated())
|
|
|
+ if (debugTarget != null && !debugTarget.isTerminated())
|
|
|
refreshInput(debugTarget);
|
|
|
}
|
|
|
|
|
|
@@ -147,259 +155,4 @@ public class DeclarationView extends AbstractDebugView implements
|
|
|
|
|
|
}
|
|
|
|
|
|
- public IExecutionContext getExecutionContext() {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- // private TableViewer eventViewer;
|
|
|
- //
|
|
|
- // private TableViewer variableViewer;
|
|
|
- //
|
|
|
- // private Map<Control, SelectionListener> controls;
|
|
|
- // private Map<Control, TableEditor> tableEditors;
|
|
|
- //
|
|
|
- // //private SimulationSession activeSession;
|
|
|
- //
|
|
|
- // public DeclarationView() {
|
|
|
- // controls = new HashMap<Control, SelectionListener>();
|
|
|
- // tableEditors = new HashMap<Control, TableEditor>();
|
|
|
- // }
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public void init(IViewSite site) throws PartInitException {
|
|
|
- // super.init(site);
|
|
|
- // DebugUITools.getDebugContextManager()
|
|
|
- // .getContextService(site.getWorkbenchWindow())
|
|
|
- // .addDebugContextListener(this);
|
|
|
- // }
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public void createPartControl(Composite parent) {
|
|
|
- // parent.setLayout(new GridLayout(1, true));
|
|
|
- // createEventViewer(parent);
|
|
|
- // createVariableViewer(parent);
|
|
|
- // }
|
|
|
- //
|
|
|
- // private void createVariableViewer(Composite parent) {
|
|
|
- // variableViewer = createTableViewer(parent);
|
|
|
- // createScopeSlotColumns(variableViewer);
|
|
|
- // setVariableViewerInput();
|
|
|
- // }
|
|
|
- //
|
|
|
- // private void createEventViewer(Composite parent) {
|
|
|
- // eventViewer = createTableViewer(parent);
|
|
|
- // createScopeSlotColumns(eventViewer);
|
|
|
- // createColumn(eventViewer, "raise", 50, 3);
|
|
|
- // setEventViewerInput();
|
|
|
- // }
|
|
|
- //
|
|
|
- // private TableViewer createTableViewer(Composite parent) {
|
|
|
- // TableViewer viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
|
|
|
- // | SWT.V_SCROLL | SWT.FULL_SELECTION);
|
|
|
- // viewer.getTable().setLinesVisible(true);
|
|
|
- // viewer.getTable().setHeaderVisible(true);
|
|
|
- // GridDataFactory.fillDefaults().grab(true, true)
|
|
|
- // .applyTo(viewer.getTable());
|
|
|
- // viewer.setContentProvider(new ArrayContentProvider());
|
|
|
- // return viewer;
|
|
|
- // }
|
|
|
- //
|
|
|
- // private TableViewerColumn createColumn(TableViewer viewer, String text,
|
|
|
- // int width, int index) {
|
|
|
- // TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
|
|
|
- // column.getColumn().setText(text);
|
|
|
- // column.getColumn().setWidth(width);
|
|
|
- // column.getColumn().setResizable(true);
|
|
|
- // column.getColumn().setMoveable(true);
|
|
|
- // column.setLabelProvider(new ScopeSlotLabelProvider(index));
|
|
|
- // return column;
|
|
|
- // }
|
|
|
- //
|
|
|
- // private void createScopeSlotColumns(TableViewer viewer) {
|
|
|
- // // createColumn(viewer, "name", 80, 0);
|
|
|
- // // createColumn(viewer, "type", 80, 1);
|
|
|
- // // TableViewerColumn valueColumn = createColumn(viewer, "value", 80, 2);
|
|
|
- // // valueColumn.setEditingSupport(new MultiEditingSupport(viewer,
|
|
|
- // // new BooleanEditingSupport(viewer, this),
|
|
|
- // // new IntegerEditingSupport(viewer, this),
|
|
|
- // // new RealEditingSupport(viewer, this)));
|
|
|
- // }
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public void setFocus() {
|
|
|
- // eventViewer.getTable().setFocus();
|
|
|
- // }
|
|
|
- //
|
|
|
- // public void setEventViewerInput() {
|
|
|
- // // if (activeSession != null) {
|
|
|
- // // List<ExecutionEvent> events = activeSession.getExecutionContext()
|
|
|
- // // .getDeclaredEvents();
|
|
|
- // //
|
|
|
- // // eventViewer.setInput(events);
|
|
|
- // //
|
|
|
- // // TableItem[] items = eventViewer.getTable().getItems();
|
|
|
- // // for (TableItem tableItem : items) {
|
|
|
- // // final TableEditor tableEditor = new TableEditor(
|
|
|
- // // eventViewer.getTable());
|
|
|
- // // tableEditor.horizontalAlignment = SWT.LEFT;
|
|
|
- // // tableEditor.grabHorizontal = true;
|
|
|
- // // tableEditor.grabVertical = true;
|
|
|
- // // Button button = new Button(eventViewer.getTable(), SWT.FLAT);
|
|
|
- // // button.setText("raise");
|
|
|
- // // ButtonListener listener = new ButtonListener(
|
|
|
- // // tableItem.getText());
|
|
|
- // // button.addSelectionListener(listener);
|
|
|
- // // tableEditor.setEditor(button, tableItem, 3);
|
|
|
- // // tableEditors.put(button, tableEditor);
|
|
|
- // // controls.put(button, listener);
|
|
|
- // // }
|
|
|
- // // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // private void setVariableViewerInput() {
|
|
|
- // // if (activeSession != null) {
|
|
|
- // // List<ExecutionVariable> variables = activeSession
|
|
|
- // // .getExecutionContext().getVariables();
|
|
|
- // // variableViewer.setInput(variables);
|
|
|
- // // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // public void clearViewerInput(boolean disposeControls) {
|
|
|
- // // clear the viewer input. This has to be done before the Buttons are
|
|
|
- // // disposed. Otherwise listeners the TableViewer adds to Buttons can't
|
|
|
- // // be removed from them what leads to a memory leak.
|
|
|
- // eventViewer.setInput(null);
|
|
|
- // eventViewer.refresh();
|
|
|
- // variableViewer.setInput(null);
|
|
|
- // eventViewer.refresh();
|
|
|
- //
|
|
|
- // for (Control control : controls.keySet()) {
|
|
|
- // if (control instanceof Button) {
|
|
|
- // // Listeners have to be removed manually otherwise the garbage
|
|
|
- // // collector can't cleanup the button
|
|
|
- // if (controls.get(control) != null) {
|
|
|
- // ((Button) control).removeSelectionListener(controls
|
|
|
- // .get(control));
|
|
|
- // }
|
|
|
- // // Same for the tableEditor
|
|
|
- // if (tableEditors.get(control) != null) {
|
|
|
- // tableEditors.get(control).dispose();
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (disposeControls) {
|
|
|
- // control.dispose();
|
|
|
- // }
|
|
|
- // }
|
|
|
- // // if the controls are disposed they are never used again and should not
|
|
|
- // // use memory anymore.
|
|
|
- // controls.clear();
|
|
|
- // tableEditors.clear();
|
|
|
- // }
|
|
|
- //
|
|
|
- // // @Override
|
|
|
- // // public void dispose() {
|
|
|
- // // clearViewerInput(false);
|
|
|
- // // super.dispose();
|
|
|
- // // }
|
|
|
- //
|
|
|
- // private final class ButtonListener implements SelectionListener {
|
|
|
- //
|
|
|
- // private final String eventName;
|
|
|
- //
|
|
|
- // public ButtonListener(String eventName) {
|
|
|
- // this.eventName = eventName;
|
|
|
- // }
|
|
|
- //
|
|
|
- // public void widgetSelected(SelectionEvent e) {
|
|
|
- // // if (activeSession != null) {
|
|
|
- // // activeSession.raiseEvent(new ExecutionEvent(eventName));
|
|
|
- // // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // public void widgetDefaultSelected(SelectionEvent e) {
|
|
|
- // // Nothing to do
|
|
|
- // }
|
|
|
- //
|
|
|
- // }
|
|
|
- //
|
|
|
- // public void debugContextChanged(DebugContextEvent event) {
|
|
|
- // // StructuredSelection strSel = (StructuredSelection) event.getContext();
|
|
|
- // // PlatformObject firstElement = (PlatformObject)
|
|
|
- // strSel.getFirstElement();
|
|
|
- // // if (firstElement == null) {
|
|
|
- // // return;
|
|
|
- // // }
|
|
|
- // // SimulationSession selectedSession = (SimulationSession) firstElement
|
|
|
- // // .getAdapter(SimulationSession.class);
|
|
|
- // // if (selectedSession == null
|
|
|
- // // || selectedSession.getCurrentState() == SimulationState.TERMINATED) {
|
|
|
- // // activeSession = selectedSession;
|
|
|
- // // clearViewerInput(true);
|
|
|
- // // }
|
|
|
- // // if (!(selectedSession == activeSession) && selectedSession != null) {
|
|
|
- // // if (activeSession != null) {
|
|
|
- // // activeSession.removeSimulationListener(this);
|
|
|
- // // activeSession.getExecutionContext()
|
|
|
- // // .removeExecutionContextListener(this);
|
|
|
- // // }
|
|
|
- // // activeSession = selectedSession;
|
|
|
- // // selectedSession.addSimulationListener(this);
|
|
|
- // // selectedSession.getExecutionContext().addExecutionContextListener(
|
|
|
- // // this);
|
|
|
- // // clearViewerInput(true);
|
|
|
- // // setEventViewerInput();
|
|
|
- // // setVariableViewerInput();
|
|
|
- // // }
|
|
|
- // }
|
|
|
- // //
|
|
|
- // // public SimulationSession getActiveSession() {
|
|
|
- // // return activeSession;
|
|
|
- // // }
|
|
|
- // //
|
|
|
- // // public void simulationStateChanged(SimulationState oldState,
|
|
|
- // // SimulationState newState) {
|
|
|
- // // switch (newState) {
|
|
|
- // // case STARTED:
|
|
|
- // // Display.getDefault().asyncExec(new Runnable() {
|
|
|
- // // public void run() {
|
|
|
- // // setEventViewerInput();
|
|
|
- // // setVariableViewerInput();
|
|
|
- // // }
|
|
|
- // // });
|
|
|
- // // break;
|
|
|
- // // case TERMINATED:
|
|
|
- // // Display.getDefault().asyncExec(new Runnable() {
|
|
|
- // // public void run() {
|
|
|
- // // clearViewerInput(true);
|
|
|
- // // }
|
|
|
- // // });
|
|
|
- // // ;
|
|
|
- // // break;
|
|
|
- // // }
|
|
|
- // // }
|
|
|
- //
|
|
|
- // public void variableDeclared(ExecutionVariable variable) {
|
|
|
- // // Nothing to do
|
|
|
- // }
|
|
|
- //
|
|
|
- // public void eventDeclared(ExecutionEvent event) {
|
|
|
- // // Nothing to do
|
|
|
- // }
|
|
|
- //
|
|
|
- // public void eventRaised(ExecutionEvent event) {
|
|
|
- // Display.getDefault().asyncExec(new Runnable() {
|
|
|
- // public void run() {
|
|
|
- // setEventViewerInput();
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
- //
|
|
|
- // public void variableValueChanged(ExecutionVariable variable) {
|
|
|
- // Display.getDefault().asyncExec(new Runnable() {
|
|
|
- // public void run() {
|
|
|
- // setVariableViewerInput();
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
}
|