Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2013-05-21 14:27:38 +0000
committervlorenzo2013-05-21 14:27:38 +0000
commit1b4e5ff9dd1a9d6e868844d158ef33245e681e63 (patch)
tree146930db5d8b1effb34d58cfefa23d3211debeda /sandbox
parentf4dbd74cdf950e84b865008728376dc71a196fb2 (diff)
downloadorg.eclipse.papyrus-1b4e5ff9dd1a9d6e868844d158ef33245e681e63.tar.gz
org.eclipse.papyrus-1b4e5ff9dd1a9d6e868844d158ef33245e681e63.tar.xz
org.eclipse.papyrus-1b4e5ff9dd1a9d6e868844d158ef33245e681e63.zip
408586: [Table 2] The table must support alias on the axis
https://bugs.eclipse.org/bugs/show_bug.cgi?id=408586
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectAxisManager.java17
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EStructuralFeatureAxisManager.java25
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/provider/EMFFeatureHeaderLabelProvider.java8
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorContextSynchronizerAxisManager.java11
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorFeatureAxisManager.java10
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/rename.gifbin0 -> 922 bytes
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml38
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusHeaderMenuConfiguration.java55
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java128
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java45
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnEditAliasHeaderHandler.java57
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowEditAliasHeaderHandler.java57
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java75
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractSynchronizedOnFeatureAxisManager.java10
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java42
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java33
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java3
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/InputDialogWithLocation.java68
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java3
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java20
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java40
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java4
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties2
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java3
24 files changed, 752 insertions, 2 deletions
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectAxisManager.java
index 1be2012c5bb..dfb68a46eaf 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectAxisManager.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager;
import org.eclipse.papyrus.infra.nattable.messages.Messages;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.NattableaxisFactory;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderPackage;
@@ -130,4 +131,20 @@ public class EObjectAxisManager extends AbstractAxisManager {
return false;
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canEditAxisHeader()
+ *
+ * @return
+ */
+ public boolean canEditAxisHeader() {
+ return false;
+ }
+
+
+ @Override
+ public String getElementAxisName(IAxis axis) {
+ throw new UnsupportedOperationException();
+ }
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EStructuralFeatureAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EStructuralFeatureAxisManager.java
index a722f9a698a..1449c5cdbfc 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EStructuralFeatureAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EStructuralFeatureAxisManager.java
@@ -205,4 +205,29 @@ public class EStructuralFeatureAxisManager extends AbstractAxisManager {
return true;
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canEditAxisHeader()
+ *
+ * @return
+ */
+ public boolean canEditAxisHeader() {
+ return true;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getElementAxisName(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis)
+ *
+ * @param axis
+ * @return
+ */
+ @Override
+ public String getElementAxisName(IAxis axis) {
+ if(axis instanceof EStructuralFeatureAxis) {
+ return ((EStructuralFeatureAxis)axis).getElement().getName();
+ }
+ return null;
+ }
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/provider/EMFFeatureHeaderLabelProvider.java b/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/provider/EMFFeatureHeaderLabelProvider.java
index 27ddbd9e432..647a7ca8520 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/provider/EMFFeatureHeaderLabelProvider.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/provider/EMFFeatureHeaderLabelProvider.java
@@ -143,8 +143,10 @@ public class EMFFeatureHeaderLabelProvider extends EMFEObjectHeaderLabelProvider
public String getText(Object element) {
final Object object = ((ILabelProviderContextElement)element).getObject();
EStructuralFeature feature = null;
+ String alias = "";
if(object instanceof EStructuralFeatureAxis) {
feature = ((EStructuralFeatureAxis)object).getElement();
+ alias = ((EStructuralFeatureAxis)object).getAlias();
} else if(feature instanceof EStructuralFeature) {
feature = (EStructuralFeature)((ILabelProviderContextElement)element).getObject();
}
@@ -158,7 +160,11 @@ public class EMFFeatureHeaderLabelProvider extends EMFEObjectHeaderLabelProvider
return ""; //$NON-NLS-1$
}
if(conf instanceof FeatureLabelProviderConfiguration) {
- return getText((FeatureLabelProviderConfiguration)conf, configRegistry, feature.getName(), feature.getEType(), feature.isDerived(), feature.getLowerBound(), feature.getUpperBound());
+ String nameToDisplay = feature.getName();
+ if(alias != null && !alias.equals("")) {
+ nameToDisplay = alias;
+ }
+ return getText((FeatureLabelProviderConfiguration)conf, configRegistry, nameToDisplay, feature.getEType(), feature.isDerived(), feature.getLowerBound(), feature.getUpperBound());
} else {
return super.getText(element);
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorContextSynchronizerAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorContextSynchronizerAxisManager.java
index 2bdc55b1e39..c93eeae04e0 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorContextSynchronizerAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorContextSynchronizerAxisManager.java
@@ -150,4 +150,15 @@ public class EditorContextSynchronizerAxisManager extends AbstractSynchronizedOn
return elements;
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canEditAxisHeader()
+ *
+ * @return
+ */
+ @Override
+ public boolean canEditAxisHeader() {
+ return false;
+ }
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorFeatureAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorFeatureAxisManager.java
index 9185e81708c..4a5a386e7a9 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorFeatureAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorFeatureAxisManager.java
@@ -43,4 +43,14 @@ public class EditorFeatureAxisManager extends AbstractAxisManager {
return true;
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canEditAxisHeader()
+ *
+ * @return
+ */
+ @Override
+ public boolean canEditAxisHeader() {
+ return true;
+ }
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/rename.gif b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/rename.gif
new file mode 100644
index 00000000000..e6f786eca9a
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/rename.gif
Binary files differ
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml
index 2c02ad85321..a1c8a5cae59 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml
@@ -873,6 +873,44 @@
commandId="org.eclipse.papyrus.infra.nattable.createdestroyrows"
icon="icons/CreateDestroyRow.gif">
</image>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <category
+ description="This category is used for all rows commands"
+ id="org.eclipse.papyrus.infra.nattable.rows.command.category"
+ name="NatTable Rows Catgerory">
+ </category>
+ <category
+ description="This category is used for all columns Commands"
+ id="org.eclipse.papyrus.infra.nattable.columns.command.category"
+ name="NatTable Columns Category">
+ </category>
+ <command
+ categoryId="org.eclipse.papyrus.infra.nattable.columns.command.category"
+ defaultHandler="org.eclipse.papyrus.infra.nattable.handler.ColumnEditAliasHeaderHandler"
+ description="Allows to Edit the name of the column header"
+ id="org.eclipse.papyrus.infra.nattable.edit.column.header"
+ name="Rename Header">
+ </command>
+ <command
+ categoryId="org.eclipse.papyrus.infra.nattable.rows.command.category"
+ defaultHandler="org.eclipse.papyrus.infra.nattable.handler.RowEditAliasHeaderHandler"
+ description="Allows to Edit the name of the row header"
+ id="org.eclipse.papyrus.infra.nattable.edit.row.header"
+ name="Rename Header">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commandImages">
+ <image
+ commandId="org.eclipse.papyrus.infra.nattable.edit.column.header"
+ icon="icons/rename.gif">
+ </image>
+ <image
+ commandId="org.eclipse.papyrus.infra.nattable.edit.row.header"
+ icon="icons/rename.gif">
+ </image>
</extension>
</plugin>
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusHeaderMenuConfiguration.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusHeaderMenuConfiguration.java
new file mode 100644
index 00000000000..ec447728d31
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusHeaderMenuConfiguration.java
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.swt.SWT;
+
+/**
+ * The configuration for the popup to use in the header of the table
+ *
+ * Adapted code from AbstractHeaderMenuConfiguration
+ *
+ * @author vl222926
+ *
+ */
+public class PapyrusHeaderMenuConfiguration extends AbstractUiBindingConfiguration {
+
+ /**
+ * the category used for the column command
+ */
+ public static final String COLUMN_COMMANDS_CATEGORY_ID = "org.eclipse.papyrus.infra.nattable.columns.command.category"; //$NON-NLS-1$
+
+ /**
+ * the category used for the row command
+ */
+ public static final String ROW_COMMANDS_CATEGORY_ID = "org.eclipse.papyrus.infra.nattable.rows.command.category"; //$NON-NLS-1$
+
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.config.IConfiguration#configureUiBindings(org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry)
+ *
+ * @param uiBindingRegistry
+ */
+ @Override
+ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, MouseEventMatcher.RIGHT_BUTTON), new PapyrusPopupMenuAction(COLUMN_COMMANDS_CATEGORY_ID));
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, MouseEventMatcher.RIGHT_BUTTON), new PapyrusPopupMenuAction(ROW_COMMANDS_CATEGORY_ID));
+
+ }
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java
new file mode 100644
index 00000000000..d377ea0c755
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java
@@ -0,0 +1,128 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+/**
+ * PopupAction for Papyrus -> The contents of the popup is builded for each right click and not builded only one time as in NatTable
+ *
+ * @author vl222926
+ *
+ */
+public class PapyrusPopupMenuAction extends PopupMenuAction {
+
+ /** the category of the commands to add to this menu */
+ private final String category;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param categoryId
+ * the category of the commands to add to this menu
+ */
+ public PapyrusPopupMenuAction(final String categoryId) {
+ super(null);//because we create the menu for each run
+ this.category = categoryId;
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction#run(org.eclipse.nebula.widgets.nattable.NatTable,
+ * org.eclipse.swt.events.MouseEvent)
+ *
+ * @param natTable
+ * @param event
+ */
+ public void run(NatTable natTable, MouseEvent event) {
+ //we need to recreate the menu each time (we need to verify for each action if it is enabled or not
+ Menu menu = new Menu(natTable.getShell());
+ buildMenu(menu, event.data);
+ menu.setData(event.data);
+ menu.setVisible(true);
+ }
+
+ /**
+ *
+ * @param popupMenu
+ * @param eventData
+ */
+ private void buildMenu(final Menu popupMenu, final Object eventData) {
+ final Collection<Command> commands = EclipseCommandUtils.getAllExistingCommandsInCategory(category);
+
+ //FIXME : we should use the EclipseContext to transfert the eventData from here to the handler, but currently we can't have dependency on e4 plugins
+ // final IEclipseContext eclipseContext = (IEclipseContext)PlatformUI.getWorkbench().getService(IEclipseContext.class);
+ // eclipseContext.set(AbstractTableHandler.NAT_EVENT_DATA_PARAMETER_ID, eventData);
+
+ for(final Command command : commands) {
+ final IHandler handler = command.getHandler();
+ if(handler == null || !(handler instanceof AbstractHandler)) {
+ continue;
+ }
+ //FIXME : we should use the EclipseContext to transfert the eventData from here to the handler, but currently we can't have dependency on e4 plugins
+ // ((AbstractHandler)handler).setEnabled(eclipseContext);
+ ((AbstractHandler)handler).setEnabled(null);
+ boolean isEnabled = handler.isEnabled();
+
+ if(isEnabled) {
+ MenuItem item = new MenuItem(popupMenu, SWT.PUSH);
+ item.setEnabled(true);
+ item.setImage(EclipseCommandUtils.getCommandIcon(command).createImage());
+ try {
+ item.setText(command.getName());
+ } catch (NotDefinedException e) {
+ Activator.log.error(e);
+ }
+ item.addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ //FIXME : we must be able to give the SelectionEvent to the handler using EclispeContext
+ Map<Object, Object> parameters = Collections.emptyMap();
+ handler.execute(new ExecutionEvent(command, parameters, null, null));
+ } catch (ExecutionException e1) {
+ Activator.log.error(e1);
+ }
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ //nothing do to
+ }
+ });
+ }
+ }
+ }
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
index 1e8763c3617..56b5c80ab5c 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
@@ -14,13 +14,21 @@
package org.eclipse.papyrus.infra.nattable.handler;
import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.infra.nattable.Activator;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
@@ -32,6 +40,9 @@ import org.eclipse.ui.PlatformUI;
*/
public abstract class AbstractTableHandler extends AbstractHandler {
+ /** the id used to find the NatEvent in the EclipseContext */
+ public static final String NAT_EVENT_DATA_PARAMETER_ID = "natEventParameterId";
+
/**
*
* @return
@@ -89,4 +100,38 @@ public abstract class AbstractTableHandler extends AbstractHandler {
return null;
}
+ /**
+ *
+ * @param evaluationContext
+ * the evaluation context
+ * @return
+ * the NatEventData from this evaluation context
+ */
+ protected NatEventData getNatEventData(final Object evaluationContext) {
+ NatEventData eventData = null;
+ if(evaluationContext instanceof IEvaluationContext) {
+ Object value = ((IEvaluationContext)evaluationContext).getVariable(NAT_EVENT_DATA_PARAMETER_ID);
+ if(value instanceof NatEventData) {
+ eventData = (NatEventData)value;
+ }
+ }
+ //FIXME : currently we can't have dependency on org.eclipse.e4....
+ //that's why we can't add the variable NAT_EVENT_DATA_PARAMETER_ID and we need to create a NatEventData instead of to get it in evaluationContext
+ if(eventData == null) {
+ Point cursorLocation = Display.getDefault().getCursorLocation();
+ Control control = Display.getDefault().getCursorControl();
+ if(control instanceof NatTable) {//FIXME : not nice, but required
+ cursorLocation = control.toControl(cursorLocation);
+ Event e = new Event();
+ e.x = cursorLocation.x;
+ e.y = cursorLocation.y;
+ e.display = Display.getDefault();
+ e.widget = control;
+ MouseEvent event = new MouseEvent(e);
+ eventData = NatEventData.createInstanceFromEvent(event);
+ }
+ }
+ return eventData;
+ }
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnEditAliasHeaderHandler.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnEditAliasHeaderHandler.java
new file mode 100644
index 00000000000..ad5123cc8b5
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnEditAliasHeaderHandler.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.papyrus.infra.nattable.manager.table.AbstractNattableWidgetManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
+
+//FIXME : this handler should be declare on org.eclipse.ui.edit (or something like this) to be binded on F2
+
+public class ColumnEditAliasHeaderHandler extends AbstractTableHandler {
+
+ //FIXME : this attribute must be removed when we introduce the dependency on e4.
+ private NatEventData eventData;
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ if(this.eventData != null) {
+ AbstractNattableWidgetManager manager = (AbstractNattableWidgetManager)getCurrentNattableModelManager();
+ manager.openEditColumnAliasDialog(this.eventData);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {//it must be the nattable selection event
+ final NatEventData eventData = getNatEventData(evaluationContext);
+ this.eventData = eventData;
+ final NattableModelManager manager = (NattableModelManager)getCurrentNattableModelManager();
+ if(eventData != null && manager != null) {
+ setBaseEnabled(manager.canEditColumnHeader(eventData));
+ } else {
+ setBaseEnabled(false);
+ }
+ }
+
+
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowEditAliasHeaderHandler.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowEditAliasHeaderHandler.java
new file mode 100644
index 00000000000..0e91f69a74b
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowEditAliasHeaderHandler.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.papyrus.infra.nattable.manager.table.AbstractNattableWidgetManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
+
+//FIXME : this handler should be declare on org.eclipse.ui.edit (or something like this) to be binded on F2
+
+public class RowEditAliasHeaderHandler extends AbstractTableHandler {
+
+ //FIXME : this attribute must be removed when we introduce the dependency on e4.
+ private NatEventData eventData;
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ if(this.eventData != null) {
+ AbstractNattableWidgetManager manager = (AbstractNattableWidgetManager)getCurrentNattableModelManager();
+ manager.openEditRowAliasDialog(this.eventData);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {//it must be the nattable selection event
+ final NatEventData eventData = getNatEventData(evaluationContext);
+ this.eventData = eventData;
+ final NattableModelManager manager = (NattableModelManager)getCurrentNattableModelManager();
+ if(eventData != null && manager != null) {
+ setBaseEnabled(manager.canEditRowHeader(eventData));
+ } else {
+ setBaseEnabled(false);
+ }
+ }
+
+
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java
index 7c6213f1240..9e1c3b95458 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java
@@ -23,6 +23,11 @@ import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
@@ -31,9 +36,16 @@ import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
import org.eclipse.papyrus.infra.nattable.messages.Messages;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.NattableaxisPackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.widgets.editors.InputDialog;
import org.eclipse.papyrus.infra.widgets.providers.IRestrictedContentProvider;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
public abstract class AbstractAxisManager implements IAxisManager {
@@ -336,4 +348,67 @@ public abstract class AbstractAxisManager implements IAxisManager {
public void moveAxis(Object elementToMove, int newIndex) {
}
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#openEditAxisAliasDialog(org.eclipse.nebula.widgets.nattable.ui.NatEventData,
+ * int)
+ *
+ * @param event
+ * @param axisPosition
+ */
+ @Override
+ public void openEditAxisAliasDialog(final NatEventData event, int axisPosition) {
+ final IAxis axis = this.representedContentProvider.getAxis().get(axisPosition);
+ String alias = axis.getAlias();
+ if(alias == null) {
+ alias = ""; //$NON-NLS-1$
+ }
+
+ final String dialogMessage = String.format(Messages.AbstractAxisManager_InputDialogMessage, getElementAxisName(axis));
+ Point location = new Point(event.getOriginalEvent().x, event.getOriginalEvent().y);
+ Control natTable = event.getNatTable();
+ location = natTable.toDisplay(location);
+ final InputDialog dialog = new InputDialogWithLocation(Display.getDefault().getActiveShell(), Messages.AbstractAxisManager_InputDialogTitle, dialogMessage, alias, null, location);
+ int result = dialog.open();
+ if(result == IDialogConstants.OK_ID) {
+ String newAlias = dialog.getText();
+ if("".equals(newAlias)) { //$NON-NLS-1$
+ newAlias = null;
+ }
+ final TransactionalEditingDomain domain = (TransactionalEditingDomain)getTableEditingDomain();
+ final SetRequest request = new SetRequest(domain, axis, NattableaxisPackage.eINSTANCE.getIAxis_Alias(), newAlias);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(axis);
+ final ICommand cmd = provider.getEditCommand(request);
+ domain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+ }
+ }
+
+ /**
+ * This method mustt be overriden by the children classes
+ *
+ * @param axis
+ * an axis
+ * @return
+ * <code>null</code> or an {@link UnsupportedOperationException} when the method {@link #canEditAxisHeader()} returns <code>false</code>
+ */
+ public String getElementAxisName(final IAxis axis) {
+ if(canEditAxisHeader()) {
+ return null;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getAxisManagerRepresentation()
+ *
+ * @return
+ */
+ @Override
+ public AxisManagerRepresentation getAxisManagerRepresentation() {
+ return this.representedAxisManager;
+ }
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractSynchronizedOnFeatureAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractSynchronizedOnFeatureAxisManager.java
index 5cdccd93dd2..d60c8b3905e 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractSynchronizedOnFeatureAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractSynchronizedOnFeatureAxisManager.java
@@ -229,4 +229,14 @@ public abstract class AbstractSynchronizedOnFeatureAxisManager extends AbstractA
return false;
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canEditAxisHeader()
+ *
+ * @return
+ */
+ @Override
+ public boolean canEditAxisHeader() {
+ return false;
+ }
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java
index 8d1111cbfc6..2ec193e262e 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java
@@ -31,9 +31,11 @@ import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.nattable.messages.Messages;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderPackage;
import org.eclipse.papyrus.infra.nattable.utils.AxisComparator;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
@@ -372,4 +374,44 @@ public class CompositeAxisManager extends AbstractAxisManager implements ICompos
};
}
+ @Override
+ public boolean canEditAxisHeader(final NatEventData axisIndex) {
+ axisIndex.getColumnPosition();//FIXME
+ if(canEditAxisHeader()) {//FIXME
+ return true;
+ } else {
+ return false;//FIXME : we need to iterate on the contents to know if it is possible or not
+ }
+ }
+
+ @Override
+ public boolean canEditAxisHeader() {
+ for(final IAxisManager current : this.subManagers) {
+ if(!current.canEditAxisHeader()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getElementAxisName(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis)
+ *
+ * @param axis
+ * @return
+ */
+ public String getElementAxisName(final IAxis axis) {
+ final AxisManagerRepresentation manager = axis.getManager();
+ for(final IAxisManager man : this.subManagers) {
+ if(man.getAxisManagerRepresentation() == manager) {
+ return man.getElementAxisName(axis);
+ }
+ }
+ if(canEditAxisHeader()) {
+ return null;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java
index 24f1f7cb143..071f220432e 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java
@@ -17,8 +17,10 @@ import java.util.Collection;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
import org.eclipse.papyrus.infra.widgets.providers.IRestrictedContentProvider;
@@ -171,5 +173,36 @@ public interface IAxisManager extends IDisposable {
*/
public boolean canCreateAxisElement(final String elementId);
+ /**
+ *
+ * @return
+ * <code>true</code> if we allows to edit the string of all axis headers.
+ */
+ public boolean canEditAxisHeader();
+ /**
+ * Open a dialog to edit the alias of an axis and set the value
+ *
+ * @param event
+ * the event
+ * @param axisIndex
+ * the position of the axis
+ */
+ public void openEditAxisAliasDialog(final NatEventData event, int axisIndex);
+
+ /**
+ *
+ * @return
+ * the axis manager representation
+ */
+ public AxisManagerRepresentation getAxisManagerRepresentation();
+
+ /**
+ *
+ * @param axis
+ * an axis
+ * @return
+ * the name used for this axis
+ */
+ public String getElementAxisName(final IAxis axis);//FIXME pb if the axisManager returns Object and not IAxis...
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java
index 808120e4e9c..829e8a67be0 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.infra.nattable.manager.axis;
import java.util.List;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
/**
@@ -46,4 +47,6 @@ public interface ICompositeAxisManager extends IAxisManager {
*/
public void sortAxisByName(final boolean alpabeticOrder, IConfigRegistry iConfigRegistry);
+ public boolean canEditAxisHeader(NatEventData evaluationContext);
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/InputDialogWithLocation.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/InputDialogWithLocation.java
new file mode 100644
index 00000000000..21ab5b76034
--- /dev/null
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/InputDialogWithLocation.java
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.axis;
+
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.papyrus.infra.widgets.editors.InputDialog;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * The developper can define the location of this input dialog
+ *
+ * @author vl222926
+ *
+ */
+public class InputDialogWithLocation extends InputDialog {
+
+ /**
+ * the location wanted to display the dialog
+ */
+ private Point location;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @see InputDialog#InputDialog(Shell, String, String, String, IInputValidator)
+ * @param parentShell
+ * @param title
+ * @param label
+ * @param initialValue
+ * @param validator
+ * @param dialogLocation
+ * the location to use for the dialog
+ */
+ public InputDialogWithLocation(Shell parentShell, String title, String label, String initialValue, IInputValidator validator, final Point dialogLocation) {
+ super(parentShell, title, label, initialValue, validator);
+ this.location = dialogLocation;
+ }
+
+ @Override
+ public void create() {
+ super.create();
+ //adapted code from AbstractStyleEditorDialog in nattable plugin
+ if(location != null) {
+ if(location.x < getParentShell().getDisplay().getBounds().x) {
+ location.x = getParentShell().getDisplay().getBounds().x;
+ } else if(location.x + getShell().getBounds().width > getParentShell().getDisplay().getBounds().x + getParentShell().getDisplay().getBounds().width) {
+ location.x = getParentShell().getDisplay().getBounds().x + getParentShell().getDisplay().getBounds().width - getShell().getBounds().width;
+ }
+ if(location.y + getShell().getBounds().height > getParentShell().getDisplay().getBounds().y + getParentShell().getDisplay().getBounds().height) {
+ location.y = getParentShell().getDisplay().getBounds().y + getParentShell().getDisplay().getBounds().height - getShell().getBounds().height;
+ }
+ }
+ getShell().setLocation(location);
+ }
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
index 86813ae549e..64da2e92045 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
@@ -56,6 +56,7 @@ import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.infra.nattable.Activator;
import org.eclipse.papyrus.infra.nattable.configuration.CornerConfiguration;
+import org.eclipse.papyrus.infra.nattable.configuration.PapyrusHeaderMenuConfiguration;
import org.eclipse.papyrus.infra.nattable.dataprovider.AbstractDataProvider;
import org.eclipse.papyrus.infra.nattable.dataprovider.BodyDataProvider;
import org.eclipse.papyrus.infra.nattable.dataprovider.ColumnHeaderDataProvider;
@@ -188,7 +189,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
//for the edition
// configureEdition(this.natTable, this.bodyLayerStack);
-
+ this.natTable.addConfiguration(new PapyrusHeaderMenuConfiguration());
this.natTable.addConfiguration(new IConfiguration() {
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
index 533ae53e2de..f933142ba46 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
@@ -19,6 +19,7 @@ import java.util.List;
import org.eclipse.emf.common.command.Command;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
import org.eclipse.papyrus.infra.nattable.layerstack.BodyLayerStack;
import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
@@ -93,6 +94,8 @@ public interface INattableModelManager extends ILimitedNattableModelManager, ITa
public Command getAddColumnElementCommand(Collection<Object> objectsToAdd);
+
+
public void print();
public void selectAll();
@@ -148,4 +151,21 @@ public interface INattableModelManager extends ILimitedNattableModelManager, ITa
public BodyLayerStack getBodyLayerStack();
+ /**
+ * Opens a dialog to edit the alias of the row
+ *
+ * @param event
+ */
+ public void openEditRowAliasDialog(final NatEventData event);
+
+ /**
+ * Opens a dialog to edit the alias of the column
+ *
+ * @param event
+ */
+ public void openEditColumnAliasDialog(final NatEventData event);
+
+ public boolean canEditColumnHeader(final NatEventData eventData);
+
+ public boolean canEditRowHeader(final NatEventData eventData);
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
index fc66798e5f9..af23616733a 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
@@ -40,6 +40,7 @@ import org.eclipse.jface.window.Window;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
@@ -985,8 +986,47 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
}
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#canEditColumnHeader(int)
+ *
+ * @param evaluationContext
+ * @return
+ */
+ public boolean canEditColumnHeader(final NatEventData evaluationContext) {
+ return this.columnManager.canEditAxisHeader(evaluationContext);
+ }
+ /***
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#canEditRowHeader(org.eclipse.nebula.widgets.nattable.ui.NatEventData)
+ *
+ * @param eventData
+ * @return
+ */
+ @Override
+ public boolean canEditRowHeader(NatEventData evaluationContext) {
+ return this.rowManager.canEditAxisHeader(evaluationContext);
+ }
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#openEditRowAliasDialog(org.eclipse.nebula.widgets.nattable.ui.NatEventData)
+ *
+ * @param event
+ */
+ public void openEditRowAliasDialog(NatEventData event) {
+ this.rowManager.openEditAxisAliasDialog(event, event.getNatTable().getRowIndexByPosition(event.getRowPosition()));
+ }
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#openEditColumnAliasDialog(org.eclipse.nebula.widgets.nattable.ui.NatEventData)
+ *
+ * @param event
+ */
+ public void openEditColumnAliasDialog(NatEventData event) {
+ this.columnManager.openEditAxisAliasDialog(event, event.getNatTable().getColumnIndexByPosition(event.getColumnPosition()));
+ }
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java
index c88034418da..e3e98cb6f7f 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java
@@ -21,6 +21,10 @@ public class Messages extends NLS {
public static String CompositeAxisManager_DestroyAxisCommand;
+ public static String AbstractAxisManager_InputDialogMessage;
+
+ public static String AbstractAxisManager_InputDialogTitle;
+
public static String AbstractCreateNattableEditorHandler_EnterTheNameForTheNewTable;
public static String AbstractCreateNattableEditorHandler_PapyrusTableCreation;
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties
index 33ef85db175..cc6af72e69a 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties
+++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties
@@ -1,3 +1,5 @@
+AbstractAxisManager_InputDialogMessage=The real name for the header is: \n\t %s \n \n Alias:
+AbstractAxisManager_InputDialogTitle=Edit Header Alias Dialog
AbstractCreateNattableEditorHandler_EnterTheNameForTheNewTable=Enter the name for the new table
AbstractCreateNattableEditorHandler_PapyrusTableCreation=Papyrus Table Creation
AbstractTableHandler_CurrentEditorCantBeFound=Current Editor can't be found
diff --git a/sandbox/TableV3/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java
index 06136e87b4d..1756c8b4a29 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java
@@ -291,4 +291,7 @@ public class UMLStereotypePropertyAxisManager extends AbstractAxisManager {
return true;
}
+ public boolean canEditAxisHeader() {
+ return true;
+ }
}

Back to the top