aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Ladenberger2012-03-27 09:07:20 (EDT)
committerMichael Jastram2012-04-05 06:40:10 (EDT)
commit7e1c32c0398dab1eaeef0c51357d95de55ced1de (patch)
treeb9faf48456402248e6dfae8365e89c24fd6ad0b2
parent37a2afb3494f10c86375340f89b38de86741b36d (diff)
downloadorg.eclipse.rmf-7e1c32c0398dab1eaeef0c51357d95de55ced1de.zip
org.eclipse.rmf-7e1c32c0398dab1eaeef0c51357d95de55ced1de.tar.gz
org.eclipse.rmf-7e1c32c0398dab1eaeef0c51357d95de55ced1de.tar.bz2
fixed bug (properties view was refreshed too many times)
-rw-r--r--org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/presentation/Reqif10Editor.java5
-rw-r--r--org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/presentation/SpecificationEditor.java43
-rw-r--r--org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/propertiesview/ProrPropertySheetPage.java55
-rw-r--r--org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/propertiesview/ProrPropertyViewer.java5
4 files changed, 77 insertions, 31 deletions
diff --git a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/presentation/Reqif10Editor.java b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/presentation/Reqif10Editor.java
index 91f8bdc..986609b 100644
--- a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/presentation/Reqif10Editor.java
+++ b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/presentation/Reqif10Editor.java
@@ -714,7 +714,6 @@ public class Reqif10Editor extends MultiPageEditorPart implements
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
firePropertyChange(IEditorPart.PROP_DIRTY);
-
// Try to select the affected objects.
//
Command mostRecentCommand = ((CommandStack) event
@@ -723,10 +722,6 @@ public class Reqif10Editor extends MultiPageEditorPart implements
setSelectionToViewer(mostRecentCommand
.getAffectedObjects());
}
- if (propertySheetPage != null
- && !propertySheetPage.getControl().isDisposed()) {
- propertySheetPage.refresh();
- }
}
});
}
diff --git a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/presentation/SpecificationEditor.java b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/presentation/SpecificationEditor.java
index f031573..0794a9d 100644
--- a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/presentation/SpecificationEditor.java
+++ b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/presentation/SpecificationEditor.java
@@ -35,7 +35,6 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.rmf.pror.reqif10.editor.actions.SpecificationWebPrintAction;
import org.eclipse.rmf.pror.reqif10.editor.agilegrid.ProrAgileGridViewer;
-import org.eclipse.rmf.pror.reqif10.editor.propertiesview.ProrPropertySheetPage;
import org.eclipse.rmf.pror.reqif10.util.ProrUtil;
import org.eclipse.rmf.reqif10.ReqIf;
import org.eclipse.rmf.reqif10.Reqif10Package;
@@ -140,28 +139,24 @@ public class SpecificationEditor extends EditorPart implements
*/
private void registerCommandStackListener(final Composite parent) {
commandStackListener = new CommandStackListener() {
- public void commandStackChanged(final EventObject event) {
- parent.getDisplay().asyncExec
- (new Runnable() {
- public void run() {
- firePropertyChange(IEditorPart.PROP_DIRTY);
-
- // Try to select the affected objects.
- //
- Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
- if (mostRecentCommand != null) {
- setSelectionToViewer(mostRecentCommand.getAffectedObjects());
- }
- ProrPropertySheetPage propSheet = reqifEditor.getPropertySheetPage();
- if (propSheet != null && propSheet.getControl() != null
- && !propSheet.getControl().isDisposed()) {
- propSheet.refresh();
- }
- }
- });
- }
- };
- getEditingDomain().getCommandStack().addCommandStackListener(commandStackListener);
+ public void commandStackChanged(final EventObject event) {
+ parent.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ // Try to select the affected objects.
+ Command mostRecentCommand = ((CommandStack) event
+ .getSource()).getMostRecentCommand();
+ if (mostRecentCommand != null) {
+ Collection<?> affectedObjects = mostRecentCommand
+ .getAffectedObjects();
+ setSelectionToViewer(affectedObjects);
+ }
+ }
+ });
+ }
+ };
+ getEditingDomain().getCommandStack().addCommandStackListener(
+ commandStackListener);
}
/**
@@ -212,11 +207,13 @@ public class SpecificationEditor extends EditorPart implements
Runnable runnable =
new Runnable() {
public void run() {
+
// Try to select the items in the current content viewer of the editor.
//
if (prorAgileGridViewer != null) {
prorAgileGridViewer.setSelection(new StructuredSelection(theSelection.toArray()), true);
}
+
}
};
getSite().getShell().getDisplay().syncExec(runnable);
diff --git a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/propertiesview/ProrPropertySheetPage.java b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/propertiesview/ProrPropertySheetPage.java
index 61c90c7..fad753c 100644
--- a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/propertiesview/ProrPropertySheetPage.java
+++ b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/propertiesview/ProrPropertySheetPage.java
@@ -11,8 +11,13 @@
package org.eclipse.rmf.pror.reqif10.editor.propertiesview;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.EventObject;
import java.util.List;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.command.CommandStackListener;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
@@ -29,8 +34,10 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.rmf.pror.reqif10.editor.presentation.SpecificationEditor;
import org.eclipse.rmf.reqif10.AttributeValue;
+import org.eclipse.rmf.reqif10.Identifiable;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.Page;
import org.eclipse.ui.views.properties.IPropertySheetPage;
@@ -55,11 +62,45 @@ public class ProrPropertySheetPage extends Page implements IPropertySheetPage {
private List<AttributeValue> objectsToSelect = new ArrayList<AttributeValue>();
+ private CommandStackListener commandStackListener;
+
public ProrPropertySheetPage(EditingDomain editingDomain,
AdapterFactory adapterFactory) {
super();
this.editingDomain = editingDomain;
this.adapterFactory = adapterFactory;
+ registerCommandStackListener();
+ }
+
+ /**
+ * We register a command stack listener in order to listen on changes on
+ * attributes values in the specification editor.
+ */
+ private void registerCommandStackListener() {
+ commandStackListener = new CommandStackListener() {
+ public void commandStackChanged(final EventObject event) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ // Try to select the affected objects.
+ Command mostRecentCommand = ((CommandStack) event
+ .getSource()).getMostRecentCommand();
+ if (mostRecentCommand != null) {
+ Collection<?> affectedObjects = mostRecentCommand
+ .getAffectedObjects();
+ if(!affectedObjects.isEmpty()) {
+ Object firstItem = affectedObjects.toArray()[0];
+ if (firstItem instanceof Identifiable
+ || firstItem instanceof AttributeValue) {
+ update();
+ }
+ }
+ }
+ }
+ });
+ }
+ };
+ editingDomain.getCommandStack().addCommandStackListener(
+ commandStackListener);
}
/**
@@ -136,11 +177,11 @@ public class ProrPropertySheetPage extends Page implements IPropertySheetPage {
}
- public void refresh() {
+ public void update() {
if (viewer == null) {
return;
}
- viewer.refresh();
+ viewer.update();
}
/**
@@ -179,4 +220,14 @@ public class ProrPropertySheetPage extends Page implements IPropertySheetPage {
}
+ @Override
+ public void dispose() {
+ if (commandStackListener != null) {
+ editingDomain.getCommandStack().removeCommandStackListener(
+ commandStackListener);
+ commandStackListener = null;
+ }
+ super.dispose();
+ }
+
}
diff --git a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/propertiesview/ProrPropertyViewer.java b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/propertiesview/ProrPropertyViewer.java
index 2afdda4..98ae2ed 100644
--- a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/propertiesview/ProrPropertyViewer.java
+++ b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/propertiesview/ProrPropertyViewer.java
@@ -71,6 +71,9 @@ public class ProrPropertyViewer extends Viewer {
@Override
public void refresh() {
+ }
+
+ public void update() {
this.contentProvider.setContent(this.currentSelectedSpecElement);
agileGrid.redraw();
}
@@ -86,7 +89,7 @@ public class ProrPropertyViewer extends Viewer {
} else {
this.currentSelectedSpecElement = null;
}
- refresh();
+ update();
}
@Override