Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2011-05-11 13:08:31 +0000
committervlorenzo2011-05-11 13:08:31 +0000
commit20b4b5fdb31c0976d3c51295ca0881dbbd6855f5 (patch)
tree3fff9af0bd5bcfd76f56e5d0c3503a26b869dd62
parenteaed02600b078452147f7399185b70c9ed59f515 (diff)
downloadorg.eclipse.papyrus-20b4b5fdb31c0976d3c51295ca0881dbbd6855f5.tar.gz
org.eclipse.papyrus-20b4b5fdb31c0976d3c51295ca0881dbbd6855f5.tar.xz
org.eclipse.papyrus-20b4b5fdb31c0976d3c51295ca0881dbbd6855f5.zip
NEW - bug 334240: [Enhancement] [TableEditor] Papyrus shall support Tabular Editors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=334240
-rw-r--r--incoming/org.eclipse.papyrus.table.common/META-INF/MANIFEST.MF2
-rw-r--r--incoming/org.eclipse.papyrus.table.common/plugin.xml6
-rw-r--r--incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/Activator.java7
-rw-r--r--incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/NatTableEditor.java181
-rw-r--r--incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/TableEditorInput.java3
5 files changed, 102 insertions, 97 deletions
diff --git a/incoming/org.eclipse.papyrus.table.common/META-INF/MANIFEST.MF b/incoming/org.eclipse.papyrus.table.common/META-INF/MANIFEST.MF
index 84463c854f3..db7f8d06d12 100644
--- a/incoming/org.eclipse.papyrus.table.common/META-INF/MANIFEST.MF
+++ b/incoming/org.eclipse.papyrus.table.common/META-INF/MANIFEST.MF
@@ -15,7 +15,7 @@ Require-Bundle: org.eclipse.emf.facet.widgets.nattable.instance,
org.eclipse.emf.facet.infra.query.editor;bundle-version="0.1.0",
org.eclipse.emf.facet.query.java;bundle-version="0.1.0",
org.eclipse.emf.facet.infra.common.core;bundle-version="0.1.0",
- org.eclipse.papyrus.properties.uml;bundle-version="0.8.0"
+ org.eclipse.papyrus.service.edit;bundle-version="0.8.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
diff --git a/incoming/org.eclipse.papyrus.table.common/plugin.xml b/incoming/org.eclipse.papyrus.table.common/plugin.xml
index a648174d5ea..f03f20db7c6 100644
--- a/incoming/org.eclipse.papyrus.table.common/plugin.xml
+++ b/incoming/org.eclipse.papyrus.table.common/plugin.xml
@@ -27,4 +27,10 @@
<extension point="org.eclipse.emf.facet.infra.browser.custom.core.registration">
<browserCustomization file="resources/table_Ecore_hideEAnnotationFeature.uiCustom"/>
</extension>
+ <extension
+ point="org.eclipse.emf.facet.widgets.celleditors.commandFactories">
+ <commandFactory
+ class="org.eclipse.papyrus.table.common.factory.PapyrusCommandFactory">
+ </commandFactory>
+ </extension>
</plugin>
diff --git a/incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/Activator.java b/incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/Activator.java
index c29ab69a9d3..cb67449a030 100644
--- a/incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/Activator.java
+++ b/incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/Activator.java
@@ -13,6 +13,7 @@
*****************************************************************************/
package org.eclipse.papyrus.table.common;
+import org.eclipse.papyrus.log.LogHelper;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -27,6 +28,7 @@ public class Activator extends AbstractUIPlugin {
// The shared instance
private static Activator plugin;
+ public LogHelper helper;
/**
* The constructor
*/
@@ -39,9 +41,10 @@ public class Activator extends AbstractUIPlugin {
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
@Override
- public void start(BundleContext context) throws Exception {
+ public void start(final BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ helper = new LogHelper(this);
}
/*
@@ -50,7 +53,7 @@ public class Activator extends AbstractUIPlugin {
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
@Override
- public void stop(BundleContext context) throws Exception {
+ public void stop(final BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
diff --git a/incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/NatTableEditor.java b/incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/NatTableEditor.java
index a3f7a15f58a..d84512bb1cf 100644
--- a/incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/NatTableEditor.java
+++ b/incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/NatTableEditor.java
@@ -26,8 +26,6 @@ import java.util.HashMap;
import org.eclipse.core.databinding.conversion.IConverter;
import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.databinding.observable.value.IValueChangeListener;
-import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.CommandStackListener;
@@ -35,6 +33,7 @@ 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.URI;
+import org.eclipse.emf.databinding.EObjectObservableValue;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -56,14 +55,14 @@ import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.papyrus.diagram.common.providers.EditorLabelProvider;
-import org.eclipse.papyrus.properties.uml.databinding.PapyrusObservableValue;
+import org.eclipse.papyrus.properties.databinding.EMFObservableValue;
import org.eclipse.papyrus.table.common.messages.Messages;
import org.eclipse.papyrus.table.instance.papyrustableinstance.PapyrusTableInstance;
import org.eclipse.papyrus.widgets.editors.StringEditor;
import org.eclipse.papyrus.widgets.editors.StringLabel;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -95,6 +94,8 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
private MenuManager menuMgr;
+ private StringLabel contextLabel;
+
private final CommandStackListener commandListener = new CommandStackListener() {
public void commandStackChanged(final EventObject event) {
@@ -107,6 +108,39 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
}
};
+ //this code comes from NatTableWidget
+ //we need to listen change on the context when its a table fillied with queries :
+ private final Adapter modelChangeAdapter = new AdapterImpl() {
+
+ @Override
+ public void notifyChanged(final Notification msg) {
+ //TODO remove the listener!
+ int eventType = msg.getEventType();
+ if(eventType != Notification.REMOVING_ADAPTER && eventType != Notification.RESOLVE) {
+ // redraw table when model changes
+ // System.out.println("we listen a change on the context");
+ }
+ }
+ };
+
+ /**
+ * we listen the context to refresh it in the table if the context change
+ */
+ private final Adapter contextListener = new AdapterImpl() {
+
+ /**
+ *
+ * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
+ *
+ * @param notification
+ */
+ @Override
+ public void notifyChanged(final Notification notification) {
+ NatTableEditor.this.contextLabel.refreshValue();
+ super.notifyChanged(notification);
+ }
+ };
+
@SuppressWarnings("rawtypes")
// We cannot change the method signature because of the override
@Override
@@ -115,7 +149,7 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
return new INatTableWidgetProvider() {
public INatTableWidget getNatTableWidget() {
- return natTableWidget;
+ return NatTableEditor.this.natTableWidget;
}
};
}
@@ -125,12 +159,12 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
@Override
public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
if(input instanceof TableEditorInput) {
- tableEditorInput = (TableEditorInput)input;
- editingDomain = tableEditorInput.getEditingDomain();
+ this.tableEditorInput = (TableEditorInput)input;
+ this.editingDomain = this.tableEditorInput.getEditingDomain();
initializeEditingDomain();
setSite(site);
- setInput(tableEditorInput);
- setPartName(tableEditorInput.getName());
+ setInput(this.tableEditorInput);
+ setPartName(this.tableEditorInput.getName());
} else if(input instanceof FileEditorInput) {
initializeEditingDomain();
FileEditorInput fileEditorInput = (FileEditorInput)input;
@@ -151,9 +185,9 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
break;
}
}
- tableEditorInput = new TableEditorInput(tableInstance, getEditingDomain());
+ this.tableEditorInput = new TableEditorInput(tableInstance, getEditingDomain());
setSite(site);
- setInput(tableEditorInput);
+ setInput(this.tableEditorInput);
setPartName(fileEditorInput.getName());
}
@@ -162,7 +196,6 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
}
}
-
/**
*
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
@@ -171,57 +204,40 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
*/
@Override
public void createPartControl(final Composite parent) {
- menuMgr = new MenuManager("#PopUp", NatTableEditor.ID); //$NON-NLS-1$
- menuMgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
- menuMgr.setRemoveAllWhenShown(true);
+ this.menuMgr = new MenuManager("#PopUp", NatTableEditor.ID); //$NON-NLS-1$
+ this.menuMgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+ this.menuMgr.setRemoveAllWhenShown(true);
- final TableInstance table = tableEditorInput.getPapyrusTableInstance().getTable();
+ final TableInstance table = this.tableEditorInput.getPapyrusTableInstance().getTable();
EClass tableEClass = table.eClass();
- final Composite editorComposite = new Composite(parent, SWT.NONE);
+ final Composite editorComposite = new Composite(parent, SWT.BORDER);
final GridLayout editorGridLayout = new GridLayout(1, false);
editorGridLayout.marginHeight = 0;
editorGridLayout.marginWidth = 0;
editorComposite.setLayout(editorGridLayout);
//we display the context of the table
- final StringLabel contextLabel = new StringLabel(editorComposite, SWT.NONE);
- contextLabel.setLabel(Messages.NatTableEditor_TableContextLabel);
- contextLabel.setToolTipText(Messages.NatTableEditor_TableContextTollTip);
-
- //TODO use EMF Observable
- EStructuralFeature contextFeature = tableEClass.getEStructuralFeature(TableinstancePackage.TABLE_INSTANCE__CONTEXT);
- final IObservableValue contextObservable = new org.eclipse.papyrus.properties.uml.databinding.PapyrusObservableValue(table, contextFeature, getEditingDomain());
- contextObservable.addValueChangeListener(new IValueChangeListener() {
-
- /**
- *
- * @see org.eclipse.core.databinding.observable.value.IValueChangeListener#handleValueChange(org.eclipse.core.databinding.observable.value.ValueChangeEvent)
- *
- * @param event
- */
- public void handleValueChange(final ValueChangeEvent event) {
- //TODO : not verified
- //Change the displayed icon for the StringLabel
- EditorLabelProvider provider = new EditorLabelProvider();
- Image im = provider.getImage(table.getContext());
- contextLabel.getValueLabel().setImage(im);
- }
- });
+ this.contextLabel = new StringLabel(editorComposite, SWT.LEFT);
+ this.contextLabel.setLabel(Messages.NatTableEditor_TableContextLabel);
+ this.contextLabel.setToolTipText(Messages.NatTableEditor_TableContextTollTip);
+ //we observe the feature context of the table (and not the name of the context, because the context is not a NamedElement, but an EObject
+ final IObservableValue contextObservable2 = new EObjectObservableValue(table, TableinstancePackage.eINSTANCE.getTableInstance_Context());
+ table.getContext().eAdapters().add(this.contextListener);
/*
* we should set the converted before the observable!
*/
- contextLabel.setConverters(null, new ContextLabelConverter());
- EditorLabelProvider provider = new EditorLabelProvider();
- contextLabel.getValueLabel().setImage(provider.getImage(table.getContext()));
- contextLabel.setModelObservable(contextObservable);
+ this.contextLabel.setConverters(null, new ContextLabelConverter());
+ this.contextLabel.setLabelProvider(new EditorLabelProvider());
+ this.contextLabel.setModelObservable(contextObservable2);
+
//set the layout for contextLabel
GridData contextGridData = new GridData();
contextGridData.grabExcessHorizontalSpace = true;
contextGridData.horizontalAlignment = SWT.FILL;
- contextLabel.setLayoutData(contextGridData);
+ this.contextLabel.setLayoutData(contextGridData);
//we display the description of the table
@@ -230,7 +246,7 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
descriptionEditor.setLabel(Messages.NatTableEditor_TaleDescriptionLabel);
descriptionEditor.setToolTipText(Messages.NatTableEditor_TableDescriptionToolTip);
EStructuralFeature myFeature = tableEClass.getEStructuralFeature(TableinstancePackage.TABLE_INSTANCE__DESCRIPTION);
- PapyrusObservableValue observable = new PapyrusObservableValue(table, myFeature, getEditingDomain());
+ EMFObservableValue observable = new EMFObservableValue(table, myFeature, getEditingDomain());
descriptionEditor.setModelObservable(observable);
//set the layout for the description editor
@@ -253,7 +269,7 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
tableComposite.setLayoutData(compositeTableGridLayout);
// the nattable widget itself
- natTableWidget = INatTableWidgetFactory.INSTANCE.createNatTableWidget(tableComposite, this, tableEditorInput.getPapyrusTableInstance().getTable(), menuMgr);
+ this.natTableWidget = INatTableWidgetFactory.INSTANCE.createNatTableWidget(tableComposite, this, this.tableEditorInput.getPapyrusTableInstance().getTable(), this.menuMgr);
final GridData tableGridData = new GridData();
@@ -261,52 +277,38 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
tableGridData.grabExcessVerticalSpace = true;
tableGridData.horizontalAlignment = SWT.FILL;
tableGridData.verticalAlignment = SWT.FILL;
- natTableWidget.getComposite().setLayoutData(tableGridData);
+ this.natTableWidget.getComposite().setLayoutData(tableGridData);
- getSite().setSelectionProvider(natTableWidget);
- getSite().registerContextMenu(menuMgr, natTableWidget);
+ getSite().setSelectionProvider(this);
+ getSite().registerContextMenu(this.menuMgr, this.natTableWidget);
//we add a listener on the resource in order to be synchronized with queries
- Resource res = tableEditorInput.getPapyrusTableInstance().getTable().getContext().eResource();
+ Resource res = this.tableEditorInput.getPapyrusTableInstance().getTable().getContext().eResource();
res.setTrackingModification(true);
- if(!res.eAdapters().contains(modelChangeAdapter)) {
- res.eAdapters().add(modelChangeAdapter);
+ if(!res.eAdapters().contains(this.modelChangeAdapter)) {
+ res.eAdapters().add(this.modelChangeAdapter);
}
-
}
@Override
public void dispose() {
- //TODO remove the listener on the context
+ this.natTableWidget.getTableInstance().getContext().eAdapters().remove(this.contextListener);
+ Resource res = this.tableEditorInput.getPapyrusTableInstance().getTable().getContext().eResource();
+ res.eAdapters().remove(this.modelChangeAdapter);
super.dispose();
}
- //this code comes from NatTableWidget
- //we need to listen change on the context when its a table fillied with queries :
- private final Adapter modelChangeAdapter = new AdapterImpl() {
-
- @Override
- public void notifyChanged(final Notification msg) {
- //TODO remove the listener!
- int eventType = msg.getEventType();
- if(eventType != Notification.REMOVING_ADAPTER && eventType != Notification.RESOLVE) {
- // redraw table when model changes
- // System.out.println("we listen a change on the context");
- }
- }
- };
-
@Override
public void setFocus() {
- natTableWidget.getComposite().setFocus();
+ this.natTableWidget.getComposite().setFocus();
}
@Override
public boolean isDirty() {
- return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
+ return ((BasicCommandStack)this.editingDomain.getCommandStack()).isSaveNeeded();
}
@Override
@@ -316,56 +318,51 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
@Override
public void doSave(final IProgressMonitor monitor) {
- natTableWidget.save();
+ this.natTableWidget.save();
firePropertyChange(PROP_DIRTY);
}
@Override
public void doSaveAs() {
- natTableWidget.saveAs();
+ this.natTableWidget.saveAs();
firePropertyChange(PROP_DIRTY);
}
- /** Override to open with a subclassed factory */
- // protected NatTableEditorFactory getFactory() {
- // return NatTableEditorFactory.getInstance();
- // }
-
public void addSelectionChangedListener(final ISelectionChangedListener listener) {
- natTableWidget.addSelectionChangedListener(listener);
+ this.natTableWidget.addSelectionChangedListener(listener);
}
public ISelection getSelection() {
- return natTableWidget.getSelection();
+ ISelection selection = this.natTableWidget.getSelection();
+ if(selection.isEmpty()) {
+ selection = new StructuredSelection(this.tableEditorInput.getPapyrusTableInstance());
+ }
+ return selection;
}
public EditingDomain getEditingDomain() {
- return editingDomain;
+ return this.editingDomain;
}
public void removeSelectionChangedListener(final ISelectionChangedListener listener) {
- natTableWidget.removeSelectionChangedListener(listener);
+ this.natTableWidget.removeSelectionChangedListener(listener);
}
public void setSelection(final ISelection selection) {
- natTableWidget.setSelection(selection);
+ this.natTableWidget.setSelection(selection);
}
- // public INatTableWidget getNatTableWidget() {
- // return this.natTableWidget;
- // }
-
/**
* This sets up the editing domain for the model editor
*/
protected void initializeEditingDomain() {
- if(editingDomain == null) {
+ if(this.editingDomain == null) {
ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
BasicCommandStack commandStack = new BasicCommandStack();
- editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
+ this.editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
}
- editingDomain.getCommandStack().removeCommandStackListener(commandListener);
- editingDomain.getCommandStack().addCommandStackListener(commandListener);
+ this.editingDomain.getCommandStack().removeCommandStackListener(this.commandListener);
+ this.editingDomain.getCommandStack().addCommandStackListener(this.commandListener);
}
public IWorkbenchPart getPart() {
diff --git a/incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/TableEditorInput.java b/incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/TableEditorInput.java
index c485554cdf5..ec776c5db29 100644
--- a/incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/TableEditorInput.java
+++ b/incoming/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/TableEditorInput.java
@@ -22,7 +22,6 @@ import org.eclipse.ui.IPersistableElement;
* Comes from org.eclipse.emf.facet.widget.nattable.workbench.
*
* This class should not be used by others plugins
- * TODO Should be deleted or merge with an other classe
*/
public class TableEditorInput implements IEditorInput {
@@ -32,7 +31,7 @@ public class TableEditorInput implements IEditorInput {
/** A textual description of what is shown in the editor */
private final String description;
- private EditingDomain editingDomain;
+ private final EditingDomain editingDomain;
public TableEditorInput(final PapyrusTableInstance papyrusTable, final EditingDomain editingDomain) {
this.tableInstance = papyrusTable;

Back to the top