Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 184328 Details for
Bug 331633
Cell editor for n-ary attributes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch that implements the cell editor for n-ary attributes
Bug 331633.patch (text/plain), 88.76 KB, created by
Nicolas Bros
on 2010-12-02 04:20:25 EST
(
hide
)
Description:
patch that implements the cell editor for n-ary attributes
Filename:
MIME Type:
Creator:
Nicolas Bros
Created:
2010-12-02 04:20:25 EST
Size:
88.76 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.facet.widgets.nattable >Index: src/org/eclipse/emf/facet/widgets/nattable/RowHeaderLayerStack.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/nattable/RowHeaderLayerStack.java (revision 9295) >+++ src/org/eclipse/emf/facet/widgets/nattable/RowHeaderLayerStack.java (working copy) >@@ -22,7 +22,8 @@ > private static final int DEFAULT_ROW_HEIGHT = 20; > > public RowHeaderLayerStack(final IDataProvider dataProvider, final BodyLayerStack bodyLayer) { >- DataLayer dataLayer = new DataLayer(dataProvider, RowHeaderLayerStack.DEFAULT_COLUMN_WIDTH, RowHeaderLayerStack.DEFAULT_ROW_HEIGHT); >+ DataLayer dataLayer = new DataLayer(dataProvider, RowHeaderLayerStack.DEFAULT_COLUMN_WIDTH, >+ RowHeaderLayerStack.DEFAULT_ROW_HEIGHT); > RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(dataLayer, bodyLayer, > bodyLayer.getSelectionLayer()); > setUnderlyingLayer(rowHeaderLayer); >Index: src/org/eclipse/emf/facet/widgets/nattable/StyledColumnHeaderConfiguration.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/nattable/StyledColumnHeaderConfiguration.java (revision 9295) >+++ src/org/eclipse/emf/facet/widgets/nattable/StyledColumnHeaderConfiguration.java (working copy) >@@ -79,7 +79,8 @@ > > private void addSelectedModeStyling(final IConfigRegistry configRegistry) { > ICellPainter selectedCellPainter = new BackgroundImagePainter(createCellPainter(), >- StyledColumnHeaderConfiguration.SELECTED_BG_IMAGE, StyledColumnHeaderConfiguration.COLOR_GRAY); >+ StyledColumnHeaderConfiguration.SELECTED_BG_IMAGE, >+ StyledColumnHeaderConfiguration.COLOR_GRAY); > > // If sorting is enabled we still want the sort icon to be drawn. > SortableHeaderTextPainter selectedHeaderPainter = new SortableHeaderTextPainter( >@@ -100,7 +101,8 @@ > private void addNormalModeStyling(final IConfigRegistry configurationRegistry) { > > ICellPainter normalCellPainter = new BackgroundImagePainter(createCellPainter(), >- StyledColumnHeaderConfiguration.BG_IMAGE, StyledColumnHeaderConfiguration.COLOR_GRAY); >+ StyledColumnHeaderConfiguration.BG_IMAGE, >+ StyledColumnHeaderConfiguration.COLOR_GRAY); > > SortableHeaderTextPainter headerPainter = new SortableHeaderTextPainter(normalCellPainter, > false); >@@ -116,7 +118,8 @@ > private void addCornerStyling(final IConfigRegistry configurationRegistry) { > // adds painting of the the gray triangle in the upper left corner > ICellPainter cornerPainter = new BackgroundImagePainter(createCellPainter(), >- StyledColumnHeaderConfiguration.BG_IMAGE, StyledColumnHeaderConfiguration.COLOR_GRAY) { >+ StyledColumnHeaderConfiguration.BG_IMAGE, >+ StyledColumnHeaderConfiguration.COLOR_GRAY) { > @Override > public void paintCell(final LayerCell cell, final GC gc, final Rectangle rectangle, > final IConfigRegistry configRegistry) { >Index: src/org/eclipse/emf/facet/widgets/nattable/NatTableWidget.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/nattable/NatTableWidget.java (revision 9303) >+++ src/org/eclipse/emf/facet/widgets/nattable/NatTableWidget.java (working copy) >@@ -56,20 +56,16 @@ > import net.sourceforge.nattable.util.GUIHelper; > import net.sourceforge.nattable.viewport.ViewportLayer; > >-import org.eclipse.core.runtime.Platform; > import org.eclipse.emf.common.notify.Adapter; > import org.eclipse.emf.common.notify.Notification; > import org.eclipse.emf.common.notify.impl.AdapterImpl; > import org.eclipse.emf.common.util.EList; > import org.eclipse.emf.ecore.EAttribute; > import org.eclipse.emf.ecore.EClass; >-import org.eclipse.emf.ecore.EClassifier; >-import org.eclipse.emf.ecore.EDataType; > import org.eclipse.emf.ecore.EEnum; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EReference; > import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.emf.ecore.EcorePackage; > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.emf.ecore.util.EcoreUtil; > import org.eclipse.emf.edit.ui.dnd.LocalTransfer; >@@ -80,9 +76,9 @@ > import org.eclipse.emf.facet.widgets.celleditors.IModelCellEditor; > import org.eclipse.emf.facet.widgets.celleditors.IModelCellEditorValidator; > import org.eclipse.emf.facet.widgets.celleditors.INaryFeatureCellEditor; >+import org.eclipse.emf.facet.widgets.celleditors.ModelCellEditor; > import org.eclipse.emf.facet.widgets.celleditors.core.EEnumCellEditor; > import org.eclipse.emf.facet.widgets.celleditors.modelCellEditor.AbstractModelCellEditor; >-import org.eclipse.emf.facet.widgets.celleditors.modelCellEditor.NaryFeatureCellEditor; > import org.eclipse.emf.facet.widgets.nattable.ColumnDescription.Type; > import org.eclipse.emf.facet.widgets.nattable.TableInput.ElementsDescription; > import org.eclipse.jface.action.MenuManager; >@@ -493,8 +489,6 @@ > // not editable if no editing domain was provided > public void configureRegistry(final IConfigRegistry configRegistry) { > if (NatTableWidget.this.fTableInput.getEditingDomain() != null) { >- List<ModelCellEditorContainer<? extends AbstractModelCellEditor>> allCellEditorContainers = CellEditorsRegistry >- .getInstance().getAllCellEditors(); > for (int nColumn = 0; nColumn < NatTableWidget.this.fColumnDescriptions.size(); nColumn++) { > ColumnDescription columnDescription = NatTableWidget.this.fColumnDescriptions > .get(nColumn); >@@ -502,14 +496,16 @@ > if (columnDescription.getType() == Type.ATTRIBUTE > && columnDescription.getAttribute().getEType() instanceof EEnum) { > registerEnumCellEditor(configRegistry, (EEnum) columnDescription >- .getFeature().getEType(), columnLabelAccumulator, >- allCellEditorContainers, nColumn, columnDescription); >+ .getFeature().getEType(), columnLabelAccumulator, nColumn, >+ columnDescription); > } else { >- registerCellEditorForColumn(columnLabelAccumulator, >- allCellEditorContainers, nColumn, columnDescription); >+ registerCellEditorForColumn(columnLabelAccumulator, nColumn, >+ columnDescription); > } > } > >+ List<ModelCellEditorContainer<? extends AbstractModelCellEditor>> allCellEditorContainers = CellEditorsRegistry >+ .getInstance().getAllCellEditors(); > for (ModelCellEditorContainer<? extends AbstractModelCellEditor> modelCellEditorContainer : allCellEditorContainers) { > registerCellEditor(modelCellEditorContainer, configRegistry); > } >@@ -519,79 +515,17 @@ > } > > private void registerCellEditorForColumn( >- final ColumnOverrideLabelAccumulator columnLabelAccumulator, >- final List<ModelCellEditorContainer<? extends AbstractModelCellEditor>> allCellEditorContainers, >- final int nColumn, final ColumnDescription columnDescription) { >+ final ColumnOverrideLabelAccumulator columnLabelAccumulator, final int nColumn, >+ final ColumnDescription columnDescription) { > if (columnDescription.getType() == ColumnDescription.Type.ATTRIBUTE > || columnDescription.getType() == ColumnDescription.Type.REFERENCE) { > EStructuralFeature feature = columnDescription.getFeature(); >+ > if (!feature.isChangeable()) { > return; > } >- >- EClassifier eType = feature.getEType(); >- >- class CellEditor { >- private final String bundleName; >- private final String cellID; >- >- public CellEditor(final String bundleName, final String cellID) { >- this.bundleName = bundleName; >- this.cellID = cellID; >- } >- >- public String getBundleName() { >- return this.bundleName; >- } >- >- public String getCellID() { >- return this.cellID; >- } >- } >- List<CellEditor> cellEditors = new ArrayList<CellEditor>(); >- >- for (ModelCellEditorContainer<? extends AbstractModelCellEditor> modelCellEditorContainer : allCellEditorContainers) { >- AbstractModelCellEditor modelCellEditor = modelCellEditorContainer >- .getModelCellEditor(); >- >- if (feature.isMany() != (modelCellEditor instanceof NaryFeatureCellEditor)) { >- continue; >- } >- >- if (isSuperType(modelCellEditor.getCellType(), eType)) { >- cellEditors.add(new CellEditor(modelCellEditorContainer.getBundleName(), >- modelCellEditor.getCellId())); >- } >- } >- >- CellEditor selectedCellEditor = null; >- if (cellEditors.size() == 1) { >- selectedCellEditor = cellEditors.get(0); >- } else if (cellEditors.size() > 1) { >- boolean skippedDefault = false; >- for (CellEditor cellEditor : cellEditors) { >- // lower priority for >- // org.eclipse.emf.facet.widgets.celleditors.* >- if (cellEditor.getBundleName().startsWith( >- "org.eclipse.emf.facet.widgets.celleditors")) { //$NON-NLS-1$ >- if (skippedDefault) { >- Logger.logError( >- "Several default cell editors are defined in EMF Facet for type: " //$NON-NLS-1$ >- + eType.getName(), Activator.getDefault()); >- selectedCellEditor = cellEditor; >- break; >- } >- skippedDefault = true; >- continue; >- } >- if (selectedCellEditor != null) { >- Logger.logWarning("Several cell editors are defined for type: " //$NON-NLS-1$ >- + eType.getName(), Activator.getDefault()); >- break; >- } >- selectedCellEditor = cellEditor; >- } >- } >+ ModelCellEditor selectedCellEditor = CellEditorsRegistry.getInstance() >+ .getCellEditorFor(feature.getEType(), feature.isMany()); > > if (selectedCellEditor != null) { > // register cell editor for this column >@@ -599,36 +533,12 @@ > selectedCellEditor.getCellID()); > } else { > Logger.logWarning( >- "No cell editor defined for type: " + EcoreUtil.getURI(eType) + " (column " + nColumn + ")", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ "No cell editor defined for type: " + EcoreUtil.getURI(feature.getEType()) + " (column " + nColumn + ")", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > Activator.getDefault()); > } > } > } > >- private boolean isSuperType(final EClassifier superType, final EClassifier subType) { >- if (superType == subType) { >- return true; >- } >- >- if (superType instanceof EClass && subType instanceof EClass) { >- // special case because isSuperTypeOf doesn't handle it >- if (superType == EcorePackage.eINSTANCE.getEObject()) { >- return true; >- } >- >- EClass superTypeEClass = (EClass) superType; >- EClass subTypeEClass = (EClass) subType; >- return superTypeEClass.isSuperTypeOf(subTypeEClass); >- } >- >- if (superType == EcorePackage.eINSTANCE.getEDataType() && subType instanceof EDataType) { >- // cf Bug 331539 - cell editor registered for type "EDataType" >- return true; >- } >- >- return false; >- } >- > /** > * Registers a cell editor in the config registry > * >@@ -639,12 +549,9 @@ > * @param nColumn > * @param columnDescription > */ >- private void registerEnumCellEditor( >- final IConfigRegistry configRegistry, >- final EEnum eType, >- final ColumnOverrideLabelAccumulator columnLabelAccumulator, >- final List<ModelCellEditorContainer<? extends AbstractModelCellEditor>> allCellEditorContainers, >- final int nColumn, final ColumnDescription columnDescription) { >+ private void registerEnumCellEditor(final IConfigRegistry configRegistry, final EEnum eType, >+ final ColumnOverrideLabelAccumulator columnLabelAccumulator, final int nColumn, >+ final ColumnDescription columnDescription) { > columnLabelAccumulator.registerColumnOverrides(nColumn, > NatTableWidget.ENUM_CELLEDITOR_LABEL); > configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, >@@ -659,51 +566,34 @@ > private void registerCellEditor( > final ModelCellEditorContainer<? extends AbstractModelCellEditor> modelCellEditorContainer, > final IConfigRegistry configRegistry) { >- AbstractModelCellEditor modelCellEditor = modelCellEditorContainer.getModelCellEditor(); >- String className = modelCellEditor.getModelCellEditorImpl(); >- >- Class<?> classInstance = null; >- try { >- classInstance = Platform.getBundle(modelCellEditorContainer.getBundleName()).loadClass( >- className); >- } catch (Exception e) { >- Logger.logError("Could not find class: " + className, //$NON-NLS-1$ >- Activator.getDefault()); >- return; >- } > >- Object instance = null; >- try { >- instance = classInstance.newInstance(); >- } catch (Exception e) { >- Logger.logError("Could not instantiate class: " + className, //$NON-NLS-1$ >- Activator.getDefault()); >- return; >- } >+ ModelCellEditor cellEditor = new ModelCellEditor(modelCellEditorContainer.getBundleName(), >+ modelCellEditorContainer.getModelCellEditor()); >+ Object cellEditorImplementation = cellEditor.getCellEditorImplementation(); > >- if (instance instanceof IModelCellEditor) { >- IModelCellEditor modelCellEditorImpl = (IModelCellEditor) instance; >+ if (cellEditorImplementation instanceof IModelCellEditor) { >+ IModelCellEditor modelCellEditorImpl = (IModelCellEditor) cellEditorImplementation; > > configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, > new NatTableCellEditorAdapter(modelCellEditorImpl, > NatTableWidget.this.fColumnDescriptions), DisplayMode.NORMAL, >- modelCellEditor.getCellId()); >+ cellEditor.getCellID()); > configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, >- IEditableRule.ALWAYS_EDITABLE, DisplayMode.EDIT, modelCellEditor.getCellId()); >- } else if (instance instanceof INaryFeatureCellEditor) { >- INaryFeatureCellEditor modelCellEditorImpl = (INaryFeatureCellEditor) instance; >+ IEditableRule.ALWAYS_EDITABLE, DisplayMode.EDIT, cellEditor.getCellID()); >+ } else if (cellEditorImplementation instanceof INaryFeatureCellEditor) { >+ INaryFeatureCellEditor modelCellEditorImpl = (INaryFeatureCellEditor) cellEditorImplementation; > > configRegistry.registerConfigAttribute( > EditConfigAttributes.CELL_EDITOR, > new NatTableNaryReferenceCellEditorAdapter(modelCellEditorImpl, > NatTableWidget.this.fColumnDescriptions, this.fTableInput >- .getEditingDomain()), DisplayMode.NORMAL, modelCellEditor >- .getCellId()); >+ .getEditingDomain()), DisplayMode.NORMAL, cellEditor >+ .getCellID()); > configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, >- IEditableRule.ALWAYS_EDITABLE, DisplayMode.EDIT, modelCellEditor.getCellId()); >+ IEditableRule.ALWAYS_EDITABLE, DisplayMode.EDIT, cellEditor.getCellID()); > // disable automatic commit for INaryReferenceCellEditor > configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, >- IDataValidator.NEVER_VALID, DisplayMode.EDIT, modelCellEditor.getCellId()); >+ IDataValidator.NEVER_VALID, DisplayMode.EDIT, cellEditor.getCellID()); > } else { > Logger.logError("Model cell editor implementation must be an instance of " //$NON-NLS-1$ > + IModelCellEditor.class.getSimpleName() + " or " //$NON-NLS-1$ >@@ -711,11 +601,11 @@ > return; > } > >- if (instance instanceof IModelCellEditorValidator) { >- IModelCellEditorValidator modelCellEditorValidator = (IModelCellEditorValidator) instance; >+ if (cellEditorImplementation instanceof IModelCellEditorValidator) { >+ IModelCellEditorValidator modelCellEditorValidator = (IModelCellEditorValidator) cellEditorImplementation; > configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, > new DataValidatorAdapter(modelCellEditorValidator), DisplayMode.EDIT, >- modelCellEditor.getCellId()); >+ cellEditor.getCellID()); > } > } > >#P org.eclipse.emf.facet.widgets.celleditors >Index: src/org/eclipse/emf/facet/widgets/celleditors/CellEditorsRegistry.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/CellEditorsRegistry.java (revision 125) >+++ src/org/eclipse/emf/facet/widgets/celleditors/CellEditorsRegistry.java (working copy) >@@ -17,10 +17,15 @@ > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.emf.common.util.EList; > import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.EClass; >+import org.eclipse.emf.ecore.EClassifier; >+import org.eclipse.emf.ecore.EDataType; > import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EcorePackage; > 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.ecore.util.EcoreUtil; > import org.eclipse.emf.facet.infra.common.core.internal.extensions.AbstractRegistry; > import org.eclipse.emf.facet.infra.common.core.logging.Logger; > import org.eclipse.emf.facet.widgets.celleditors.modelCellEditor.AbstractModelCellEditor; >@@ -85,6 +90,81 @@ > return allCellEditors; > } > >+ public ModelCellEditor getCellEditorFor(final EClassifier type, final boolean many) { >+ >+ List<CellEditorsRegistry.ModelCellEditorContainer<? extends AbstractModelCellEditor>> allCellEditorContainers = getAllCellEditors(); >+ >+ List<ModelCellEditor> cellEditors = new ArrayList<ModelCellEditor>(); >+ >+ for (ModelCellEditorContainer<? extends AbstractModelCellEditor> modelCellEditorContainer : allCellEditorContainers) { >+ AbstractModelCellEditor modelCellEditor = modelCellEditorContainer.getModelCellEditor(); >+ >+ if (many != (modelCellEditor instanceof NaryFeatureCellEditor)) { >+ continue; >+ } >+ >+ if (isSuperType(modelCellEditor.getCellType(), type)) { >+ cellEditors.add(new ModelCellEditor(modelCellEditorContainer.getBundleName(), >+ modelCellEditorContainer.getModelCellEditor())); >+ } >+ } >+ >+ ModelCellEditor selectedCellEditor = null; >+ if (cellEditors.size() == 1) { >+ selectedCellEditor = cellEditors.get(0); >+ } else if (cellEditors.size() > 1) { >+ boolean skippedDefault = false; >+ for (ModelCellEditor cellEditor : cellEditors) { >+ // lower priority for >+ // org.eclipse.emf.facet.widgets.celleditors.* >+ if (cellEditor.getBundleName().startsWith( >+ "org.eclipse.emf.facet.widgets.celleditors")) { //$NON-NLS-1$ >+ if (skippedDefault) { >+ Logger.logError( >+ "Several default cell editors are defined in EMF Facet for type: " //$NON-NLS-1$ >+ + EcoreUtil.getURI(type), Activator.getDefault()); >+ selectedCellEditor = cellEditor; >+ break; >+ } >+ skippedDefault = true; >+ continue; >+ } >+ if (selectedCellEditor != null) { >+ Logger.logWarning("Several cell editors are defined for type: " //$NON-NLS-1$ >+ + EcoreUtil.getURI(type), Activator.getDefault()); >+ break; >+ } >+ selectedCellEditor = cellEditor; >+ } >+ } >+ >+ return selectedCellEditor; >+ } >+ >+ private boolean isSuperType(final EClassifier superType, final EClassifier subType) { >+ if (superType == subType) { >+ return true; >+ } >+ >+ if (superType instanceof EClass && subType instanceof EClass) { >+ // special case because isSuperTypeOf doesn't handle it >+ if (superType == EcorePackage.eINSTANCE.getEObject()) { >+ return true; >+ } >+ >+ EClass superTypeEClass = (EClass) superType; >+ EClass subTypeEClass = (EClass) subType; >+ return superTypeEClass.isSuperTypeOf(subTypeEClass); >+ } >+ >+ if (superType == EcorePackage.eINSTANCE.getEDataType() && subType instanceof EDataType) { >+ // cf Bug 331539 - cell editor registered for type "EDataType" >+ return true; >+ } >+ >+ return false; >+ } >+ > public List<CellEditorsRegistry.ModelCellEditorContainer<BasicCellEditor>> getBasicCellEditors() { > return this.basicCellEditors; > } >Index: src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/impl/NaryFeatureCellEditorImpl.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/impl/NaryFeatureCellEditorImpl.java (revision 125) >+++ src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/impl/NaryFeatureCellEditorImpl.java (working copy) >@@ -152,7 +152,8 @@ > switch (featureID) { > case ModelCellEditorPackage.NARY_FEATURE_CELL_EDITOR__NARY_FEATURE_CELL_EDITOR_IMPL: > return NaryFeatureCellEditorImpl.NARY_FEATURE_CELL_EDITOR_IMPL_EDEFAULT == null ? this.naryFeatureCellEditorImpl != null >- : !NaryFeatureCellEditorImpl.NARY_FEATURE_CELL_EDITOR_IMPL_EDEFAULT.equals(this.naryFeatureCellEditorImpl); >+ : !NaryFeatureCellEditorImpl.NARY_FEATURE_CELL_EDITOR_IMPL_EDEFAULT >+ .equals(this.naryFeatureCellEditorImpl); > } > return super.eIsSet(featureID); > } >Index: src/org/eclipse/emf/facet/widgets/celleditors/DefaultCommandFactory.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/DefaultCommandFactory.java (revision 137) >+++ src/org/eclipse/emf/facet/widgets/celleditors/DefaultCommandFactory.java (working copy) >@@ -34,6 +34,11 @@ > return SetCommand.create(domain, owner, feature, value); > } > >+ public Command createSetCommand(final EditingDomain domain, final Object owner, >+ final Object feature, final Object value, final int index) { >+ return SetCommand.create(domain, owner, feature, value, index); >+ } >+ > public Command createMoveCommand(final EditingDomain domain, final Object owner, > final Object feature, final Object value, final int index) { > return MoveCommand.create(domain, owner, feature, value, index); >Index: src/org/eclipse/emf/facet/widgets/celleditors/ModelCellEditor.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/ModelCellEditor.java (revision 0) >+++ src/org/eclipse/emf/facet/widgets/celleditors/ModelCellEditor.java (revision 0) >@@ -0,0 +1,80 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 CEA LIST. >+ * >+ * 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: >+ * Nicolas Bros (Mia-Software) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.emf.facet.widgets.celleditors; >+ >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.emf.facet.infra.common.core.logging.Logger; >+import org.eclipse.emf.facet.widgets.celleditors.modelCellEditor.AbstractModelCellEditor; >+ >+public class ModelCellEditor { >+ private final String bundleName; >+ private final AbstractModelCellEditor modelCellEditor; >+ >+ public ModelCellEditor(final String bundleName, final AbstractModelCellEditor modelCellEditor) { >+ this.bundleName = bundleName; >+ this.modelCellEditor = modelCellEditor; >+ } >+ >+ public String getBundleName() { >+ return this.bundleName; >+ } >+ >+ public String getCellID() { >+ return this.modelCellEditor.getCellId(); >+ } >+ >+ public AbstractModelCellEditor getModelCellEditor() { >+ return this.modelCellEditor; >+ } >+ >+ public Object getCellEditorImplementation() { >+ String className = this.modelCellEditor.getModelCellEditorImpl(); >+ >+ Class<?> classInstance = null; >+ try { >+ classInstance = Platform.getBundle(this.bundleName).loadClass(className); >+ } catch (Exception e) { >+ Logger.logError("Could not find class: " + className, //$NON-NLS-1$ >+ Activator.getDefault()); >+ return null; >+ } >+ >+ Object instance = null; >+ try { >+ instance = classInstance.newInstance(); >+ } catch (Exception e) { >+ Logger.logError("Could not instantiate class: " + className, //$NON-NLS-1$ >+ Activator.getDefault()); >+ return null; >+ } >+ return instance; >+ } >+ >+ @Override >+ public boolean equals(final Object obj) { >+ if (obj instanceof ModelCellEditor) { >+ ModelCellEditor other = (ModelCellEditor) obj; >+ return other.getCellID().equals(getCellID()); >+ } >+ return false; >+ } >+ >+ @Override >+ public int hashCode() { >+ return getCellID().hashCode(); >+ } >+ >+ @Override >+ public String toString() { >+ return getBundleName() + "#" + getCellID(); //$NON-NLS-1$ >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/emf/facet/widgets/celleditors/ui/ModelCellsEditingSupport.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/ui/ModelCellsEditingSupport.java (revision 0) >+++ src/org/eclipse/emf/facet/widgets/celleditors/ui/ModelCellsEditingSupport.java (revision 0) >@@ -0,0 +1,155 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 CEA LIST. >+ * >+ * 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: >+ * Nicolas Bros (Mia-Software) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.emf.facet.widgets.celleditors.ui; >+ >+import java.util.List; >+ >+import org.eclipse.emf.common.command.Command; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+import org.eclipse.emf.facet.widgets.celleditors.CellEditorsRegistry; >+import org.eclipse.emf.facet.widgets.celleditors.CommandFactoriesRegistry; >+import org.eclipse.emf.facet.widgets.celleditors.ICommandFactory; >+import org.eclipse.emf.facet.widgets.celleditors.IModelCellEditHandler; >+import org.eclipse.emf.facet.widgets.celleditors.IModelCellEditor; >+import org.eclipse.emf.facet.widgets.celleditors.ModelCellEditor; >+import org.eclipse.jface.viewers.CellEditor; >+import org.eclipse.jface.viewers.ColumnViewer; >+import org.eclipse.jface.viewers.EditingSupport; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+ >+public class ModelCellsEditingSupport extends EditingSupport { >+ >+ private final EStructuralFeature feature; >+ private IModelCellEditor cellEditor; >+ private final EObject eObject; >+ private final EditingDomain editingDomain; >+ private final ColumnViewer columnViewer; >+ private final Object newValuePlaceholder; >+ >+ public ModelCellsEditingSupport(final ColumnViewer columnViewer, >+ final EStructuralFeature feature, final EObject eObject, >+ final EditingDomain editingDomain, final Object newValuePlaceholder) { >+ super(columnViewer); >+ this.columnViewer = columnViewer; >+ this.feature = feature; >+ this.eObject = eObject; >+ this.editingDomain = editingDomain; >+ this.newValuePlaceholder = newValuePlaceholder; >+ ModelCellEditor modelCellEditor = CellEditorsRegistry.getInstance().getCellEditorFor( >+ this.feature.getEType(), false); >+ Object cellEditorImplementation = modelCellEditor.getCellEditorImplementation(); >+ if (cellEditorImplementation instanceof IModelCellEditor) { >+ this.cellEditor = (IModelCellEditor) cellEditorImplementation; >+ } else { >+ throw new IllegalStateException("cell editor " + modelCellEditor //$NON-NLS-1$ >+ + " doesn't implement " + IModelCellEditor.class.getSimpleName()); //$NON-NLS-1$ >+ } >+ } >+ >+ @Override >+ protected CellEditor getCellEditor(final Object element) { >+ return new CellEditor((Composite) this.columnViewer.getControl()) { >+ >+ private Control control; >+ >+ @Override >+ protected void doSetValue(final Object value) { >+ // >+ } >+ >+ @Override >+ protected void doSetFocus() { >+ this.control.setFocus(); >+ } >+ >+ @Override >+ protected Object doGetValue() { >+ return null; >+ } >+ >+ @Override >+ protected Control createControl(final Composite parent) { >+ IModelCellEditHandler editHandler = new IModelCellEditHandler() { >+ public void commit() { >+ Object value = ModelCellsEditingSupport.this.cellEditor.getValue(); >+ List<?> list = (List<?>) ModelCellsEditingSupport.this.eObject >+ .eGet(ModelCellsEditingSupport.this.feature); >+ int index = list.indexOf(element); >+ if (index != -1 >+ || element == ModelCellsEditingSupport.this.newValuePlaceholder) { >+ changeValue(element, value, index); >+ } >+ ModelCellsEditingSupport.this.columnViewer.refresh(); >+ // dispose(); >+ close(); >+ } >+ }; >+ >+ Object originalValue = null; >+ if (element != ModelCellsEditingSupport.this.newValuePlaceholder) { >+ originalValue = element; >+ } >+ >+ this.control = ModelCellsEditingSupport.this.cellEditor.activateCell(parent, >+ originalValue, editHandler, ModelCellsEditingSupport.this.feature, >+ ModelCellsEditingSupport.this.eObject); >+ return this.control; >+ } >+ >+ public void close() { >+ deactivate(); >+ Control parentControl = ModelCellsEditingSupport.this.columnViewer.getControl(); >+ if (parentControl != null && !parentControl.isDisposed()) { >+ parentControl.forceFocus(); >+ } >+ dispose(); >+ // if (this.control != null && !this.control.isDisposed()) { >+ // this.control.dispose(); >+ // } >+ } >+ }; >+ // return new TextCellEditor(); >+ } >+ >+ @Override >+ protected boolean canEdit(final Object element) { >+ return true; >+ } >+ >+ @Override >+ protected Object getValue(final Object element) { >+ return element; >+ } >+ >+ @Override >+ protected void setValue(final Object element, final Object value) { >+ // TODO Auto-generated method stub >+ } >+ >+ private void changeValue(final Object oldValue, final Object newValue, final int index) { >+ ICommandFactory commandFactory = CommandFactoriesRegistry.getInstance() >+ .getCommandFactoryFor(this.editingDomain); >+ if (oldValue == this.newValuePlaceholder) { >+ Command addCommand = commandFactory.createAddCommand(this.editingDomain, this.eObject, >+ this.feature, newValue); >+ this.editingDomain.getCommandStack().execute(addCommand); >+ } else { >+ Command setCommand = commandFactory.createSetCommand(this.editingDomain, this.eObject, >+ this.feature, newValue, index); >+ this.editingDomain.getCommandStack().execute(setCommand); >+ } >+ } >+ >+} >Index: src/org/eclipse/emf/facet/widgets/celleditors/core/NaryAttributeCellEditor.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/core/NaryAttributeCellEditor.java (revision 0) >+++ src/org/eclipse/emf/facet/widgets/celleditors/core/NaryAttributeCellEditor.java (revision 0) >@@ -0,0 +1,45 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 CEA LIST. >+ * >+ * 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: >+ * Nicolas Bros (Mia-Software) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.emf.facet.widgets.celleditors.core; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+import org.eclipse.emf.facet.widgets.celleditors.INaryFeatureCellEditor; >+import org.eclipse.emf.facet.widgets.celleditors.ui.NaryAttributeEditingDialog; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+ >+public class NaryAttributeCellEditor implements INaryFeatureCellEditor { >+ >+ public Control activateCell(final Composite parent, final EStructuralFeature feature, >+ final EObject source, final EditingDomain editingDomain) { >+ final Composite placeholderComposite = new Composite(parent, SWT.NONE); >+ NaryAttributeEditingDialog naryAttributeEditingDialog = new NaryAttributeEditingDialog( >+ parent.getShell(), feature, source, editingDomain) { >+ @Override >+ public boolean close() { >+ placeholderComposite.dispose(); >+ return super.close(); >+ } >+ }; >+ naryAttributeEditingDialog.open(); >+ >+ return placeholderComposite; >+ } >+ >+ public Object getValue() { >+ throw new UnsupportedOperationException(); >+ } >+ >+} >Index: src/org/eclipse/emf/facet/widgets/celleditors/ui/EditingUtils.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/ui/EditingUtils.java (revision 0) >+++ src/org/eclipse/emf/facet/widgets/celleditors/ui/EditingUtils.java (revision 0) >@@ -0,0 +1,84 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 CEA LIST. >+ * >+ * 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: >+ * Nicolas Bros (Mia-Software) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.emf.facet.widgets.celleditors.ui; >+ >+import java.util.Collection; >+import java.util.List; >+ >+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.edit.domain.EditingDomain; >+import org.eclipse.emf.facet.widgets.celleditors.ICommandFactory; >+ >+public final class EditingUtils { >+ private EditingUtils() { >+ // >+ } >+ >+ public static void moveElementsUp(final EObject eObject, final EStructuralFeature feature, >+ final Collection<Object> elements, final ICommandFactory commandFactory, >+ final EditingDomain editingDomain) { >+ CompoundCommand compoundCommand = new CompoundCommand(); >+ >+ List<?> list = (List<?>) eObject.eGet(feature); >+ >+ int minIndex = 0; >+ for (Object element : elements) { >+ final int index = list.indexOf(element); >+ >+ Command moveCommand = commandFactory.createMoveCommand(editingDomain, eObject, feature, >+ element, Math.max(index - 1, minIndex++)); >+ compoundCommand.append(moveCommand); >+ } >+ editingDomain.getCommandStack().execute(compoundCommand); >+ // int[] selectionIndices; >+ // Arrays.sort(selectionIndices); >+ // CompoundCommand compoundCommand = new CompoundCommand(); >+ // int minIndex = 0; >+ // for(int index : selectionIndices) { >+ // Command moveCommand = MoveCommand.create(editingDomain, >+ // eObject,feature, index, Math.max(index - 1, >+ // minIndex++)); >+ // compoundCommand.append(moveCommand); >+ // } >+ // editingDomain.getCommandStack().execute(compoundCommand); >+ } >+ >+ public static void moveElementsDown(final EObject eObject, final EStructuralFeature feature, >+ final Collection<Object> elements, final ICommandFactory commandFactory, >+ final EditingDomain editingDomain) { >+ Object value = eObject.eGet(feature); >+ List<?> list = (List<?>) value; >+ >+ CompoundCommand compoundCommand = new CompoundCommand(); >+ >+ // prevent the last two elements from swapping >+ boolean canMove = !elements.contains(list.get(list.size() - 1)); >+ for (int i = list.size() - 2; i >= 0; i--) { >+ final Object selectedObject = list.get(i); >+ if (elements.contains(selectedObject)) { >+ if (canMove) { >+ Command moveCommand = commandFactory.createMoveCommand(editingDomain, eObject, >+ feature, selectedObject, i + 1); >+ compoundCommand.append(moveCommand); >+ } >+ } else { >+ canMove = true; >+ } >+ >+ } >+ editingDomain.getCommandStack().execute(compoundCommand); >+ } >+ >+} >Index: src/org/eclipse/emf/facet/widgets/celleditors/ui/AssignableValuesContentProvider.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/ui/AssignableValuesContentProvider.java (revision 0) >+++ src/org/eclipse/emf/facet/widgets/celleditors/ui/AssignableValuesContentProvider.java (revision 0) >@@ -0,0 +1,78 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 CEA LIST. >+ * >+ * 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: >+ * Nicolas Bros (Mia-Software) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.emf.facet.widgets.celleditors.ui; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.emf.common.notify.Notifier; >+import org.eclipse.emf.common.util.TreeIterator; >+import org.eclipse.emf.ecore.EClassifier; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.Viewer; >+ >+public class AssignableValuesContentProvider implements ITreeContentProvider { >+ public Object[] getElements(final Object inputElement) { >+ if (inputElement instanceof FeatureValuesInput) { >+ FeatureValuesInput assignableValuesInput = (FeatureValuesInput) inputElement; >+ EStructuralFeature feature = assignableValuesInput.getFeature(); >+ EClassifier eType = feature.getEType(); >+ EObject source = assignableValuesInput.getSource(); >+ List<?> featureValues = (List<?>) source.eGet(feature); >+ >+ // build a list of EObjects assignable to the EReference >+ List<EObject> list = new ArrayList<EObject>(); >+ Resource eResource = source.eResource(); >+ if (eResource == null) { >+ return new Object[0]; >+ } >+ ResourceSet resourceSet = eResource.getResourceSet(); >+ TreeIterator<Notifier> allContents = resourceSet.getAllContents(); >+ while (allContents.hasNext()) { >+ Notifier notifier = allContents.next(); >+ if (notifier instanceof EObject) { >+ EObject eObject = (EObject) notifier; >+ if (eType.isInstance(eObject) >+ && (!feature.isUnique() || !featureValues.contains(eObject))) { >+ list.add(eObject); >+ } >+ } >+ } >+ return list.toArray(); >+ } >+ throw new IllegalArgumentException(FeatureValuesInput.class.getSimpleName() + " expected"); //$NON-NLS-1$ >+ } >+ >+ public void dispose() { >+ // >+ } >+ >+ public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { >+ // >+ } >+ >+ public Object[] getChildren(final Object parentElement) { >+ return null; >+ } >+ >+ public Object getParent(final Object element) { >+ return null; >+ } >+ >+ public boolean hasChildren(final Object element) { >+ return false; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/emf/facet/widgets/celleditors/ui/NaryReferenceEditingDialog.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/ui/NaryReferenceEditingDialog.java (revision 125) >+++ src/org/eclipse/emf/facet/widgets/celleditors/ui/NaryReferenceEditingDialog.java (working copy) >@@ -11,20 +11,14 @@ > *******************************************************************************/ > package org.eclipse.emf.facet.widgets.celleditors.ui; > >-import java.util.ArrayList; > import java.util.Iterator; > import java.util.List; > > import org.eclipse.emf.common.command.Command; > import org.eclipse.emf.common.command.CompoundCommand; >-import org.eclipse.emf.common.notify.Notifier; >-import org.eclipse.emf.common.util.TreeIterator; >-import org.eclipse.emf.ecore.EClassifier; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EReference; > import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.resource.ResourceSet; > import org.eclipse.emf.edit.domain.EditingDomain; > import org.eclipse.emf.facet.widgets.CustomizableLabelProvider; > import org.eclipse.emf.facet.widgets.celleditors.CommandFactoriesRegistry; >@@ -36,7 +30,6 @@ > import org.eclipse.jface.viewers.IOpenListener; > import org.eclipse.jface.viewers.IStructuredContentProvider; > import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.jface.viewers.ITreeContentProvider; > import org.eclipse.jface.viewers.ListViewer; > import org.eclipse.jface.viewers.OpenEvent; > import org.eclipse.jface.viewers.TreeViewer; >@@ -61,8 +54,8 @@ > /** A dialog to edit a multiplicity-many {@link EReference} */ > public class NaryReferenceEditingDialog extends Dialog { > >- private static final int CUSTOMIZATIONS_TREE_WIDTH = 200; >- private static final int CUSTOMIZATIONS_TREE_HEIGHT = 250; >+ private static final int AVAILABLE_VALUES_TREE_WIDTH = 200; >+ private static final int AVAILABLE_VALUES_TREE_HEIGHT = 250; > private static final int NUM_COLUMNS = 4; > // this is a *tree* viewer because PatternFilter only supports Trees > private TreeViewer fAvailableValuesTreeViewer; >@@ -79,79 +72,6 @@ > private AssignableValuesContentProvider assignableValuesContentProvider; > private final ICommandFactory commandFactory; > >- private class FeatureValuesInput { >- private final EStructuralFeature feature; >- private final EObject source; >- >- public FeatureValuesInput(final EStructuralFeature feature, final EObject source) { >- this.feature = feature; >- this.source = source; >- } >- >- public EStructuralFeature getFeature() { >- return this.feature; >- } >- >- public EObject getSource() { >- return this.source; >- } >- } >- >- private class AssignableValuesContentProvider implements ITreeContentProvider { >- public Object[] getElements(final Object inputElement) { >- if (inputElement instanceof FeatureValuesInput) { >- FeatureValuesInput assignableValuesInput = (FeatureValuesInput) inputElement; >- EStructuralFeature feature = assignableValuesInput.getFeature(); >- EClassifier eType = feature.getEType(); >- EObject source = assignableValuesInput.getSource(); >- List<?> featureValues = (List<?>) source.eGet(feature); >- >- // build a list of EObjects assignable to the EReference >- List<EObject> list = new ArrayList<EObject>(); >- Resource eResource = source.eResource(); >- if (eResource == null) { >- return new Object[0]; >- } >- ResourceSet resourceSet = eResource.getResourceSet(); >- TreeIterator<Notifier> allContents = resourceSet.getAllContents(); >- while (allContents.hasNext()) { >- Notifier notifier = allContents.next(); >- if (notifier instanceof EObject) { >- EObject eObject = (EObject) notifier; >- if (eType.isInstance(eObject) >- && (!feature.isUnique() || !featureValues.contains(eObject))) { >- list.add(eObject); >- } >- } >- } >- return list.toArray(); >- } >- throw new IllegalArgumentException( >- NaryReferenceEditingDialog.FeatureValuesInput.class.getSimpleName() >- + " expected"); //$NON-NLS-1$ >- } >- >- public void dispose() { >- // >- } >- >- public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { >- // >- } >- >- public Object[] getChildren(final Object parentElement) { >- return null; >- } >- >- public Object getParent(final Object element) { >- return null; >- } >- >- public boolean hasChildren(final Object element) { >- return false; >- } >- } >- > private class AssignedValuesContentProvider implements IStructuredContentProvider { > public Object[] getElements(final Object inputElement) { > if (inputElement instanceof FeatureValuesInput) { >@@ -161,9 +81,8 @@ > List<?> list = (List<?>) source.eGet(feature); > return list.toArray(); > } >- throw new IllegalArgumentException( >- NaryReferenceEditingDialog.FeatureValuesInput.class.getSimpleName() >- + " expected"); //$NON-NLS-1$ >+ throw new IllegalArgumentException(FeatureValuesInput.class.getSimpleName() >+ + " expected"); //$NON-NLS-1$ > } > > public void dispose() { >@@ -283,77 +202,19 @@ > > @SuppressWarnings("unchecked") > private void upButtonClicked() { >- >- // int[] selectionIndices = >- // this.fFeatureValuesListViewer.getList().getSelectionIndices(); >- // Arrays.sort(selectionIndices); >- // >- // CompoundCommand compoundCommand = new CompoundCommand(); >- // >- // int minIndex = 0; >- // for(int index : selectionIndices) { >- // Command moveCommand = MoveCommand.create(this.editingDomain, >- // this.fEObject, this.fFeature, index, Math.max(index - 1, >- // minIndex++)); >- // compoundCommand.append(moveCommand); >- // } >- // this.fFeatureValuesListViewer.refresh(); >- // this.editingDomain.getCommandStack().execute(compoundCommand); >- > final IStructuredSelection selection = (IStructuredSelection) this.fFeatureValuesListViewer > .getSelection(); >- >- CompoundCommand compoundCommand = new CompoundCommand(); >- >- List<?> list = (List<?>) this.fEObject.eGet(this.fFeature); >- >- int minIndex = 0; >- for (final Iterator<EObject> it = selection.iterator(); it.hasNext();) { >- final EObject element = it.next(); >- >- final int index = list.indexOf(element); >- >- Command moveCommand = this.commandFactory.createMoveCommand(this.editingDomain, >- this.fEObject, this.fFeature, element, Math.max(index - 1, minIndex++)); >- compoundCommand.append(moveCommand); >- } >- this.editingDomain.getCommandStack().execute(compoundCommand); >+ EditingUtils.moveElementsUp(this.fEObject, this.fFeature, selection.toList(), >+ this.commandFactory, this.editingDomain); > this.fFeatureValuesListViewer.refresh(); > } > > private void downButtonClicked() { > final IStructuredSelection selection = (IStructuredSelection) this.fFeatureValuesListViewer > .getSelection(); >- final ArrayList<EObject> selectedObjects = new ArrayList<EObject>(); >- for (final Object selectedObject : selection.toArray()) { >- selectedObjects.add((EObject) selectedObject); >- } >- >- Object value = this.fEObject.eGet(this.fFeature); >- if (value instanceof List<?>) { >- List<?> list = (List<?>) value; >- >- CompoundCommand compoundCommand = new CompoundCommand(); >- >- // prevent the last two elements from swapping >- boolean canMove = !selectedObjects.contains(list.get(list.size() - 1)); >- for (int i = list.size() - 2; i >= 0; i--) { >- final Object selectedEObject = list.get(i); >- if (selectedObjects.contains(selectedEObject)) { >- if (canMove) { >- Command moveCommand = this.commandFactory.createMoveCommand( >- this.editingDomain, this.fEObject, this.fFeature, selectedEObject, >- i + 1); >- compoundCommand.append(moveCommand); >- } >- } else { >- canMove = true; >- } >- >- } >- this.editingDomain.getCommandStack().execute(compoundCommand); >- this.fFeatureValuesListViewer.refresh(); >- } >+ EditingUtils.moveElementsDown(this.fEObject, this.fFeature, selection.toList(), >+ this.commandFactory, this.editingDomain); >+ this.fFeatureValuesListViewer.refresh(); > } > > @SuppressWarnings("unchecked") >@@ -498,8 +359,8 @@ > > final Tree availableValuesTree = new Tree(choiceComposite, SWT.MULTI | SWT.BORDER); > final GridData availableValuesGridData = new GridData(); >- availableValuesGridData.widthHint = NaryReferenceEditingDialog.CUSTOMIZATIONS_TREE_WIDTH; >- availableValuesGridData.heightHint = NaryReferenceEditingDialog.CUSTOMIZATIONS_TREE_HEIGHT; >+ availableValuesGridData.widthHint = NaryReferenceEditingDialog.AVAILABLE_VALUES_TREE_WIDTH; >+ availableValuesGridData.heightHint = NaryReferenceEditingDialog.AVAILABLE_VALUES_TREE_HEIGHT; > availableValuesGridData.horizontalAlignment = SWT.FILL; > availableValuesGridData.verticalAlignment = SWT.FILL; > availableValuesGridData.grabExcessHorizontalSpace = true; >@@ -613,18 +474,18 @@ > valuesLabelGridData.verticalAlignment = SWT.FILL; > featureLabel.setLayoutData(valuesLabelGridData); > >- final org.eclipse.swt.widgets.List loadedCustomizationsList = new org.eclipse.swt.widgets.List( >+ final org.eclipse.swt.widgets.List availableValuesList = new org.eclipse.swt.widgets.List( > featureComposite, SWT.MULTI | SWT.BORDER); >- final GridData loadedCustomizationsGridData = new GridData(); >- loadedCustomizationsGridData.widthHint = NaryReferenceEditingDialog.CUSTOMIZATIONS_TREE_WIDTH; >- loadedCustomizationsGridData.heightHint = NaryReferenceEditingDialog.CUSTOMIZATIONS_TREE_HEIGHT; >- loadedCustomizationsGridData.verticalAlignment = SWT.FILL; >- loadedCustomizationsGridData.horizontalAlignment = SWT.FILL; >- loadedCustomizationsGridData.grabExcessHorizontalSpace = true; >- loadedCustomizationsGridData.grabExcessVerticalSpace = true; >- loadedCustomizationsList.setLayoutData(loadedCustomizationsGridData); >+ final GridData availableValuesGridData = new GridData(); >+ availableValuesGridData.widthHint = NaryReferenceEditingDialog.AVAILABLE_VALUES_TREE_WIDTH; >+ availableValuesGridData.heightHint = NaryReferenceEditingDialog.AVAILABLE_VALUES_TREE_HEIGHT; >+ availableValuesGridData.verticalAlignment = SWT.FILL; >+ availableValuesGridData.horizontalAlignment = SWT.FILL; >+ availableValuesGridData.grabExcessHorizontalSpace = true; >+ availableValuesGridData.grabExcessVerticalSpace = true; >+ availableValuesList.setLayoutData(availableValuesGridData); > >- this.fFeatureValuesListViewer = new ListViewer(loadedCustomizationsList); >+ this.fFeatureValuesListViewer = new ListViewer(availableValuesList); > this.fFeatureValuesListViewer.setContentProvider(new AssignedValuesContentProvider()); > this.fFeatureValuesListViewer.setLabelProvider(new CustomizableLabelProvider()); > this.fFeatureValuesListViewer >Index: src/org/eclipse/emf/facet/widgets/celleditors/ICommandFactory.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/ICommandFactory.java (revision 137) >+++ src/org/eclipse/emf/facet/widgets/celleditors/ICommandFactory.java (working copy) >@@ -33,6 +33,13 @@ > Command createSetCommand(EditingDomain domain, final Object owner, Object feature, Object value); > > /** >+ * This creates a {@link SetCommand} to set the owner's feature to the >+ * specified value at the specified index. >+ */ >+ Command createSetCommand(EditingDomain domain, final Object owner, Object feature, >+ Object value, int index); >+ >+ /** > * This creates a {@link MoveCommand} to move a particular value to a > * particular index in the specified feature of the owner. The feature will > * often be <code>null</code> because the domain will deduce it. >Index: src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/impl/BasicCellEditorImpl.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/impl/BasicCellEditorImpl.java (revision 125) >+++ src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/impl/BasicCellEditorImpl.java (working copy) >@@ -151,7 +151,8 @@ > switch (featureID) { > case ModelCellEditorPackage.BASIC_CELL_EDITOR__BASIC_CELL_EDITOR_IMPL: > return BasicCellEditorImpl.BASIC_CELL_EDITOR_IMPL_EDEFAULT == null ? this.basicCellEditorImpl != null >- : !BasicCellEditorImpl.BASIC_CELL_EDITOR_IMPL_EDEFAULT.equals(this.basicCellEditorImpl); >+ : !BasicCellEditorImpl.BASIC_CELL_EDITOR_IMPL_EDEFAULT >+ .equals(this.basicCellEditorImpl); > } > return super.eIsSet(featureID); > } >Index: org.eclipse.emf.facet.widgets.celleditors.core.modelcelleditors >=================================================================== >--- org.eclipse.emf.facet.widgets.celleditors.core.modelcelleditors (revision 125) >+++ org.eclipse.emf.facet.widgets.celleditors.core.modelcelleditors (working copy) >@@ -6,4 +6,7 @@ > <modelCellEditors xsi:type="modelCellEditor:NaryFeatureCellEditor" cellId="naryref_cell" naryFeatureCellEditorImpl="org.eclipse.emf.facet.widgets.celleditors.core.NaryReferenceCellEditor"> > <cellType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/> > </modelCellEditors> >+ <modelCellEditors xsi:type="modelCellEditor:NaryFeatureCellEditor" cellId="naryattr_cell" naryFeatureCellEditorImpl="org.eclipse.emf.facet.widgets.celleditors.core.NaryAttributeCellEditor"> >+ <cellType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EDataType"/> >+ </modelCellEditors> > </modelCellEditor:ModelCellEditorDeclarations> >Index: src/org/eclipse/emf/facet/widgets/celleditors/Messages.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/Messages.java (revision 125) >+++ src/org/eclipse/emf/facet/widgets/celleditors/Messages.java (working copy) >@@ -15,6 +15,9 @@ > > public final class Messages extends NLS { > private static final String BUNDLE_NAME = "org.eclipse.emf.facet.widgets.celleditors.messages"; //$NON-NLS-1$ >+ public static String NaryAttributeEditingDialog_add; >+ public static String NaryAttributeEditingDialog_delete; >+ public static String NaryAttributeEditingDialog_enterNewValuePlaceholder; > public static String NaryReferenceEditingDialog_add; > public static String NaryReferenceEditingDialog_addAll; > public static String NaryReferenceEditingDialog_addAllTooltip; >Index: src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/impl/AbstractModelCellEditorImpl.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/impl/AbstractModelCellEditorImpl.java (revision 125) >+++ src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/impl/AbstractModelCellEditorImpl.java (working copy) >@@ -151,7 +151,8 @@ > this.cellId = newCellId; > if (eNotificationRequired()) { > eNotify(new ENotificationImpl(this, Notification.SET, >- ModelCellEditorPackage.ABSTRACT_MODEL_CELL_EDITOR__CELL_ID, oldCellId, this.cellId)); >+ ModelCellEditorPackage.ABSTRACT_MODEL_CELL_EDITOR__CELL_ID, oldCellId, >+ this.cellId)); > } > } > >@@ -232,7 +233,8 @@ > case ModelCellEditorPackage.ABSTRACT_MODEL_CELL_EDITOR__CELL_TYPE: > return this.cellType != null; > case ModelCellEditorPackage.ABSTRACT_MODEL_CELL_EDITOR__CELL_ID: >- return AbstractModelCellEditorImpl.CELL_ID_EDEFAULT == null ? this.cellId != null : !AbstractModelCellEditorImpl.CELL_ID_EDEFAULT.equals(this.cellId); >+ return AbstractModelCellEditorImpl.CELL_ID_EDEFAULT == null ? this.cellId != null >+ : !AbstractModelCellEditorImpl.CELL_ID_EDEFAULT.equals(this.cellId); > } > return super.eIsSet(featureID); > } >Index: src/org/eclipse/emf/facet/widgets/celleditors/ui/FeatureValuesInput.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/ui/FeatureValuesInput.java (revision 0) >+++ src/org/eclipse/emf/facet/widgets/celleditors/ui/FeatureValuesInput.java (revision 0) >@@ -0,0 +1,33 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 CEA LIST. >+ * >+ * 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: >+ * Nicolas Bros (Mia-Software) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.emf.facet.widgets.celleditors.ui; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+public class FeatureValuesInput { >+ private final EStructuralFeature feature; >+ private final EObject source; >+ >+ public FeatureValuesInput(final EStructuralFeature feature, final EObject source) { >+ this.feature = feature; >+ this.source = source; >+ } >+ >+ public EStructuralFeature getFeature() { >+ return this.feature; >+ } >+ >+ public EObject getSource() { >+ return this.source; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/emf/facet/widgets/celleditors/messages.properties >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/messages.properties (revision 125) >+++ src/org/eclipse/emf/facet/widgets/celleditors/messages.properties (working copy) >@@ -1,29 +1,37 @@ >+NaryAttributeEditingDialog_delete=D&elete >+NaryAttributeEditingDialog_enterNewValuePlaceholder=<enter new value> >+############################################################################### >+# Copyright (c) 2010 CEA >+# >+# 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: >+# Nicolas Bros (Mia-Software) - initial API and implementation >+############################################################################### >+NaryAttributeEditingDialog_add=&Add > NaryReferenceEditingDialog_addAll=>> > NaryReferenceEditingDialog_addAllTooltip=Add all > NaryReferenceEditingDialog_addTooltip=Add > NaryReferenceEditingDialog_availableValues=Available values > NaryReferenceEditingDialog_deleteElements=Delete elements? > NaryReferenceEditingDialog_deleteElementsLong=Since the feature is composite, this will delete the selected element(s) from the model. >-NaryReferenceEditingDialog_down=Down >+NaryReferenceEditingDialog_down=&Down > NaryReferenceEditingDialog_featureIsComposite=The feature is composite. > NaryReferenceEditingDialog_moveElement=Move element? >-NaryReferenceEditingDialog_remove=< >+NaryReferenceEditingDialog_remove=&< > NaryReferenceEditingDialog_removeAll=<< > NaryReferenceEditingDialog_removeAllTooltip=Remove all > NaryReferenceEditingDialog_removeTooltip=Remove > NaryReferenceEditingDialog_shellTitle=Edit {0} of {1} > NaryReferenceEditingDialog_typeFilterText=type filter text >-NaryReferenceEditingDialog_up=Up >+NaryReferenceEditingDialog_up=&Up > NaryReferenceEditingDialog_values=Values > NaryReferenceEditingDialog_valueWillBeMoved=The selected value will be moved from its previous parent. > NaryReferenceEditingDialog_valueWillBeMovedAndPreviousLost=The selected value will be moved from its previous parent and the previous value will be lost. >-############################################################################### >-# Copyright (c) 2010 CEA >-# >-# Contributors: >-# Nicolas Bros (Mia-Software) - initial API and implementation >-############################################################################### >-NaryReferenceEditingDialog_add=> >+NaryReferenceEditingDialog_add=&> > UnaryReferenceCellEditorComposite_0=Invalid selection > UnaryReferenceCellEditorComposite_1=Please select an EObject > UnaryReferenceCellEditorComposite_2=Select an EObject >Index: src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/impl/ModelCellEditorPackageImpl.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/impl/ModelCellEditorPackageImpl.java (revision 125) >+++ src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/impl/ModelCellEditorPackageImpl.java (working copy) >@@ -269,14 +269,18 @@ > ModelCellEditorPackage.MODEL_CELL_EDITOR_DECLARATIONS__MODEL_CELL_EDITORS); > > this.abstractModelCellEditorEClass = createEClass(ModelCellEditorPackage.ABSTRACT_MODEL_CELL_EDITOR); >- createEReference(this.abstractModelCellEditorEClass, ModelCellEditorPackage.ABSTRACT_MODEL_CELL_EDITOR__CELL_TYPE); >- createEAttribute(this.abstractModelCellEditorEClass, ModelCellEditorPackage.ABSTRACT_MODEL_CELL_EDITOR__CELL_ID); >+ createEReference(this.abstractModelCellEditorEClass, >+ ModelCellEditorPackage.ABSTRACT_MODEL_CELL_EDITOR__CELL_TYPE); >+ createEAttribute(this.abstractModelCellEditorEClass, >+ ModelCellEditorPackage.ABSTRACT_MODEL_CELL_EDITOR__CELL_ID); > > this.basicCellEditorEClass = createEClass(ModelCellEditorPackage.BASIC_CELL_EDITOR); >- createEAttribute(this.basicCellEditorEClass, ModelCellEditorPackage.BASIC_CELL_EDITOR__BASIC_CELL_EDITOR_IMPL); >+ createEAttribute(this.basicCellEditorEClass, >+ ModelCellEditorPackage.BASIC_CELL_EDITOR__BASIC_CELL_EDITOR_IMPL); > > this.unaryReferenceCellEditorEClass = createEClass(ModelCellEditorPackage.UNARY_REFERENCE_CELL_EDITOR); >- createEAttribute(this.unaryReferenceCellEditorEClass, >+ createEAttribute( >+ this.unaryReferenceCellEditorEClass, > ModelCellEditorPackage.UNARY_REFERENCE_CELL_EDITOR__UNARY_REFERENCE_CELL_EDITOR_IMPL); > > this.naryFeatureCellEditorEClass = createEClass(ModelCellEditorPackage.NARY_FEATURE_CELL_EDITOR); >@@ -319,33 +323,51 @@ > this.naryFeatureCellEditorEClass.getESuperTypes().add(getAbstractModelCellEditor()); > > // Initialize classes and features; add operations and parameters >- initEClass(this.modelCellEditorDeclarationsEClass, ModelCellEditorDeclarations.class, >+ initEClass( >+ this.modelCellEditorDeclarationsEClass, >+ ModelCellEditorDeclarations.class, > "ModelCellEditorDeclarations", !EPackageImpl.IS_ABSTRACT, !EPackageImpl.IS_INTERFACE, //$NON-NLS-1$ > EPackageImpl.IS_GENERATED_INSTANCE_CLASS); > initEReference(getModelCellEditorDeclarations_ModelCellEditors(), > getAbstractModelCellEditor(), null, "modelCellEditors", null, 0, -1, //$NON-NLS-1$ >- ModelCellEditorDeclarations.class, !EPackageImpl.IS_TRANSIENT, !EPackageImpl.IS_VOLATILE, EPackageImpl.IS_CHANGEABLE, >- EPackageImpl.IS_COMPOSITE, !EPackageImpl.IS_RESOLVE_PROXIES, !EPackageImpl.IS_UNSETTABLE, EPackageImpl.IS_UNIQUE, !EPackageImpl.IS_DERIVED, >- EPackageImpl.IS_ORDERED); >+ ModelCellEditorDeclarations.class, !EPackageImpl.IS_TRANSIENT, >+ !EPackageImpl.IS_VOLATILE, EPackageImpl.IS_CHANGEABLE, EPackageImpl.IS_COMPOSITE, >+ !EPackageImpl.IS_RESOLVE_PROXIES, !EPackageImpl.IS_UNSETTABLE, >+ EPackageImpl.IS_UNIQUE, !EPackageImpl.IS_DERIVED, EPackageImpl.IS_ORDERED); > >- initEClass(this.abstractModelCellEditorEClass, AbstractModelCellEditor.class, >+ initEClass( >+ this.abstractModelCellEditorEClass, >+ AbstractModelCellEditor.class, > "AbstractModelCellEditor", EPackageImpl.IS_ABSTRACT, !EPackageImpl.IS_INTERFACE, EPackageImpl.IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ >- initEReference(getAbstractModelCellEditor_CellType(), this.ecorePackage.getEClassifier(), null, >+ initEReference( >+ getAbstractModelCellEditor_CellType(), >+ this.ecorePackage.getEClassifier(), >+ null, > "cellType", null, 1, 1, AbstractModelCellEditor.class, !EPackageImpl.IS_TRANSIENT, !EPackageImpl.IS_VOLATILE, //$NON-NLS-1$ >- EPackageImpl.IS_CHANGEABLE, !EPackageImpl.IS_COMPOSITE, EPackageImpl.IS_RESOLVE_PROXIES, !EPackageImpl.IS_UNSETTABLE, EPackageImpl.IS_UNIQUE, >- !EPackageImpl.IS_DERIVED, EPackageImpl.IS_ORDERED); >- initEAttribute(getAbstractModelCellEditor_CellId(), this.ecorePackage.getEString(), "cellId", //$NON-NLS-1$ >- null, 1, 1, AbstractModelCellEditor.class, !EPackageImpl.IS_TRANSIENT, !EPackageImpl.IS_VOLATILE, >- EPackageImpl.IS_CHANGEABLE, !EPackageImpl.IS_UNSETTABLE, !EPackageImpl.IS_ID, EPackageImpl.IS_UNIQUE, !EPackageImpl.IS_DERIVED, EPackageImpl.IS_ORDERED); >+ EPackageImpl.IS_CHANGEABLE, !EPackageImpl.IS_COMPOSITE, >+ EPackageImpl.IS_RESOLVE_PROXIES, !EPackageImpl.IS_UNSETTABLE, >+ EPackageImpl.IS_UNIQUE, !EPackageImpl.IS_DERIVED, EPackageImpl.IS_ORDERED); >+ initEAttribute( >+ getAbstractModelCellEditor_CellId(), >+ this.ecorePackage.getEString(), >+ "cellId", //$NON-NLS-1$ >+ null, 1, 1, AbstractModelCellEditor.class, !EPackageImpl.IS_TRANSIENT, >+ !EPackageImpl.IS_VOLATILE, EPackageImpl.IS_CHANGEABLE, !EPackageImpl.IS_UNSETTABLE, >+ !EPackageImpl.IS_ID, EPackageImpl.IS_UNIQUE, !EPackageImpl.IS_DERIVED, >+ EPackageImpl.IS_ORDERED); > > addEOperation(this.abstractModelCellEditorEClass, this.ecorePackage.getEString(), > "getModelCellEditorImpl", 1, 1, EPackageImpl.IS_UNIQUE, EPackageImpl.IS_ORDERED); //$NON-NLS-1$ > >- initEClass(this.basicCellEditorEClass, BasicCellEditor.class, "BasicCellEditor", !EPackageImpl.IS_ABSTRACT, //$NON-NLS-1$ >+ initEClass(this.basicCellEditorEClass, BasicCellEditor.class, >+ "BasicCellEditor", !EPackageImpl.IS_ABSTRACT, //$NON-NLS-1$ > !EPackageImpl.IS_INTERFACE, EPackageImpl.IS_GENERATED_INSTANCE_CLASS); >- initEAttribute(getBasicCellEditor_BasicCellEditorImpl(), this.ecorePackage.getEString(), >+ initEAttribute( >+ getBasicCellEditor_BasicCellEditorImpl(), >+ this.ecorePackage.getEString(), > "basicCellEditorImpl", null, 1, 1, BasicCellEditor.class, !EPackageImpl.IS_TRANSIENT, //$NON-NLS-1$ >- !EPackageImpl.IS_VOLATILE, EPackageImpl.IS_CHANGEABLE, !EPackageImpl.IS_UNSETTABLE, !EPackageImpl.IS_ID, EPackageImpl.IS_UNIQUE, !EPackageImpl.IS_DERIVED, >+ !EPackageImpl.IS_VOLATILE, EPackageImpl.IS_CHANGEABLE, !EPackageImpl.IS_UNSETTABLE, >+ !EPackageImpl.IS_ID, EPackageImpl.IS_UNIQUE, !EPackageImpl.IS_DERIVED, > EPackageImpl.IS_ORDERED); > > initEClass(this.unaryReferenceCellEditorEClass, UnaryReferenceCellEditor.class, >@@ -353,15 +375,20 @@ > EPackageImpl.IS_GENERATED_INSTANCE_CLASS); > initEAttribute(getUnaryReferenceCellEditor_UnaryReferenceCellEditorImpl(), > this.ecorePackage.getEString(), "unaryReferenceCellEditorImpl", null, 1, 1, //$NON-NLS-1$ >- UnaryReferenceCellEditor.class, !EPackageImpl.IS_TRANSIENT, !EPackageImpl.IS_VOLATILE, EPackageImpl.IS_CHANGEABLE, >- !EPackageImpl.IS_UNSETTABLE, !EPackageImpl.IS_ID, EPackageImpl.IS_UNIQUE, !EPackageImpl.IS_DERIVED, EPackageImpl.IS_ORDERED); >+ UnaryReferenceCellEditor.class, !EPackageImpl.IS_TRANSIENT, >+ !EPackageImpl.IS_VOLATILE, EPackageImpl.IS_CHANGEABLE, !EPackageImpl.IS_UNSETTABLE, >+ !EPackageImpl.IS_ID, EPackageImpl.IS_UNIQUE, !EPackageImpl.IS_DERIVED, >+ EPackageImpl.IS_ORDERED); > >- initEClass(this.naryFeatureCellEditorEClass, NaryFeatureCellEditor.class, >+ initEClass( >+ this.naryFeatureCellEditorEClass, >+ NaryFeatureCellEditor.class, > "NaryFeatureCellEditor", !EPackageImpl.IS_ABSTRACT, !EPackageImpl.IS_INTERFACE, EPackageImpl.IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ > initEAttribute(getNaryFeatureCellEditor_NaryFeatureCellEditorImpl(), > this.ecorePackage.getEString(), "naryFeatureCellEditorImpl", null, 1, 1, //$NON-NLS-1$ >- NaryFeatureCellEditor.class, !EPackageImpl.IS_TRANSIENT, !EPackageImpl.IS_VOLATILE, EPackageImpl.IS_CHANGEABLE, >- !EPackageImpl.IS_UNSETTABLE, !EPackageImpl.IS_ID, EPackageImpl.IS_UNIQUE, !EPackageImpl.IS_DERIVED, EPackageImpl.IS_ORDERED); >+ NaryFeatureCellEditor.class, !EPackageImpl.IS_TRANSIENT, !EPackageImpl.IS_VOLATILE, >+ EPackageImpl.IS_CHANGEABLE, !EPackageImpl.IS_UNSETTABLE, !EPackageImpl.IS_ID, >+ EPackageImpl.IS_UNIQUE, !EPackageImpl.IS_DERIVED, EPackageImpl.IS_ORDERED); > > // Create resource > createResource(ModelCellEditorPackage.eNS_URI); >Index: src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/ModelCellEditorPackage.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/ModelCellEditorPackage.java (revision 125) >+++ src/org/eclipse/emf/facet/widgets/celleditors/modelCellEditor/ModelCellEditorPackage.java (working copy) >@@ -450,7 +450,8 @@ > * @see org.eclipse.emf.facet.widgets.celleditors.modelCellEditor.impl.ModelCellEditorPackageImpl#getModelCellEditorDeclarations() > * @generated > */ >- EClass MODEL_CELL_EDITOR_DECLARATIONS = ModelCellEditorPackage.eINSTANCE.getModelCellEditorDeclarations(); >+ EClass MODEL_CELL_EDITOR_DECLARATIONS = ModelCellEditorPackage.eINSTANCE >+ .getModelCellEditorDeclarations(); > > /** > * The meta object literal for the '<em><b>Model Cell Editors</b></em>' >@@ -472,7 +473,8 @@ > * @see org.eclipse.emf.facet.widgets.celleditors.modelCellEditor.impl.ModelCellEditorPackageImpl#getAbstractModelCellEditor() > * @generated > */ >- EClass ABSTRACT_MODEL_CELL_EDITOR = ModelCellEditorPackage.eINSTANCE.getAbstractModelCellEditor(); >+ EClass ABSTRACT_MODEL_CELL_EDITOR = ModelCellEditorPackage.eINSTANCE >+ .getAbstractModelCellEditor(); > > /** > * The meta object literal for the '<em><b>Cell Type</b></em>' reference >@@ -524,7 +526,8 @@ > * @see org.eclipse.emf.facet.widgets.celleditors.modelCellEditor.impl.ModelCellEditorPackageImpl#getUnaryReferenceCellEditor() > * @generated > */ >- EClass UNARY_REFERENCE_CELL_EDITOR = ModelCellEditorPackage.eINSTANCE.getUnaryReferenceCellEditor(); >+ EClass UNARY_REFERENCE_CELL_EDITOR = ModelCellEditorPackage.eINSTANCE >+ .getUnaryReferenceCellEditor(); > > /** > * The meta object literal for the ' >@@ -546,7 +549,8 @@ > * @see org.eclipse.emf.facet.widgets.celleditors.modelCellEditor.impl.ModelCellEditorPackageImpl#getNaryFeatureCellEditor() > * @generated > */ >- EClass NARY_FEATURE_CELL_EDITOR = ModelCellEditorPackage.eINSTANCE.getNaryFeatureCellEditor(); >+ EClass NARY_FEATURE_CELL_EDITOR = ModelCellEditorPackage.eINSTANCE >+ .getNaryFeatureCellEditor(); > > /** > * The meta object literal for the ' >Index: src/org/eclipse/emf/facet/widgets/celleditors/ui/NaryAttributeEditingDialog.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/celleditors/ui/NaryAttributeEditingDialog.java (revision 0) >+++ src/org/eclipse/emf/facet/widgets/celleditors/ui/NaryAttributeEditingDialog.java (revision 0) >@@ -0,0 +1,464 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 CEA LIST. >+ * >+ * 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: >+ * Nicolas Bros (Mia-Software) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.emf.facet.widgets.celleditors.ui; >+ >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.emf.common.command.Command; >+import org.eclipse.emf.common.command.CompoundCommand; >+import org.eclipse.emf.ecore.EAttribute; >+import org.eclipse.emf.ecore.EDataType; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+import org.eclipse.emf.facet.widgets.CustomizableLabelProvider; >+import org.eclipse.emf.facet.widgets.celleditors.CommandFactoriesRegistry; >+import org.eclipse.emf.facet.widgets.celleditors.ICommandFactory; >+import org.eclipse.emf.facet.widgets.celleditors.Messages; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.viewers.ColumnLabelProvider; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.jface.viewers.TableViewerColumn; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ControlEvent; >+import org.eclipse.swt.events.ControlListener; >+import org.eclipse.swt.events.KeyAdapter; >+import org.eclipse.swt.events.KeyEvent; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Listener; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Table; >+import org.eclipse.swt.widgets.TableColumn; >+ >+/** A dialog to edit a multiplicity-many {@link EAttribute} */ >+public class NaryAttributeEditingDialog extends Dialog { >+ >+ private static final int LIST_WIDTH = 200; >+ private static final int LIST_HEIGHT = 250; >+ private static final int NUM_COLUMNS = 2; >+ private TableViewer fFeatureValuesTableViewer; >+ private Button fAddButton; >+ private Button fRemoveButton; >+ private Button fUpButton; >+ private Button fDownButton; >+ private final EStructuralFeature fFeature; >+ private final EObject fEObject; >+ private final EditingDomain editingDomain; >+ private final ICommandFactory commandFactory; >+ >+ private boolean bAddingValue = false; >+ >+ public boolean isAddingValue() { >+ return this.bAddingValue; >+ } >+ >+ private final Object newValuePlaceholder = new Object(); >+ >+ private class AssignedValuesContentProvider implements IStructuredContentProvider { >+ public Object[] getElements(final Object inputElement) { >+ if (inputElement instanceof FeatureValuesInput) { >+ FeatureValuesInput valuesInput = (FeatureValuesInput) inputElement; >+ EStructuralFeature feature = valuesInput.getFeature(); >+ EObject source = valuesInput.getSource(); >+ List<?> list = (List<?>) source.eGet(feature); >+ // add a temporary cell when editing >+ if (isAddingValue()) { >+ Object[] result = new Object[list.size() + 1]; >+ int i = 0; >+ for (Object object : list) { >+ result[i++] = object; >+ } >+ result[i] = NaryAttributeEditingDialog.this.newValuePlaceholder; >+ return result; >+ } >+ return list.toArray(); >+ } >+ throw new IllegalArgumentException(FeatureValuesInput.class.getSimpleName() >+ + " expected"); //$NON-NLS-1$ >+ } >+ >+ public void dispose() { >+ // >+ } >+ >+ public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { >+ // >+ } >+ } >+ >+ private final ColumnLabelProvider labelProvider = new ColumnLabelProvider() { >+ private final LabelProvider delegateLabelProvider = new CustomizableLabelProvider(); >+ >+ @Override >+ public Image getImage(final Object element) { >+ return this.delegateLabelProvider.getImage(element); >+ } >+ >+ @Override >+ public String getText(final Object element) { >+ if (element == NaryAttributeEditingDialog.this.newValuePlaceholder) { >+ return Messages.NaryAttributeEditingDialog_enterNewValuePlaceholder; >+ } >+ return this.delegateLabelProvider.getText(element); >+ } >+ >+ @Override >+ public Color getForeground(final Object element) { >+ if (element == NaryAttributeEditingDialog.this.newValuePlaceholder) { >+ return Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY); >+ } >+ return null; >+ } >+ }; >+ >+ /** >+ * @param parent >+ * the parent {@link Shell} >+ * @param feature >+ * the feature to edit >+ * @param eObject >+ * the {@link EObject} on which the feature must be edited >+ * @param editingDomain >+ * the {@link EditingDomain} through which all editing is done >+ */ >+ public NaryAttributeEditingDialog(final Shell parent, final EStructuralFeature feature, >+ final EObject eObject, final EditingDomain editingDomain) { >+ super(parent); >+ if (!(feature.getEType() instanceof EDataType)) { >+ throw new IllegalArgumentException("feature type must be EDataType"); //$NON-NLS-1$ >+ } >+ >+ this.fFeature = feature; >+ this.fEObject = eObject; >+ this.editingDomain = editingDomain; >+ this.commandFactory = CommandFactoriesRegistry.getInstance().getCommandFactoryFor( >+ this.editingDomain); >+ } >+ >+ @Override >+ protected void configureShell(final Shell shell) { >+ super.configureShell(shell); >+ shell.setText(NLS.bind(Messages.NaryReferenceEditingDialog_shellTitle, >+ this.fFeature.getName(), this.fEObject.eClass().getName())); >+ // prevent Escape or Enter from closing the dialog >+ // when a cell editor is active >+ shell.addListener(SWT.Traverse, new Listener() { >+ public void handleEvent(final Event e) { >+ if ((e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) >+ && NaryAttributeEditingDialog.this.fFeatureValuesTableViewer >+ .isCellEditorActive()) { >+ e.doit = false; >+ } >+ } >+ }); >+ } >+ >+ @Override >+ protected Control createDialogArea(final Composite parent) { >+ final Composite contents = (Composite) super.createDialogArea(parent); >+ >+ final GridLayout contentsGridLayout = (GridLayout) contents.getLayout(); >+ contentsGridLayout.numColumns = NaryAttributeEditingDialog.NUM_COLUMNS; >+ >+ final GridData contentsGridData = (GridData) contents.getLayoutData(); >+ contentsGridData.horizontalAlignment = SWT.FILL; >+ contentsGridData.verticalAlignment = SWT.FILL; >+ >+ createValuesPane(contents); >+ createButtonsPane(contents); >+ >+ // this.fFeatureValuesTableViewer.addOpenListener(new IOpenListener() { >+ // public void open(final OpenEvent event) { >+ // editSelectedElement(); >+ // } >+ // }); >+ >+ this.fUpButton.addSelectionListener(new SelectionAdapter() { >+ @Override >+ public void widgetSelected(final SelectionEvent event) { >+ upButtonClicked(); >+ } >+ }); >+ >+ this.fDownButton.addSelectionListener(new SelectionAdapter() { >+ @Override >+ public void widgetSelected(final SelectionEvent event) { >+ downButtonClicked(); >+ } >+ }); >+ >+ this.fAddButton.addSelectionListener(new SelectionAdapter() { >+ @Override >+ public void widgetSelected(final SelectionEvent event) { >+ addButtonClicked(); >+ } >+ }); >+ >+ this.fRemoveButton.addSelectionListener(new SelectionAdapter() { >+ @Override >+ public void widgetSelected(final SelectionEvent event) { >+ removeButtonClicked(); >+ } >+ }); >+ >+ return contents; >+ } >+ >+ @SuppressWarnings("unchecked") >+ private void upButtonClicked() { >+ final IStructuredSelection selection = (IStructuredSelection) this.fFeatureValuesTableViewer >+ .getSelection(); >+ >+ EditingUtils.moveElementsUp(this.fEObject, this.fFeature, selection.toList(), >+ this.commandFactory, this.editingDomain); >+ >+ this.fFeatureValuesTableViewer.refresh(); >+ } >+ >+ @SuppressWarnings("unchecked") >+ private void downButtonClicked() { >+ final IStructuredSelection selection = (IStructuredSelection) this.fFeatureValuesTableViewer >+ .getSelection(); >+ >+ EditingUtils.moveElementsDown(this.fEObject, this.fFeature, selection.toList(), >+ this.commandFactory, this.editingDomain); >+ >+ this.fFeatureValuesTableViewer.refresh(); >+ } >+ >+ private void addButtonClicked() { >+ this.bAddingValue = true; >+ // EDataType dataType = (EDataType) this.fFeature.getEType(); >+ // Object defaultValue = dataType.getDefaultValue(); >+ // if (dataType == EcorePackage.eINSTANCE.getEString()) { >+ // defaultValue = ""; >+ // } >+ // Command addCommand = >+ // this.commandFactory.createAddCommand(this.editingDomain, >+ // this.fEObject, this.fFeature, defaultValue); >+ // this.editingDomain.getCommandStack().execute(addCommand); >+ refresh(); >+ // this.fFeatureValuesTableViewer.setSelection(new >+ // StructuredSelection(this.tempCellForNewValue), >+ // true); >+ this.fFeatureValuesTableViewer.editElement(this.newValuePlaceholder, 0); >+ } >+ >+ @SuppressWarnings("unchecked") >+ private void removeButtonClicked() { >+ final IStructuredSelection selection = (IStructuredSelection) this.fFeatureValuesTableViewer >+ .getSelection(); >+ >+ CompoundCommand compoundCommand = new CompoundCommand(); >+ >+ List<?> list = (List<?>) this.fEObject.eGet(this.fFeature); >+ >+ for (final Iterator<Object> it = selection.iterator(); it.hasNext();) { >+ final Object element = it.next(); >+ >+ if (list.contains(element)) { >+ Command removeCommand = this.commandFactory.createRemoveCommand(this.editingDomain, >+ this.fEObject, this.fFeature, element); >+ compoundCommand.append(removeCommand); >+ } >+ } >+ this.editingDomain.getCommandStack().execute(compoundCommand); >+ refresh(); >+ } >+ >+ private void spacer(final Composite parent) { >+ @SuppressWarnings("unused") >+ Label label = new Label(parent, SWT.NONE); >+ } >+ >+ private void createButtonsPane(final Composite contents) { >+ final Composite buttonsComposite = new Composite(contents, SWT.NONE); >+ final GridData buttonsCompositeGridData = new GridData(); >+ buttonsCompositeGridData.verticalAlignment = SWT.FILL; >+ buttonsCompositeGridData.horizontalAlignment = SWT.FILL; >+ buttonsComposite.setLayoutData(buttonsCompositeGridData); >+ buttonsComposite.setLayout(new GridLayout()); >+ >+ // spacer >+ spacer(buttonsComposite); >+ >+ this.fAddButton = new Button(buttonsComposite, SWT.PUSH); >+ this.fAddButton.setText(Messages.NaryAttributeEditingDialog_add); >+ final GridData addButtonGridData = new GridData(); >+ addButtonGridData.verticalAlignment = SWT.FILL; >+ addButtonGridData.horizontalAlignment = SWT.FILL; >+ // addButtonGridData.widthHint = 70; >+ this.fAddButton.setLayoutData(addButtonGridData); >+ >+ this.fRemoveButton = new Button(buttonsComposite, SWT.PUSH); >+ this.fRemoveButton.setText(Messages.NaryAttributeEditingDialog_delete); >+ final GridData removeButtonGridData = new GridData(); >+ removeButtonGridData.verticalAlignment = SWT.FILL; >+ removeButtonGridData.horizontalAlignment = SWT.FILL; >+ this.fRemoveButton.setLayoutData(removeButtonGridData); >+ >+ spacer(buttonsComposite); >+ >+ this.fUpButton = new Button(buttonsComposite, SWT.PUSH); >+ this.fUpButton.setText(Messages.NaryReferenceEditingDialog_up); >+ final GridData upButtonGridData = new GridData(); >+ upButtonGridData.verticalAlignment = SWT.FILL; >+ upButtonGridData.horizontalAlignment = SWT.FILL; >+ this.fUpButton.setLayoutData(upButtonGridData); >+ >+ this.fDownButton = new Button(buttonsComposite, SWT.PUSH); >+ this.fDownButton.setText(Messages.NaryReferenceEditingDialog_down); >+ final GridData downButtonGridData = new GridData(); >+ downButtonGridData.verticalAlignment = SWT.FILL; >+ downButtonGridData.horizontalAlignment = SWT.FILL; >+ this.fDownButton.setLayoutData(downButtonGridData); >+ } >+ >+ private void createValuesPane(final Composite contents) { >+ final Composite featureComposite = new Composite(contents, SWT.NONE); >+ final GridData featureCompositeData = new GridData(SWT.FILL, SWT.FILL, true, true); >+ featureCompositeData.horizontalAlignment = SWT.END; >+ featureComposite.setLayoutData(featureCompositeData); >+ >+ final GridLayout featureCompositeLayout = new GridLayout(); >+ featureCompositeData.horizontalAlignment = SWT.FILL; >+ featureCompositeLayout.marginHeight = 0; >+ featureCompositeLayout.marginWidth = 0; >+ featureCompositeLayout.numColumns = 1; >+ featureComposite.setLayout(featureCompositeLayout); >+ >+ final Label featureLabel = new Label(featureComposite, SWT.NONE); >+ featureLabel.setText(Messages.NaryReferenceEditingDialog_values); >+ final GridData valuesLabelGridData = new GridData(); >+ valuesLabelGridData.horizontalSpan = 2; >+ valuesLabelGridData.horizontalAlignment = SWT.FILL; >+ valuesLabelGridData.verticalAlignment = SWT.FILL; >+ featureLabel.setLayoutData(valuesLabelGridData); >+ >+ final Table table = new Table(featureComposite, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); >+ final GridData tableGridData = new GridData(); >+ tableGridData.widthHint = NaryAttributeEditingDialog.LIST_WIDTH; >+ tableGridData.heightHint = NaryAttributeEditingDialog.LIST_HEIGHT; >+ tableGridData.verticalAlignment = SWT.FILL; >+ tableGridData.horizontalAlignment = SWT.FILL; >+ tableGridData.grabExcessHorizontalSpace = true; >+ tableGridData.grabExcessVerticalSpace = true; >+ table.setLayoutData(tableGridData); >+ final TableColumn tableColumn = new TableColumn(table, SWT.CENTER); >+ >+ // full-width column >+ table.addControlListener(new ControlListener() { >+ public void controlResized(final ControlEvent e) { >+ tableColumn.setWidth(table.getClientArea().width); >+ } >+ >+ public void controlMoved(final ControlEvent e) { >+ // >+ } >+ }); >+ >+ this.fFeatureValuesTableViewer = new TableViewer(table); >+ this.fFeatureValuesTableViewer.setContentProvider(new AssignedValuesContentProvider()); >+ // this.fFeatureValuesTableViewer.setLabelProvider(this.labelProvider); >+ this.fFeatureValuesTableViewer >+ .setInput(new FeatureValuesInput(this.fFeature, this.fEObject)); >+ >+ final TableViewerColumn tableViewerColumn = new TableViewerColumn( >+ this.fFeatureValuesTableViewer, tableColumn); >+ tableViewerColumn.setLabelProvider(this.labelProvider); >+ >+ tableViewerColumn.setEditingSupport(new ModelCellsEditingSupport( >+ this.fFeatureValuesTableViewer, this.fFeature, this.fEObject, this.editingDomain, >+ this.newValuePlaceholder)); >+ >+ // keyboard accessibility >+ table.addKeyListener(new KeyAdapter() { >+ @Override >+ public void keyPressed(final KeyEvent e) { >+ if (e.keyCode == SWT.F2) { >+ editSelectedElement(); >+ } >+ if (e.keyCode == SWT.DEL) { >+ if (NaryAttributeEditingDialog.this.fRemoveButton.isEnabled()) { >+ NaryAttributeEditingDialog.this.fRemoveButton.notifyListeners( >+ SWT.Selection, null); >+ } >+ } >+ if (e.keyCode == SWT.ARROW_UP >+ && ((e.stateMask & SWT.COMMAND) != 0 || (e.stateMask & SWT.CONTROL) != 0)) { >+ if (NaryAttributeEditingDialog.this.fUpButton.isEnabled()) { >+ NaryAttributeEditingDialog.this.fUpButton.notifyListeners(SWT.Selection, >+ null); >+ } >+ } >+ if (e.keyCode == SWT.ARROW_DOWN >+ && ((e.stateMask & SWT.COMMAND) != 0 || (e.stateMask & SWT.CONTROL) != 0)) { >+ if (NaryAttributeEditingDialog.this.fDownButton.isEnabled()) { >+ NaryAttributeEditingDialog.this.fDownButton.notifyListeners(SWT.Selection, >+ null); >+ } >+ } >+ } >+ }); >+ >+ } >+ >+ private void editSelectedElement() { >+ ISelection selection = NaryAttributeEditingDialog.this.fFeatureValuesTableViewer >+ .getSelection(); >+ if (selection instanceof IStructuredSelection) { >+ IStructuredSelection structuredSelection = (IStructuredSelection) selection; >+ if (structuredSelection.getFirstElement() != null) { >+ NaryAttributeEditingDialog.this.fFeatureValuesTableViewer.editElement( >+ structuredSelection.getFirstElement(), 0); >+ } >+ } >+ } >+ >+ @Override >+ protected void okPressed() { >+ super.okPressed(); >+ } >+ >+ private void refresh() { >+ this.fFeatureValuesTableViewer.refresh(); >+ } >+ >+ @Override >+ protected boolean isResizable() { >+ return true; >+ } >+ >+ @Override >+ protected void createButtonsForButtonBar(final Composite parent) { >+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); >+ } >+} >#P org.eclipse.emf.facet.widgets.nattable.workbench >Index: src/org/eclipse/emf/facet/widgets/nattable/workbench/editor/NatTableEditorFactory.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/nattable/workbench/editor/NatTableEditorFactory.java (revision 9297) >+++ src/org/eclipse/emf/facet/widgets/nattable/workbench/editor/NatTableEditorFactory.java (working copy) >@@ -106,9 +106,11 @@ > } else { > int nElements = tableElements.size(); > if (nElements > 1) { >- description = NLS.bind(Messages.NatTableEditorFactory_queryResults, new Integer(nElements)); >+ description = NLS.bind(Messages.NatTableEditorFactory_queryResults, new Integer( >+ nElements)); > } else { >- description = NLS.bind(Messages.NatTableEditorFactory_queryResult, new Integer(nElements)); >+ description = NLS.bind(Messages.NatTableEditorFactory_queryResult, new Integer( >+ nElements)); > } > queryName = Messages.NatTableEditorFactory_aQuery; > } >Index: src/org/eclipse/emf/facet/widgets/nattable/workbench/view/NatTableView.java >=================================================================== >--- src/org/eclipse/emf/facet/widgets/nattable/workbench/view/NatTableView.java (revision 9301) >+++ src/org/eclipse/emf/facet/widgets/nattable/workbench/view/NatTableView.java (working copy) >@@ -73,7 +73,8 @@ > List<TableElement> tableElements = new ArrayList<TableElement>(); > for (ModelQueryResult modelQueryResult : result) { > Object value = modelQueryResult.getValue(); >- TableElementWithContext.flattenToList(value, tableElements, modelQueryResult.getSource()); >+ TableElementWithContext.flattenToList(value, tableElements, >+ modelQueryResult.getSource()); > } > openOn(new TableInput(tableElements, editingDomain)); > } >@@ -150,7 +151,7 @@ > manager.add(this.actionSortColumnsByType); > manager.add(this.actionHideEmptyColumns); > manager.add(this.actionOnlyShowCommonColumns); >- >+ > } > > private void fillContextMenu(final IMenuManager manager) { >@@ -220,7 +221,8 @@ > } > }; > >- this.actionRemoveLine = new Action(Messages.NatTableView_removeSelectedLines, IAction.AS_PUSH_BUTTON) { >+ this.actionRemoveLine = new Action(Messages.NatTableView_removeSelectedLines, >+ IAction.AS_PUSH_BUTTON) { > { > setToolTipText(Messages.NatTableView_removeSelectedLines); > setImageDescriptor(ImageProvider.getInstance().getRemoveLineIconDescriptor());
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
gdupe
:
iplog-
Actions:
View
|
Diff
Attachments on
bug 331633
:
184328