Merge commit 'refs/changes/18/36218/1' of ssh://git.eclipse.org:29418/rmf/org.eclipse.rmf into develop
Conflicts:
org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/presentation/Reqif10Editor.java
diff --git a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/AbstractProrCellEditorProvider.java b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/AbstractProrCellEditorProvider.java
index 92b1975..12c87f2 100644
--- a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/AbstractProrCellEditorProvider.java
+++ b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/AbstractProrCellEditorProvider.java
@@ -16,6 +16,7 @@
import org.agilemore.agilegrid.CellEditor;
import org.agilemore.agilegrid.DefaultCellEditorProvider;
import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.rmf.reqif10.AttributeDefinitionEnumeration;
@@ -40,13 +41,11 @@
public abstract class AbstractProrCellEditorProvider extends
DefaultCellEditorProvider {
- protected final EditingDomain editingDomain;
protected final AdapterFactory adapterFactory;
public AbstractProrCellEditorProvider(AgileGrid agileGrid,
- AdapterFactory adapterFactory, EditingDomain editingDomain) {
+ AdapterFactory adapterFactory) {
super(agileGrid);
- this.editingDomain = editingDomain;
this.adapterFactory = adapterFactory;
}
@@ -60,8 +59,7 @@
* @return the default cell editor for the attribute value
*/
protected CellEditor getDefaultCellEditor(AttributeValue value,
- Object parent,
- Object affectedObject) {
+ Object parent, Object affectedObject) {
DatatypeDefinition dd = ReqIF10Util.getDatatypeDefinition(value);
if (dd == null) {
MessageDialog
@@ -69,60 +67,62 @@
"This attribute cannot be edited, as no Datatype Definition has been set.");
return null;
}
+ EditingDomain editingDomain = AdapterFactoryEditingDomain
+ .getEditingDomainFor(dd);
+ if (editingDomain != null) {
+ // Parent may be SpecHierarchy or SpecElement or Attribute (default
+ // value).
+ if (parent instanceof SpecHierarchy)
+ parent = ((SpecHierarchy) parent).getObject();
- // Parent may be SpecHierarchy or SpecElement or Attribute (default value).
- if (parent instanceof SpecHierarchy) parent = ((SpecHierarchy) parent)
- .getObject();
-
- if (dd instanceof DatatypeDefinitionBoolean) {
- return new ProrCheckboxCellEditor(agileGrid, editingDomain,
- parent, affectedObject);
- }
- else if (dd instanceof DatatypeDefinitionDate) {
- return new ProrDateCellEditor(agileGrid, editingDomain,
- parent,
- affectedObject);
- } else if (dd instanceof DatatypeDefinitionInteger) {
- DatatypeDefinitionInteger ddi = (DatatypeDefinitionInteger) dd;
- ProrIntegerCellEditor integerCellEditor = new ProrIntegerCellEditor(
- agileGrid, parent,
- editingDomain, affectedObject);
- integerCellEditor.setRange(ddi.getMin(), ddi.getMax());
- return integerCellEditor;
- } else if (dd instanceof DatatypeDefinitionReal) {
- DatatypeDefinitionReal ddr = (DatatypeDefinitionReal) dd;
- ProrRealCellEditor realCellEditor = new ProrRealCellEditor(
- agileGrid, editingDomain,
- parent, affectedObject);
- realCellEditor.setRange(ddr.getMin(), ddr.getMax());
- return realCellEditor;
- } else if (dd instanceof DatatypeDefinitionString) {
- DatatypeDefinitionString dds = (DatatypeDefinitionString) dd;
- ProrStringCellEditor stringCellEditor = new ProrStringCellEditor(
- agileGrid, editingDomain,
- parent, affectedObject);
- stringCellEditor.setMaxLength(dds.getMaxLength() != null ? dds
- .getMaxLength() : new BigInteger(Integer.MAX_VALUE + ""));
- return stringCellEditor;
- } else if (dd instanceof DatatypeDefinitionEnumeration) {
- DatatypeDefinitionEnumeration dde = (DatatypeDefinitionEnumeration) dd;
- Boolean multiValued = ((AttributeDefinitionEnumeration) ReqIF10Util
- .getAttributeDefinition(value)).isMultiValued();
- if (multiValued == null || multiValued.booleanValue() == false) {
- return new ProrEnumerationSingleValueCellEditor(agileGrid, dde,
- parent, affectedObject,
- editingDomain, adapterFactory);
- } else {
- return new ProrEnumerationMultiValueCellEditor(agileGrid, dde,
- parent, affectedObject,
- editingDomain, adapterFactory);
+ if (dd instanceof DatatypeDefinitionBoolean) {
+ return new ProrCheckboxCellEditor(agileGrid, editingDomain,
+ parent, affectedObject);
+ } else if (dd instanceof DatatypeDefinitionDate) {
+ return new ProrDateCellEditor(agileGrid, editingDomain, parent,
+ affectedObject);
+ } else if (dd instanceof DatatypeDefinitionInteger) {
+ DatatypeDefinitionInteger ddi = (DatatypeDefinitionInteger) dd;
+ ProrIntegerCellEditor integerCellEditor = new ProrIntegerCellEditor(
+ agileGrid, parent, editingDomain, affectedObject);
+ integerCellEditor.setRange(ddi.getMin(), ddi.getMax());
+ return integerCellEditor;
+ } else if (dd instanceof DatatypeDefinitionReal) {
+ DatatypeDefinitionReal ddr = (DatatypeDefinitionReal) dd;
+ ProrRealCellEditor realCellEditor = new ProrRealCellEditor(
+ agileGrid, editingDomain, parent, affectedObject);
+ realCellEditor.setRange(ddr.getMin(), ddr.getMax());
+ return realCellEditor;
+ } else if (dd instanceof DatatypeDefinitionString) {
+ DatatypeDefinitionString dds = (DatatypeDefinitionString) dd;
+ ProrStringCellEditor stringCellEditor = new ProrStringCellEditor(
+ agileGrid, editingDomain, parent, affectedObject);
+ stringCellEditor.setMaxLength(dds.getMaxLength() != null ? dds
+ .getMaxLength()
+ : new BigInteger(Integer.MAX_VALUE + ""));
+ return stringCellEditor;
+ } else if (dd instanceof DatatypeDefinitionEnumeration) {
+ DatatypeDefinitionEnumeration dde = (DatatypeDefinitionEnumeration) dd;
+ Boolean multiValued = ((AttributeDefinitionEnumeration) ReqIF10Util
+ .getAttributeDefinition(value)).isMultiValued();
+ if (multiValued == null || multiValued.booleanValue() == false) {
+ return new ProrEnumerationSingleValueCellEditor(agileGrid,
+ dde, parent, affectedObject, editingDomain,
+ adapterFactory);
+ } else {
+ return new ProrEnumerationMultiValueCellEditor(agileGrid,
+ dde, parent, affectedObject, editingDomain,
+ adapterFactory);
+ }
+ } else if (dd instanceof DatatypeDefinitionXHTML) {
+ ProrXhtmlSimplifiedCellEditor stringCellEditor = new ProrXhtmlSimplifiedCellEditor(
+ agileGrid, editingDomain, parent, affectedObject);
+ return stringCellEditor;
}
- } else if (dd instanceof DatatypeDefinitionXHTML) {
- ProrXhtmlSimplifiedCellEditor stringCellEditor = new ProrXhtmlSimplifiedCellEditor(
- agileGrid, editingDomain, parent, affectedObject);
- return stringCellEditor;
+
+ throw new IllegalArgumentException("No editor for: " + value);
}
- throw new IllegalArgumentException("No editor for: " + value);
+ return null;
}
/**
diff --git a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/ProrAgileGridViewer.java b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/ProrAgileGridViewer.java
index b30ee47..53eb431 100644
--- a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/ProrAgileGridViewer.java
+++ b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/ProrAgileGridViewer.java
@@ -107,7 +107,7 @@
private EContentAdapter specHierarchyRootContentAdapter;
private Adapter emfColumnListener;
private ICellResizeListener agColumnListener;
-
+
private ICellDoubleClickListener doubleClickListener;
/**
@@ -264,7 +264,7 @@
unregisterSpecHierarchyListener();
unregisterSpecRelationListener();
unregisterDoubleClickListener();
-
+
this.specification = (Specification) input;
this.specViewConfig = ConfigurationUtil.createSpecViewConfiguration(
specification, editingDomain);
@@ -274,10 +274,10 @@
agileGrid.setCellRendererProvider(new ProrCellRendererProvider(
agileGrid, adapterFactory, editingDomain));
agileGrid.setCellEditorProvider(new ProrCellEditorProvider(agileGrid,
- editingDomain, adapterFactory, agileCellEditorActionHandler));
+ adapterFactory, agileCellEditorActionHandler));
agileGrid.setRowResizeCursor(new Cursor(agileGrid.getDisplay(),
SWT.CURSOR_ARROW));
-
+
updateRowCount();
updateColumnInformation();
registerColumnListener();
@@ -450,7 +450,7 @@
ReqIF10Util.getReqIF(specification).getCoreContent().eAdapters()
.add(specRelationContentAdapter);
}
-
+
private void registerDoubleClickListener() {
doubleClickListener = new ICellDoubleClickListener() {
public void cellDoubleClicked(CellDoubleClickEvent event) {
@@ -473,7 +473,7 @@
};
agileGrid.addCellDoubleClickListener(doubleClickListener);
}
-
+
private void unregisterDoubleClickListener() {
if (doubleClickListener != null && !agileGrid.isDisposed())
agileGrid.removeDoubleClickListener(doubleClickListener);
@@ -504,7 +504,7 @@
// SpecHierarchies
selectionChangedistener = new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
- if (settingSelection){
+ if (settingSelection) {
return;
}
Set<Cell> cells = event.getNewSelections();
@@ -675,7 +675,8 @@
private void enableDragNDrop() {
int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(),
- LocalSelectionTransfer.getTransfer(), PluginTransfer.getInstance() };
+ LocalSelectionTransfer.getTransfer(),
+ PluginTransfer.getInstance() };
addDragSupport(dndOperations, transfers, new ViewerDragAdapter(this) {
// Modified to allow resizing of columns
@@ -754,7 +755,7 @@
} else if (row instanceof ProrRowSpecRelation) {
target = row.getSpecElement();
}
-
+
if (target instanceof SpecHierarchy) {
dragTarget = (SpecHierarchy) target;
float location = getLocation(e);
@@ -869,7 +870,8 @@
public void setFilter(ReqifFilter filter) {
if (agileGrid.getContentProvider() instanceof ProrAgileGridContentProvider) {
- ((ProrAgileGridContentProvider)agileGrid.getContentProvider()).setFilter(filter);
+ ((ProrAgileGridContentProvider) agileGrid.getContentProvider())
+ .setFilter(filter);
this.refresh();
}
}
diff --git a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/ProrCellEditorProvider.java b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/ProrCellEditorProvider.java
index d43fae0..8a9cfb2 100644
--- a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/ProrCellEditorProvider.java
+++ b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/ProrCellEditorProvider.java
@@ -13,6 +13,7 @@
import org.agilemore.agilegrid.AgileGrid;
import org.agilemore.agilegrid.CellEditor;
import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.rmf.reqif10.AttributeValue;
@@ -30,10 +31,11 @@
private final ProrAgileGridContentProvider contentProvider;
private final AgileCellEditorActionHandler agileCellEditorActionHandler;
-
+
public ProrCellEditorProvider(AgileGrid agileGrid,
- EditingDomain editingDomain, AdapterFactory adapterFactory, AgileCellEditorActionHandler agileCellEditorActionHandler) {
- super(agileGrid, adapterFactory, editingDomain);
+ AdapterFactory adapterFactory,
+ AgileCellEditorActionHandler agileCellEditorActionHandler) {
+ super(agileGrid, adapterFactory);
this.contentProvider = (ProrAgileGridContentProvider) agileGrid
.getContentProvider();
this.agileCellEditorActionHandler = agileCellEditorActionHandler;
@@ -52,49 +54,52 @@
.getContentProvider();
ProrRow prorRow = provider.getProrRow(row);
if (prorRow instanceof ProrRowSpecHierarchy) {
- return ((ProrRowSpecHierarchy)prorRow).getSpecHierarchy();
+ return ((ProrRowSpecHierarchy) prorRow).getSpecHierarchy();
}
return (Identifiable) prorRow.getSpecElement();
}
@Override
public CellEditor getCellEditor(int row, int col, Object hint) {
+ CellEditor cellEditor = null;
SpecElementWithAttributes specElement = contentProvider.getProrRow(row)
.getSpecElement();
-
- CellEditor cellEditor = null;
- AttributeValue av = getAttributeValue(row, col);
-
- // Consult the presentation
- ProrPresentationConfiguration config = ConfigurationUtil
- .getPresentationConfiguration(av);
- if (config != null) {
- ItemProviderAdapter ip = ProrUtil.getItemProvider(adapterFactory,
- config);
- if (ip instanceof PresentationEditorInterface) {
- cellEditor = ((PresentationEditorInterface) ip).getCellEditor(
- agileGrid, editingDomain, av, specElement,
+
+ EditingDomain editingDomain = AdapterFactoryEditingDomain
+ .getEditingDomainFor(specElement);
+ if (editingDomain != null) {
+ AttributeValue av = getAttributeValue(row, col);
+
+ // Consult the presentation
+ ProrPresentationConfiguration config = ConfigurationUtil
+ .getPresentationConfiguration(av);
+ if (config != null) {
+ ItemProviderAdapter ip = ProrUtil.getItemProvider(
+ adapterFactory, config);
+ if (ip instanceof PresentationEditorInterface) {
+ cellEditor = ((PresentationEditorInterface) ip)
+ .getCellEditor(agileGrid, editingDomain, av,
+ specElement, getAffectedElement(row, col));
+ }
+ }
+
+ // See whether there is a default editor
+ if (cellEditor == null) {
+ cellEditor = PresentationServiceManager.getDefaultCellEditor(
+ agileGrid, editingDomain, adapterFactory, av,
+ specElement, getAffectedElement(row, col));
+ }
+
+ if (cellEditor == null) {
+ cellEditor = getDefaultCellEditor(av, specElement,
getAffectedElement(row, col));
}
- }
-
- // See whether there is a default editor
- if (cellEditor == null) {
- cellEditor = PresentationServiceManager.getDefaultCellEditor(
- agileGrid, editingDomain, adapterFactory, av, specElement,
- getAffectedElement(row, col));
- }
- if (cellEditor == null) {
- cellEditor = getDefaultCellEditor(av, specElement,
- getAffectedElement(row, col));
+ if (cellEditor != null)
+ agileCellEditorActionHandler.setActiveCellEditor(cellEditor);
}
-
- if (cellEditor != null)
- agileCellEditorActionHandler.setActiveCellEditor(cellEditor);
-
return cellEditor;
-
+
}
@Override
diff --git a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/presentation/Reqif10Editor.java b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/presentation/Reqif10Editor.java
index eb562b2..76cdfa6 100644
--- a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/presentation/Reqif10Editor.java
+++ b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/presentation/Reqif10Editor.java
@@ -705,7 +705,7 @@
protected void initializeEditingDomain() {
// Create an adapter factory that yields item providers.
//
-
+
adapterFactory = new ComposedAdapterFactory(
ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
@@ -713,14 +713,12 @@
.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory
.addAdapterFactory(new ReqIF10ItemProviderAdapterFactory());
- adapterFactory
- .addAdapterFactory(new XhtmlItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new XhtmlItemProviderAdapterFactory());
adapterFactory
.addAdapterFactory(new ConfigurationItemProviderAdapterFactory());
adapterFactory
.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
-
// Create the command stack that will notify this editor as commands are
// executed.
//
@@ -758,6 +756,11 @@
//
editingDomain = new AdapterFactoryEditingDomain(adapterFactory,
commandStack, new XMLPersistenceMappingResourceSetImpl());
+ editingDomain
+ .getResourceSet()
+ .eAdapters()
+ .add(new AdapterFactoryEditingDomain.EditingDomainProvider(
+ editingDomain));
// FIXME (mj) this got diabled for now, due to Bug 381494
// System.out.println("XXX");
// commandStack.setEditingDomain(editingDomain);
@@ -1055,7 +1058,8 @@
editingDomain
.getResourceSet()
.getLoadOptions()
- .put(XMLPersistenceMappingResource.OPTION_PROGRESS_MONITOR, monitor);
+ .put(XMLPersistenceMappingResource.OPTION_PROGRESS_MONITOR,
+ monitor);
createModel();
monitor.done();
}
@@ -1455,10 +1459,8 @@
/**
* This is for implementing {@link IEditorPart} and simply saves the model
- * file.
- * <!-- begin-user-doc -->
- * Upon each save, the ReqIF ID is updated.
- * <!-- end-user-doc -->
+ * file. <!-- begin-user-doc --> Upon each save, the ReqIF ID is updated.
+ * <!-- end-user-doc -->
*
* @generated NOT
*/
@@ -1467,7 +1469,7 @@
ISelection currentSelection = getSite().getSelectionProvider().getSelection();
// Update ReqIF ID.
reqif.getTheHeader().setIdentifier(UUID.randomUUID().toString());
-
+
// Save only resources that have actually changed.
//
final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
diff --git a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/propertiesview/ProrPropertyCellEditorProvider.java b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/propertiesview/ProrPropertyCellEditorProvider.java
index 18c9560..bbb50ba 100644
--- a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/propertiesview/ProrPropertyCellEditorProvider.java
+++ b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/propertiesview/ProrPropertyCellEditorProvider.java
@@ -27,6 +27,7 @@
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
@@ -63,14 +64,15 @@
* @author Lukas Ladenberger
* @author Michael Jastram
*/
-public class ProrPropertyCellEditorProvider extends AbstractProrCellEditorProvider {
+public class ProrPropertyCellEditorProvider extends
+ AbstractProrCellEditorProvider {
private final ProrPropertyContentProvider contentProvider;
-
+
public ProrPropertyCellEditorProvider(AgileGrid agileGrid,
- AdapterFactory adapterFactory, EditingDomain editingDomain,
+ AdapterFactory adapterFactory,
ProrPropertyContentProvider contentProvider) {
- super(agileGrid, adapterFactory, editingDomain);
+ super(agileGrid, adapterFactory);
this.contentProvider = contentProvider;
}
@@ -102,7 +104,7 @@
}
return null;
}
-
+
@Override
public boolean canEdit(int row, int col) {
@@ -161,32 +163,36 @@
// If the attribute is a reqif attribute (an attribute value exists),
// when try to get the presentation service
if (attrValue != null) {
-
- // Ask Presentation
- ProrPresentationConfiguration config = ConfigurationUtil
- .getPresentationConfiguration(attrValue);
- if (config != null) {
- ItemProviderAdapter ip = ProrUtil.getItemProvider(
- adapterFactory, config);
- if (ip instanceof PresentationEditorInterface) {
- cellEditor = ((PresentationEditorInterface) ip)
- .getCellEditor(agileGrid, editingDomain, attrValue,
- specElement, getAffectedElement(row, col));
+ EditingDomain editingDomain = AdapterFactoryEditingDomain
+ .getEditingDomainFor(specElement);
+ if (editingDomain != null) {
+ // Ask Presentation
+ ProrPresentationConfiguration config = ConfigurationUtil
+ .getPresentationConfiguration(attrValue);
+ if (config != null) {
+ ItemProviderAdapter ip = ProrUtil.getItemProvider(
+ adapterFactory, config);
+ if (ip instanceof PresentationEditorInterface) {
+ cellEditor = ((PresentationEditorInterface) ip)
+ .getCellEditor(agileGrid, editingDomain,
+ attrValue, specElement,
+ getAffectedElement(row, col));
+ }
}
+
+ // See whether there is a default editor
+ if (cellEditor == null) {
+ cellEditor = PresentationServiceManager
+ .getDefaultCellEditor(agileGrid, editingDomain,
+ adapterFactory, attrValue, specElement,
+ getAffectedElement(row, col));
+ }
+
+ if (cellEditor == null)
+ cellEditor = getDefaultCellEditor(attrValue,
+ contentProvider.getElement(),
+ getAffectedElement(row, col));
}
-
- // See whether there is a default editor
- if (cellEditor == null) {
- cellEditor = PresentationServiceManager.getDefaultCellEditor(
- agileGrid, editingDomain, adapterFactory, attrValue,
- specElement, getAffectedElement(row, col));
- }
-
- if (cellEditor == null)
- cellEditor = getDefaultCellEditor(attrValue,
- contentProvider.getElement(),
- getAffectedElement(row, col));
-
} else { // If the attribute is an EMF attribute (no attribute value
// exists) return a default celleditor
@@ -195,24 +201,25 @@
final IItemPropertyDescriptor descriptor = rowDescriptor
.getItemPropertyDescriptor();
-
+
String categoryName = descriptor.getCategory(contentProvider
.getElement());
Object selectedElement = contentProvider.getElement();
-
+
if (categoryName != null
&& categoryName
.equals(ProrPropertyContentProvider.SPEC_OBJECT_NAME)) {
- if (this.contentProvider.getElement() instanceof SpecHierarchy)
- selectedElement = ((SpecHierarchy) this.contentProvider.getElement())
- .getObject();
- }
-
- cellEditor = getNonAttributeCellEditor(selectedElement, descriptor);
+ if (this.contentProvider.getElement() instanceof SpecHierarchy)
+ selectedElement = ((SpecHierarchy) this.contentProvider
+ .getElement()).getObject();
+ }
+
+ cellEditor = getNonAttributeCellEditor(selectedElement,
+ descriptor);
}
}
return cellEditor;
-
+
}
/**
@@ -225,213 +232,226 @@
CellEditor getNonAttributeCellEditor(final Object object,
final IItemPropertyDescriptor itemPropertyDescriptor) {
- if (!itemPropertyDescriptor.canSetProperty(object)) {
- return null;
- }
-
CellEditor result = null;
-
- Object genericFeature = itemPropertyDescriptor.getFeature(object);
- if (genericFeature instanceof EReference[]) {
-
- result = null;
-
- result = new ExtendedAgileComboBoxCellEditor(agileGrid,
- editingDomain, new ArrayList<Object>(
- itemPropertyDescriptor.getChoiceOfValues(object)),
- itemPropertyDescriptor, object,
- itemPropertyDescriptor.isSortChoices(object));
-
- } else if (genericFeature instanceof EStructuralFeature) {
-
- final EStructuralFeature feature = (EStructuralFeature) genericFeature;
- final EClassifier eType = feature.getEType();
- final Collection<?> choiceOfValues = itemPropertyDescriptor
- .getChoiceOfValues(object);
-
- if (choiceOfValues != null) {
-
- if (itemPropertyDescriptor.isMany(object)) {
- boolean valid = true;
- for (Object choice : choiceOfValues) {
- if (!eType.isInstance(choice)) {
- valid = false;
- break;
- }
- }
-
- if (valid) {
-
- final ILabelProvider editLabelProvider = getLabelProvider(
- itemPropertyDescriptor, object);
-
- result = new ExtendedAgileDialogCellEditor(agileGrid,
- editingDomain, itemPropertyDescriptor, object) {
-
- @Override
- protected Object openDialogBox(
- Control cellEditorWindow) {
-
- FeatureEditorDialog dialog = new FeatureEditorDialog(
- cellEditorWindow.getShell(),
- editLabelProvider,
- object,
- feature.getEType(),
- (List<?>) doGetValue(),
- getDisplayName(itemPropertyDescriptor,
- object), new ArrayList<Object>(
- choiceOfValues), false,
- itemPropertyDescriptor
- .isSortChoices(object), feature
- .isUnique());
- super.openDialogBox(cellEditorWindow);
- dialog.open();
- return dialog.getResult();
-
- }
-
- };
-
- }
-
- }
-
- if (result == null) {
- result = new ExtendedAgileComboBoxCellEditor(agileGrid,
- editingDomain, new ArrayList<Object>(
- itemPropertyDescriptor
- .getChoiceOfValues(object)),
- itemPropertyDescriptor, object,
- itemPropertyDescriptor.isSortChoices(object));
- }
-
+ EditingDomain editingDomain = AdapterFactoryEditingDomain
+ .getEditingDomainFor(object);
+ if (editingDomain != null) {
+ if (!itemPropertyDescriptor.canSetProperty(object)) {
+ return null;
}
- else if (eType instanceof EDataType) {
+ Object genericFeature = itemPropertyDescriptor.getFeature(object);
+ if (genericFeature instanceof EReference[]) {
- final EDataType eDataType = (EDataType) eType;
+ result = null;
- if (eDataType.isSerializable()) {
+ result = new ExtendedAgileComboBoxCellEditor(agileGrid,
+ editingDomain, new ArrayList<Object>(
+ itemPropertyDescriptor
+ .getChoiceOfValues(object)),
+ itemPropertyDescriptor, object,
+ itemPropertyDescriptor.isSortChoices(object));
+
+ } else if (genericFeature instanceof EStructuralFeature) {
+
+ final EStructuralFeature feature = (EStructuralFeature) genericFeature;
+ final EClassifier eType = feature.getEType();
+ final Collection<?> choiceOfValues = itemPropertyDescriptor
+ .getChoiceOfValues(object);
+
+ if (choiceOfValues != null) {
+
if (itemPropertyDescriptor.isMany(object)) {
- final ILabelProvider editLabelProvider = getLabelProvider(
- itemPropertyDescriptor, object);
-
- result = new ExtendedAgileDialogCellEditor(agileGrid,
- editingDomain, itemPropertyDescriptor, object) {
- @Override
- protected Object openDialogBox(
- Control cellEditorWindow) {
-
- FeatureEditorDialog dialog = new FeatureEditorDialog(
- cellEditorWindow.getShell(),
- editLabelProvider, object,
- feature.getEType(),
- (List<?>) doGetValue(),
- getDisplayName(itemPropertyDescriptor,
- object), null,
- itemPropertyDescriptor
- .isMultiLine(object), false,
- feature.isUnique());
- super.openDialogBox(cellEditorWindow);
- dialog.open();
- return dialog.getResult();
-
+ boolean valid = true;
+ for (Object choice : choiceOfValues) {
+ if (!eType.isInstance(choice)) {
+ valid = false;
+ break;
}
- };
- } else if (eDataType.getInstanceClass() == Boolean.class
- || eDataType.getInstanceClass() == Boolean.TYPE) {
- result = new ExtendedAgileComboBoxCellEditor(agileGrid,
- editingDomain, Arrays.asList(new Object[] {
- Boolean.FALSE, Boolean.TRUE }),
- itemPropertyDescriptor, object,
- itemPropertyDescriptor.isSortChoices(object));
- } else {
+ }
- if (itemPropertyDescriptor.isMultiLine(object)) {
+ if (valid) {
+
+ final ILabelProvider editLabelProvider = getLabelProvider(
+ itemPropertyDescriptor, object);
result = new ExtendedAgileDialogCellEditor(
agileGrid, editingDomain,
itemPropertyDescriptor, object) {
- // TODO: not working yet ...
-
- protected EDataTypeValueHandler valueHandler = new EDataTypeValueHandler(
- eDataType);
-
@Override
protected Object openDialogBox(
Control cellEditorWindow) {
- InputDialog dialog = new MultiLineInputDialog(
+
+ FeatureEditorDialog dialog = new FeatureEditorDialog(
cellEditorWindow.getShell(),
- EMFEditUIPlugin.INSTANCE
- .getString(
- "_UI_FeatureEditorDialog_title",
- new Object[] {
- getDisplayName(
- itemPropertyDescriptor,
- object),
- getLabelProvider(
- itemPropertyDescriptor,
- object)
- .getText(
- object) }),
- EMFEditUIPlugin.INSTANCE
- .getString("_UI_MultiLineInputDialog_message"),
- valueHandler.toString(getValue()),
- valueHandler);
- return dialog.open() == Window.OK ? valueHandler
- .toValue(dialog.getValue()) : null;
+ editLabelProvider, object,
+ feature.getEType(),
+ (List<?>) doGetValue(),
+ getDisplayName(
+ itemPropertyDescriptor,
+ object),
+ new ArrayList<Object>(
+ choiceOfValues), false,
+ itemPropertyDescriptor
+ .isSortChoices(object),
+ feature.isUnique());
+ super.openDialogBox(cellEditorWindow);
+ dialog.open();
+ return dialog.getResult();
+
}
+
};
- } else {
-
- result = new EDataTypeAgileCellEditor(agileGrid,
- editingDomain, itemPropertyDescriptor,
- object, eDataType);
-
}
}
- }
- }
+ if (result == null) {
+ result = new ExtendedAgileComboBoxCellEditor(agileGrid,
+ editingDomain, new ArrayList<Object>(
+ itemPropertyDescriptor
+ .getChoiceOfValues(object)),
+ itemPropertyDescriptor, object,
+ itemPropertyDescriptor.isSortChoices(object));
+ }
+
+ }
+
+ else if (eType instanceof EDataType) {
+
+ final EDataType eDataType = (EDataType) eType;
+
+ if (eDataType.isSerializable()) {
+ if (itemPropertyDescriptor.isMany(object)) {
+ final ILabelProvider editLabelProvider = getLabelProvider(
+ itemPropertyDescriptor, object);
+
+ result = new ExtendedAgileDialogCellEditor(
+ agileGrid, editingDomain,
+ itemPropertyDescriptor, object) {
+ @Override
+ protected Object openDialogBox(
+ Control cellEditorWindow) {
+
+ FeatureEditorDialog dialog = new FeatureEditorDialog(
+ cellEditorWindow.getShell(),
+ editLabelProvider, object,
+ feature.getEType(),
+ (List<?>) doGetValue(),
+ getDisplayName(
+ itemPropertyDescriptor,
+ object), null,
+ itemPropertyDescriptor
+ .isMultiLine(object),
+ false, feature.isUnique());
+ super.openDialogBox(cellEditorWindow);
+ dialog.open();
+ return dialog.getResult();
+
+ }
+ };
+ } else if (eDataType.getInstanceClass() == Boolean.class
+ || eDataType.getInstanceClass() == Boolean.TYPE) {
+ result = new ExtendedAgileComboBoxCellEditor(
+ agileGrid, editingDomain,
+ Arrays.asList(new Object[] { Boolean.FALSE,
+ Boolean.TRUE }),
+ itemPropertyDescriptor, object,
+ itemPropertyDescriptor
+ .isSortChoices(object));
+ } else {
+
+ if (itemPropertyDescriptor.isMultiLine(object)) {
+
+ result = new ExtendedAgileDialogCellEditor(
+ agileGrid, editingDomain,
+ itemPropertyDescriptor, object) {
+
+ // TODO: not working yet ...
+
+ protected EDataTypeValueHandler valueHandler = new EDataTypeValueHandler(
+ eDataType);
+
+ @Override
+ protected Object openDialogBox(
+ Control cellEditorWindow) {
+ InputDialog dialog = new MultiLineInputDialog(
+ cellEditorWindow.getShell(),
+ EMFEditUIPlugin.INSTANCE
+ .getString(
+ "_UI_FeatureEditorDialog_title",
+ new Object[] {
+ getDisplayName(
+ itemPropertyDescriptor,
+ object),
+ getLabelProvider(
+ itemPropertyDescriptor,
+ object)
+ .getText(
+ object) }),
+ EMFEditUIPlugin.INSTANCE
+ .getString("_UI_MultiLineInputDialog_message"),
+ valueHandler
+ .toString(getValue()),
+ valueHandler);
+ return dialog.open() == Window.OK ? valueHandler
+ .toValue(dialog.getValue())
+ : null;
+ }
+ };
+
+ } else {
+
+ result = new EDataTypeAgileCellEditor(
+ agileGrid, editingDomain,
+ itemPropertyDescriptor, object,
+ eDataType);
+
+ }
+
+ }
+ }
+ }
+
+ }
}
return result;
}
-
-// /**
-// * This method undos the last command, wrapps it to change the affected
-// * objects, and executes it again.
-// * <p>
-// * This is a workaround, as we modify properties via
-// * {@link IItemPropertyDescriptor#setPropertyValue(Object, Object)}. That
-// * method builds the appropriate command and executes it. However, the
-// * affected objects are incorrect, as this is typically the
-// * {@link SpecElementWithAttributes} (or {@link SpecHierarchy}), but the
-// * property belongs to {@link AttributeValue}, which is therefore reported
-// * as the affected element.
-// */
-// private void fixAffectedObjectsOfLastcommand() {
-// Command lastCmd = editingDomain.getCommandStack().getMostRecentCommand();
-// if (lastCmd == null) return;
-// editingDomain.getCommandStack().undo();
-// CommandWrapper wrappedCmd = new CommandWrapper(lastCmd) {
-// public java.util.Collection<?> getAffectedObjects() {
-// List<Object> list = new ArrayList<Object>();
-// list.add(contentProvider.getIdentifiable());
-// return list;
-// }
-// };
-// editingDomain.getCommandStack().execute(wrappedCmd);
-// }
-
+
+ // /**
+ // * This method undos the last command, wrapps it to change the affected
+ // * objects, and executes it again.
+ // * <p>
+ // * This is a workaround, as we modify properties via
+ // * {@link IItemPropertyDescriptor#setPropertyValue(Object, Object)}. That
+ // * method builds the appropriate command and executes it. However, the
+ // * affected objects are incorrect, as this is typically the
+ // * {@link SpecElementWithAttributes} (or {@link SpecHierarchy}), but the
+ // * property belongs to {@link AttributeValue}, which is therefore reported
+ // * as the affected element.
+ // */
+ // private void fixAffectedObjectsOfLastcommand() {
+ // Command lastCmd = editingDomain.getCommandStack().getMostRecentCommand();
+ // if (lastCmd == null) return;
+ // editingDomain.getCommandStack().undo();
+ // CommandWrapper wrappedCmd = new CommandWrapper(lastCmd) {
+ // public java.util.Collection<?> getAffectedObjects() {
+ // List<Object> list = new ArrayList<Object>();
+ // list.add(contentProvider.getIdentifiable());
+ // return list;
+ // }
+ // };
+ // editingDomain.getCommandStack().execute(wrappedCmd);
+ // }
+
@Override
public Object getAffectedElement(int row, int col) {
if (this.contentProvider != null)
- return this.contentProvider.getElement();
+ return this.contentProvider.getElement();
return null;
}
diff --git a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/propertiesview/ProrPropertyControl.java b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/propertiesview/ProrPropertyControl.java
index a05a11e..605849b 100644
--- a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/propertiesview/ProrPropertyControl.java
+++ b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/propertiesview/ProrPropertyControl.java
@@ -21,6 +21,7 @@
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -53,19 +54,19 @@
* @author Michael Jastram
*
*/
-public class ProrPropertyControl extends AgileGrid implements PropertyChangeListener {
+public class ProrPropertyControl extends AgileGrid implements
+ PropertyChangeListener {
private ProrPropertyContentProvider contentProvider;
-
+
private Object object;
- private EditingDomain editingDomain;
+ private AttributeValue removeValue;
- public ProrPropertyControl(Composite parent, EditingDomain editingDomain,
- AdapterFactory adapterFactory, boolean showAllProps) {
+ public ProrPropertyControl(Composite parent, AdapterFactory adapterFactory,
+ boolean showAllProps) {
super(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWTX.FILL_WITH_LASTCOL
| SWT.MULTI | SWT.DOUBLE_BUFFERED);
- this.editingDomain = editingDomain;
setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
this.contentProvider = new ProrPropertyContentProvider(adapterFactory,
showAllProps);
@@ -74,9 +75,9 @@
adapterFactory, contentProvider));
setLayoutAdvisor(new ProrPropertyLayoutAdvisor(this));
setCellEditorProvider(new ProrPropertyCellEditorProvider(this,
- adapterFactory, editingDomain, this.contentProvider));
+ adapterFactory, this.contentProvider));
setRowResizeCursor(new Cursor(this.getDisplay(), SWT.CURSOR_ARROW));
-
+
// listen to property changes in content
// Fix of 378041
contentProvider.addPropertyChangeListener(this);
@@ -85,18 +86,21 @@
}
/**
- * Sets up a context menu that allows the value to be removed from {@link SpecElementWithAttributes}.
+ * Sets up a context menu that allows the value to be removed from
+ * {@link SpecElementWithAttributes}.
+ *
* @param parent
*/
private void configurePopupMenu(Composite parent) {
-
- // Required to set the selection properly, before a context menu pops up.
+
+ // Required to set the selection properly, before a context menu pops
+ // up.
addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
- Cell[] cells = new Cell[] {getCell(e.x, e.y)};
+ Cell[] cells = new Cell[] { getCell(e.x, e.y) };
ProrPropertyControl.this.clearSelection();
ProrPropertyControl.this.selectCells(cells);
- }
+ }
});
// The actual menu.
@@ -104,12 +108,12 @@
final MenuItem item = new MenuItem(menu, SWT.NONE);
item.setText("Remove Value");
item.addSelectionListener(new SelectionAdapter() {
-
+
public void widgetSelected(SelectionEvent e) {
removeValue();
}
});
-
+
// Prepares the menu, before it is shown.
menu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent e) {
@@ -117,7 +121,8 @@
removeValue = null;
Cell[] selection = ProrPropertyControl.this.getCellSelection();
if (selection.length == 1) {
- PropertyRow row = contentProvider.getRowContent(selection[0].row);
+ PropertyRow row = contentProvider
+ .getRowContent(selection[0].row);
if (row instanceof Descriptor) {
Descriptor descriptor = (Descriptor) row;
if (descriptor.isRMFSpecific()) {
@@ -133,35 +138,37 @@
});
setMenu(menu);
}
-
- private AttributeValue removeValue;
private void removeValue() {
- Command cmd = null;
- if (removeValue.eContainer() instanceof SpecElementWithAttributes) {
- cmd = RemoveCommand
- .create(editingDomain,
- removeValue.eContainer(),
- ReqIF10Package.Literals.SPEC_ELEMENT_WITH_ATTRIBUTES__VALUES,
- removeValue);
- } else if (removeValue.eContainer() instanceof AttributeDefinition) {
- AttributeDefinition ad = (AttributeDefinition) removeValue
- .eContainer();
+ EditingDomain editingDomain = AdapterFactoryEditingDomain
+ .getEditingDomainFor(removeValue);
+ if (editingDomain != null) {
+ Command cmd = null;
+ if (removeValue.eContainer() instanceof SpecElementWithAttributes) {
+ cmd = RemoveCommand
+ .create(editingDomain,
+ removeValue.eContainer(),
+ ReqIF10Package.Literals.SPEC_ELEMENT_WITH_ATTRIBUTES__VALUES,
+ removeValue);
+ } else if (removeValue.eContainer() instanceof AttributeDefinition) {
+ AttributeDefinition ad = (AttributeDefinition) removeValue
+ .eContainer();
- cmd = SetCommand.create(editingDomain, ad,
- ReqIF10Util.getDefaultValueFeature(ad), null);
- System.out.println(cmd.canExecute());
- }
+ cmd = SetCommand.create(editingDomain, ad,
+ ReqIF10Util.getDefaultValueFeature(ad), null);
+ System.out.println(cmd.canExecute());
+ }
- if (cmd != null) {
- editingDomain.getCommandStack().execute(cmd);
- redrawCells(ProrPropertyControl.this.getCellSelection());
- } else {
- System.err
- .println("Don't know parent: " + removeValue.eContainer());
+ if (cmd != null) {
+ editingDomain.getCommandStack().execute(cmd);
+ redrawCells(ProrPropertyControl.this.getCellSelection());
+ } else {
+ System.err.println("Don't know parent: "
+ + removeValue.eContainer());
+ }
}
}
-
+
void setSelection(ISelection selection) {
if (selection instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection) selection;
diff --git a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/propertiesview/ProrPropertySheetPage.java b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/propertiesview/ProrPropertySheetPage.java
index 6d9908b..60f39eb 100644
--- a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/propertiesview/ProrPropertySheetPage.java
+++ b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/propertiesview/ProrPropertySheetPage.java
@@ -20,7 +20,9 @@
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.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.jface.action.Action;
@@ -68,45 +70,60 @@
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();
+ protected void registerCommandStackListener() {
+ if (editingDomain != null) {
+ editingDomain.getCommandStack().addCommandStackListener(
+ getCommandStackListener());
+ }
+ }
+
+ protected void unRegisterCommandStackListener() {
+ if (editingDomain != null) {
+ editingDomain.getCommandStack().removeCommandStackListener(
+ getCommandStackListener());
+ }
+ }
+
+ protected CommandStackListener getCommandStackListener() {
+ if (commandStackListener == null) {
+ 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);
+ });
+ }
+ };
+ }
+ return commandStackListener;
}
/**
@@ -118,14 +135,14 @@
tabFolder = new TabFolder(parent, SWT.BOTTOM);
standardProperties = new ProrPropertyControl(tabFolder,
- editingDomain, adapterFactory, false);
+ adapterFactory, false);
TabItem tabStandard = new TabItem(tabFolder, SWT.NONE);
tabStandard.setText(Reqif10EditorPlugin.getPlugin().getString(
"_UI_Standard_Properties"));
tabStandard.setControl(standardProperties);
- allProperties = new ProrPropertyControl(tabFolder, editingDomain,
- adapterFactory, true);
+ allProperties = new ProrPropertyControl(tabFolder, adapterFactory,
+ true);
TabItem tabAll = new TabItem(tabFolder, SWT.NONE);
tabAll.setText(Reqif10EditorPlugin.getPlugin().getString(
"_UI_All_Properties"));
@@ -170,15 +187,36 @@
* {@link SpecificationEditor}.
*/
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
-
- if (allProperties != null && ! allProperties.isDisposed()) {
+ EditingDomain newEditingDomain = null;
+ if (part instanceof IEditingDomainProvider) {
+ newEditingDomain = ((IEditingDomainProvider) part)
+ .getEditingDomain();
+ } else if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ if (structuredSelection.size() == 1) {
+ newEditingDomain = AdapterFactoryEditingDomain
+ .getEditingDomainFor(structuredSelection
+ .getFirstElement());
+ }
+ }
+ updateEditingDomain(newEditingDomain);
+ if (allProperties != null && !allProperties.isDisposed()) {
allProperties.setSelection(selection);
}
- if (standardProperties != null && ! standardProperties.isDisposed()) {
+ if (standardProperties != null && !standardProperties.isDisposed()) {
standardProperties.setSelection(selection);
}
}
+ private void updateEditingDomain(EditingDomain newEditingDomain) {
+ if (editingDomain != newEditingDomain) {
+ unRegisterCommandStackListener();
+ editingDomain = newEditingDomain;
+ registerCommandStackListener();
+ }
+
+ }
+
private void update() {
if (allProperties != null && !allProperties.isDisposed()) {
allProperties.update();
@@ -225,8 +263,10 @@
@Override
public void dispose() {
if (commandStackListener != null) {
- editingDomain.getCommandStack().removeCommandStackListener(
- commandStackListener);
+ if (editingDomain != null) {
+ editingDomain.getCommandStack().removeCommandStackListener(
+ commandStackListener);
+ }
commandStackListener = null;
}
super.dispose();
diff --git a/org.eclipse.rmf.reqif10.search.edit/build.properties b/org.eclipse.rmf.reqif10.search.edit/build.properties
index 061672e..9ac8d14 100644
--- a/org.eclipse.rmf.reqif10.search.edit/build.properties
+++ b/org.eclipse.rmf.reqif10.search.edit/build.properties
@@ -4,7 +4,10 @@
icons/,\
META-INF/,\
plugin.xml,\
- plugin.properties
+ plugin.properties,\
+ notice.html,\
+ epl-v10.html,\
+ about.html
jars.compile.order = .
source.. = src/
output.. = bin/
diff --git a/org.eclipse.rmf.reqif10.search.edit/src/org/eclipse/rmf/reqif10/search/edit/util/ReqIFEditSearcher.java b/org.eclipse.rmf.reqif10.search.edit/src/org/eclipse/rmf/reqif10/search/edit/util/ReqIFEditSearcher.java
index a57e7a8..aa232ae 100644
--- a/org.eclipse.rmf.reqif10.search.edit/src/org/eclipse/rmf/reqif10/search/edit/util/ReqIFEditSearcher.java
+++ b/org.eclipse.rmf.reqif10.search.edit/src/org/eclipse/rmf/reqif10/search/edit/util/ReqIFEditSearcher.java
@@ -12,13 +12,16 @@
package org.eclipse.rmf.reqif10.search.edit.util;
import java.util.Collection;
+import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.rmf.reqif10.search.criteria.Criteria;
import org.eclipse.rmf.reqif10.search.util.ReqIFSearcher;
@@ -29,13 +32,13 @@
*/
public class ReqIFEditSearcher extends ReqIFSearcher {
/**
- * The editing domain
- */
- private EditingDomain editingDomain;
- /**
* The compound command
*/
private CompoundCommand compoundCommand;
+ /**
+ * The editing domain
+ */
+ private EditingDomain editingDomain;
/**
* The constructor
@@ -43,46 +46,51 @@
* @param editingDomain
* : The editing domain
*/
- public ReqIFEditSearcher(EditingDomain editingDomain) {
+ public ReqIFEditSearcher() {
super();
- this.editingDomain = editingDomain;
}
- public static Collection<EObject> find(ResourceSet resourceSet,
- Collection<Criteria> criterias) {
+ public static Map<Resource, Collection<EObject>> find(
+ IProgressMonitor monitor, Collection<Resource> resources,
+ Collection<Criteria> criterias, boolean replace) {
ReqIFSearcher searcher = new ReqIFSearcher();
- return searcher.search(resourceSet, criterias, false);
- }
-
- public static Collection<EObject> findAndReplcae(
- EditingDomain editingDomain, ResourceSet resourceSet,
- Collection<Criteria> criterias) {
- ReqIFEditSearcher searcher = new ReqIFEditSearcher(editingDomain);
- return searcher.search(resourceSet, criterias, true);
+ return searcher.search(monitor, resources, criterias, replace);
}
@Override
- public Collection<EObject> search(ResourceSet resourceSet,
- Collection<Criteria> criterias, boolean replace) {
+ protected Collection<EObject> search(IProgressMonitor monitor,
+ Resource resource, Collection<Criteria> criterias, boolean replace) {
Collection<EObject> result = null;
+ editingDomain = AdapterFactoryEditingDomain
+ .getEditingDomainFor(resource.getContents().get(0));
if (replace) {
compoundCommand = new CompoundCommand();
- result = super.search(resourceSet, criterias, replace);
- editingDomain.getCommandStack().execute(compoundCommand);
+ result = super.search(monitor, resource, criterias, replace);
+ executeCommand(editingDomain, compoundCommand);
compoundCommand = null;
+ editingDomain = null;
} else {
- result = super.search(resourceSet, criterias, replace);
+ result = super.search(monitor, resource, criterias, replace);
}
return result;
+ }
+ protected void executeCommand(EditingDomain editingDomain, Command command) {
+ if (editingDomain != null) {
+ editingDomain.getCommandStack().execute(command);
+ }
}
@Override
protected void doSetValue(EObject eObject, EStructuralFeature feature,
Object value) {
- Command command = SetCommand.create(editingDomain, eObject, feature,
- value);
- compoundCommand.append(command);
+ if (editingDomain != null) {
+ Command command = SetCommand.create(editingDomain, eObject,
+ feature, value);
+ compoundCommand.append(command);
+ } else {
+ super.doSetValue(eObject, feature, value);
+ }
}
}
diff --git a/org.eclipse.rmf.reqif10.search.ui/build.properties b/org.eclipse.rmf.reqif10.search.ui/build.properties
index 061672e..15f69b6 100644
--- a/org.eclipse.rmf.reqif10.search.ui/build.properties
+++ b/org.eclipse.rmf.reqif10.search.ui/build.properties
@@ -1,10 +1,13 @@
#
bin.includes = .,\
- icons/,\
META-INF/,\
plugin.xml,\
- plugin.properties
+ plugin.properties,\
+ about.html,\
+ epl-v10.html,\
+ notice.html,\
+ icons/
jars.compile.order = .
source.. = src/
output.. = bin/
diff --git a/org.eclipse.rmf.reqif10.search.ui/icons/full/ctool16/CreateCriterias_criterias_Criteria.gif b/org.eclipse.rmf.reqif10.search.ui/icons/full/ctool16/CreateCriterias_criterias_Criteria.gif
deleted file mode 100644
index ab255f3..0000000
--- a/org.eclipse.rmf.reqif10.search.ui/icons/full/ctool16/CreateCriterias_criterias_Criteria.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/Criteria.gif b/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/Criteria.gif
deleted file mode 100644
index 2b69256..0000000
--- a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/Criteria.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/Criterias.gif b/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/Criterias.gif
deleted file mode 100644
index cdd3b76..0000000
--- a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/Criterias.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/ReqIf.png b/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/ReqIf.png
new file mode 100644
index 0000000..f77086c
--- /dev/null
+++ b/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/ReqIf.png
Binary files differ
diff --git a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/Search.png b/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/Search.png
deleted file mode 100644
index 7d5ec8a..0000000
--- a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/Search.png
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/add.gif b/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/add.gif
deleted file mode 100644
index 252d7eb..0000000
--- a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/add.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/delete.gif b/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/delete.gif
deleted file mode 100644
index b6922ac..0000000
--- a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/delete.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/redo.gif b/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/redo.gif
deleted file mode 100644
index c84e5b1..0000000
--- a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/redo.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/undo.gif b/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/undo.gif
deleted file mode 100644
index eae118a..0000000
--- a/org.eclipse.rmf.reqif10.search.ui/icons/full/obj16/undo.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.rmf.reqif10.search.ui/plugin.properties b/org.eclipse.rmf.reqif10.search.ui/plugin.properties
index ca18ff8..399ee84 100644
--- a/org.eclipse.rmf.reqif10.search.ui/plugin.properties
+++ b/org.eclipse.rmf.reqif10.search.ui/plugin.properties
@@ -3,33 +3,5 @@
pluginName = ReqIF Search UI Support
providerName = Eclipse Modeling Project
-_UI_CreateChild_text = {0}
-_UI_CreateChild_text2 = {1} {0}
-_UI_CreateChild_text3 = {1}
-_UI_CreateChild_tooltip = Create New {0} Under {1} Feature
-_UI_CreateChild_description = Create a new child of type {0} for the {1} feature of the selected {2}.
-_UI_CreateSibling_description = Create a new sibling of type {0} for the selected {2}, under the {1} feature of their parent.
-
-_UI_PropertyDescriptor_description = The {0} of the {1}
-
-_UI_Criterias_type = Criterias
-_UI_Criteria_type = Criteria
-_UI_Unknown_type = Object
-
-_UI_Unknown_datatype= Value
-
-_UI_Criterias_criterias_feature = Criterias
-_UI_Criteria_feature_feature = Feature
-_UI_Criteria_operator_feature = Operator
-_UI_Criteria_serachedText_feature = Serached Text
-_UI_Criteria_sensitiveCase_feature = Sensitive Case
-_UI_Unknown_feature = Unspecified
-
-_UI_Operator_EQUALS_literal = Equals
-_UI_Operator_CONTAINS_literal = Contains
-_UI_Operator_NOT_EQUALS_literal = Not Equals
-_UI_Criteria_featureName_feature = Feature Name
-
-
_UI_HorizontalOrientation_label = Horizontal orientation
_UI_VerticalOrientation_label = Vertical orientation
\ No newline at end of file
diff --git a/org.eclipse.rmf.reqif10.search.ui/plugin.xml b/org.eclipse.rmf.reqif10.search.ui/plugin.xml
index 92d4131..ab01e37 100644
--- a/org.eclipse.rmf.reqif10.search.ui/plugin.xml
+++ b/org.eclipse.rmf.reqif10.search.ui/plugin.xml
@@ -10,62 +10,19 @@
point="org.eclipse.search.searchResultViewPages">
<viewPage
class="org.eclipse.rmf.reqif10.search.ui.ReqIFSearchResultPage"
- id="org.eclipse.rmf.reqif10.search.ui.ReqIFSearchResultPage"
+ id="org.eclipse.rmf.reqif10.search.ui.page.result.reqif"
searchResultClass="org.eclipse.rmf.reqif10.search.ui.UsageSearchResult">
</viewPage>
</extension>
<extension
- point="org.eclipse.ui.menus">
- <menuContribution
- allPopups="false"
- locationURI="toolbar:org.eclipse.ui.main.toolbar">
- <toolbar
- id="org.eclipse.rmf.reqif10.search.searchtoolbar"
- label="ReqIFSearch">
- <command
- commandId="org.eclipse.rmf.reqif10.search.command.search"
- icon="icons/full/obj16/Search.png"
- label="Search"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeEditor">
- <or>
- <instanceof
- value="org.eclipse.rmf.reqif10.pror.editor.presentation.Reqif10Editor">
- </instanceof>
- <instanceof
- value="org.eclipse.rmf.reqif10.pror.editor.presentation.SpecificationEditor">
- </instanceof>
- </or>
- </with>
- </visibleWhen>
- </command>
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeEditor">
- <or>
- <instanceof
- value="org.eclipse.rmf.reqif10.pror.editor.presentation.Reqif10Editor">
- </instanceof>
- <instanceof
- value="org.eclipse.rmf.reqif10.pror.editor.presentation.SpecificationEditor">
- </instanceof>
- </or>
- </with>
- </visibleWhen>
- </toolbar>
- </menuContribution>
- </extension>
- <extension
- point="org.eclipse.ui.commands">
- <command
- defaultHandler="org.eclipse.rmf.reqif10.search.ui.handlers.SearchHandler"
- id="org.eclipse.rmf.reqif10.search.command.search"
- name="Search">
- </command>
+ point="org.eclipse.search.searchPages">
+ <page
+ class="org.eclipse.rmf.reqif10.search.ui.ReqIFSearchPage"
+ icon="icons/full/obj16/ReqIf.png"
+ id="org.eclipse.rmf.reqif10.search.ui.page.reqif"
+ label="ReqIF"
+ showScopeSection="true">
+ </page>
</extension>
</plugin>
diff --git a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/ReqIFSearchPage.java b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/ReqIFSearchPage.java
new file mode 100644
index 0000000..0a8d700
--- /dev/null
+++ b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/ReqIFSearchPage.java
@@ -0,0 +1,314 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Hussein Mhanna
+ *
+ * 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:
+ * Hussein Mhanna - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.rmf.reqif10.search.ui;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.emf.edit.ui.util.EditUIUtil;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.rmf.reqif10.pror.editor.presentation.Reqif10Editor;
+import org.eclipse.rmf.reqif10.search.criteria.Criteria;
+import org.eclipse.rmf.reqif10.search.edit.util.ReqIFEditSearcher;
+import org.eclipse.rmf.reqif10.search.ui.masterdetails.CriteriasMasterDetailsBlock;
+import org.eclipse.search.ui.IReplacePage;
+import org.eclipse.search.ui.ISearchPage;
+import org.eclipse.search.ui.ISearchPageContainer;
+import org.eclipse.search.ui.ISearchQuery;
+import org.eclipse.search.ui.NewSearchUI;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.ManagedForm;
+
+public class ReqIFSearchPage extends DialogPage implements ISearchPage,
+ IReplacePage {
+ private static final String REQIF_EXTENSION = "reqif";
+ private ISearchPageContainer container;
+ private CriteriasMasterDetailsBlock masterDetailsBlock;
+
+ public ReqIFSearchPage() {
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
+ true, true));
+ composite.setLayout(new FillLayout());
+ IManagedForm managedForm = new ManagedForm(composite);
+ masterDetailsBlock = new CriteriasMasterDetailsBlock();
+ masterDetailsBlock.createContent(managedForm);
+ container.setPerformActionEnabled(true);
+ setControl(parent);
+ }
+
+ private List<IResource> getResources() {
+ IResource[] resources = new IResource[0];
+ switch (container.getSelectedScope()) {
+ case ISearchPageContainer.SELECTION_SCOPE:
+ Object[] objects = ((IStructuredSelection) (container
+ .getSelection())).toArray();
+ Set<IResource> resList = new HashSet<IResource>(objects.length);
+ for (Object object : objects) {
+ if (object instanceof IResource) {
+ resList.add((IResource) object);
+ } else if (object instanceof EObject) {
+ EObject eObject = (EObject) object;
+ Resource eResource = eObject.eResource();
+ if (eResource != null) {
+ URI eUri = eResource.getURI();
+ if (eUri.isPlatformResource()) {
+ String platformString = eUri.toPlatformString(true);
+ IResource resource = ResourcesPlugin.getWorkspace()
+ .getRoot().findMember(platformString);
+ resList.add(resource);
+ }
+ }
+ }
+ }
+ resources = resList.toArray(new IResource[0]);
+ break;
+ case ISearchPageContainer.WORKSPACE_SCOPE:
+ resources = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ break;
+ case ISearchPageContainer.WORKING_SET_SCOPE:
+ resources = convertToResources(container.getSelectedWorkingSets());
+ break;
+ }
+ return getReqIFResources(resources);
+ }
+
+ private List<IResource> getReqIFResources(IResource[] resources) {
+ List<IResource> reqIFResources = new ArrayList<IResource>();
+ for (IResource resource : resources) {
+ if (resource instanceof IFile
+ && resource.getFileExtension() != null
+ && resource.getFileExtension().equals(REQIF_EXTENSION)) {
+ reqIFResources.add(resource);
+ } else if (resource instanceof IContainer) {
+ try {
+ reqIFResources
+ .addAll(getReqIFResources(((IContainer) resource)
+ .members()));
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return reqIFResources;
+ }
+
+ private static IResource[] convertToResources(IWorkingSet[] workingSets) {
+ List<IResource> res = new ArrayList<IResource>();
+ for (int i = 0; i < workingSets.length; i++) {
+ IWorkingSet workingSet = workingSets[i];
+ if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) {
+ return new IResource[] { ResourcesPlugin.getWorkspace()
+ .getRoot() };
+ }
+ IAdaptable[] elements = workingSet.getElements();
+ for (int k = 0; k < elements.length; k++) {
+ IResource curr = (IResource) elements[k]
+ .getAdapter(IResource.class);
+ if (curr != null) {
+ res.add(curr);
+ }
+ }
+ }
+ return (IResource[]) res.toArray(new IResource[res.size()]);
+ }
+
+ final void updateOKStatus() {
+ container.setPerformActionEnabled(true);
+ }
+
+ public Map<URI, EditingDomain> getEditorsURIMap() {
+ final Map<URI, EditingDomain> uriMap = new HashMap<URI, EditingDomain>();
+
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ IEditorReference[] editorReferences = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage()
+ .getEditorReferences();
+ for (IEditorReference editorReference : editorReferences) {
+ IEditorPart editorPart = editorReference.getEditor(false);
+ if (editorPart instanceof Reqif10Editor) {
+ try {
+ uriMap.put(EditUIUtil.getURI(editorReference
+ .getEditorInput()),
+ ((IEditingDomainProvider) editorPart)
+ .getEditingDomain());
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ });
+ return uriMap;
+ }
+
+ public List<Resource> getEMFResources(Map<URI, EditingDomain> uriMap) {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ List<IResource> resources = getResources();
+ List<Resource> emfResources = new ArrayList<Resource>();
+ for (IResource resource : resources) {
+ URI uri = URI.createPlatformResourceURI(resource.getFullPath()
+ .toOSString(), true);
+ EditingDomain editingDomain = uriMap.get(uri);
+ if (editingDomain != null) {
+ emfResources.addAll(editingDomain.getResourceSet()
+ .getResources());
+ } else {
+ Resource emfResource = resourceSet.getResource(uri, true);
+ if (emfResource != null) {
+ emfResources.add(emfResource);
+ }
+ }
+ }
+ return emfResources;
+ }
+
+ @Override
+ public boolean performReplace() {
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+
+ @Override
+ public void run(final IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ monitor.beginTask("Start Searching ...",
+ IProgressMonitor.UNKNOWN);
+ final Map<URI, EditingDomain> uriMap = getEditorsURIMap();
+ final List<Resource> resources = getEMFResources(uriMap);
+ ExtendedReqIFEdit reqIFEditSearcher = new ExtendedReqIFEdit(
+ uriMap);
+ reqIFEditSearcher.search(monitor, resources,
+ masterDetailsBlock.getCriterias(), true);
+ }
+ };
+ try {
+ new ProgressMonitorDialog(getShell()).run(true, true, runnable);
+ } catch (InvocationTargetException e) {
+ ReqIFSearchUIPlugin.getPlugin().log(e);
+ } catch (InterruptedException e) {
+ ReqIFSearchUIPlugin.getPlugin().log(e);
+ }
+ return true;
+ }
+
+ @SuppressWarnings("restriction")
+ @Override
+ public boolean performAction() {
+ ISearchQuery query = newQuery();
+ // Note : In the javadoc its explaned that we need to only call
+ // NewSearchUI.runQueryInForeground but due to a bug this doesn't work
+ // so I had to do the code below.
+ org.eclipse.search2.internal.ui.SearchView searchView = null;
+ try {
+ searchView = (org.eclipse.search2.internal.ui.SearchView) PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .showView(NewSearchUI.SEARCH_VIEW_ID);
+ } catch (final PartInitException e) {
+ ReqIFSearchUIPlugin.INSTANCE.log(e);
+ }
+ NewSearchUI.runQueryInForeground(new ProgressMonitorDialog(getShell()),
+ query);
+ if (searchView != null) {
+ searchView.showSearchResult(query.getSearchResult());
+ }
+ return true;
+ }
+
+ private ISearchQuery newQuery() {
+ return new ReqIFSearchQuery(this,
+ masterDetailsBlock.getCriterias());
+ }
+
+ @Override
+ public void setContainer(ISearchPageContainer container) {
+ this.container = container;
+ }
+
+ protected class ExtendedReqIFEdit extends ReqIFEditSearcher {
+ private final Map<URI, EditingDomain> uriMap;
+
+ public ExtendedReqIFEdit(Map<URI, EditingDomain> uriMap) {
+ this.uriMap = uriMap;
+ }
+
+ @Override
+ protected Collection<EObject> search(IProgressMonitor monitor,
+ Resource resource, Collection<Criteria> criterias,
+ boolean replace) {
+ final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
+ saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED,
+ Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+ Collection<EObject> result = super.search(monitor, resource,
+ criterias, replace);
+ if (false == uriMap.containsKey(resource.getURI())) {
+ try {
+ resource.save(saveOptions);
+ } catch (IOException e) {
+ ReqIFSearchUIPlugin.getPlugin().log(e);
+ }
+ }
+ return result;
+ }
+
+ public void executeCommand(final EditingDomain editingDomain,
+ final Command command) {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ ExtendedReqIFEdit.super.executeCommand(editingDomain,
+ command);
+ }
+ });
+ }
+
+ }
+}
diff --git a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/ReqIFSearchQuery.java b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/ReqIFSearchQuery.java
index 7a9f86b..c74678d 100644
--- a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/ReqIFSearchQuery.java
+++ b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/ReqIFSearchQuery.java
@@ -12,14 +12,14 @@
package org.eclipse.rmf.reqif10.search.ui;
import java.util.Collection;
+import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.rmf.reqif10.search.criteria.Criteria;
import org.eclipse.rmf.reqif10.search.edit.util.ReqIFEditSearcher;
import org.eclipse.search.ui.ISearchQuery;
@@ -36,24 +36,17 @@
* The usage search result
*/
private UsageSearchResult usageSearchResult;
- private ResourceSet resourceSet;
+ private Collection<Resource> resources;
private Collection<Criteria> criterias;
- private EditingDomain editingDomain;
+
+ private final ReqIFSearchPage page;
/**
* @param operator
* @param iSelection
*/
- public ReqIFSearchQuery(EditingDomain editingDomain,
- Collection<Criteria> criterias) {
- StringBuilder searchedTextBuilder = new StringBuilder();
- for (Criteria criteria : criterias) {
- searchedTextBuilder.append(criteria.getSerachedText())
- .append(" - ");
- }
- this.editingDomain = editingDomain;
- this.searchedText = searchedTextBuilder.toString();
- this.resourceSet = editingDomain.getResourceSet();
+ public ReqIFSearchQuery(ReqIFSearchPage page, Collection<Criteria> criterias) {
+ this.page = page;
this.criterias = criterias;
}
@@ -80,16 +73,20 @@
private void doRun(IProgressMonitor monitor) {
monitor.beginTask("Searching...", IProgressMonitor.UNKNOWN);
- Collection<EObject> result = ReqIFEditSearcher.find(resourceSet,
- criterias);
- usageSearchResult.getSearchEntries().addAll(result);
+ StringBuilder searchedTextBuilder = new StringBuilder();
+ for (Criteria criteria : criterias) {
+ searchedTextBuilder.append(criteria.getSerachedText())
+ .append(" - ");
+ }
+ this.searchedText = searchedTextBuilder.toString();
+ this.resources = page.getEMFResources(page.getEditorsURIMap());
+ Map<Resource, Collection<EObject>> result = ReqIFEditSearcher.find(
+ monitor, resources, criterias, false);
+ usageSearchResult.getSearchEntries().clear();
+ usageSearchResult.getSearchEntries().putAll(result);
monitor.done();
}
- public UsageSearchResult getUsageSearchResult() {
- return usageSearchResult;
- }
-
@Override
public String getLabel() {
return searchedText;
@@ -109,12 +106,4 @@
public ISearchResult getSearchResult() {
return usageSearchResult;
}
-
- public ResourceSet getResourceSet() {
- return resourceSet;
- }
-
- public EditingDomain getEditingDomain() {
- return editingDomain;
- }
}
diff --git a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/ReqIFSearchResultPage.java b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/ReqIFSearchResultPage.java
index 8af40aa..7587be8 100644
--- a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/ReqIFSearchResultPage.java
+++ b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/ReqIFSearchResultPage.java
@@ -13,12 +13,14 @@
import java.util.Collection;
import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
@@ -31,6 +33,7 @@
import org.eclipse.rmf.reqif10.pror.configuration.provider.ConfigurationItemProviderAdapterFactory;
import org.eclipse.rmf.reqif10.pror.editor.propertiesview.ProrPropertySheetPage;
import org.eclipse.rmf.reqif10.pror.provider.ReqIF10ItemProviderAdapterFactory;
+import org.eclipse.rmf.reqif10.pror.provider.ReqIFContentItemProvider;
import org.eclipse.rmf.reqif10.pror.util.ProrUtil;
import org.eclipse.rmf.reqif10.xhtml.provider.XhtmlItemProviderAdapterFactory;
import org.eclipse.search.ui.ISearchResult;
@@ -60,17 +63,22 @@
private AdapterFactoryContentProvider contentProvider;
private Set<Object> objectsFound = new HashSet<Object>();
private ComposedAdapterFactory adapterFactory;
-
- private ProrPropertySheetPage propertySheetPage;
-
- private EditingDomain editingDomain;
+ /**
+ * This is the property sheet page.
+ */
+ protected ProrPropertySheetPage propertySheetPage;
private ComposedAdapterFactory createAdapterFactory() {
ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory();
adapterFactory
.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory
- .addAdapterFactory(new ReqIF10ItemProviderAdapterFactory());
+ .addAdapterFactory(new ReqIF10ItemProviderAdapterFactory() {
+ @Override
+ public Adapter createReqIFContentAdapter() {
+ return new ReqIFContentItemProvider(this);
+ }
+ });
adapterFactory.addAdapterFactory(new XhtmlItemProviderAdapterFactory());
adapterFactory
.addAdapterFactory(new ConfigurationItemProviderAdapterFactory());
@@ -128,23 +136,32 @@
public void setInput(final ISearchResult searchResult, final Object uiState) {
if (searchResult instanceof UsageSearchResult) {
this.searchResult = (UsageSearchResult) searchResult;
- Set<Object> objects = ((ReqIFSearchQuery) (this.searchResult)
- .getQuery()).getUsageSearchResult().getSearchEntries();
+
+ Set<Object> objects = new HashSet<Object>();
+ Map<Resource, Collection<EObject>> resultMap = this.searchResult
+ .getSearchEntries();
+ for (Entry<Resource, Collection<EObject>> entry : resultMap
+ .entrySet()) {
+ if (false == entry.getValue().isEmpty()) {
+ objects.addAll(entry.getValue());
+ }
+ }
+
objectsFound.clear();
objectsFound.addAll(objects);
+ Set<Resource> inputSet = new HashSet<Resource>();
for (Object object : objects) {
Object temp = contentProvider.getParent(object);
while (temp != null) {
+ if (temp instanceof Resource) {
+ inputSet.add((Resource) temp);
+ }
objectsFound.add(temp);
temp = contentProvider.getParent(temp);
}
- }
- editingDomain = ((ReqIFSearchQuery) (this.searchResult).getQuery())
- .getEditingDomain();
- Resource resource = this.searchResult.getResourceSet()
- .getResources().get(0);
- treeViewer.setInput(resource);
+ }
+ treeViewer.setInput(inputSet);
treeViewer.expandAll();
} else {
treeViewer.setInput(null);
@@ -229,6 +246,9 @@
treeViewer.getControl().setFocus();
}
+ /**
+ * {@inheritDoc}
+ */
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class key) {
@@ -238,11 +258,11 @@
return null;
}
- public ProrPropertySheetPage getPropertySheetPage() {
+ private ProrPropertySheetPage getPropertySheetPage() {
if (propertySheetPage == null) {
- propertySheetPage = new ProrPropertySheetPage(editingDomain,
- adapterFactory);
+ propertySheetPage = new ProrPropertySheetPage(null, adapterFactory);
}
+
return propertySheetPage;
}
diff --git a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/UsageSearchResult.java b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/UsageSearchResult.java
index b541923..042ee15 100644
--- a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/UsageSearchResult.java
+++ b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/UsageSearchResult.java
@@ -13,10 +13,13 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
-import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.search.ui.ISearchQuery;
import org.eclipse.search.ui.ISearchResult;
@@ -30,13 +33,13 @@
private final ReqIFSearchQuery query;
- private final Set<Object> searchEntries;
+ private final Map<Resource, Collection<EObject>> searchEntries;
private final Collection<ISearchResultListener> searchResultListeners = new ArrayList<ISearchResultListener>();
public UsageSearchResult(final ReqIFSearchQuery query) {
this.query = query;
- this.searchEntries = new HashSet<Object>();
+ this.searchEntries = new HashMap<Resource, Collection<EObject>>();
}
/**
@@ -63,12 +66,30 @@
*/
@Override
public String getLabel() {
- String resourceName = getResourceSet().getResources().get(0).getURI()
- .lastSegment();
- StringBuilder stringBuilder = new StringBuilder("Search in file '")
- .append(resourceName).append("' - result : ")
- .append(searchEntries.size()).append(" occurences");
- return stringBuilder.toString();
+ StringBuilder builder = new StringBuilder("Search in files '");
+ int resultFoundSize = 0;
+ for (Entry<Resource, Collection<EObject>> entry : searchEntries
+ .entrySet()) {
+ if (false == entry.getValue().isEmpty()) {
+ resultFoundSize++;
+ }
+ }
+ // to limit the label, we take only max three resources
+ int max = resultFoundSize > 0 ? Math.min(3, resultFoundSize) : 3;
+ int count = 0;
+ Collection<Resource> resources = searchEntries.keySet();
+ for (Iterator<Resource> iterator = resources.iterator(); iterator
+ .hasNext() && count < max;) {
+ Resource resource = iterator.next();
+ builder.append(resource.getURI().lastSegment()).append(" - ");
+ count++;
+ }
+ if (count < resultFoundSize) {
+ builder.append("... - ");
+ }
+ builder.append("' result : ").append(resultFoundSize)
+ .append(" occurences");
+ return builder.toString();
}
/**
@@ -106,15 +127,7 @@
*
* @return The collection of search entries
*/
- public Set<Object> getSearchEntries() {
+ public Map<Resource, Collection<EObject>> getSearchEntries() {
return searchEntries;
}
-
- public void addSearchEntry(String string) {
- searchEntries.add(string);
- }
-
- public ResourceSet getResourceSet() {
- return query.getResourceSet();
- }
}
diff --git a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/dialogs/ReqIFSearchDialog.java b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/dialogs/ReqIFSearchDialog.java
deleted file mode 100644
index 41e6313..0000000
--- a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/dialogs/ReqIFSearchDialog.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Hussein Mhanna
- *
- * 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:
- * Hussein Mhanna - initial API and implementation
- ******************************************************************************/
-package org.eclipse.rmf.reqif10.search.ui.dialogs;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.rmf.reqif10.search.edit.util.ReqIFEditSearcher;
-import org.eclipse.rmf.reqif10.search.ui.ReqIFSearchQuery;
-import org.eclipse.rmf.reqif10.search.ui.ReqIFSearchUIPlugin;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.ManagedForm;
-
-public class ReqIFSearchDialog extends Dialog {
- private CriteriasMasterDetailsBlock masterDetailsBlock;
-
- private static final int REPLACE_ID = 2;
-
- /**
- * Create the dialog.
- *
- * @param parentShell
- */
- public ReqIFSearchDialog(Shell parentShell) {
- super(parentShell);
- }
-
- /**
- * Create contents of the dialog.
- *
- * @param parent
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite container = (Composite) super.createDialogArea(parent);
- container.setLayout(new FillLayout());
- IManagedForm managedForm = new ManagedForm(container);
- masterDetailsBlock = new CriteriasMasterDetailsBlock();
- masterDetailsBlock.createContent(managedForm);
- return container;
- }
-
- /**
- * Create contents of the button bar.
- *
- * @param parent
- */
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, "Search", true);
- createButton(parent, REPLACE_ID, "Replace", false);
- createButton(parent, IDialogConstants.CANCEL_ID,
- IDialogConstants.CANCEL_LABEL, false);
- }
-
- @Override
- protected void buttonPressed(int buttonId) {
- if (buttonId == REPLACE_ID) {
- replacePressed();
- } else {
- super.buttonPressed(buttonId);
- }
- }
-
- private void replacePressed() {
- setReturnCode(OK);
- close();
- EditingDomain editingDomain = getActiveEditorEditingDomain();
- ReqIFEditSearcher.findAndReplcae(editingDomain,
- editingDomain.getResourceSet(),
- masterDetailsBlock.getCriterias());
- }
-
- @SuppressWarnings("restriction")
- @Override
- protected void okPressed() {
- super.okPressed();
- ISearchQuery query = newQuery();
-
- // Note : In the javadoc its explaned that we need to only call
- // NewSearchUI.runQueryInForeground but due to a bug this doesn't work
- // so I had to do the code below.
- org.eclipse.search2.internal.ui.SearchView searchView = null;
- try {
- searchView = (org.eclipse.search2.internal.ui.SearchView) PlatformUI
- .getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .showView(NewSearchUI.SEARCH_VIEW_ID);
- } catch (final PartInitException e) {
- ReqIFSearchUIPlugin.INSTANCE.log(e);
- }
- IStatus status = NewSearchUI.runQueryInForeground(new ProgressMonitorDialog(
- getParentShell()), query);
- if (! status.isOK()) {
- MessageDialog.openError(getShell(), "Exception: " + status.getException(), "Problem while searching: " + status.getMessage());
- if (status.getException() != null) {
- status.getException().printStackTrace();
- }
- }
- if (searchView != null) {
- searchView.showSearchResult(query.getSearchResult());
- }
- }
-
- private EditingDomain getActiveEditorEditingDomain() {
- IEditorPart activeEditor = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- if (activeEditor instanceof IEditingDomainProvider) {
- return ((IEditingDomainProvider) activeEditor).getEditingDomain();
- }
- return null;
- }
-
- private ISearchQuery newQuery() {
- EditingDomain editingDomain = getActiveEditorEditingDomain();
- return new ReqIFSearchQuery(editingDomain,
- masterDetailsBlock.getCriterias());
- }
-
- @Override
- protected boolean isResizable() {
- return true;
- }
-
- /**
- * Return the initial size of the dialog.
- */
- @Override
- protected Point getInitialSize() {
- return new Point(600, 400);
- }
-}
diff --git a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/handlers/SearchHandler.java b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/handlers/SearchHandler.java
deleted file mode 100644
index a87ecdc..0000000
--- a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/handlers/SearchHandler.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Hussein Mhanna
- *
- * 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:
- * Hussein Mhanna - initial API and implementation
- ******************************************************************************/
-package org.eclipse.rmf.reqif10.search.ui.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.rmf.reqif10.search.ui.dialogs.ReqIFSearchDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-public class SearchHandler extends AbstractHandler {
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ReqIFSearchDialog reqIFSearchDialog = new ReqIFSearchDialog(
- HandlerUtil.getActiveShell(event));
- reqIFSearchDialog.open();
- return null;
- }
-
-}
diff --git a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/dialogs/CriteriaDetailsPage.java b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/masterdetails/CriteriaDetailsPage.java
similarity index 99%
rename from org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/dialogs/CriteriaDetailsPage.java
rename to org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/masterdetails/CriteriaDetailsPage.java
index dee315f..18b90ae 100644
--- a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/dialogs/CriteriaDetailsPage.java
+++ b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/masterdetails/CriteriaDetailsPage.java
@@ -9,7 +9,7 @@
* Contributors:
* Hussein Mhanna - initial API and implementation
******************************************************************************/
-package org.eclipse.rmf.reqif10.search.ui.dialogs;
+package org.eclipse.rmf.reqif10.search.ui.masterdetails;
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
diff --git a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/dialogs/CriteriasMasterDetailsBlock.java b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/masterdetails/CriteriasMasterDetailsBlock.java
similarity index 99%
rename from org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/dialogs/CriteriasMasterDetailsBlock.java
rename to org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/masterdetails/CriteriasMasterDetailsBlock.java
index 218f487..288f4eb 100644
--- a/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/dialogs/CriteriasMasterDetailsBlock.java
+++ b/org.eclipse.rmf.reqif10.search.ui/src/org/eclipse/rmf/reqif10/search/ui/masterdetails/CriteriasMasterDetailsBlock.java
@@ -9,7 +9,7 @@
* Contributors:
* Hussein Mhanna - initial API and implementation
******************************************************************************/
-package org.eclipse.rmf.reqif10.search.ui.dialogs;
+package org.eclipse.rmf.reqif10.search.ui.masterdetails;
import java.io.IOException;
import java.util.ArrayList;
diff --git a/org.eclipse.rmf.reqif10.search/build.properties b/org.eclipse.rmf.reqif10.search/build.properties
index 4d3b182..7f5211a 100644
--- a/org.eclipse.rmf.reqif10.search/build.properties
+++ b/org.eclipse.rmf.reqif10.search/build.properties
@@ -4,7 +4,10 @@
model/,\
META-INF/,\
plugin.xml,\
- plugin.properties
+ plugin.properties,\
+ about.html,\
+ epl-v10.html,\
+ notice.html
jars.compile.order = .
source.. = src/
output.. = bin/
diff --git a/org.eclipse.rmf.reqif10.search/src/org/eclipse/rmf/reqif10/search/util/ReqIFSearcher.java b/org.eclipse.rmf.reqif10.search/src/org/eclipse/rmf/reqif10/search/util/ReqIFSearcher.java
index 6c1f812..6131f28 100644
--- a/org.eclipse.rmf.reqif10.search/src/org/eclipse/rmf/reqif10/search/util/ReqIFSearcher.java
+++ b/org.eclipse.rmf.reqif10.search/src/org/eclipse/rmf/reqif10/search/util/ReqIFSearcher.java
@@ -12,16 +12,18 @@
package org.eclipse.rmf.reqif10.search.util;
import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
-import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.rmf.reqif10.AttributeDefinition;
import org.eclipse.rmf.reqif10.AttributeValue;
@@ -43,27 +45,40 @@
public ReqIFSearcher() {
}
- public Collection<EObject> search(ResourceSet resourceSet,
- Collection<Criteria> criterias, boolean replace) {
+ public Map<Resource, Collection<EObject>> search(IProgressMonitor monitor,
+ Collection<Resource> resources, Collection<Criteria> criterias,
+ boolean replace) {
+ Map<Resource, Collection<EObject>> result = new HashMap<Resource, Collection<EObject>>();
+ for (Resource resource : resources) {
+ Collection<EObject> searchresult = search(monitor, resource,
+ criterias, replace);
+ result.put(resource, searchresult);
+ if (monitor.isCanceled()) {
+ break;
+ }
+ }
+ monitor.done();
+ return result;
+ }
+
+ protected Collection<EObject> search(IProgressMonitor monitor,
+ Resource resource, Collection<Criteria> criterias, boolean replace) {
Set<EObject> result = new HashSet<EObject>();
// we create a set of specifications to add to add the SpecHierarchy
// having reference to found SpecObject
Set<Specification> specifications = new HashSet<Specification>();
- for (TreeIterator<Notifier> contents = resourceSet.getAllContents(); contents
+ for (TreeIterator<EObject> contents = resource.getAllContents(); contents
.hasNext();) {
- Object object = contents.next();
- if (object instanceof EObject) {
- EObject eObject = (EObject) object;
- Entry entry = isCompatibleWithCriteria(eObject, criterias);
- if (entry != null) {
- result.add(eObject);
- if (replace) {
- setValue(entry);
- }
+ EObject eObject = contents.next();
+ Entry entry = isCompatibleWithCriteria(eObject, criterias);
+ if (entry != null) {
+ result.add(eObject);
+ if (replace) {
+ setValue(entry);
}
}
- if (object instanceof Specification) {
- specifications.add((Specification) object);
+ if (eObject instanceof Specification) {
+ specifications.add((Specification) eObject);
}
}
// For each Specification in the resource set, we add to the result the