Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2011-05-15 16:31:57 +0000
committervlorenzo2011-05-15 16:31:57 +0000
commitc154837935d6dd87a742f40f00916c1169c506be (patch)
treeb6468674dbd726ca1584aadc4134c8efd0cf5940
parent6fb7b38471b148a64da217ff0c9ed6f438e28fd6 (diff)
downloadorg.eclipse.papyrus-c154837935d6dd87a742f40f00916c1169c506be.tar.gz
org.eclipse.papyrus-c154837935d6dd87a742f40f00916c1169c506be.tar.xz
org.eclipse.papyrus-c154837935d6dd87a742f40f00916c1169c506be.zip
NEW - bug 339650: [Enhancement][TableEditor] Table editor should be synchronized with the table context using filling queries.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=339650
-rw-r--r--plugins/uml/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/NatTableEditor.java140
1 files changed, 99 insertions, 41 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/NatTableEditor.java b/plugins/uml/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/NatTableEditor.java
index 8fcec07251b..b3266a7e007 100644
--- a/plugins/uml/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/NatTableEditor.java
+++ b/plugins/uml/org.eclipse.papyrus.table.common/src/org/eclipse/papyrus/table/common/internal/NatTableEditor.java
@@ -60,12 +60,15 @@ import org.eclipse.papyrus.diagram.common.providers.EditorLabelProvider;
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.table.instance.papyrustableinstance.PapyrustableinstancePackage;
+import org.eclipse.papyrus.widgets.editors.BooleanRadio;
import org.eclipse.papyrus.widgets.editors.StringEditor;
import org.eclipse.papyrus.widgets.editors.StringLabel;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
@@ -193,41 +196,117 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
this.menuMgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
this.menuMgr.setRemoveAllWhenShown(true);
- final TableInstance table = this.tableEditorInput.getPapyrusTableInstance().getTable();
- EClass tableEClass = table.eClass();
+ final Composite editorComposite = createCompositeCompositeWthTableBorder(parent);
+ createFirstLine(editorComposite);
+ createDescription(editorComposite);
+
+ // the composite owning the table
+ final Composite tableComposite = new Composite(editorComposite, SWT.NONE);
+ GridLayout tableCompositeGridLayout = new GridLayout(1, true);
+ tableComposite.setLayout(tableCompositeGridLayout);
+
+ final GridData compositeTableGridLayout = new GridData();
+ compositeTableGridLayout.grabExcessHorizontalSpace = true;
+ compositeTableGridLayout.grabExcessVerticalSpace = true;
+ compositeTableGridLayout.horizontalAlignment = SWT.FILL;
+ compositeTableGridLayout.verticalAlignment = SWT.FILL;
+ tableComposite.setLayoutData(compositeTableGridLayout);
+
+ // the nattable widget itself
+ this.natTableWidget = INatTableWidgetFactory.INSTANCE.createNatTableWidget(tableComposite, this, this.tableEditorInput.getPapyrusTableInstance().getTable(), this.menuMgr);
+
+
+ final GridData tableGridData = new GridData();
+ tableGridData.grabExcessHorizontalSpace = true;
+ tableGridData.grabExcessVerticalSpace = true;
+ tableGridData.horizontalAlignment = SWT.FILL;
+ tableGridData.verticalAlignment = SWT.FILL;
+ this.natTableWidget.getComposite().setLayoutData(tableGridData);
+
+ getSite().setSelectionProvider(this);
+ getSite().registerContextMenu(this.menuMgr, this.natTableWidget);
+ }
+
- final Composite editorComposite = new Composite(parent, SWT.BORDER);
- final GridLayout editorGridLayout = new GridLayout(1, false);
+ private Composite createCompositeCompositeWthTableBorder(final Composite parent){
+ Composite editorComposite = new Composite(parent, SWT.BORDER);
+ final GridLayout editorGridLayout = new GridLayout(1, true);
editorGridLayout.marginHeight = 0;
editorGridLayout.marginWidth = 0;
+
+ GridData data = new GridData();
+ data.grabExcessHorizontalSpace = true;
+ data.horizontalAlignment = SWT.FILL;
+ editorComposite.setLayoutData(data);
editorComposite.setLayout(editorGridLayout);
+ return editorComposite;
+ }
+
+ /**
+ *
+ * @param parent
+ * the parent composite
+ */
+ protected void createFirstLine(final Composite parent){
+
+ final TableInstance table = this.tableEditorInput.getPapyrusTableInstance().getTable();
+ Composite firstLineComposite = new Composite(parent, SWT.NONE);
+ final GridLayout smallGridLayout = new GridLayout(2, true);
+ smallGridLayout.marginHeight = 0;
+ smallGridLayout.marginWidth = 0;
+ smallGridLayout.marginLeft = 0;
+ smallGridLayout.marginRight = 0;
+
+ firstLineComposite.setLayout(smallGridLayout);
+ GridData lineData = new GridData();
+ lineData.horizontalSpan = 1;
+ lineData.horizontalAlignment = SWT.FILL;
+ firstLineComposite.setLayoutData(lineData);
//we display the context of the table
- this.contextLabel = new StringLabel(editorComposite, SWT.LEFT);
+ this.contextLabel = new StringLabel(firstLineComposite,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());
+ final IObservableValue contextObservable = new EObjectObservableValue(table, TableinstancePackage.eINSTANCE.getTableInstance_Context());
table.getContext().eAdapters().add(this.contextListener);
/*
* we should set the converted before the observable!
*/
this.contextLabel.setConverters(null, new ContextLabelConverter());
this.contextLabel.setLabelProvider(new EditorLabelProvider());
- this.contextLabel.setModelObservable(contextObservable2);
-
+ this.contextLabel.setModelObservable(contextObservable);
//set the layout for contextLabel
GridData contextGridData = new GridData();
contextGridData.grabExcessHorizontalSpace = true;
contextGridData.horizontalAlignment = SWT.FILL;
+ contextGridData.horizontalSpan=1;
this.contextLabel.setLayoutData(contextGridData);
+ BooleanRadio checkbox = new BooleanRadio(firstLineComposite, SWT.NONE, "IsSynchronized :" );
+ checkbox.setToolTipText("Indicates if the table is synchronized with queries");
+ final IObservableValue isSynchronizedObservable = new EMFObservableValue(this.tableEditorInput.getPapyrusTableInstance(), PapyrustableinstancePackage.eINSTANCE.getPapyrusTableInstance_IsSynchronized(), getEditingDomain());
+ checkbox.setModelObservable(isSynchronizedObservable);
+
+ GridData checkboxGridData = new GridData();
+ checkboxGridData.grabExcessHorizontalSpace = true;
+ checkboxGridData.horizontalAlignment = SWT.FILL;
+ checkbox.setLayoutData(checkboxGridData);
+
+ }
+
+ protected void createDescription(final Composite parent){
+ final TableInstance table = this.tableEditorInput.getPapyrusTableInstance().getTable();
+ EClass tableEClass = table.eClass();
+
//we display the description of the table
- final StringEditor descriptionEditor = new StringEditor(editorComposite, SWT.MULTI);
+ final StringEditor descriptionEditor = new StringEditor(parent, SWT.MULTI);
descriptionEditor.setLabel(Messages.NatTableEditor_TaleDescriptionLabel);
descriptionEditor.setToolTipText(Messages.NatTableEditor_TableDescriptionToolTip);
+
+
EStructuralFeature myFeature = tableEClass.getEStructuralFeature(TableinstancePackage.TABLE_INSTANCE__DESCRIPTION);
EMFObservableValue observable = new EMFObservableValue(table, myFeature, getEditingDomain());
descriptionEditor.setModelObservable(observable);
@@ -237,34 +316,6 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
descriptionGridData.grabExcessHorizontalSpace = true;
descriptionGridData.horizontalAlignment = SWT.FILL;
descriptionEditor.setLayoutData(descriptionGridData);
-
-
- // the composite owning the table
- final Composite tableComposite = new Composite(editorComposite, SWT.NONE);
- GridLayout tableCompositeGridLayout = new GridLayout(1, true);
- tableComposite.setLayout(tableCompositeGridLayout);
-
- final GridData compositeTableGridLayout = new GridData();
- compositeTableGridLayout.grabExcessHorizontalSpace = true;
- compositeTableGridLayout.grabExcessVerticalSpace = true;
- compositeTableGridLayout.horizontalAlignment = SWT.FILL;
- compositeTableGridLayout.verticalAlignment = SWT.FILL;
- tableComposite.setLayoutData(compositeTableGridLayout);
-
- // the nattable widget itself
- this.natTableWidget = INatTableWidgetFactory.INSTANCE.createNatTableWidget(tableComposite, this, this.tableEditorInput.getPapyrusTableInstance().getTable(), this.menuMgr);
-
-
- final GridData tableGridData = new GridData();
- tableGridData.grabExcessHorizontalSpace = true;
- tableGridData.grabExcessVerticalSpace = true;
- tableGridData.horizontalAlignment = SWT.FILL;
- tableGridData.verticalAlignment = SWT.FILL;
- this.natTableWidget.getComposite().setLayoutData(tableGridData);
-
- getSite().setSelectionProvider(this);
- getSite().registerContextMenu(this.menuMgr, this.natTableWidget);
-
}
@Override
@@ -305,11 +356,18 @@ public class NatTableEditor extends EditorPart implements ISelectionProvider, IE
}
public ISelection getSelection() {
- ISelection selection = this.natTableWidget.getSelection();
- if(selection.isEmpty()) {
- selection = new StructuredSelection(this.tableEditorInput.getPapyrusTableInstance());
+ /*
+ * if nattable has the focus : we retun the nattable selection
+ * if not, we return the papyrus table instance
+ */
+ Control[] children = ((Composite)this.natTableWidget).getChildren();
+ if(children.length!=0){
+ boolean focus = children[0].isFocusControl();
+ if(focus){
+ return this.natTableWidget.getSelection();
+ }
}
- return selection;
+ return new StructuredSelection(this.tableEditorInput.getPapyrusTableInstance());
}
public EditingDomain getEditingDomain() {

Back to the top