Przeglądaj źródła

#142 Do not update Simulation View when Cell Editor is open

Andreas Muelder 10 lat temu
rodzic
commit
0289e3be05

+ 15 - 2
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ExecutionContextContentProvider.java

@@ -33,6 +33,7 @@ public class ExecutionContextContentProvider implements ITreeContentProvider, IP
 
 	private Viewer viewer;
 	protected RefreshAdapter refreshAdapter = new RefreshAdapter();
+	protected boolean shouldUpdate = true;
 
 	public void dispose() {
 		getStore().removePropertyChangeListener(this);
@@ -93,17 +94,29 @@ public class ExecutionContextContentProvider implements ITreeContentProvider, IP
 				viewer.refresh();
 		}
 	}
+	
+	
+
+	public boolean isShouldUpdate() {
+		return shouldUpdate;
+	}
+
+	public void setShouldUpdate(boolean shouldUpdate) {
+		this.shouldUpdate = shouldUpdate;
+	}
+
+
 
 	protected final class RefreshAdapter extends EContentAdapter {
 		@Override
-		public void notifyChanged(Notification notification) {
+		public void notifyChanged(final Notification notification) {
 			if (notification.getFeature() == SRuntimePackage.Literals.EXECUTION_SLOT__VALUE
 					|| notification.getFeature() == SRuntimePackage.Literals.EXECUTION_EVENT__RAISED
 					|| notification.getFeature() == SRuntimePackage.Literals.EXECUTION_EVENT__SCHEDULED
 					|| notification.getFeature() == SRuntimePackage.Literals.COMPOSITE_SLOT__SLOTS)
 				Display.getDefault().asyncExec(new Runnable() {
 					public void run() {
-						if (viewer != null && !viewer.getControl().isDisposed())
+						if (viewer != null && !viewer.getControl().isDisposed() && shouldUpdate)
 							viewer.refresh();
 					}
 				});

+ 86 - 59
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ExecutionContextViewerFactory.java

@@ -1,59 +1,86 @@
-/**
- * Copyright (c) 2013 committers of YAKINDU and others.
- * 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:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.simulation.ui.view;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.yakindu.sct.simulation.ui.view.editing.BooleanEditingSupport;
-import org.yakindu.sct.simulation.ui.view.editing.EnumerationEditingSupport;
-import org.yakindu.sct.simulation.ui.view.editing.IntegerEditingSupport;
-import org.yakindu.sct.simulation.ui.view.editing.LongEditingSupport;
-import org.yakindu.sct.simulation.ui.view.editing.MultiEditingSupport;
-import org.yakindu.sct.simulation.ui.view.editing.RealEditingSupport;
-import org.yakindu.sct.simulation.ui.view.editing.StringEditingSupport;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class ExecutionContextViewerFactory {
-
-	
-	public static TreeViewer createViewer(Composite parent, boolean readOnly) {
-		TreeViewer viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
-		viewer.getTree().setHeaderVisible(true);
-		viewer.getTree().setLinesVisible(true);
-		viewer.setContentProvider(new ExecutionContextContentProvider());
-		viewer.setFilters(new ViewerFilter[] { new TimeEventViewerFilter() });
-		TreeViewerColumn nameColumn = new TreeViewerColumn(viewer, SWT.DEFAULT);
-		nameColumn.getColumn().setText("Name");
-		nameColumn.getColumn().setMoveable(true);
-		nameColumn.getColumn().setWidth(150);
-		nameColumn.setLabelProvider(new ExecutionContextLabelProvider(0));
-
-		TreeViewerColumn valueColumn = new TreeViewerColumn(viewer, SWT.DEFAULT);
-		valueColumn.getColumn().setText("Value");
-		valueColumn.getColumn().setMoveable(true);
-		valueColumn.getColumn().setWidth(100);
-		if (!readOnly)
-			valueColumn.setEditingSupport(new MultiEditingSupport(viewer, new BooleanEditingSupport(viewer),
-					new LongEditingSupport(viewer), new RealEditingSupport(viewer),
-					new StringEditingSupport(viewer), new EnumerationEditingSupport(viewer), new IntegerEditingSupport(viewer)));
-
-		valueColumn.setLabelProvider(new ExecutionContextLabelProvider(1));
-
-		return viewer;
-	}
-}
+/**
+ * Copyright (c) 2013 committers of YAKINDU and others.
+ * 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.simulation.ui.view;
+
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationListener;
+import org.eclipse.jface.viewers.ColumnViewerEditorDeactivationEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.yakindu.sct.simulation.ui.view.editing.BooleanEditingSupport;
+import org.yakindu.sct.simulation.ui.view.editing.EnumerationEditingSupport;
+import org.yakindu.sct.simulation.ui.view.editing.IntegerEditingSupport;
+import org.yakindu.sct.simulation.ui.view.editing.LongEditingSupport;
+import org.yakindu.sct.simulation.ui.view.editing.MultiEditingSupport;
+import org.yakindu.sct.simulation.ui.view.editing.RealEditingSupport;
+import org.yakindu.sct.simulation.ui.view.editing.StringEditingSupport;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class ExecutionContextViewerFactory {
+
+	public static TreeViewer createViewer(Composite parent, boolean readOnly) {
+		final TreeViewer viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
+		viewer.getTree().setHeaderVisible(true);
+		viewer.getTree().setLinesVisible(true);
+		final ExecutionContextContentProvider contentProvider = new ExecutionContextContentProvider();
+		viewer.setContentProvider(contentProvider);
+		viewer.setFilters(new ViewerFilter[] { new TimeEventViewerFilter() });
+		TreeViewerColumn nameColumn = new TreeViewerColumn(viewer, SWT.DEFAULT);
+		nameColumn.getColumn().setText("Name");
+		nameColumn.getColumn().setMoveable(true);
+		nameColumn.getColumn().setWidth(150);
+		nameColumn.setLabelProvider(new ExecutionContextLabelProvider(0));
+
+		TreeViewerColumn valueColumn = new TreeViewerColumn(viewer, SWT.DEFAULT);
+		valueColumn.getColumn().setText("Value");
+		valueColumn.getColumn().setMoveable(true);
+		valueColumn.getColumn().setWidth(100);
+		if (!readOnly)
+			valueColumn.setEditingSupport(new MultiEditingSupport(viewer, new BooleanEditingSupport(viewer),
+					new LongEditingSupport(viewer), new RealEditingSupport(viewer), new StringEditingSupport(viewer),
+					new EnumerationEditingSupport(viewer), new IntegerEditingSupport(viewer)));
+
+		valueColumn.setLabelProvider(new ExecutionContextLabelProvider(1));
+
+		valueColumn.getViewer().getColumnViewerEditor()
+				.addEditorActivationListener(new ColumnViewerEditorActivationListener() {
+					@Override
+					public void afterEditorDeactivated(ColumnViewerEditorDeactivationEvent event) {
+						contentProvider.shouldUpdate = true;
+						viewer.refresh();
+
+					}
+
+					@Override
+					public void afterEditorActivated(ColumnViewerEditorActivationEvent event) {
+						contentProvider.shouldUpdate = false;
+
+					}
+
+					@Override
+					public void beforeEditorDeactivated(ColumnViewerEditorDeactivationEvent event) {
+					}
+
+					@Override
+					public void beforeEditorActivated(ColumnViewerEditorActivationEvent event) {
+					}
+				});
+
+		return viewer;
+	}
+}