Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlink.java11
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlinkEditorShell.java176
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlinkHelper.java11
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java7
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperlinkNavigationMenuEditPolicy.java18
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java7
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/helper/EditorHyperLinkHelper.java9
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/messages/messages.properties4
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/object/HyperLinkEditor.java17
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java10
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/EditorHyperLinkEditorShell.java195
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/EditorLookForEditorShell.java129
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/LocalDefaultLinkDiagramTab.java10
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/.classpath2
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/AbstractHyperLinkHelper.java14
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/CompositeHyperlinkHelper.java8
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/DocumentHyperLinkHelper.java8
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/ObjectHyperLinkHelper.java9
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/WebHyperLinkHelper.java14
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/Messages.java31
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/messages.properties31
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkDocument.java19
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkObject.java7
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkSpecificObject.java9
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkWeb.java19
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractEditHyperlinkDocumentShell.java235
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractEditHyperlinkShell.java207
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractHyperLinkManagerShell.java169
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractHyperLinkTab.java52
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractLookForEditorShell.java212
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/DefaultHyperLinkTab.java163
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkWebShell.java154
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperlinkDocumentShell.java163
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkManagerShell.java127
-rw-r--r--plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkTab.java187
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/EditorHelper.java32
38 files changed, 1002 insertions, 1482 deletions
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlink.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlink.java
index 7af8c23de85..9ff96b6ae59 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlink.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlink.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009, 2015 CEA LIST and others.
+ * Copyright (c) 2009, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -12,6 +12,7 @@
* Christian W. Damus (CEA LIST) - adapted for CDO repository resource hyperlinks
* Christian W. Damus (CEA) - adapt to source-incompatible API change in CDO Luna M6
* Eike Stepper (CEA) - bug 466520
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.ui.hyperlink;
@@ -32,12 +33,14 @@ import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
import org.eclipse.net4j.util.ui.UIUtil;
import org.eclipse.osgi.util.NLS;
import org.eclipse.papyrus.cdo.internal.ui.editors.PapyrusCDOEditorOpener;
import org.eclipse.papyrus.cdo.internal.ui.views.DIResourceQuery;
import org.eclipse.papyrus.infra.hyperlink.Activator;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
@@ -139,10 +142,10 @@ public class CDOResourceHyperlink extends HyperLinkObject {
}
@Override
- public void executeEditMousePressed(List<HyperLinkObject> list, EObject aModel) {
- CDOResourceHyperlinkEditorShell editor = new CDOResourceHyperlinkEditorShell();
+ public void executeEditMousePressed(Shell parentShell, List<HyperLinkObject> list, EObject aModel) {
+ CDOResourceHyperlinkEditorShell editor = new CDOResourceHyperlinkEditorShell(parentShell);
editor.setHyperlink(this);
- if (editor.open()) {
+ if (editor.open() == Window.OK) {
int index = list.indexOf(this);
list.set(index, editor.getHyperlink());
}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlinkEditorShell.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlinkEditorShell.java
index fbc38dc163c..b5e907e2c42 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlinkEditorShell.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlinkEditorShell.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009, 2015 CEA LIST and others.
+ * Copyright (c) 2009, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,6 +11,7 @@
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA LIST) - adapted for CDO repository resource hyperlinks
* Eike Stepper (CEA) - bug 466520
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.ui.hyperlink;
@@ -19,24 +20,27 @@ import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.cdo.internal.ui.dialogs.CheckoutBrowseDialog;
-import org.eclipse.papyrus.infra.hyperlink.ui.AbstractEditHyperlinkDocumentShell;
+import org.eclipse.papyrus.infra.hyperlink.ui.AbstractEditHyperlinkShell;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import com.google.common.base.Objects;
/**
* The editor shell facade for creation and editing of CDO resource hyperlinks.
*/
-public class CDOResourceHyperlinkEditorShell extends AbstractEditHyperlinkDocumentShell {
+public class CDOResourceHyperlinkEditorShell extends AbstractEditHyperlinkShell {
private boolean usedefaultTooltip = true;
private CDOResourceHyperlink hyperlink;
- private boolean okPressed;
+ /**
+ * Instantiates me.
+ */
+ public CDOResourceHyperlinkEditorShell(Shell parentShell) {
+ super(parentShell, true);
+ }
public CDOResourceHyperlink getHyperlink() {
return hyperlink;
@@ -44,118 +48,90 @@ public class CDOResourceHyperlinkEditorShell extends AbstractEditHyperlinkDocume
public void setHyperlink(CDOResourceHyperlink hyperlink) {
this.hyperlink = hyperlink;
-
- getObjectLabeltext().setText(hyperlink.getHyperlink().toString());
- getTooltipInputText().setText(hyperlink.getTooltipText());
-
- usedefaultTooltip = Objects.equal(getObjectLabeltext().getText(), getTooltipInputText().getText());
- getUseDefaultCheckBox().setSelection(usedefaultTooltip);
- getTooltipInputText().setEditable(!usedefaultTooltip);
+ updateFields();
}
- /**
- * Open.
- */
- public boolean open() {
- Display display = Display.getCurrent();
-
- okPressed = false;
-
- // code use to wait for an action from the user
- getEditHyperlinkShell().pack();
- getEditHyperlinkShell().open();
- while (!getEditHyperlinkShell().isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- return okPressed;
- }
-
- /**
- * Instantiates me.
- */
- public CDOResourceHyperlinkEditorShell() {
- super();
-
- createEditHyperlinkShell();
-
+ @Override
+ protected void contentsCreated() {
// intialize "use default" check box
getUseDefaultCheckBox().setSelection(usedefaultTooltip);
- getObjectLabeltext().setEditable(false);
+ getObjectLabelText().setEditable(false);
if (usedefaultTooltip) {
getTooltipInputText().setEditable(false);
- getTooltipInputText().setText(getObjectLabeltext().getText());
+ getTooltipInputText().setText(getObjectLabelText().getText());
}
- // add listener "use default button"
- getUseDefaultCheckBox().addMouseListener(new MouseAdapter() {
-
- @Override
- public void mouseUp(MouseEvent e) {
- usedefaultTooltip = getUseDefaultCheckBox().getSelection();
- if (usedefaultTooltip) {
- getTooltipInputText().setEditable(false);
- getTooltipInputText().setText(getObjectLabeltext().getText());
- } else {
- getTooltipInputText().setEditable(true);
- }
- }
- });
- getChooseDiagramButton().addMouseListener(new MouseAdapter() {
+ updateFields();
+ }
+
+ private void updateFields() {
+ if (hyperlink != null) {
+ if (getObjectLabelText() != null) {
+ getObjectLabelText().setText(hyperlink.getHyperlink().toString());
+ }
+ if (getTooltipInputText() != null) {
+ getTooltipInputText().setText(hyperlink.getTooltipText());
+ }
- @Override
- public void mouseDown(MouseEvent e) {
- CheckoutBrowseDialog browse = new CheckoutBrowseDialog(getEditHyperlinkShell(), Messages.CDOResourceHyperlinkEditorShell_title, Messages.CDOResourceHyperlinkEditorShell_message, null, SWT.OPEN);
- browse.setBlockOnOpen(true);
+ if ((getObjectLabelText() != null) && (getTooltipInputText() != null)) {
+ usedefaultTooltip = Objects.equal(getObjectLabelText().getText(), getTooltipInputText().getText());
+ getUseDefaultCheckBox().setSelection(usedefaultTooltip);
+ getTooltipInputText().setEditable(!usedefaultTooltip);
+ }
+ }
+ }
- String initialURIString = getObjectLabeltext().getText().trim();
- if (!initialURIString.isEmpty()) {
- browse.setInitialURI(URI.createURI(initialURIString));
- }
+ @Override
+ protected void onSearch() {
+ CheckoutBrowseDialog browse = new CheckoutBrowseDialog(getShell(), Messages.CDOResourceHyperlinkEditorShell_title, Messages.CDOResourceHyperlinkEditorShell_message, null, SWT.OPEN);
+ browse.setBlockOnOpen(true);
- // select resource nodes of file or model kind, not folders
- browse.setNodeTypeFilter(EresourcePackage.Literals.CDO_RESOURCE_LEAF);
+ String initialURIString = getObjectLabelText().getText().trim();
+ if (!initialURIString.isEmpty()) {
+ browse.setInitialURI(URI.createURI(initialURIString));
+ }
- if (browse.open() == Window.OK) {
- URI selected = browse.getSelectedURI();
- if (selected != null) {
- getObjectLabeltext().setText(selected.toString());
- }
+ // select resource nodes of file or model kind, not folders
+ browse.setNodeTypeFilter(EresourcePackage.Literals.CDO_RESOURCE_LEAF);
- if (usedefaultTooltip) {
- getTooltipInputText().setText(selected.toString());
- }
- }
+ if (browse.open() == Window.OK) {
+ URI selected = browse.getSelectedURI();
+ if (selected != null) {
+ getObjectLabelText().setText(selected.toString());
}
- });
-
- // listener to cancel
- this.getCancelButton().addMouseListener(new MouseAdapter() {
- @Override
- public void mouseDown(MouseEvent e) {
- hyperlink = null;
- getEditHyperlinkShell().close();
+ if (usedefaultTooltip) {
+ getTooltipInputText().setText(selected.toString());
}
- });
- // listener to click on OK
- this.getOkButton().addMouseListener(new MouseAdapter() {
+ }
+ }
+
+ @Override
+ protected void onUseDefaultTooltip() {
+ usedefaultTooltip = getUseDefaultCheckBox().getSelection();
+ if (usedefaultTooltip) {
+ getTooltipInputText().setEditable(false);
+ getTooltipInputText().setText(getObjectLabelText().getText());
+ } else {
+ getTooltipInputText().setEditable(true);
+ }
+ }
- @Override
- public void mouseDown(MouseEvent e) {
- if (hyperlink == null) {
- hyperlink = new CDOResourceHyperlink();
- }
+ @Override
+ protected void cancelPressed() {
+ hyperlink = null;
+ super.cancelPressed();
+ }
- hyperlink.setHyperlink(URI.createURI(getObjectLabeltext().getText().trim()));
- hyperlink.setTooltipText(getTooltipInputText().getText().trim());
+ @Override
+ protected void okPressed() {
+ if (hyperlink == null) {
+ hyperlink = new CDOResourceHyperlink();
+ }
- okPressed = true;
+ hyperlink.setHyperlink(URI.createURI(getObjectLabelText().getText().trim()));
+ hyperlink.setTooltipText(getTooltipInputText().getText().trim());
- getEditHyperlinkShell().close();
- }
- });
+ super.okPressed();
}
}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlinkHelper.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlinkHelper.java
index 9a2372bbb21..d86702b50ca 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlinkHelper.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.hyperlink/src/org/eclipse/papyrus/cdo/internal/ui/hyperlink/CDOResourceHyperlinkHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011, 2013 CEA LIST and others.
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,6 +10,7 @@
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA LIST) - adapted for CDO repository resource hyperlinks
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
@@ -30,12 +31,14 @@ import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.cdo.internal.ui.views.DIModel;
import org.eclipse.papyrus.infra.core.utils.AdapterUtils;
import org.eclipse.papyrus.infra.hyperlink.helper.AbstractHyperLinkHelper;
import org.eclipse.papyrus.infra.hyperlink.helper.IHyperlinkHelperExtension;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkConstants;
+import org.eclipse.swt.widgets.Shell;
import com.google.common.collect.ImmutableList;
@@ -82,9 +85,9 @@ public class CDOResourceHyperlinkHelper extends AbstractHyperLinkHelper implemen
}
@Override
- public void executeNewMousePressed(List<HyperLinkObject> list, EObject aModel) {
- CDOResourceHyperlinkEditorShell editor = new CDOResourceHyperlinkEditorShell();
- if (editor.open()) {
+ public void executeNewMousePressed(Shell parentShell, List<HyperLinkObject> list, EObject aModel) {
+ CDOResourceHyperlinkEditorShell editor = new CDOResourceHyperlinkEditorShell(parentShell);
+ if (editor.open() == Window.OK) {
list.add(editor.getHyperlink());
}
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java
index 701afe40cbe..f725819ed57 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java
@@ -8,7 +8,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Christian W. Damus - bugs 451230, 485220
+ * Christian W. Damus - bugs 451230, 485220, 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies;
@@ -41,6 +41,8 @@ import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkHelpersRegistrationUtil
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.infra.ui.editorsfactory.IPageIconsRegistry;
import org.eclipse.papyrus.infra.ui.editorsfactory.PageIconsRegistry;
+import org.eclipse.papyrus.infra.ui.util.EditorHelper;
+import org.eclipse.swt.widgets.Shell;
/**
* The Class HyperLinkPopupBarEditPolicy can be applied on edit part to display
@@ -125,7 +127,8 @@ public class HyperLinkPopupBarEditPolicy extends PapyrusPopupBarEditPolicy {
return new Command("Add Hyperlink") {
@Override
public void execute() {
- hyperLinkManagerShell = new HyperLinkManagerShell(getEditorRegistry(), ((IGraphicalEditPart) getHost()).getEditingDomain(), (EModelElement) ((IGraphicalEditPart) getHost()).getNotationView().getElement(),
+ Shell parentShell = EditorHelper.getActiveShell();
+ hyperLinkManagerShell = new HyperLinkManagerShell(parentShell, getEditorRegistry(), ((IGraphicalEditPart) getHost()).getEditingDomain(), (EModelElement) ((IGraphicalEditPart) getHost()).getNotationView().getElement(),
((IGraphicalEditPart) getHost()).getNotationView(), hyperlinkHelperFactory);
hyperLinkManagerShell.setInput(hyperLinkObjectList);
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperlinkNavigationMenuEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperlinkNavigationMenuEditPolicy.java
index 86a5ec70a86..c37014874e5 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperlinkNavigationMenuEditPolicy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperlinkNavigationMenuEditPolicy.java
@@ -8,7 +8,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Christian W. Damus - bugs 451230, 485220
+ * Christian W. Damus - bugs 451230, 485220, 488965
* Shuai Li - Modifications for navigation menu integration
*
*****************************************************************************/
@@ -46,12 +46,16 @@ import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkHelpersRegistrationUtil
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.infra.ui.editorsfactory.IPageIconsRegistry;
import org.eclipse.papyrus.infra.ui.editorsfactory.PageIconsRegistry;
+import org.eclipse.papyrus.infra.ui.util.EditorHelper;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
/**
* The Class HyperlinkNavigationMenuEditPolicy can be applied on edit part to display
* shortcuts on sub-diagrams or to associate hyper-link of files, in addition to the
* tools provided by the Navigation menu.
+ *
+ * @since 2.0
*/
public class HyperlinkNavigationMenuEditPolicy extends NavigationEditPolicy {
@@ -174,14 +178,18 @@ public class HyperlinkNavigationMenuEditPolicy extends NavigationEditPolicy {
public class AddHyperlinkAction extends AbstractHyperlinkAction {
@Override
public void run() {
- hyperLinkManagerShell = new HyperLinkManagerShell(getEditorRegistry(), ((IGraphicalEditPart) getHost()).getEditingDomain(), (EModelElement) ((IGraphicalEditPart) getHost()).getNotationView().getElement(),
+ Shell parentShell = EditorHelper.getActiveShell();
+ hyperLinkManagerShell = new HyperLinkManagerShell(parentShell, getEditorRegistry(), ((IGraphicalEditPart) getHost()).getEditingDomain(), (EModelElement) ((IGraphicalEditPart) getHost()).getNotationView().getElement(),
((IGraphicalEditPart) getHost()).getNotationView(), hyperlinkHelperFactory);
hyperLinkManagerShell.setInput(hyperLinkObjectList);
- // Hide the navigation menu now because the shell is modal
- // destroyViewerContext();
+ // Do this asynchronously because the dialog is modal and we need the menu to disappear
+ parentShell.getDisplay().asyncExec(new Runnable() {
- hyperLinkManagerShell.open();
+ public void run() {
+ hyperLinkManagerShell.open();
+ }
+ });
}
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java
index e82f0960fad..72e40231f41 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java
@@ -11,7 +11,7 @@
* Patrick Tessier (CEA LIST)-modification
* Christian W. Damus (CEA) - bug 421411
* Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Bug 454386
- * Christian W. Damus - bugs 460583, 485220
+ * Christian W. Damus - bugs 460583, 485220, 488965
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies;
@@ -58,6 +58,8 @@ import org.eclipse.papyrus.infra.hyperlink.ui.HyperLinkManagerShell;
import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkHelpersRegistrationUtil;
import org.eclipse.papyrus.infra.ui.editorsfactory.IPageIconsRegistry;
import org.eclipse.papyrus.infra.ui.editorsfactory.PageIconsRegistry;
+import org.eclipse.papyrus.infra.ui.util.EditorHelper;
+import org.eclipse.swt.widgets.Shell;
/**
* This class is used to open a new diagram when the double click is detected.
@@ -308,7 +310,8 @@ public class NavigationEditPolicy extends OpenEditPolicy {
addLinkCommand = new Command("Add Hyperlink") {
@Override
public void execute() {
- HyperLinkManagerShell hyperLinkManagerShell = new HyperLinkManagerShell(createEditorRegistry(), ((IGraphicalEditPart) getHost()).getEditingDomain(),
+ Shell parentShell = EditorHelper.getActiveShell();
+ HyperLinkManagerShell hyperLinkManagerShell = new HyperLinkManagerShell(parentShell, createEditorRegistry(), ((IGraphicalEditPart) getHost()).getEditingDomain(),
(EModelElement) ((IGraphicalEditPart) getHost()).getNotationView().getElement(),
((IGraphicalEditPart) getHost()).getNotationView(), hyperlinkHelperFactory);
hyperLinkManagerShell.setInput(hyperLinkObjectList);
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/helper/EditorHyperLinkHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/helper/EditorHyperLinkHelper.java
index 4208d7d2837..c6fba024da9 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/helper/EditorHyperLinkHelper.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/helper/EditorHyperLinkHelper.java
@@ -9,7 +9,7 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Christian W. Damus (CEA LIST) - implement extension API to support drag-and-drop
- * Christian W. Damus - bug 485220
+ * Christian W. Damus - bugs 485220, 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.hyperlink.helper;
@@ -40,10 +40,13 @@ import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkConstants;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.infra.ui.editorsfactory.IPageIconsRegistry;
+import org.eclipse.swt.widgets.Shell;
/**
*
* The helper for editors
+ *
+ * @since 2.0
*
*/
public class EditorHyperLinkHelper extends AbstractHyperLinkHelper implements IHyperlinkHelperExtension {
@@ -62,7 +65,7 @@ public class EditorHyperLinkHelper extends AbstractHyperLinkHelper implements IH
* @param aModel
*/
@Override
- public void executeNewMousePressed(final List<HyperLinkObject> list, final EObject aModel) {
+ public void executeNewMousePressed(Shell parentShell, final List<HyperLinkObject> list, final EObject aModel) {
IPageIconsRegistry editorRegistry;
try {
editorRegistry = ServiceUtilsForEObject.getInstance().getService(IPageIconsRegistry.class, aModel);
@@ -70,7 +73,7 @@ public class EditorHyperLinkHelper extends AbstractHyperLinkHelper implements IH
Activator.log.error(e);
return;
}
- EditorHyperLinkEditorShell editor = new EditorHyperLinkEditorShell(editorRegistry, aModel);
+ EditorHyperLinkEditorShell editor = new EditorHyperLinkEditorShell(parentShell, editorRegistry, aModel);
editor.open();
if (editor.getHyperLinkEditor() != null) {
list.add(editor.getHyperLinkEditor());
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/messages/messages.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/messages/messages.properties
index d36f735bae0..5d49220db77 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/messages/messages.properties
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/messages/messages.properties
@@ -8,8 +8,8 @@
# Contributors:
# CEA LIST - Initial API and implementation
# Christian W. Damus (CEA LIST) - Consolidate all hyperlink helper contributions into one tab
-# Christian W. Damus - bug 485220
+# Christian W. Damus - bugs 485220, 488965
#
EditorHyperLinkEditorShell_ICanFindTheHyperLinkEditorObject=I can't find the HyperlinkEditorObject for : {0}
-EditorHyperLinkEditorShell_View=View :
+EditorHyperLinkEditorShell_View=View:
EditorHyperLinkHelper_Editor=View
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/object/HyperLinkEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/object/HyperLinkEditor.java
index c0f94624ae4..633ac9eca13 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/object/HyperLinkEditor.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/object/HyperLinkEditor.java
@@ -8,7 +8,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- * Christian W. Damus - bug 485220
+ * Christian W. Damus - bugs 485220, 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.hyperlink.object;
@@ -24,8 +24,12 @@ import org.eclipse.papyrus.infra.gmfdiag.hyperlink.ui.EditorHyperLinkEditorShell
import org.eclipse.papyrus.infra.hyperlink.Activator;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
import org.eclipse.papyrus.infra.ui.editorsfactory.IPageIconsRegistry;
+import org.eclipse.swt.widgets.Shell;
+/**
+ * @since 2.0
+ */
public class HyperLinkEditor extends HyperLinkObject {
@Override
@@ -47,15 +51,8 @@ public class HyperLinkEditor extends HyperLinkObject {
}
}
- /**
- *
- * @see org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject#executeEditMousePressed(java.util.List, org.eclipse.emf.ecore.EObject)
- *
- * @param list
- * @param amodel
- */
@Override
- public void executeEditMousePressed(List<HyperLinkObject> list, EObject amodel) {
+ public void executeEditMousePressed(Shell parentShell, List<HyperLinkObject> list, EObject amodel) {
IPageIconsRegistry editorRegistry;
try {
editorRegistry = ServiceUtilsForEObject.getInstance().getService(IPageIconsRegistry.class, amodel);
@@ -64,7 +61,7 @@ public class HyperLinkEditor extends HyperLinkObject {
return;
}
- EditorHyperLinkEditorShell editor = new EditorHyperLinkEditorShell(editorRegistry, amodel);
+ EditorHyperLinkEditorShell editor = new EditorHyperLinkEditorShell(parentShell, editorRegistry, amodel);
editor.setHyperLinkEditor(this);
editor.open();
if (editor.getHyperLinkEditor() != null) {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java
index 33ff3bfb55f..aa68cc88e94 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009-2011 CEA LIST.
+ * Copyright (c) 2009, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,6 +11,7 @@
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
* Arthur Daussy (Atos) arthur.daussy@atos.net - Bug 363827 - [Improvement] Diagram creation, remember the latest tab chosen
* Vincent Lorenzo (CEA-LIST) Vincent.lorenzo@cea.fr (refactoring of the hyperlink)
+ * Christian W. Damus - bug 488965
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.hyperlink.ui;
@@ -30,6 +31,7 @@ import org.eclipse.papyrus.infra.hyperlink.helper.HyperLinkHelperFactory;
import org.eclipse.papyrus.infra.hyperlink.ui.AbstractHyperLinkTab;
import org.eclipse.papyrus.infra.hyperlink.ui.HyperLinkManagerShell;
import org.eclipse.papyrus.infra.ui.editorsfactory.IPageIconsRegistry;
+import org.eclipse.swt.widgets.Shell;
/**
*
@@ -54,8 +56,8 @@ public class AdvancedHLManager extends HyperLinkManagerShell {
* the view of the uml element
*
*/
- public AdvancedHLManager(IPageIconsRegistry editorFactoryRegistry, TransactionalEditingDomain domain, EModelElement semanticElement, View aview, HyperLinkHelperFactory hyperHelperFactory) {
- super(editorFactoryRegistry, domain, semanticElement, aview, hyperHelperFactory);
+ public AdvancedHLManager(Shell parentShell, IPageIconsRegistry editorFactoryRegistry, TransactionalEditingDomain domain, EModelElement semanticElement, View aview, HyperLinkHelperFactory hyperHelperFactory) {
+ super(parentShell, editorFactoryRegistry, domain, semanticElement, aview, hyperHelperFactory);
}
/**
@@ -112,7 +114,7 @@ public class AdvancedHLManager extends HyperLinkManagerShell {
private LocalDefaultLinkDiagramTab getHeuristicTab() {
int i = 0;
LocalDefaultLinkDiagramTab tab = null;
- for (AbstractHyperLinkTab current : tabList) {
+ for (AbstractHyperLinkTab current : getTabs()) {
if (current instanceof LocalDefaultLinkDiagramTab) {
tab = (LocalDefaultLinkDiagramTab) current;
i++;
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/EditorHyperLinkEditorShell.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/EditorHyperLinkEditorShell.java
index 15ee47a6b54..a99c562a4d8 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/EditorHyperLinkEditorShell.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/EditorHyperLinkEditorShell.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011, 2014 CEA LIST and others.
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,6 +10,7 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 431397
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.hyperlink.ui;
@@ -25,19 +26,19 @@ import org.eclipse.papyrus.infra.gmfdiag.hyperlink.helper.EditorHyperLinkHelper;
import org.eclipse.papyrus.infra.gmfdiag.hyperlink.messages.Messages;
import org.eclipse.papyrus.infra.gmfdiag.hyperlink.object.HyperLinkEditor;
import org.eclipse.papyrus.infra.hyperlink.Activator;
-import org.eclipse.papyrus.infra.hyperlink.ui.AbstractEditHyperlinkDocumentShell;
+import org.eclipse.papyrus.infra.hyperlink.ui.AbstractEditHyperlinkShell;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.infra.ui.editorsfactory.IPageIconsRegistry;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
/**
*
* This shell is used to find the editors
+ *
+ * @since 2.0
*
*/
-public class EditorHyperLinkEditorShell extends AbstractEditHyperlinkDocumentShell {
+public class EditorHyperLinkEditorShell extends AbstractEditHyperlinkShell {
/** The usedefault tooltip. */
protected boolean usedefaultTooltip = true;
@@ -52,23 +53,6 @@ public class EditorHyperLinkEditorShell extends AbstractEditHyperlinkDocumentShe
protected final EObject amodel;
/**
- * Open.
- */
- public void open() {
- Display display = Display.getCurrent();
- // code use to wait for an action from the user
-
- // getEditHyperlinkShell().setBounds(500, 500, 600, 120);
- getEditHyperlinkShell().pack();
- getEditHyperlinkShell().open();
- while (!getEditHyperlinkShell().isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- }
-
- /**
* Instantiates a new editor hyperlink diagram shell.
*
* @param editorFactoryRegistry
@@ -76,89 +60,117 @@ public class EditorHyperLinkEditorShell extends AbstractEditHyperlinkDocumentShe
* @param model
* the model
*/
- public EditorHyperLinkEditorShell(IPageIconsRegistry editorFactoryRegistry, EObject model) {
- super();
+ public EditorHyperLinkEditorShell(Shell parentShell, IPageIconsRegistry editorFactoryRegistry, EObject model) {
+ super(parentShell, true);
+
this.amodel = model;
this.editorRegistry = editorFactoryRegistry;
- createEditHyperlinkShell();
- getObjectcLabel().setText(Messages.EditorHyperLinkEditorShell_View); // TODO : where is it used?
+ }
+
+ @Override
+ protected void contentsCreated() {
+ getObjectLabel().setText(Messages.EditorHyperLinkEditorShell_View); // TODO : where is it used?
+
+ updateFields();
// intialize "use default" check box
getUseDefaultCheckBox().setSelection(usedefaultTooltip);
- getObjectLabeltext().setEditable(false);
+ getObjectLabelText().setEditable(false);
if (usedefaultTooltip) {
getTooltipInputText().setEditable(false);
- getTooltipInputText().setText(getObjectLabeltext().getText());
+ getTooltipInputText().setText(getObjectLabelText().getText());
}
- // add listener "use default button"
- getUseDefaultCheckBox().addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- usedefaultTooltip = getUseDefaultCheckBox().getSelection();
- if (usedefaultTooltip) {
- getTooltipInputText().setEditable(false);
- getTooltipInputText().setText(getObjectLabeltext().getText());
- } else {
- getTooltipInputText().setEditable(true);
+ }
+
+ private void updateFields() {
+ if (hyperLinkEditor != null) {
+ if (getObjectLabelText() != null) {
+ getObjectLabelText().setText(getLabel(hyperLinkEditor.getObject()));
+ }
+ if (getTooltipInputText() != null) {
+ getTooltipInputText().setText(hyperLinkEditor.getTooltipText());
+ if (getTooltipInputText().getText().equals(getObjectLabelText().getText())) {
+ usedefaultTooltip = true;
}
}
- });
+ }
+
+ }
+
+ private String getLabel(Object object) {
+ String result = null;
+
+ // TODO : remove this dependency
+ ILabelProvider labelProvider = null;
+
+ try {
+ try {
+ labelProvider = ServiceUtilsForEObject.getInstance().getServiceRegistry(amodel).getService(LabelProviderService.class).getLabelProvider();
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ labelProvider = new LabelProvider();
+ }
+ result = labelProvider.getText(hyperLinkEditor.getObject());
+ } finally {
+ if (labelProvider != null) {
+ labelProvider.dispose();
+ }
+ }
+
+ return result;
+ }
+ @Override
+ protected void onSearch() {
// launch a new editor to choose or create diagrams
- getChooseDiagramButton().addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- EditorLookForEditorShell editorLookForDiagram = new EditorLookForEditorShell(editorRegistry, amodel);
- editorLookForDiagram.open();
- Object selection = editorLookForDiagram.getSelectedEditor();
- if (selection == null) {// cancelled or no selection
- // nothing to do
- } else {
-
- EditorHyperLinkHelper helper = new EditorHyperLinkHelper();
- hyperLinkEditor = helper.getHyperLinkObjectFor(selection);
- Assert.isNotNull(hyperLinkEditor, NLS.bind(Messages.EditorHyperLinkEditorShell_ICanFindTheHyperLinkEditorObject, selection));
- hyperLinkEditor.setObject(selection);
-
- // TODO : remove this dependency
- ILabelProvider labelProvider;
- try {
- labelProvider = ServiceUtilsForEObject.getInstance().getServiceRegistry(amodel).getService(LabelProviderService.class).getLabelProvider();
- } catch (ServiceException ex) {
- Activator.log.error(ex);
- labelProvider = new LabelProvider();
- }
- getObjectLabeltext().setText(labelProvider.getText(selection));
- if (usedefaultTooltip) {
- getTooltipInputText().setText(getObjectLabeltext().getText());
- }
- }
+ EditorLookForEditorShell editorLookForDiagram = new EditorLookForEditorShell(EditorHyperLinkEditorShell.this, editorRegistry, amodel);
+ editorLookForDiagram.open();
+ Object selection = editorLookForDiagram.getSelectedEditor();
+ if (selection == null) {// cancelled or no selection
+ // nothing to do
+ } else {
+
+ EditorHyperLinkHelper helper = new EditorHyperLinkHelper();
+ hyperLinkEditor = helper.getHyperLinkObjectFor(selection);
+ Assert.isNotNull(hyperLinkEditor, NLS.bind(Messages.EditorHyperLinkEditorShell_ICanFindTheHyperLinkEditorObject, selection));
+ hyperLinkEditor.setObject(selection);
+
+ getObjectLabelText().setText(getLabel(selection));
+ if (usedefaultTooltip) {
+ getTooltipInputText().setText(getObjectLabelText().getText());
}
- });
+ }
+ }
- // listener to cancel
- this.getCancelButton().addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
+ @Override
+ protected void onUseDefaultTooltip() {
+ usedefaultTooltip = getUseDefaultCheckBox().getSelection();
+ if (usedefaultTooltip) {
+ getTooltipInputText().setEditable(false);
+ getTooltipInputText().setText(getObjectLabelText().getText());
+ } else {
+ getTooltipInputText().setEditable(true);
+ }
+ }
+
+ @Override
+ protected void cancelPressed() {
+ hyperLinkEditor = null;
+ super.cancelPressed();
+ }
+
+ @Override
+ protected void okPressed() {
+ if (hyperLinkEditor != null) {
+ hyperLinkEditor.setTooltipText(getTooltipInputText().getText().trim());
+ // if diagram is null, maybe bad selection or other it
+ // return null!
+ if (hyperLinkEditor.getObject() == null) {
hyperLinkEditor = null;
- getEditHyperlinkShell().close();
}
- });
- // listener to click on OK
- this.getOkButton().addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (hyperLinkEditor != null) {
- hyperLinkEditor.setTooltipText(getTooltipInputText().getText().trim());
- // if diagram is null, maybe bad selection or other it
- // return null!
- if (hyperLinkEditor.getObject() == null) {
- hyperLinkEditor = null;
- }
- }
- getEditHyperlinkShell().close();
- }
- });
+ }
+
+ super.okPressed();
}
/**
@@ -177,8 +189,7 @@ public class EditorHyperLinkEditorShell extends AbstractEditHyperlinkDocumentShe
* the hyperLinkEditor to set
*/
public void setHyperLinkEditor(HyperLinkEditor hyperLinkEditor) {
- // TODO
- getTooltipInputText().setText(hyperLinkEditor.getTooltipText());
this.hyperLinkEditor = hyperLinkEditor;
+ updateFields();
}
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/EditorLookForEditorShell.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/EditorLookForEditorShell.java
index e77b706ce2e..ec2caecd0fb 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/EditorLookForEditorShell.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/EditorLookForEditorShell.java
@@ -10,7 +10,7 @@
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 410346
* Christian W. Damus (CEA) - bug 431397
- * Christian W. Damus - bug 485220
+ * Christian W. Damus - bugs 485220, 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.hyperlink.ui;
@@ -24,12 +24,15 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IDisposable;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.window.IShellProvider;
import org.eclipse.papyrus.commands.CreationCommandDescriptor;
import org.eclipse.papyrus.commands.CreationCommandRegistry;
import org.eclipse.papyrus.commands.ICreationCommand;
@@ -57,13 +60,15 @@ import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
-//TODO: Refactor. Remove the diagram creation listener, and use a Dialog (Which is blocker) instead of a Shell
+//TODO: Refactor. Remove the diagram creation listener
+/**
+ * @since 2.0
+ */
public class EditorLookForEditorShell extends AbstractLookForEditorShell {
/** The adapter factory. */
@@ -191,7 +196,19 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
}
+ /**
+ * Instantiates a new editor look for diagram.
+ *
+ * @param editorFactoryRegistry
+ * the editor factory registry
+ * @param amodel
+ * the amodel
+ */
+ public EditorLookForEditorShell(Shell parentShell, IPageIconsRegistry editorFactoryRegistry, EObject amodel) {
+ super(parentShell);
+ this.model = amodel;
+ }
/**
* Instantiates a new editor look for diagram.
@@ -201,30 +218,18 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
* @param amodel
* the amodel
*/
- public EditorLookForEditorShell(IPageIconsRegistry editorFactoryRegistry, EObject amodel) {
- super();
+ public EditorLookForEditorShell(IShellProvider parentShell, IPageIconsRegistry editorFactoryRegistry, EObject amodel) {
+ super(parentShell);
+
this.model = amodel;
- // create the shell
- createLookforShell();
+ }
+
+ @Override
+ protected void contentsCreated() {
// intall tree with uml element
treeViewer = getModeFilteredTree().getViewer();
treeViewer.setUseHashlookup(true);
- // treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory) {
- //
- // @Override
- // public Image getImage(Object object) {
- // //TODO
- // // if(object instanceof PapyrusTableInstance) {
- // // return editorRegistry.getEditorIcon((object));
- // // } else {
- // // return super.getImage(object);
- // // }
- // Image im = super.getImage(object);
- // return im;
- // // return null;
- // }
- // });
ILabelProvider labelProvider;
ServicesRegistry registry = null;
@@ -238,20 +243,20 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
}
treeViewer.setLabelProvider(labelProvider);
+
// treeViewer.setContentProvider(new
// CustomAdapterFactoryContentProvider(adapterFactory));
// treeViewer.setContentProvider(new
// SemanticEMFContentProvider(amodel)); //This content provider will
// only display the selected element, instead of the root element
// FIXME: Use a standard, non-deprecated content
- IHierarchicContentProvider semanticProvider = new TreeViewContentProvider(new EObject[] { EcoreUtil.getRootContainer(amodel) });
+ IHierarchicContentProvider semanticProvider = new TreeViewContentProvider(new EObject[] { EcoreUtil.getRootContainer(model) });
ContainmentBrowseStrategy strategy = new ContainmentBrowseStrategy(semanticProvider);
IGraphicalContentProvider graphicalContentProvider = new EMFGraphicalContentProvider(strategy, model.eResource().getResourceSet(), Activator.PLUGIN_ID + ".editorTreeView");
treeViewer.setContentProvider(graphicalContentProvider);
// treeViewer.setInput(model.eResource());
treeViewer.setInput(registry);
graphicalContentProvider.createAfter(getAfterTreeViewComposite());
- this.setChildrenBackground(getAfterTreeViewComposite(), Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
// install diagramlist
diagramListTreeViewer = getDiagramfilteredTree().getViewer();
@@ -277,7 +282,7 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
menuItem.addSelectionListener(new DiagramCreateListener(desc, null, commandRegistry));
menuItem.setText(desc.getLabel());
}
- getNewDiagrambutton().addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
+ getNewDiagrambutton().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
@@ -286,7 +291,7 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
});
// add listener to remove diagram
- getRemoveDiagrambutton().addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
+ getRemoveDiagrambutton().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
@@ -322,6 +327,13 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
}
});
+ IDoubleClickListener doubleClickHandler = new IDoubleClickListener() {
+
+ public void doubleClick(DoubleClickEvent event) {
+ okPressed();
+ }
+ };
+
// add listener to keep the selected diagram in the list for the model
// view
getModeFilteredTree().getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
@@ -331,6 +343,7 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
refresh(selection);
}
});
+ getModeFilteredTree().getViewer().addDoubleClickListener(doubleClickHandler);
// add listener to keep in mind the selected diagram in the list for the
// view of digram list
@@ -341,36 +354,10 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
refresh(selection);
}
});
-
- // add listener for the button ok, keep the selected diagram
- getOKbutton().addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- if (treeViewer.getContentProvider() instanceof ICommitListener) {
- ((ICommitListener) treeViewer.getContentProvider()).commit(null);
- }
- getLookforShell().close();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- // add listener for the button cancel, remove the value of the selected
- // diagram
- getCancelbutton().addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- setSelectedEditor(null);
- getLookforShell().close();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
+ getDiagramfilteredTree().getViewer().addDoubleClickListener(doubleClickHandler);
// dispose the adapter factory when the shell is closed
- getLookforShell().addDisposeListener(new DisposeListener() {
+ getShell().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
// we created the adapter factory, so we should dispose it
@@ -379,33 +366,27 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
}
}
});
-
}
- /**
- * Open the shell
- */
- public void open() {
- Display display = Display.getCurrent();
- getLookforShell().pack();
- // getLookforShell().setSize(700, 500);
-
- // code use to wait for an action from the user
- getLookforShell().pack();
- // getLookforShell().setBounds(500, 500, 500, 300);
- getLookforShell().open();
- while (!getLookforShell().isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
+ @Override
+ protected void okPressed() {
+ if (treeViewer.getContentProvider() instanceof ICommitListener) {
+ ((ICommitListener) treeViewer.getContentProvider()).commit(null);
}
+ super.okPressed();
+ }
+
+ @Override
+ protected void cancelPressed() {
+ setSelectedEditor(null);
+ super.cancelPressed();
}
+
protected void refresh(Object selectedElement) {
selectedElement = EMFHelper.getEObject(selectedElement);
- Button but = getOKbutton();
+ Button but = getButton(OK);
if (isAValidEditor(selectedElement)) {
- but = getOKbutton();
but.setEnabled(true);
selectedEditor = selectedElement;
} else {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/LocalDefaultLinkDiagramTab.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/LocalDefaultLinkDiagramTab.java
index 50689a10cb8..1eaf43d7140 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/LocalDefaultLinkDiagramTab.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/LocalDefaultLinkDiagramTab.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.hyperlink.ui;
@@ -48,6 +49,8 @@ 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.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
@@ -141,13 +144,14 @@ public class LocalDefaultLinkDiagramTab extends AbstractHyperLinkTab {
}
@Override
- public void init(CTabFolder tabFolder, List<HyperLinkObject> hyperlinkObjects, EObject element) {
+ public void init(TabFolder tabFolder, List<HyperLinkObject> hyperlinkObjects, EObject element) {
super.init(tabFolder, hyperlinkObjects, element);
+
this.semanticElement = element;
// init list of descriptor to fill the table
initLocalNavigableElement();
// associate the composite to the tabfolder
- CTabItem tbtmDefaultsHyperlinks = new CTabItem(tabFolder, SWT.NONE);
+ TabItem tbtmDefaultsHyperlinks = new TabItem(tabFolder, SWT.NONE);
tbtmDefaultsHyperlinks.setText("Hyperlink diagram with Heuristic");
defaultHyperlinkComposite = new Composite(tabFolder, SWT.NONE);
defaultHyperlinkComposite.setLayout(new GridLayout(1, false));
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/.classpath b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/.classpath
index 64c5e31b7a2..eca7bdba8f0 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/.classpath
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/.settings/org.eclipse.jdt.core.prefs
index c585cc455ae..b3aa6d60f94 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/META-INF/MANIFEST.MF b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/META-INF/MANIFEST.MF
index 7a685c377cf..3bc3d9a6715 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/META-INF/MANIFEST.MF
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/META-INF/MANIFEST.MF
@@ -21,4 +21,4 @@ Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.infra.hyperlink.Activator
Bundle-Description: %pluginDescription
Bundle-SymbolicName: org.eclipse.papyrus.infra.hyperlink;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/AbstractHyperLinkHelper.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/AbstractHyperLinkHelper.java
index 00ed44b4892..4a3de8cc502 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/AbstractHyperLinkHelper.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/AbstractHyperLinkHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
@@ -22,6 +23,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
+import org.eclipse.swt.widgets.Shell;
/**
* this class is an abstract helper used to serialize and deserialize a HyperLink Object
@@ -38,7 +40,7 @@ public abstract class AbstractHyperLinkHelper {
* Getter for this{@link #tabid}
*
* @return
- * this{@link #tabid}
+ * this{@link #tabid}
*/
public final String getTabId() {
return this.tabid;
@@ -70,7 +72,7 @@ public abstract class AbstractHyperLinkHelper {
* TODO
*/
// TODO remove this method
- public abstract void executeNewMousePressed(List<HyperLinkObject> list, EObject aModel);
+ public abstract void executeNewMousePressed(Shell parentShell, List<HyperLinkObject> list, EObject aModel);
/**
@@ -84,8 +86,8 @@ public abstract class AbstractHyperLinkHelper {
* @param HyperLinkObject
* the HyperLinkObject to edit
*/
- public void executeEditMousePressed(List<HyperLinkObject> list, HyperLinkObject HyperLinkObject, EObject amodel) {
- HyperLinkObject.executeEditMousePressed(list, amodel);
+ public void executeEditMousePressed(Shell parentShell, List<HyperLinkObject> list, HyperLinkObject hyperLinkObject, EObject amodel) {
+ hyperLinkObject.executeEditMousePressed(parentShell, list, amodel);
}
/**
@@ -96,7 +98,7 @@ public abstract class AbstractHyperLinkHelper {
* the list of HyperLinkObjects
* @return a list of hyperlink object with the same kind
*/
- public abstract List<HyperLinkObject> getFilteredObject(List<HyperLinkObject> HyperLinkObjects);
+ public abstract List<HyperLinkObject> getFilteredObject(List<HyperLinkObject> hyperLinkObjects);
/**
*
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/CompositeHyperlinkHelper.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/CompositeHyperlinkHelper.java
index 75cc7b17f75..7b20a53660e 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/CompositeHyperlinkHelper.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/CompositeHyperlinkHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST and others.
+ * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus - bug 488965
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.helper;
@@ -24,6 +25,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
+import org.eclipse.swt.widgets.Shell;
/**
@@ -63,10 +65,10 @@ public class CompositeHyperlinkHelper extends AbstractHyperLinkHelper {
}
@Override
- public void executeNewMousePressed(List<HyperLinkObject> list, EObject aModel) {
+ public void executeNewMousePressed(Shell parentShell, List<HyperLinkObject> list, EObject aModel) {
if (activeHelper != null) {
final int originalSize = list.size();
- activeHelper.executeNewMousePressed(list, aModel);
+ activeHelper.executeNewMousePressed(parentShell, list, aModel);
// remember the helper that created these hyperlinks; we may need it later
for (int i = originalSize; i < list.size(); i++) {
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/DocumentHyperLinkHelper.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/DocumentHyperLinkHelper.java
index e32d3924752..f40cfc36236 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/DocumentHyperLinkHelper.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/DocumentHyperLinkHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
@@ -29,6 +30,7 @@ import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkDocument;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
import org.eclipse.papyrus.infra.hyperlink.ui.EditorHyperlinkDocumentShell;
import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkConstants;
+import org.eclipse.swt.widgets.Shell;
@@ -74,8 +76,8 @@ public class DocumentHyperLinkHelper extends AbstractHyperLinkHelper {
}
@Override
- public void executeNewMousePressed(List<HyperLinkObject> list, EObject aModel) {
- EditorHyperlinkDocumentShell editor = new EditorHyperlinkDocumentShell();
+ public void executeNewMousePressed(Shell parentShell, List<HyperLinkObject> list, EObject aModel) {
+ EditorHyperlinkDocumentShell editor = new EditorHyperlinkDocumentShell(parentShell);
editor.open();
if (editor.getHyperlinkDocument() != null) {
list.add(editor.getHyperlinkDocument());
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/ObjectHyperLinkHelper.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/ObjectHyperLinkHelper.java
index b04b41b196e..01e438bb80b 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/ObjectHyperLinkHelper.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/ObjectHyperLinkHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Camille Letavernier (camille.letavernier@cea.fr) - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.helper;
@@ -40,7 +41,7 @@ import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog;
import org.eclipse.papyrus.infra.widgets.providers.CompositeContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.ICompositeContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.swt.widgets.Shell;
/**
* An Hyperlink Helper for referencing objects (i.e. specific object within an
@@ -57,7 +58,7 @@ public class ObjectHyperLinkHelper extends AbstractHyperLinkHelper {
}
@Override
- public void executeNewMousePressed(List<HyperLinkObject> list, EObject aModel) {
+ public void executeNewMousePressed(Shell parentShell, List<HyperLinkObject> list, EObject aModel) {
ServicesRegistry servicesRegistry;
LabelProviderService labelProviderService;
ModelSet modelSet;
@@ -75,7 +76,7 @@ public class ObjectHyperLinkHelper extends AbstractHyperLinkHelper {
}
// Create and opens a dialog for page models
- TreeSelectorDialog selectionDialog = new TreeSelectorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ TreeSelectorDialog selectionDialog = new TreeSelectorDialog(parentShell);
selectionDialog.setBlockOnOpen(true);
IHierarchicContentProvider semanticProvider = getContentProvider();
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/WebHyperLinkHelper.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/WebHyperLinkHelper.java
index e263b4dc5c1..26b1a62ecd3 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/WebHyperLinkHelper.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/WebHyperLinkHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.helper;
@@ -28,6 +29,7 @@ import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkWeb;
import org.eclipse.papyrus.infra.hyperlink.ui.EditorHyperLinkWebShell;
import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkConstants;
+import org.eclipse.swt.widgets.Shell;
/**
* this is an helper to manager hyperlink web
@@ -47,8 +49,7 @@ public class WebHyperLinkHelper extends AbstractHyperLinkHelper {
if (eAnnotation.getDetails().get(HyperLinkConstants.HYPERLINK_IS_DEFAULT_NAVIGATION) != null) {
boolean isDefaultNaviagation = Boolean.parseBoolean(eAnnotation.getDetails().get(HyperLinkConstants.HYPERLINK_IS_DEFAULT_NAVIGATION));
hyperLinkWeb.setIsDefault(isDefaultNaviagation);
- }
- else {
+ } else {
hyperLinkWeb.setIsDefault(false);
}
@@ -63,8 +64,7 @@ public class WebHyperLinkHelper extends AbstractHyperLinkHelper {
if (HyperLinkObject instanceof HyperLinkWeb) {
HyperLinkWeb hyperLinkWeb = (HyperLinkWeb) HyperLinkObject;
return new CreateHyperLinkWebCommand(domain, object, hyperLinkWeb.getTooltipText(), hyperLinkWeb.getHyperLinkWeb(), HyperLinkObject.getIsDefault());
- }
- else {
+ } else {
return null;
}
}
@@ -75,8 +75,8 @@ public class WebHyperLinkHelper extends AbstractHyperLinkHelper {
}
@Override
- public void executeNewMousePressed(List<HyperLinkObject> list, EObject aModel) {
- EditorHyperLinkWebShell editor = new EditorHyperLinkWebShell();
+ public void executeNewMousePressed(Shell parentShell, List<HyperLinkObject> list, EObject aModel) {
+ EditorHyperLinkWebShell editor = new EditorHyperLinkWebShell(parentShell);
editor.open();
if (editor.getHyperLinkWeb() != null) {
list.add(editor.getHyperLinkWeb());
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/Messages.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/Messages.java
index 7ce443f8893..99786d555ed 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/Messages.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/Messages.java
@@ -9,7 +9,7 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Christian W. Damus (CEA LIST) - Consolidate all hyperlink helper contributions into one tab
- * Christian W. Damus - bug 485220
+ * Christian W. Damus - bugs 485220, 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.messages;
@@ -20,10 +20,6 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.hyperlink.messages.messages"; //$NON-NLS-1$
- public static String HyperLinkEditorHelpersRegistrationUtil_ICantCreateTheClassForAnHelper;
-
- public static String HyperLinkEditorHelpersRegistrationUtil_NotAnInstanceOf;
-
public static String HyperLinkHelpersRegistrationUtil_ICantCreateTheClassForAnHelper;
public static String HyperLinkHelpersRegistrationUtil_TheHelperWillBeIgnored;
@@ -34,54 +30,36 @@ public class Messages extends NLS {
public static String HyperLinkTabRegistrationUtil_NotAnInstanceOf;
- public static String AbstractEditHyperlinkDocumentShell_Cancel;
-
- public static String AbstractEditHyperlinkDocumentShell_Diagram;
-
public static String AbstractEditHyperlinkDocumentShell_Document;
public static String AbstractEditHyperlinkDocumentShell_EditHyperlink;
public static String AbstractEditHyperlinkDocumentShell_EditionOfAHyperLink;
- public static String AbstractEditHyperlinkDocumentShell_OK;
-
public static String AbstractEditHyperlinkDocumentShell_TooltipText;
public static String AbstractEditHyperlinkDocumentShell_ToolTipText;
public static String AbstractEditHyperlinkDocumentShell_UseDefault;
- public static String AbstractEditHyperlinkShell_Cancel;
-
public static String AbstractEditHyperlinkShell_EditHyperLink;
public static String AbstractEditHyperlinkShell_EditionOfAHyperLink;
public static String AbstractEditHyperlinkShell_object;
- public static String AbstractEditHyperlinkShell_OK;
-
public static String AbstractEditHyperlinkShell_ToolTipText;
public static String AbstractEditHyperlinkShell_ToolTipText_;
public static String AbstractEditHyperlinkShell_UseDefault;
- public static String AbstractHyperLinkManagerShell_Cancel;
-
public static String AbstractHyperLinkManagerShell_HyperLink;
- public static String AbstractHyperLinkManagerShell_OK;
-
- public static String AbstractLookForEditorShell_Cancel;
-
public static String AbstractLookForEditorShell_EditorsList;
public static String AbstractLookForEditorShell_New;
- public static String AbstractLookForEditorShell_OK;
-
public static String AbstractLookForEditorShell_Remove;
public static String AbstractLookForEditorShell_TreeView;
@@ -106,12 +84,6 @@ public class Messages extends NLS {
public static String HyperLinkManagerShell_InputOutputException;
public static String HyperLinkTab_addTooltip;
- public static String HyperLinkTab_Hyperlink;
-
- public static String HyperLinkTab_Hyperlinks;
-
- public static String HyperLinkTab_hyperLinks;
-
public static String HyperLinkTab_title;
public static String HyperLinkTab_Listof;
@@ -125,7 +97,6 @@ public class Messages extends NLS {
public static String HyperLinkHelperFactory_ImpossibleToFindACommandToSerialize;
public static String WebHyperLinkHelper_Web;
- public static String HyperLinkDocument_ExternalFiles;
static {
// initialize resource bundle
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/messages.properties b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/messages.properties
index 3b8138bee92..9ae1b8c0974 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/messages.properties
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/messages.properties
@@ -8,55 +8,41 @@
# Contributors:
# CEA LIST - Initial API and implementation
# Christian W. Damus (CEA LIST) - Consolidate all hyperlink helper contributions into one tab
-# Christian W. Damus - bug 485220
+# Christian W. Damus - bugs 485220, 488965
-HyperLinkEditorHelpersRegistrationUtil_ICantCreateTheClassForAnHelper=I can't create the class for an helper
-HyperLinkEditorHelpersRegistrationUtil_NotAnInstanceOf={0} is not an instanceof {1}
HyperLinkHelpersRegistrationUtil_ICantCreateTheClassForAnHelper=I can't create the class for an helper
HyperLinkHelpersRegistrationUtil_TheHelperWillBeIgnored=The helper {0} will be ignored because I can't read its position
HyperLinkTabRegistrationUtil_ICantCreateTheTab=I can't create the class for a tab
HyperLinkTabRegistrationUtil_tabWillBeIgnored=The tab {0} will be ignored because I can't read its position
HyperLinkTabRegistrationUtil_NotAnInstanceOf=The class {0} is not an instance of {1}.
-AbstractEditHyperlinkDocumentShell_Cancel=Cancel
-AbstractEditHyperlinkDocumentShell_Diagram=Diagram
AbstractEditHyperlinkDocumentShell_Document=Document:
AbstractEditHyperlinkDocumentShell_EditHyperlink=Edit Hyperlink
AbstractEditHyperlinkDocumentShell_EditionOfAHyperLink=Edition of a hyperlink
-AbstractEditHyperlinkDocumentShell_OK=Ok
AbstractEditHyperlinkDocumentShell_TooltipText=Tooltip text:
AbstractEditHyperlinkDocumentShell_ToolTipText=Tooltip text
AbstractEditHyperlinkDocumentShell_UseDefault=Use default Tooltip
-AbstractEditHyperlinkShell_Cancel=Cancel
AbstractEditHyperlinkShell_EditHyperLink=Edit Hyperlink
AbstractEditHyperlinkShell_EditionOfAHyperLink=Edition of a hyperlink
AbstractEditHyperlinkShell_object=object
-AbstractEditHyperlinkShell_OK=Ok
AbstractEditHyperlinkShell_ToolTipText=Tooltip text:
AbstractEditHyperlinkShell_ToolTipText_=Tooltip text
AbstractEditHyperlinkShell_UseDefault=Use Default Tooltip
-AbstractHyperLinkManagerShell_Cancel=Cancel
-AbstractHyperLinkManagerShell_HyperLink=HyperLink
-AbstractHyperLinkManagerShell_OK=Ok
-AbstractLookForEditorShell_Cancel=Cancel
-AbstractLookForEditorShell_EditorsList=Editors list
+AbstractHyperLinkManagerShell_HyperLink=Manage Hyperlinks
+AbstractLookForEditorShell_EditorsList=Editor list
AbstractLookForEditorShell_New=New
-AbstractLookForEditorShell_OK=OK
AbstractLookForEditorShell_Remove=Remove
AbstractLookForEditorShell_TreeView=Tree view
-DefaultHyperLinkTab_DefaultHyperlinks=Defaults HyperLinks
-DefaultHyperLinkTab_DefaultHyperLinks=Default Hyperlinks (by double-click):
-DefaultHyperLinkTab_HyperLinks=HyperLinks :
+DefaultHyperLinkTab_DefaultHyperlinks=Default Hyperlinks
+DefaultHyperLinkTab_DefaultHyperLinks=Default hyperlinks (by double-click):
+DefaultHyperLinkTab_HyperLinks=Available hyperlinks:
DiagramNavigationDialog_ChooseHyperLinks=Choose hyperlink:
DiagramNavigationDialog_WhichHyperLinksWouldYouToNavigateTo=Which hyperlinks would you like to navigate to?
EditorHyperlinkDocumentShell_Open=Open
-EditorHyperLinkWebShell_Hyperlinks=Hyperlinks:
-HyperLinkManagerShell_HyperLinksCommands=HyperLinks Commands
+EditorHyperLinkWebShell_Hyperlinks=Hyperlink:
+HyperLinkManagerShell_HyperLinksCommands=Hyperlinks Commands
HyperLinkManagerShell_ImpossibleToReadPreferences=Impossible to read preferences
HyperLinkManagerShell_InputOutputException=input/ouput exception
HyperLinkTab_addTooltip=Create a {0} hyperlink
-HyperLinkTab_Hyperlink=\ hyperlinks:
-HyperLinkTab_hyperLinks=\ hyperlinks
-HyperLinkTab_Hyperlinks=hyperlinks
HyperLinkTab_title=Hyperlinks
HyperLinkTab_Listof=List of hyperlinks:
HyperLinkTab_SetOf=List of hyperlinks
@@ -64,4 +50,3 @@ DocumentHyperLinkHelper_Document=Document in local filesystem
HyperLinkHelperFactory_addHyperLinksCommand=Add hyperlinks command
HyperLinkHelperFactory_ImpossibleToFindACommandToSerialize=Impossible to find a command to serialize
WebHyperLinkHelper_Web=Web
-HyperLinkDocument_ExternalFiles=External Files
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkDocument.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkDocument.java
index 6b52450caee..fd2d135eb22 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkDocument.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkDocument.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
+ * Copyright (c) 2009, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.object;
@@ -23,6 +24,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.infra.hyperlink.Activator;
import org.eclipse.papyrus.infra.hyperlink.ui.EditorHyperlinkDocumentShell;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
@@ -62,7 +64,7 @@ public class HyperLinkDocument extends HyperLinkObject {
super.setObject(relativeURI.toString());
} catch (Exception e) {
Activator.log.error(e);
- super.setObject("");
+ super.setObject(""); //$NON-NLS-1$
}
}
@@ -87,14 +89,15 @@ public class HyperLinkDocument extends HyperLinkObject {
}
@Override
- public void executeEditMousePressed(List<HyperLinkObject> list, EObject amodel) {
- EditorHyperlinkDocumentShell editor = new EditorHyperlinkDocumentShell();
+ public void executeEditMousePressed(Shell parentShell, List<HyperLinkObject> list, EObject amodel) {
+ EditorHyperlinkDocumentShell editor = new EditorHyperlinkDocumentShell(parentShell);
editor.setHyperlinkDocument(this);
editor.open();
- int index = list.indexOf(this);
- list.remove(this);
- list.add(index, editor.getHyperlinkDocument());
-
+ if (editor.getHyperlinkDocument() != null) {
+ int index = list.indexOf(this);
+ list.remove(this);
+ list.add(index, editor.getHyperlinkDocument());
+ }
}
@Override
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkObject.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkObject.java
index 2d96fb8daf0..e4d3417dda2 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkObject.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkObject.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.object;
@@ -16,6 +17,7 @@ package org.eclipse.papyrus.infra.hyperlink.object;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.swt.widgets.Shell;
/**
@@ -96,8 +98,9 @@ public abstract class HyperLinkObject {
* of hyperlink that are containted by a graphical element
* @param amodel
* the top package root element
+ * @since 2.0
*/
- public abstract void executeEditMousePressed(List<HyperLinkObject> list, EObject amodel);
+ public abstract void executeEditMousePressed(Shell parentShell, List<HyperLinkObject> list, EObject amodel);
/**
* Tells whether openLink() should be called within an EMF command
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkSpecificObject.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkSpecificObject.java
index 9728c59aed1..6f0ec440731 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkSpecificObject.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkSpecificObject.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Camille Letavernier (camille.letavernier@cea.fr) - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.object;
@@ -20,6 +21,7 @@ import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.emf.Activator;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.infra.services.openelement.service.OpenElementService;
+import org.eclipse.swt.widgets.Shell;
/**
* References a specific object in a View (Diagram/Table/...)
@@ -40,9 +42,8 @@ public class HyperLinkSpecificObject extends HyperLinkObject {
}
@Override
- public void executeEditMousePressed(List<HyperLinkObject> list, EObject amodel) {
- // TODO Auto-generated method stub
- // Edit the hyperlink
+ public void executeEditMousePressed(Shell parentShell, List<HyperLinkObject> list, EObject amodel) {
+ throw new UnsupportedOperationException("Object links are not editable"); //$NON-NLS-1$
}
public void setTargetElement(EObject targetElement) {
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkWeb.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkWeb.java
index 8bf354142df..0038de3a452 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkWeb.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkWeb.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.object;
@@ -19,6 +20,7 @@ import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.infra.hyperlink.Activator;
import org.eclipse.papyrus.infra.hyperlink.ui.EditorHyperLinkWebShell;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
@@ -29,12 +31,10 @@ import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
public class HyperLinkWeb extends HyperLinkObject {
public String getHyperLinkWeb() {
- // TODO Auto-generated method stub
return (String) super.getObject();
}
public void setHyperLinkWeb(String object) {
- // TODO Auto-generated method stub
super.setObject(object);
}
@@ -50,14 +50,15 @@ public class HyperLinkWeb extends HyperLinkObject {
}
@Override
- public void executeEditMousePressed(List<HyperLinkObject> list, EObject amodel) {
- EditorHyperLinkWebShell editor = new EditorHyperLinkWebShell();
+ public void executeEditMousePressed(Shell parentShell, List<HyperLinkObject> list, EObject amodel) {
+ EditorHyperLinkWebShell editor = new EditorHyperLinkWebShell(parentShell);
editor.setHyperLinkWeb(this);
editor.open();
- int index = list.indexOf(this);
- list.remove(this);
- list.add(index, editor.getHyperLinkWeb());
-
+ if (editor.getHyperLinkWeb() != null) {
+ int index = list.indexOf(this);
+ list.remove(this);
+ list.add(index, editor.getHyperLinkWeb());
+ }
}
@Override
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractEditHyperlinkDocumentShell.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractEditHyperlinkDocumentShell.java
deleted file mode 100644
index 6d9d3bb3057..00000000000
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractEditHyperlinkDocumentShell.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.hyperlink.ui;
-
-import org.eclipse.papyrus.infra.hyperlink.Activator;
-import org.eclipse.papyrus.infra.hyperlink.messages.Messages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-
-// TODO: Auto-generated Javadoc
-/**
- * The Class AbstractEditHyperlinkDocumentShell. This Class has been generated
- * from VisualEditor. Do not modify it manually by adding behavior! you will
- * lose the capacity to open with VE. So this class is abstract and it contains
- * set of getter in order to connect behavior in subclasses
- */
-public class AbstractEditHyperlinkDocumentShell {
-
- /** The Constant OBJECT_LABEL. */
- // @unused
- protected static final String OBJECT_LABEL = Messages.AbstractEditHyperlinkDocumentShell_Diagram;
-
- /** The edit hyperlink shell. */
- private Shell editHyperlinkShell = null; // @jve:decl-index=0:visual-constraint="44,36"
-
- /** The Ok button. */
- private Button OkButton = null;
-
- /** The cancel button. */
- private Button cancelButton = null;
-
- /** The tooltip input text. */
- private Text tooltipInputText = null;
-
- /** The tooltip input label. */
- private CLabel tooltipInputLabel = null;
-
- /** The Object labeltext. */
- private Text ObjectLabeltext = null;
-
- /** The Objectc label. */
- private CLabel ObjectcLabel = null;
-
- /** The choose diagram button. */
- private Button chooseDiagramButton = null;
-
- /** The use defaultcheck box. */
- private Button useDefaultcheckBox = null;
-
- /**
- * This method initializes editHyperlinkShell.
- */
- protected void createEditHyperlinkShell() {
- GridData gridData51 = new GridData();
- gridData51.horizontalAlignment = GridData.FILL;
- gridData51.verticalAlignment = GridData.CENTER;
- GridData gridData3 = new GridData();
- gridData3.grabExcessHorizontalSpace = true;
- gridData3.verticalAlignment = GridData.CENTER;
- gridData3.horizontalAlignment = GridData.FILL;
- GridData gridData2 = new GridData();
- gridData2.grabExcessHorizontalSpace = true;
- gridData2.verticalAlignment = GridData.CENTER;
- gridData2.horizontalAlignment = GridData.FILL;
- GridData gridData1 = new GridData();
- gridData1.verticalAlignment = GridData.CENTER;
- gridData1.grabExcessHorizontalSpace = true;
- gridData1.grabExcessVerticalSpace = false;
- gridData1.horizontalSpan = 5;
- gridData1.horizontalAlignment = GridData.FILL;
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.CENTER;
- gridData.horizontalSpan = 5;
- gridData.grabExcessHorizontalSpace = true;
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 7;
- gridLayout.makeColumnsEqualWidth = true;
- // this line has to be commented in order to open with VISUAL EDITOR
- editHyperlinkShell = new Shell(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.DIALOG_TRIM | SWT.RESIZE);
-
- // editHyperlinkShell = new Shell();
- editHyperlinkShell.setText(Messages.AbstractEditHyperlinkDocumentShell_EditHyperlink);
- editHyperlinkShell.setToolTipText(Messages.AbstractEditHyperlinkDocumentShell_EditionOfAHyperLink);
- editHyperlinkShell.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- editHyperlinkShell.setLayout(gridLayout);
- // editHyperlinkShell.setSize(new Point(625, 119));
- ObjectcLabel = new CLabel(editHyperlinkShell, SWT.NONE);
- ObjectcLabel.setText(Messages.AbstractEditHyperlinkDocumentShell_Document);
- ObjectcLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- ObjectLabeltext = new Text(getEditHyperlinkShell(), SWT.BORDER);
- ObjectLabeltext.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- ObjectLabeltext.setEditable(true);
- ObjectLabeltext.setLayoutData(gridData1);
- chooseDiagramButton = new Button(getEditHyperlinkShell(), SWT.NONE);
- chooseDiagramButton.setImage(Activator.getDefault().getIcon(Activator.IMG_LOUPE));
- chooseDiagramButton.setLayoutData(gridData51);
- chooseDiagramButton.setText(""); //$NON-NLS-1$
- tooltipInputLabel = new CLabel(editHyperlinkShell, SWT.NONE);
- tooltipInputLabel.setText(Messages.AbstractEditHyperlinkDocumentShell_TooltipText);
- tooltipInputLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- tooltipInputLabel.setToolTipText(Messages.AbstractEditHyperlinkDocumentShell_ToolTipText);
- tooltipInputText = new Text(getEditHyperlinkShell(), SWT.BORDER);
- tooltipInputText.setLayoutData(gridData);
- useDefaultcheckBox = new Button(getEditHyperlinkShell(), SWT.CHECK);
- useDefaultcheckBox.setText(Messages.AbstractEditHyperlinkDocumentShell_UseDefault);
- useDefaultcheckBox.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- new Label(editHyperlinkShell, SWT.NONE);
- new Label(getEditHyperlinkShell(), SWT.NONE);
- new Label(editHyperlinkShell, SWT.NONE);
- new Label(editHyperlinkShell, SWT.NONE);
- new Label(getEditHyperlinkShell(), SWT.NONE);
- OkButton = new Button(getEditHyperlinkShell(), SWT.NONE);
- OkButton.setText(Messages.AbstractEditHyperlinkDocumentShell_OK);
- OkButton.setLayoutData(gridData2);
- cancelButton = new Button(getEditHyperlinkShell(), SWT.NONE);
- cancelButton.setText(Messages.AbstractEditHyperlinkDocumentShell_Cancel);
- cancelButton.setLayoutData(gridData3);
-
- editHyperlinkShell.pack();
- }
-
- /**
- * Gets the edit hyperlink shell.
- *
- * @return the editHyperlinkShell
- */
- protected Shell getEditHyperlinkShell() {
- return editHyperlinkShell;
- }
-
- /**
- * Gets the ok button.
- *
- * @return the okButton
- */
- protected Button getOkButton() {
- return OkButton;
- }
-
- /**
- * Gets the cancel button.
- *
- * @return the cancelButton
- */
- protected Button getCancelButton() {
- return cancelButton;
- }
-
- /**
- * Gets the tooltip input text.
- *
- * @return the tooltipInputText
- */
- protected Text getTooltipInputText() {
- return tooltipInputText;
- }
-
- /**
- * Gets the object labeltext.
- *
- * @return the objectLabeltext
- */
- protected Text getObjectLabeltext() {
- return ObjectLabeltext;
- }
-
- /**
- * Gets the choose diagram button.
- *
- * @return the chooseDiagramButton
- */
- protected Button getChooseDiagramButton() {
- return chooseDiagramButton;
- }
-
- /**
- * Gets the tooltip input label.
- *
- * @return the tooltipInputLabel
- */
- // @unused
- protected CLabel getTooltipInputLabel() {
- return tooltipInputLabel;
- }
-
- /**
- * Gets the objectc label.
- *
- * @return the objectcLabel
- */
- protected CLabel getObjectcLabel() {
- return ObjectcLabel;
- }
-
- /**
- * Gets the use default check box.
- *
- * @return the useDefaultcheckBox
- */
- protected Button getUseDefaultCheckBox() {
- return useDefaultcheckBox;
- }
-
- /**
- * Sets the cancel button.
- *
- * @param cancelButton
- * the cancelButton to set
- */
- // @unused
- protected void setCancelButton(Button cancelButton) {
- this.cancelButton = cancelButton;
- }
-
-}
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractEditHyperlinkShell.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractEditHyperlinkShell.java
index bcfcc316c4a..5ff6968fa1a 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractEditHyperlinkShell.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractEditHyperlinkShell.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
+ * Copyright (c) 2009, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,42 +9,35 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.ui;
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.papyrus.infra.hyperlink.Activator;
import org.eclipse.papyrus.infra.hyperlink.messages.Messages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
/**
- * The Class EditHyperlinkShell. This Class has been generated from
- * VisualEditor. Do not modify it manually by adding behavior! you will lose the
- * capacity to open with VE. So this class is abstract and it contains set of
- * getter in order to connect behavior in subclasses
+ * Abstract superclass of the dialog presented for creation of a new hyperlink.
*/
-public abstract class AbstractEditHyperlinkShell {
+public abstract class AbstractEditHyperlinkShell extends TrayDialog {
/** The Constant OBJECT_LABEL. */
protected static final String OBJECT_LABEL = Messages.AbstractEditHyperlinkShell_object;
- /** The edit hyperlink shell. */
- private Shell editHyperlinkShell = null; // @jve:decl-index=0:visual-constraint="12,45"
-
- /** The Ok button. */
- private Button OkButton = null;
-
- /** The cancel button. */
- private Button cancelButton = null;
-
/** The tooltip input text. */
private Text tooltipInputText = null;
@@ -52,17 +45,51 @@ public abstract class AbstractEditHyperlinkShell {
private CLabel tooltipInputLabel = null;
/** The Object labeltext. */
- private Text ObjectLabeltext = null;
+ private Text objectLabeltext = null;
/** The Objectc label. */
- private CLabel ObjectcLabel = null;
+ private CLabel objectLabel = null;
private Button useDefaultCheckBox = null;
+ /** The search button. */
+ private Button searchButton = null;
+
+ private boolean hasSearchButton;
+
+ /**
+ * @since 2.0
+ */
+ protected AbstractEditHyperlinkShell(Shell shell, boolean hasSearchButton) {
+ super(shell);
+
+ this.hasSearchButton = hasSearchButton;
+ }
+
/**
- * This method initializes editHyperlinkShell.
+ * @since 2.0
*/
- protected void createEditHyperlinkShell() {
+ protected AbstractEditHyperlinkShell(IShellProvider shellProvider, boolean hasSearchButton) {
+ super(shellProvider);
+
+ this.hasSearchButton = hasSearchButton;
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+
+ newShell.setText(Messages.AbstractEditHyperlinkShell_EditHyperLink);
+ newShell.setToolTipText(Messages.AbstractEditHyperlinkShell_EditionOfAHyperLink);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite result = (Composite) super.createDialogArea(parent);
+
+ GridData gridData51 = new GridData();
+ gridData51.horizontalAlignment = GridData.FILL;
+ gridData51.verticalAlignment = GridData.CENTER;
GridData gridData3 = new GridData();
gridData3.grabExcessHorizontalSpace = true;
gridData3.verticalAlignment = GridData.CENTER;
@@ -72,8 +99,8 @@ public abstract class AbstractEditHyperlinkShell {
gridData2.verticalAlignment = GridData.CENTER;
gridData2.horizontalAlignment = GridData.FILL;
GridData gridData1 = new GridData();
- gridData1.horizontalSpan = 6;
- gridData1.verticalAlignment = GridData.FILL;
+ gridData1.horizontalSpan = hasSearchButton ? 5 : 6;
+ gridData1.verticalAlignment = GridData.CENTER;
gridData1.grabExcessHorizontalSpace = true;
gridData1.grabExcessVerticalSpace = false;
gridData1.horizontalAlignment = GridData.FILL;
@@ -86,104 +113,104 @@ public abstract class AbstractEditHyperlinkShell {
gridLayout.numColumns = 7;
gridLayout.makeColumnsEqualWidth = true;
- // this line has to be commented in order to open with VISUAL EDITOR
- editHyperlinkShell = new Shell(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL);
-
- // editHyperlinkShell = new Shell(display, SWT.DIALOG_TRIM |
- // SWT.APPLICATION_MODAL);
-
- // editHyperlinkShell = new Shell();
- editHyperlinkShell.setText(Messages.AbstractEditHyperlinkShell_EditHyperLink);
- editHyperlinkShell.setToolTipText(Messages.AbstractEditHyperlinkShell_EditionOfAHyperLink);
- editHyperlinkShell.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- editHyperlinkShell.setLayout(gridLayout);
- // editHyperlinkShell.setSize(new Point(601, 119));
- ObjectcLabel = new CLabel(editHyperlinkShell, SWT.NONE);
- ObjectcLabel.setText(OBJECT_LABEL);
- ObjectcLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- ObjectLabeltext = new Text(editHyperlinkShell, SWT.BORDER);
- ObjectLabeltext.setLayoutData(gridData1);
- tooltipInputLabel = new CLabel(editHyperlinkShell, SWT.NONE);
+ result.setLayout(gridLayout);
+
+ objectLabel = new CLabel(result, SWT.NONE);
+ objectLabel.setText(OBJECT_LABEL);
+ objectLabeltext = new Text(result, SWT.BORDER);
+ objectLabeltext.setLayoutData(gridData1);
+
+ if (hasSearchButton) {
+ searchButton = new Button(result, SWT.PUSH);
+ searchButton.setImage(Activator.getDefault().getIcon(Activator.IMG_LOUPE));
+ searchButton.setLayoutData(gridData51);
+ searchButton.setText(""); //$NON-NLS-1$
+ searchButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ onSearch();
+ }
+ });
+ }
+
+ tooltipInputLabel = new CLabel(result, SWT.NONE);
tooltipInputLabel.setText(Messages.AbstractEditHyperlinkShell_ToolTipText);
- tooltipInputLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
tooltipInputLabel.setToolTipText(Messages.AbstractEditHyperlinkShell_ToolTipText_);
- tooltipInputText = new Text(editHyperlinkShell, SWT.BORDER);
+ tooltipInputText = new Text(result, SWT.BORDER);
tooltipInputText.setLayoutData(gridData);
- useDefaultCheckBox = new Button(getEditHyperlinkShell(), SWT.CHECK);
+
+ useDefaultCheckBox = new Button(result, SWT.CHECK);
useDefaultCheckBox.setText(Messages.AbstractEditHyperlinkShell_UseDefault);
- useDefaultCheckBox.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- new Label(editHyperlinkShell, SWT.NONE);
- new Label(editHyperlinkShell, SWT.NONE);
- new Label(editHyperlinkShell, SWT.NONE);
- new Label(editHyperlinkShell, SWT.NONE);
- new Label(getEditHyperlinkShell(), SWT.NONE);
- OkButton = new Button(getEditHyperlinkShell(), SWT.NONE);
- OkButton.setText(Messages.AbstractEditHyperlinkShell_OK);
- OkButton.setLayoutData(gridData2);
- cancelButton = new Button(getEditHyperlinkShell(), SWT.NONE);
- cancelButton.setText(Messages.AbstractEditHyperlinkShell_Cancel);
- cancelButton.setLayoutData(gridData3);
-
- editHyperlinkShell.pack();
+ useDefaultCheckBox.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ onUseDefaultTooltip();
+ }
+ });
+
+ contentsCreated();
+
+ return result;
}
/**
- * Gets the edit hyperlink shell.
- *
- * @return the editHyperlinkShell
+ * Hook that subclasses may override to handle the creation of the dialog contents.
+ *
+ * @since 2.0
*/
- public Shell getEditHyperlinkShell() {
- return editHyperlinkShell;
+ protected void contentsCreated() {
+ // Pass
}
/**
- * Gets the ok button.
+ * Gets the tooltip input text.
*
- * @return the okButton
+ * @return the tooltipInputText
*/
- protected Button getOkButton() {
- return OkButton;
+ protected Text getTooltipInputText() {
+ return tooltipInputText;
}
/**
- * Gets the cancel button.
- *
- * @return the cancelButton
+ * @since 2.0
*/
- protected Button getCancelButton() {
- return cancelButton;
+ protected Text getObjectLabelText() {
+ return objectLabeltext;
}
/**
- * Gets the tooltip input text.
- *
- * @return the tooltipInputText
+ * @since 2.0
*/
- protected Text getTooltipInputText() {
- return tooltipInputText;
+ protected CLabel getObjectLabel() {
+ return objectLabel;
+ }
+
+ protected Button getUseDefaultCheckBox() {
+ return useDefaultCheckBox;
}
/**
- * Gets the object labeltext.
- *
- * @return the objectLabeltext
+ * @since 2.0
*/
- protected Text getObjectLabeltext() {
- return ObjectLabeltext;
+ protected Button getSearchButton() {
+ return searchButton;
}
/**
- * @return the objectcLabel
+ * Overridden by subclasses to handle invocation of the search button.
+ *
+ * @since 2.0
*/
- public CLabel getObjectcLabel() {
- return ObjectcLabel;
+ protected void onSearch() {
+ // Pass
}
/**
- * @return the useDefaultCheckBox
+ * Overridden by subclasses to handle invocation of the "use default tooltip" button.
+ *
+ * @since 2.0
*/
- protected Button getUseDefaultCheckBox() {
- return useDefaultCheckBox;
+ protected void onUseDefaultTooltip() {
+ // Pass
}
-
}
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractHyperLinkManagerShell.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractHyperLinkManagerShell.java
index 5693a4be01b..376ef2a280e 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractHyperLinkManagerShell.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractHyperLinkManagerShell.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009-2011 CEA LIST.
+ * Copyright (c) 2009, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,132 +9,121 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.ui;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.jface.window.IShellProvider;
import org.eclipse.papyrus.infra.hyperlink.messages.Messages;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.swt.widgets.TabFolder;
/**
- * The Class AbstractHyperLinkManagerShell. This Class has been generated from VisualEditor. Do not
- * modify it manually by adding behavior! you will lose the capacity to open with VE. So this class
- * is abstract and it contains set of getter in order to connect behavior in subclasses
+ * Abstract superclass of the initial dialog shown for managing the hyperlinks attached
+ * to an object.
*/
-public abstract class AbstractHyperLinkManagerShell {
+public abstract class AbstractHyperLinkManagerShell extends TrayDialog {
- /** The hyper link shell. */
- protected Shell hyperLinkShell = null;
+ private TabFolder tabFolder = null;
+ private ArrayList<AbstractHyperLinkTab> tabList = new ArrayList<>();
- public Shell getHyperLinkShell() {
- return hyperLinkShell;
- }
-
- /** The c tab folder. */
- private CTabFolder cTabFolder = null;
+ /**
+ * @since 2.0
+ */
+ public AbstractHyperLinkManagerShell(Shell parentShell) {
+ super(parentShell);
- public CTabFolder getcTabFolder() {
- return cTabFolder;
+ setShellStyle(getShellStyle() | SWT.RESIZE);
}
-
-
- /** The Ok button. */
- protected Button OkButton = null;
-
- /** The cancel button. */
- protected Button cancelButton = null;
-
-
-
- protected ArrayList<AbstractHyperLinkTab> tabList = new ArrayList<AbstractHyperLinkTab>();
-
/**
- * This method initializes cTabFolder.
+ * @since 2.0
*/
- private void createCTabFolder() {
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalSpan = 14;
- gridData.verticalAlignment = GridData.FILL;
- cTabFolder = new CTabFolder(hyperLinkShell, SWT.NONE);
- cTabFolder.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- cTabFolder.setLayoutData(gridData);
-
+ public AbstractHyperLinkManagerShell(IShellProvider parentProvider) {
+ super(parentProvider);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
}
-
-
/**
- * This method initializes HyperlinkComposite.
+ * @since 2.0
*/
+ protected TabFolder getTabFolder() {
+ return tabFolder;
+ }
/**
- * This method initializes hyperLinkShell.
- *
- * @wbp.parser.entryPoint
+ * Obtains an unmodifiable view of the tabs instantiated in the dialog.
+ *
+ * @return an unmodifiable view of my tabs
+ *
+ * @since 2.0
*/
- protected void createHyperLinkShell() {
- GridData gridData9 = new GridData();
- gridData9.grabExcessHorizontalSpace = true;
- gridData9.verticalAlignment = GridData.FILL;
- gridData9.horizontalSpan = 2;
- gridData9.horizontalAlignment = GridData.FILL;
- GridData gridData8 = new GridData();
- gridData8.horizontalAlignment = GridData.FILL;
- gridData8.grabExcessHorizontalSpace = true;
- gridData8.horizontalSpan = 2;
- gridData8.verticalAlignment = GridData.FILL;
- GridLayout gridLayout2 = new GridLayout();
- gridLayout2.numColumns = 14;
- gridLayout2.makeColumnsEqualWidth = true;
-
- // this line has to be commented in order to open with VISUAL EDITOR
- hyperLinkShell = new Shell(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL);
-
- // hyperLinkShell = new Shell();
- hyperLinkShell.setText(Messages.AbstractHyperLinkManagerShell_HyperLink);
- hyperLinkShell.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- createCTabFolder();
- hyperLinkShell.setLayout(gridLayout2);
- hyperLinkShell.setSize(new Point(687, 308));
- OkButton = new Button(hyperLinkShell, SWT.NONE);
- OkButton.setText(Messages.AbstractHyperLinkManagerShell_OK);
- OkButton.setLayoutData(gridData9);
- cancelButton = new Button(hyperLinkShell, SWT.NONE);
- cancelButton.setText(Messages.AbstractHyperLinkManagerShell_Cancel);
- cancelButton.setLayoutData(gridData8);
-
- getHyperLinkShell().pack();
+ protected List<AbstractHyperLinkTab> getTabs() {
+ return Collections.unmodifiableList(tabList);
}
/**
- * @return the okButton
+ * Adds a tab to the dialog.
+ *
+ * @param tab
+ * a tab to add
+ *
+ * @since 2.0
*/
- public Button getOkButton() {
- return OkButton;
+ protected void addTab(AbstractHyperLinkTab tab) {
+ tabList.add(tab);
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+
+ newShell.setText(Messages.AbstractHyperLinkManagerShell_HyperLink);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ // Tabs on the top
+ tabFolder = new TabFolder(parent, SWT.TOP);
+ tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+ applyDialogFont(tabFolder);
+ return tabFolder;
+ }
+
+ @Override
+ protected void cancelPressed() {
+ tabList.clear();
+ super.cancelPressed();
+ }
+
+ @Override
+ protected void okPressed() {
+ saveDialogSettings();
+ tabList.clear();
+
+ super.okPressed();
}
/**
- * @return the cancelButton
+ * Overridden by subclasses to save dialog-specific settings.
+ * The default implementation does nothing.
+ *
+ * @since 2.0
*/
- public Button getCancelButton() {
- return cancelButton;
+ protected void saveDialogSettings() {
+ // Pass
}
-
}
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractHyperLinkTab.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractHyperLinkTab.java
index 5ab795acd66..e9ffa77b507 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractHyperLinkTab.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractHyperLinkTab.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011, 2013 CEA LIST and others.
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,16 +10,18 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Christian W. Damus (CEA LIST) - Consolidate all hyperlink helper contributions into one tab
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.ui;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.infra.hyperlink.helper.AbstractHyperLinkHelper;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
-import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.widgets.TabFolder;
/**
*
@@ -33,26 +35,20 @@ public abstract class AbstractHyperLinkTab {
*/
private String tabId;
- // TODO these parameters should be privated
/**
* The HyperLinkHelper for this tab
*/
- protected AbstractHyperLinkHelper hyperLinkHelper;
+ private AbstractHyperLinkHelper hyperLinkHelper;
/**
* The hyperlink object
*/
- protected List<HyperLinkObject> hyperlinkObjects;
-
- /**
- * the CTabFolder
- */
- protected CTabFolder cTabFolder;
+ private List<HyperLinkObject> hyperlinkObjects;
/**
* The edited element
*/
- protected EObject element;
+ private EObject element;
/**
*
@@ -82,7 +78,7 @@ public abstract class AbstractHyperLinkTab {
* Getter for {@link #tabId}
*
* @return
- * this{@link #tabId}
+ * this{@link #tabId}
*/
public final String getTabId() {
return this.tabId;
@@ -108,34 +104,40 @@ public abstract class AbstractHyperLinkTab {
/**
* This method allows to init the parameter of the tab. These parameter can be set only one time!
*
- * @param cTabFolder
- * the CTabFolder for this tab
+ * @param tabFolder
+ * the TabFolder for this tab
* @param hyperlinkObjects
* the hyperlink objects
* @param element
* the edited element
+ * @since 2.0
*/
- public void init(final CTabFolder cTabFolder, List<HyperLinkObject> hyperlinkObjects, final EObject element/* , final IHyperLinkShell shell */) {
- if (this.cTabFolder == null) {
- this.cTabFolder = cTabFolder;
- }
- if (this.hyperlinkObjects == null) {
- this.hyperlinkObjects = hyperlinkObjects;
- }
- if (this.element == null) {
- this.element = element;
- }
+ public void init(final TabFolder tabFolder, List<HyperLinkObject> hyperlinkObjects, final EObject element/* , final IHyperLinkShell shell */) {
+ this.hyperlinkObjects = new ArrayList<>(hyperlinkObjects);
+ this.element = element;
}
/**
* Getter for {@link #hyperlinkObjects}
*
* @return
- * this{@link #hyperlinkObjects}
+ * this{@link #hyperlinkObjects}
*/
public List<HyperLinkObject> getHyperlinkObjects() {
return this.hyperlinkObjects;
}
+ /**
+ * @since 2.0
+ */
+ protected AbstractHyperLinkHelper getHyperLinkHelper() {
+ return hyperLinkHelper;
+ }
+ /**
+ * @since 2.0
+ */
+ protected EObject getElement() {
+ return element;
+ }
}
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractLookForEditorShell.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractLookForEditorShell.java
index 40de94d33fd..9d8daadf0e6 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractLookForEditorShell.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractLookForEditorShell.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
+ * Copyright (c) 2009, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,45 +9,38 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.ui;
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.jface.window.IShellProvider;
import org.eclipse.papyrus.infra.hyperlink.messages.Messages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
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.Label;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.FilteredTree;
import org.eclipse.ui.dialogs.PatternFilter;
/**
- * The Class AbstractLookForDiagramShell. This Class has been generated from
- * VisualEditor. Do not modify it manually by adding behavior! you will lose the
- * capacity to open with VE. So this class is abstract and it contains set of
- * getter in order to connect behavior in subclasses
+ * Abstract superclass of the dialog used to search for a notation editor in the
+ * currently open model(s).
*/
-public class AbstractLookForEditorShell {
+public class AbstractLookForEditorShell extends TrayDialog {
- /** The lookfor shell. */
- private Shell lookforShell = null; // @jve:decl-index=0:visual-constraint="108,60"
-
- /** The c tab folder. */
- private CTabFolder cTabFolder = null;
+ /** The tab folder. */
+ private TabFolder tabFolder = null;
/** The diagram listcomposite. */
private Composite diagramListcomposite = null;
@@ -66,12 +59,6 @@ public class AbstractLookForEditorShell {
/** The remove diagrambutton. */
private Button removeDiagrambutton = null;
- /** The O kbutton. */
- private Button OKbutton = null;
-
- /** The cancelbutton. */
- private Button cancelbutton = null;
-
/** The diagram listtree. */
private final Tree diagramListtree = null;
@@ -85,61 +72,55 @@ public class AbstractLookForEditorShell {
private CLabel cLabel = null;
/**
- * This method initializes lookforShell.
+ * @since 2.0
+ */
+ public AbstractLookForEditorShell(Shell parentShell) {
+ super(parentShell);
+ }
+
+ /**
+ * @since 2.0
*/
- protected void createLookforShell() {
- GridData gridData2 = new GridData();
- gridData2.horizontalAlignment = GridData.FILL;
- gridData2.verticalAlignment = GridData.CENTER;
- GridData gridData1 = new GridData();
- gridData1.grabExcessHorizontalSpace = false;
- gridData1.horizontalAlignment = GridData.FILL;
- gridData1.verticalAlignment = GridData.CENTER;
- gridData1.grabExcessVerticalSpace = false;
- GridLayout gridLayout1 = new GridLayout();
- gridLayout1.numColumns = 5;
- gridLayout1.makeColumnsEqualWidth = true;
- // this line has to be commented in order to open with VISUAL EDITOR
- lookforShell = new Shell(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.DIALOG_TRIM | SWT.RESIZE);
-
- // lookforShell = new Shell();
- lookforShell.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- createCTabFolder();
- lookforShell.setLayout(gridLayout1);
- lookforShell.setSize(new Point(501, 313));
- new Label(lookforShell, SWT.NONE);
- new Label(lookforShell, SWT.NONE);
- new Label(lookforShell, SWT.NONE);
- OKbutton = new Button(lookforShell, SWT.NONE);
- OKbutton.setText(Messages.AbstractLookForEditorShell_OK);
- OKbutton.setLayoutData(gridData1);
- OKbutton.setEnabled(false);
- cancelbutton = new Button(lookforShell, SWT.NONE);
- cancelbutton.setText(Messages.AbstractLookForEditorShell_Cancel);
- cancelbutton.setLayoutData(gridData2);
+ public AbstractLookForEditorShell(IShellProvider parentShell) {
+ super(parentShell);
}
/**
- * This method initializes cTabFolder.
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ * @return
*/
- protected void createCTabFolder() {
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalSpan = 5;
- gridData.verticalAlignment = GridData.FILL;
- cTabFolder = new CTabFolder(lookforShell, SWT.NONE);
- cTabFolder.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- cTabFolder.setLayoutData(gridData);
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ // Tabs on the top
+ tabFolder = new TabFolder(parent, SWT.TOP);
+ tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+ applyDialogFont(tabFolder);
+
createDiagramListcomposite();
createTreeViewcomposite();
- CTabItem cTabItem = new CTabItem(cTabFolder, SWT.None);
- cTabItem.setControl(diagramListcomposite);
- cTabItem.setText(Messages.AbstractLookForEditorShell_EditorsList);// TODO change this name into Editor List
- CTabItem cTabItem1 = new CTabItem(cTabFolder, SWT.None);
- cTabItem1.setText(Messages.AbstractLookForEditorShell_TreeView);
- cTabItem1.setControl(treeViewcomposite);
+
+ TabItem tabItem = new TabItem(tabFolder, SWT.None);
+ tabItem.setControl(diagramListcomposite);
+ tabItem.setText(Messages.AbstractLookForEditorShell_EditorsList);
+
+ TabItem tabItem1 = new TabItem(tabFolder, SWT.None);
+ tabItem1.setText(Messages.AbstractLookForEditorShell_TreeView);
+ tabItem1.setControl(treeViewcomposite);
+
+ contentsCreated();
+
+ return tabFolder;
+ }
+
+ /**
+ * Hook that subclasses may override to handle the creation of the dialog contents.
+ *
+ * @since 2.0
+ */
+ protected void contentsCreated() {
+ // Pass
}
/**
@@ -147,8 +128,7 @@ public class AbstractLookForEditorShell {
*/
private void createDiagramListcomposite() {
GridLayout gridLayout2 = new GridLayout();
- diagramListcomposite = new Composite(cTabFolder, SWT.BORDER);
- diagramListcomposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+ diagramListcomposite = new Composite(tabFolder, SWT.BORDER);
createDiagramfilteredTree();
diagramListcomposite.setLayout(gridLayout2);
}
@@ -166,8 +146,7 @@ public class AbstractLookForEditorShell {
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
- treeViewcomposite = new Composite(cTabFolder, SWT.NONE);
- treeViewcomposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+ treeViewcomposite = new Composite(tabFolder, SWT.NONE);
createModelFilteredTree();
@@ -180,30 +159,10 @@ public class AbstractLookForEditorShell {
removeDiagrambutton.setLayoutData(gridData5);
cLabel = new CLabel(treeViewcomposite, SWT.NONE);
cLabel.setText(" "); //$NON-NLS-1$
- cLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
afterTreeViewComposite = new Composite(treeViewcomposite, SWT.NONE);
afterTreeViewComposite.setLayout(new FillLayout());
afterTreeViewComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- afterTreeViewComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- }
-
- /**
- * Recursively set the background of all children of parent composite to chosen color
- *
- * @param parent
- * The composite that contains children
- * @param color
- * The background color
- * @since 2.0
- */
- protected void setChildrenBackground(Composite parent, Color color) {
- for (Control child : parent.getChildren()) {
- child.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- if (child instanceof Composite) {
- setChildrenBackground((Composite) child, color);
- }
- }
}
/**
@@ -257,46 +216,6 @@ public class AbstractLookForEditorShell {
}
/**
- * Gets the o kbutton.
- *
- * @return the oKbutton
- */
- protected Button getOKbutton() {
- return OKbutton;
- }
-
- /**
- * Sets the o kbutton.
- *
- * @param oKbutton
- * the oKbutton to set
- */
- // @unused
- protected void setOKbutton(Button oKbutton) {
- OKbutton = oKbutton;
- }
-
- /**
- * Gets the cancelbutton.
- *
- * @return the cancelbutton
- */
- protected Button getCancelbutton() {
- return cancelbutton;
- }
-
- /**
- * Sets the cancelbutton.
- *
- * @param cancelbutton
- * the cancelbutton to set
- */
- // @unused
- protected void setCancelbutton(Button cancelbutton) {
- this.cancelbutton = cancelbutton;
- }
-
- /**
* Gets the diagram listtree.
*
* @return the diagramListtree
@@ -307,26 +226,6 @@ public class AbstractLookForEditorShell {
}
/**
- * Gets the lookfor shell.
- *
- * @return the lookforShell
- */
- protected Shell getLookforShell() {
- return lookforShell;
- }
-
- /**
- * Sets the lookfor shell.
- *
- * @param lookforShell
- * the lookforShell to set
- */
- // @unused
- protected void setLookforShell(Shell lookforShell) {
- this.lookforShell = lookforShell;
- }
-
- /**
* This method initializes diagramfilteredTree.
*/
private void createDiagramfilteredTree() {
@@ -350,7 +249,6 @@ public class AbstractLookForEditorShell {
gridData3.verticalSpan = 3;
gridData3.verticalAlignment = GridData.FILL;
modeFilteredTree = new FilteredTree(treeViewcomposite, SWT.BORDER, new PatternFilter(), true);
- modeFilteredTree.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
modeFilteredTree.setLayoutData(gridData3);
}
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/DefaultHyperLinkTab.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/DefaultHyperLinkTab.java
index c1d246d9279..8347ae181fe 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/DefaultHyperLinkTab.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/DefaultHyperLinkTab.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +8,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.ui;
@@ -21,6 +21,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
@@ -32,15 +33,15 @@ import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.infra.widgets.providers.CollectionContentProvider;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
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.Label;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
/**
@@ -97,22 +98,13 @@ public class DefaultHyperLinkTab extends AbstractHyperLinkTab {
return defaultHyperLinkObject;
}
- /**
- *
- * @see org.eclipse.papyrus.infra.hyperlink.ui.AbstractHyperLinkTab#init(org.eclipse.swt.custom.CTabFolder, java.util.List, org.eclipse.emf.ecore.EObject)
- *
- * @param cTabFolder
- * @param hyperlinkObjects
- * @param element
- */
@Override
- public void init(final CTabFolder cTabFolder, List<HyperLinkObject> hyperlinkObjects, EObject element) {
- super.init(cTabFolder, hyperlinkObjects, element);
- CTabItem tbtmDefaultsHyperlinks = new CTabItem(cTabFolder, SWT.NONE);
+ public void init(final TabFolder tabFolder, List<HyperLinkObject> hyperlinkObjects, EObject element) {
+ super.init(tabFolder, hyperlinkObjects, element);
+
+ TabItem tbtmDefaultsHyperlinks = new TabItem(tabFolder, SWT.NONE);
tbtmDefaultsHyperlinks.setText(Messages.DefaultHyperLinkTab_DefaultHyperlinks);
- defaultHyperlinkComposite = new Composite(cTabFolder, SWT.NONE);
- defaultHyperlinkComposite.setBackgroundMode(SWT.INHERIT_DEFAULT);
- defaultHyperlinkComposite.setBackground(defaultHyperlinkComposite.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ defaultHyperlinkComposite = new Composite(tabFolder, SWT.NONE);
defaultHyperlinkComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
defaultHyperlinkComposite.setLayout(new GridLayout(4, false));
@@ -145,57 +137,22 @@ public class DefaultHyperLinkTab extends AbstractHyperLinkTab {
availableHyperLink.setLayoutData(new GridData(GridData.FILL_BOTH));
- defaultHRight = new Button(addRemoveButtonsComposite, SWT.NONE);
- defaultHRight.addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
-
- }
-
- public void mouseDown(MouseEvent e) {
- // move element left to right
- if (availableHyperLinkViewer.getSelection() != null) {
- // normally this viewer contains only hyperlinkObject
- if (availableHyperLinkViewer.getSelection() instanceof IStructuredSelection) {
- HyperLinkObject hyperlinkObjectToMove = (HyperLinkObject) ((IStructuredSelection) availableHyperLinkViewer.getSelection()).getFirstElement();
- hyperlinkObjectToMove.setIsDefault(true);
- availableHyperLinkObject.remove(hyperlinkObjectToMove);
- defaultHyperLinkObject.add(hyperlinkObjectToMove);
- refresh();
- }
- }
- }
-
- public void mouseDoubleClick(MouseEvent e) {
+ defaultHRight = new Button(addRemoveButtonsComposite, SWT.PUSH);
+ defaultHRight.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleRightButton();
}
});
defaultHRight.setToolTipText("Set default hyperlink");
- defaultHleft = new Button(addRemoveButtonsComposite, SWT.NONE);
- defaultHleft.addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
-
- }
-
- public void mouseDown(MouseEvent e) {
- // move element right to left
- if (defaultHyperLinkViewer.getSelection() != null) {
- // normally this viewer contains only hyperlinkObject
- if (defaultHyperLinkViewer.getSelection() instanceof IStructuredSelection) {
-
- HyperLinkObject hyperlinkObjectToMove = (HyperLinkObject) ((IStructuredSelection) defaultHyperLinkViewer.getSelection()).getFirstElement();
- hyperlinkObjectToMove.setIsDefault(false);
- defaultHyperLinkObject.remove(hyperlinkObjectToMove);
- availableHyperLinkObject.add(hyperlinkObjectToMove);
- refresh();
- }
- }
- }
-
- public void mouseDoubleClick(MouseEvent e) {
+ defaultHleft = new Button(addRemoveButtonsComposite, SWT.PUSH);
+ defaultHleft.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleLeftButton();
}
});
defaultHleft.setToolTipText("Remove default hyperlink");
@@ -205,16 +162,13 @@ public class DefaultHyperLinkTab extends AbstractHyperLinkTab {
defaultHyperLink.setLayoutData(new GridData(GridData.FILL_BOTH));
- defaultHup = new Button(upDownButtonsComposite, SWT.NONE);
+ defaultHup = new Button(upDownButtonsComposite, SWT.PUSH);
defaultHup.setToolTipText("Move default hyperlink up");
- defaultHup.addMouseListener(new MouseListener() {
+ defaultHup.addSelectionListener(new SelectionAdapter() {
- public void mouseUp(MouseEvent e) {
-
- }
-
- public void mouseDown(MouseEvent e) {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
// move element bottom to top
if (defaultHyperLinkViewer.getSelection() != null) {
// normally this viewer contains only hyperlinkObject
@@ -226,26 +180,20 @@ public class DefaultHyperLinkTab extends AbstractHyperLinkTab {
defaultHyperLinkObject.remove(hyperlinkObjectToMove);
defaultHyperLinkObject.add(index - 1, hyperlinkObjectToMove);
refresh();
+ updateButtonEnablement(null);
}
}
}
}
-
- public void mouseDoubleClick(MouseEvent e) {
-
- }
});
- defaultHdown = new Button(upDownButtonsComposite, SWT.NONE);
+ defaultHdown = new Button(upDownButtonsComposite, SWT.PUSH);
defaultHdown.setToolTipText("Move default hyperlink down");
- defaultHdown.addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
-
- }
+ defaultHdown.addSelectionListener(new SelectionAdapter() {
- public void mouseDown(MouseEvent e) {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
// move element top to bottom
if (defaultHyperLinkViewer.getSelection() != null) {
// normally this viewer contains only hyperlinkObject
@@ -258,14 +206,11 @@ public class DefaultHyperLinkTab extends AbstractHyperLinkTab {
defaultHyperLinkObject.remove(hyperlinkObjectToMove);
defaultHyperLinkObject.add(index + 1, hyperlinkObjectToMove);
refresh();
+ updateButtonEnablement(null);
}
}
}
}
-
- public void mouseDoubleClick(MouseEvent e) {
-
- }
});
@@ -297,10 +242,54 @@ public class DefaultHyperLinkTab extends AbstractHyperLinkTab {
availableHyperLinkViewer.setContentProvider(CollectionContentProvider.instance);
availableHyperLinkViewer.setInput(hyperlinkObjects);
+ availableHyperLinkViewer.addSelectionChangedListener(this::updateButtonEnablement);
+ availableHyperLinkViewer.addDoubleClickListener(event -> handleRightButton());
defaultHyperLinkViewer = new TableViewer(defaultHyperLink);
defaultHyperLinkViewer.setLabelProvider(provider);
defaultHyperLinkViewer.setContentProvider(CollectionContentProvider.instance);
+ defaultHyperLinkViewer.addSelectionChangedListener(this::updateButtonEnablement);
+ defaultHyperLinkViewer.addDoubleClickListener(event -> handleLeftButton());
+
+ updateButtonEnablement(null);
+ }
+
+ private void handleRightButton() {
+ // move element left to right
+ if (availableHyperLinkViewer.getSelection() != null) {
+ // normally this viewer contains only hyperlinkObject
+ if (availableHyperLinkViewer.getSelection() instanceof IStructuredSelection) {
+ HyperLinkObject hyperlinkObjectToMove = (HyperLinkObject) ((IStructuredSelection) availableHyperLinkViewer.getSelection()).getFirstElement();
+ hyperlinkObjectToMove.setIsDefault(true);
+ availableHyperLinkObject.remove(hyperlinkObjectToMove);
+ defaultHyperLinkObject.add(hyperlinkObjectToMove);
+ refresh();
+ }
+ }
+ }
+
+ private void handleLeftButton() {
+ // move element right to left
+ if (defaultHyperLinkViewer.getSelection() != null) {
+ // normally this viewer contains only hyperlinkObject
+ if (defaultHyperLinkViewer.getSelection() instanceof IStructuredSelection) {
+
+ HyperLinkObject hyperlinkObjectToMove = (HyperLinkObject) ((IStructuredSelection) defaultHyperLinkViewer.getSelection()).getFirstElement();
+ hyperlinkObjectToMove.setIsDefault(false);
+ defaultHyperLinkObject.remove(hyperlinkObjectToMove);
+ availableHyperLinkObject.add(hyperlinkObjectToMove);
+ refresh();
+ }
+ }
+ }
+
+ private void updateButtonEnablement(SelectionChangedEvent event) {
+ defaultHRight.setEnabled(!availableHyperLinkViewer.getSelection().isEmpty());
+ defaultHleft.setEnabled(!defaultHyperLinkViewer.getSelection().isEmpty());
+
+ int index = defaultHyperLinkViewer.getTable().getSelectionIndex();
+ defaultHup.setEnabled(index > 0);
+ defaultHdown.setEnabled((index >= 0) && (index < (defaultHyperLinkObject.size() - 1)));
}
/**
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkWebShell.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkWebShell.java
index 6376778beb7..969bef889f4 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkWebShell.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkWebShell.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
- *
+ * Copyright (c) 2009, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +8,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.ui;
@@ -16,11 +16,9 @@ package org.eclipse.papyrus.infra.hyperlink.ui;
import org.eclipse.papyrus.infra.hyperlink.messages.Messages;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkWeb;
+import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
/**
* The Class HyperlinkWebEditor is used to add or modify an hyperlink web entry.
@@ -41,113 +39,78 @@ public class EditorHyperLinkWebShell extends AbstractEditHyperlinkShell {
private boolean usedefaultTooltip = true;
/**
- * Open.
+ * Instantiates a new hyperlink web editor.
+ *
+ * @since 2.0
*/
- public void open() {
- Display display = Display.getCurrent();
-
- // code use to wait for an action from the user
- getEditHyperlinkShell().pack();
- // getEditHyperlinkShell().setBounds(500, 500, 600, 120);
- getEditHyperlinkShell().open();
- while (!getEditHyperlinkShell().isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
+ public EditorHyperLinkWebShell(Shell parentShell) {
+ super(parentShell, false);
}
- /**
- * Instantiates a new hyperlink web editor.
- */
- public EditorHyperLinkWebShell() {
- super();
- createEditHyperlinkShell();
+ @Override
+ protected void contentsCreated() {
+ this.getObjectLabel().setText(HYPERLINKS_LABEL);
+
+ updateFields();
- this.getObjectcLabel().setText(HYPERLINKS_LABEL);
// fill information
if (hyperLinkWeb != null) {
- this.getObjectLabeltext().setText(hyperLinkWeb.getHyperLinkWeb());
+ this.getObjectLabelText().setText(hyperLinkWeb.getHyperLinkWeb());
this.getTooltipInputText().setText(hyperLinkWeb.getTooltipText());
} else {
- this.getObjectLabeltext().setText(HTTP);
- this.getObjectLabeltext().setSelection(HTTP.length());
+ this.getObjectLabelText().setText(HTTP);
+ this.getObjectLabelText().setSelection(HTTP.length());
}
- // listener to cancel
- this.getCancelButton().addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
- hyperLinkWeb = null;
- getEditHyperlinkShell().close();
- }
-
- public void mouseDoubleClick(MouseEvent e) {
- }
- });
- // listener to click on OK
- this.getOkButton().addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
- if (hyperLinkWeb == null) {
- hyperLinkWeb = new HyperLinkWeb();
- }
- hyperLinkWeb.setHyperLinkWeb(getObjectLabeltext().getText().trim());
- hyperLinkWeb.setTooltipText(getTooltipInputText().getText().trim());
-
- getEditHyperlinkShell().close();
- }
-
- public void mouseDoubleClick(MouseEvent e) {
- }
- });
// intialize "use default" check box
getUseDefaultCheckBox().setSelection(usedefaultTooltip);
if (usedefaultTooltip) {
getTooltipInputText().setEditable(false);
- getTooltipInputText().setText(getObjectLabeltext().getText());
+ getTooltipInputText().setText(getObjectLabelText().getText());
}
- // add listener "use default button"
- getUseDefaultCheckBox().addMouseListener(new MouseListener() {
- public void mouseUp(MouseEvent e) {
- usedefaultTooltip = getUseDefaultCheckBox().getSelection();
+ // add a key listener on inputText to synchronize with the tooltip in
+ // the case of use default
+ getObjectLabelText().addKeyListener(new KeyAdapter() {
+
+ @Override
+ public void keyReleased(KeyEvent e) {
if (usedefaultTooltip) {
- getTooltipInputText().setEditable(false);
- getTooltipInputText().setText(getObjectLabeltext().getText());
- } else {
- getTooltipInputText().setEditable(true);
+ getTooltipInputText().setText(getObjectLabelText().getText());
}
}
+ });
+ }
- public void mouseDown(MouseEvent e) {
- }
+ @Override
+ protected void onUseDefaultTooltip() {
+ usedefaultTooltip = getUseDefaultCheckBox().getSelection();
+ if (usedefaultTooltip) {
+ getTooltipInputText().setEditable(false);
+ getTooltipInputText().setText(getObjectLabelText().getText());
+ } else {
+ getTooltipInputText().setEditable(true);
+ }
+ }
- public void mouseDoubleClick(MouseEvent e) {
- }
- });
+ @Override
+ protected void cancelPressed() {
+ hyperLinkWeb = null;
+ super.cancelPressed();
+ }
- // add a key listener on inputText to synchronize with the tooltip in
- // the case of use
- // default
- getObjectLabeltext().addKeyListener(new KeyListener() {
- public void keyReleased(KeyEvent e) {
- if (usedefaultTooltip) {
- getTooltipInputText().setText(getObjectLabeltext().getText());
- }
- }
+ @Override
+ protected void okPressed() {
+ if (hyperLinkWeb == null) {
+ hyperLinkWeb = new HyperLinkWeb();
+ }
+ hyperLinkWeb.setHyperLinkWeb(getObjectLabelText().getText().trim());
+ hyperLinkWeb.setTooltipText(getTooltipInputText().getText().trim());
- public void keyPressed(KeyEvent e) {
- }
- });
+ super.okPressed();
}
+
/**
* Gets the hyper link web.
*
@@ -165,8 +128,19 @@ public class EditorHyperLinkWebShell extends AbstractEditHyperlinkShell {
*/
public void setHyperLinkWeb(HyperLinkWeb hyperLinkWeb) {
this.hyperLinkWeb = hyperLinkWeb;
- this.getObjectLabeltext().setText(hyperLinkWeb.getHyperLinkWeb());
- this.getTooltipInputText().setText(hyperLinkWeb.getTooltipText());
+ updateFields();
+ }
+
+ private void updateFields() {
+ if (hyperLinkWeb != null) {
+ if (getObjectLabelText() != null) {
+ getObjectLabelText().setText(hyperLinkWeb.getHyperLinkWeb());
+ }
+ if (getTooltipInputText() != null) {
+ getTooltipInputText().setText(hyperLinkWeb.getTooltipText());
+ }
+ }
+
}
}
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperlinkDocumentShell.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperlinkDocumentShell.java
index 2fc7da1a338..67849d0181a 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperlinkDocumentShell.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperlinkDocumentShell.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
+ * Copyright (c) 2009, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.ui;
@@ -16,15 +17,13 @@ package org.eclipse.papyrus.infra.hyperlink.ui;
import org.eclipse.papyrus.infra.hyperlink.messages.Messages;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkDocument;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
/**
* The Class EditorHyperlinkDocumentShell.
*/
-public class EditorHyperlinkDocumentShell extends AbstractEditHyperlinkDocumentShell {
+public class EditorHyperlinkDocumentShell extends AbstractEditHyperlinkShell {
/** The usedefault tooltip. */
protected boolean usedefaultTooltip = true;
@@ -33,6 +32,15 @@ public class EditorHyperlinkDocumentShell extends AbstractEditHyperlinkDocumentS
protected HyperLinkDocument hyperlinkDocument;
/**
+ * Instantiates a new editor hyperlink document shell.
+ *
+ * @since 2.0
+ */
+ public EditorHyperlinkDocumentShell(Shell parentShell) {
+ super(parentShell, true);
+ }
+
+ /**
* Gets the hyperlink document.
*
* @return the hyperlinkDocument
@@ -49,116 +57,75 @@ public class EditorHyperlinkDocumentShell extends AbstractEditHyperlinkDocumentS
*/
public void setHyperlinkDocument(HyperLinkDocument hyperlinkDocument) {
this.hyperlinkDocument = hyperlinkDocument;
- getObjectLabeltext().setText(getHyperlinkDocument().getHyperlinkDocument());
- getTooltipInputText().setText(getHyperlinkDocument().getTooltipText());
+ updateFields();
}
- /**
- * Open.
- */
- public void open() {
- Display display = Display.getCurrent();
-
- // code use to wait for an action from the user
- // getEditHyperlinkShell().setBounds(500, 500, 600, 120);
- getEditHyperlinkShell().pack();
- getEditHyperlinkShell().open();
- while (!getEditHyperlinkShell().isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- }
-
- /**
- * Instantiates a new editor hyperlink document shell.
- */
- public EditorHyperlinkDocumentShell() {
- super();
- createEditHyperlinkShell();
+ @Override
+ protected void contentsCreated() {
+ getObjectLabel().setText(Messages.AbstractEditHyperlinkDocumentShell_Document);
// intialize "use default" check box
getUseDefaultCheckBox().setSelection(usedefaultTooltip);
- getObjectLabeltext().setEditable(false);
+ getObjectLabelText().setEditable(false);
if (usedefaultTooltip) {
getTooltipInputText().setEditable(false);
- getTooltipInputText().setText(getObjectLabeltext().getText());
+ getTooltipInputText().setText(getObjectLabelText().getText());
}
- // add listener "use default button"
- getUseDefaultCheckBox().addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
- usedefaultTooltip = getUseDefaultCheckBox().getSelection();
- if (usedefaultTooltip) {
- getTooltipInputText().setEditable(false);
- getTooltipInputText().setText(getObjectLabeltext().getText());
- } else {
- getTooltipInputText().setEditable(true);
- }
- }
-
- public void mouseDown(MouseEvent e) {
- }
-
- public void mouseDoubleClick(MouseEvent e) {
- }
- });
- getChooseDiagramButton().addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
- FileDialog fd = new FileDialog(getEditHyperlinkShell(), SWT.OPEN);
- fd.setText(Messages.EditorHyperlinkDocumentShell_Open);
- String[] filterExt = { "*.pdf", "*.doc", "*.txt", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- fd.setFilterExtensions(filterExt);
- String selected = fd.open();
- if (selected != null) {
- getObjectLabeltext().setText(selected);
- if (usedefaultTooltip) {
- getTooltipInputText().setText(selected);
- }
- }
- }
-
- public void mouseDoubleClick(MouseEvent e) {
- }
- });
-
- // listener to cancel
- this.getCancelButton().addMouseListener(new MouseListener() {
+ updateFields();
+ }
- public void mouseUp(MouseEvent e) {
+ private void updateFields() {
+ if (getHyperlinkDocument() != null) {
+ if (getObjectLabelText() != null) {
+ getObjectLabelText().setText(getHyperlinkDocument().getHyperlinkDocument());
}
-
- public void mouseDown(MouseEvent e) {
- hyperlinkDocument = null;
- getEditHyperlinkShell().close();
+ if (getTooltipInputText() != null) {
+ getTooltipInputText().setText(getHyperlinkDocument().getTooltipText());
}
+ }
+ }
- public void mouseDoubleClick(MouseEvent e) {
+ @Override
+ protected void onSearch() {
+ FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
+ fd.setText(Messages.EditorHyperlinkDocumentShell_Open);
+ String[] filterExt = { "*.pdf", "*.doc", "*.txt", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ fd.setFilterExtensions(filterExt);
+ String selected = fd.open();
+ if (selected != null) {
+ getObjectLabelText().setText(selected);
+ if (usedefaultTooltip) {
+ getTooltipInputText().setText(selected);
}
- });
- // listener to click on OK
- this.getOkButton().addMouseListener(new MouseListener() {
+ }
+ }
- public void mouseUp(MouseEvent e) {
- }
+ @Override
+ protected void onUseDefaultTooltip() {
+ usedefaultTooltip = getUseDefaultCheckBox().getSelection();
+ if (usedefaultTooltip) {
+ getTooltipInputText().setEditable(false);
+ getTooltipInputText().setText(getObjectLabelText().getText());
+ } else {
+ getTooltipInputText().setEditable(true);
+ }
+ }
- public void mouseDown(MouseEvent e) {
- if (hyperlinkDocument == null) {
- hyperlinkDocument = new HyperLinkDocument();
- }
- hyperlinkDocument.setHyperlinkDocument(getObjectLabeltext().getText().trim());
- hyperlinkDocument.setTooltipText(getTooltipInputText().getText().trim());
+ @Override
+ protected void cancelPressed() {
+ hyperlinkDocument = null;
+ super.cancelPressed();
+ }
- getEditHyperlinkShell().close();
- }
+ @Override
+ protected void okPressed() {
+ if (hyperlinkDocument == null) {
+ hyperlinkDocument = new HyperLinkDocument();
+ }
+ hyperlinkDocument.setHyperlinkDocument(getObjectLabelText().getText().trim());
+ hyperlinkDocument.setTooltipText(getTooltipInputText().getText().trim());
- public void mouseDoubleClick(MouseEvent e) {
- }
- });
+ super.cancelPressed();
}
}
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkManagerShell.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkManagerShell.java
index bb352431fba..72cb6549268 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkManagerShell.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkManagerShell.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
+ * Copyright (c) 2009, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,6 +10,7 @@
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
* Arthut Daussy (Atos) arthur.daussy@atos.net - Bug 363827 - [Improvement] Diagram creation, remember the latest tab chosen
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.ui;
@@ -38,11 +39,11 @@ import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkException;
import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkTabsRegistrationUtil;
import org.eclipse.papyrus.infra.ui.editorsfactory.IPageIconsRegistry;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.XMLMemento;
@@ -89,10 +90,9 @@ public class HyperLinkManagerShell extends AbstractHyperLinkManagerShell {
public void setInput(List<HyperLinkObject> hyperLinkObjectList) {
this.allhypHyperlinkObjects.clear();
this.allhypHyperlinkObjects.addAll(hyperLinkObjectList);
- Iterator<AbstractHyperLinkTab> iter = tabList.iterator();
- while (iter.hasNext()) {
- AbstractHyperLinkTab hyperLinkTab = iter.next();
- hyperLinkTab.setInput(allhypHyperlinkObjects);
+
+ for (AbstractHyperLinkTab tab : getTabs()) {
+ tab.setInput(allhypHyperlinkObjects);
}
}
@@ -111,48 +111,26 @@ public class HyperLinkManagerShell extends AbstractHyperLinkManagerShell {
* the aview of the uml element
* @since 2.0
*/
- public HyperLinkManagerShell(IPageIconsRegistry editorFactoryRegistry, TransactionalEditingDomain domain, EModelElement semanticElement, EModelElement aview, HyperLinkHelperFactory hyperHelperFactory) {
- super();
+ public HyperLinkManagerShell(Shell parentShell, IPageIconsRegistry editorFactoryRegistry, TransactionalEditingDomain domain, EModelElement semanticElement, EModelElement aview, HyperLinkHelperFactory hyperHelperFactory) {
+ super(parentShell);
+
this.hyperLinkHelperFactory = hyperHelperFactory;
this.view = aview;
this.semanticElement = semanticElement;
this.transactionalEditingDomain = domain;
- createHyperLinkShell();
+ }
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Control result = super.createDialogArea(parent);
initializeFolder(null);
-
- // // associate tableViewer for each table
- // Iterator<AbstractHyperLinkHelper> iter = hyperHelperFactory.getHyperLinkHelpers().iterator();
- // while(iter.hasNext()) {
- // AbstractHyperLinkHelper abstractHyperLinkHelper = (AbstractHyperLinkHelper)iter.next();
- // initializeFolder(abstractHyperLinkHelper);
- // }
- // listener for the button cancel
- getCancelButton().addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- tabList.clear();
- getHyperLinkShell().close();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- };
- });
- // listener for the button OK
- SelectionListener okListener = new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- executeOkButton();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- };
- getOkButton().addSelectionListener(okListener);
+ return result;
}
- protected void executeOkButton() {// should be final?
+ @Override
+ protected final void okPressed() {
CompoundCommand myCommand = getCommand();
+
// clear the current annotations
myCommand.append(HyperLinkHelperFactory.getEmptyAllHyperLinkCommand(transactionalEditingDomain, view));
doAction();
@@ -167,23 +145,18 @@ public class HyperLinkManagerShell extends AbstractHyperLinkManagerShell {
// execute the command
Assert.isTrue(myCommand.canExecute());
this.transactionalEditingDomain.getCommandStack().execute(myCommand);
- closeDialog();
- }
-
+ // Close up
+ super.okPressed();
+ }
/**
* do the action and fill the command
*/
protected void doAction() {
- // empty all hyperlinks
- // clear command
- // CompoundCommand tmp = getCommand();
- // tmp.append(HyperLinkHelperFactory.getEmptyAllHyperLinkCommand(transactionalEditingDomain, view));
-
-
allhypHyperlinkObjects.clear();
allhypHyperlinkObjects.addAll(getSelectedHyperLinkObjectCrossingTabs());
+
// set all hyper links is default to false
Iterator<HyperLinkObject> iterator = allhypHyperlinkObjects.iterator();
while (iterator.hasNext()) {
@@ -191,7 +164,6 @@ public class HyperLinkManagerShell extends AbstractHyperLinkManagerShell {
hyperLink.setIsDefault(false);
}
-
// specific behavior for the DefautHyperLinkTab
DefaultHyperLinkTab defaultHyperLinkTab = getDefaultHyperLinkTab();
@@ -206,20 +178,6 @@ public class HyperLinkManagerShell extends AbstractHyperLinkManagerShell {
}
i--;
}
-
- // //store eannotation command
- // try {
- // tmp.append(hyperLinkHelperFactory.getAddHyperLinkCommand(transactionalEditingDomain, view, allhypHyperlinkObjects));
- // } catch (HyperLinkException e) {
- // Activator.log.error(e);
- // }
- }
-
- private void closeDialog() {
- // save the corresponding tab
- saveCorrespondingTab();
- tabList.clear();
- getHyperLinkShell().close();
}
protected CompoundCommand getCommand() {
@@ -233,40 +191,27 @@ public class HyperLinkManagerShell extends AbstractHyperLinkManagerShell {
* Initialize diagram folder.
*/
public void initializeFolder(final AbstractHyperLinkHelper abstractHyperLinkHelper) { // TODO remove this parameter which is not used!
- Iterator<AbstractHyperLinkTab> iter = HyperLinkTabsRegistrationUtil.INSTANCE.getAllHyperLinkTab().iterator();
- while (iter.hasNext()) {
- AbstractHyperLinkTab current = iter.next();
- current.init(getcTabFolder(), allhypHyperlinkObjects, semanticElement);
- tabList.add(current);
+ for (AbstractHyperLinkTab tab : HyperLinkTabsRegistrationUtil.INSTANCE.getAllHyperLinkTab()) {
+ tab.init(getTabFolder(), allhypHyperlinkObjects, semanticElement);
+ addTab(tab);
}
// specific behavior for the default tab :
final DefaultHyperLinkTab defaultTab = getDefaultHyperLinkTab();
defaultTab.getMainComposite().addListener(SWT.Show, new Listener() {
+ @Override
public void handleEvent(Event event) {
defaultTab.setInput(HyperLinkManagerShell.this.getSelectedHyperLinkObjectCrossingTabs());
}
});
+ selectLastTab();
}
- /**
- * Open the shell.
- */
- public void open() {
- Display display = Display.getCurrent();
- getHyperLinkShell().pack();
- // getHyperLinkShell().setBounds(500, 500, 700, 300);
- getHyperLinkShell().open();
- // Select the good tab
- selectLastTab();
- // code use to wait for an action from the user
- while (!getHyperLinkShell().isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
+ @Override
+ protected void saveDialogSettings() {
+ saveCorrespondingTab();
}
/**
@@ -281,7 +226,7 @@ public class HyperLinkManagerShell extends AbstractHyperLinkManagerShell {
if (semanticElement != null) {
// Save the corresponding tab for the element
// Use InstanceTypeName in order to make a convenient ID
- int selectionIndex = getcTabFolder().getSelectionIndex();
+ int selectionIndex = getTabFolder().getSelectionIndex();
memento.putInteger(semanticElement.eClass().getInstanceTypeName(), selectionIndex);
// Save the global last tab used
memento.putInteger(LAST_GLOBAL_TAB_USED, selectionIndex);
@@ -307,9 +252,9 @@ public class HyperLinkManagerShell extends AbstractHyperLinkManagerShell {
}
}
try {
- getcTabFolder().setSelection(lastIndexUsed);
+ getTabFolder().setSelection(lastIndexUsed);
} catch (IndexOutOfBoundsException e) {
- getcTabFolder().setSelection(0);
+ getTabFolder().setSelection(0);
}
}
@@ -388,7 +333,7 @@ public class HyperLinkManagerShell extends AbstractHyperLinkManagerShell {
// TODO : should be a set ?
public List<HyperLinkObject> getSelectedHyperLinkObjectCrossingTabs() {
Set<HyperLinkObject> selectedObjects = new HashSet<HyperLinkObject>();
- for (AbstractHyperLinkTab current : tabList) {
+ for (AbstractHyperLinkTab current : getTabs()) {
if (!(current instanceof DefaultHyperLinkTab)) {
List<HyperLinkObject> tmp = current.getHyperlinkObjects();
if (tmp != null) {
@@ -402,7 +347,7 @@ public class HyperLinkManagerShell extends AbstractHyperLinkManagerShell {
protected DefaultHyperLinkTab getDefaultHyperLinkTab() {
int nbTab = 0;
DefaultHyperLinkTab defaultHyperLinkTab = null;
- for (AbstractHyperLinkTab current : tabList) {
+ for (AbstractHyperLinkTab current : getTabs()) {
if (current instanceof DefaultHyperLinkTab) {
defaultHyperLinkTab = (DefaultHyperLinkTab) current;
nbTab++;
diff --git a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkTab.java b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkTab.java
index 9d916a5589e..5110b38fb20 100644
--- a/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkTab.java
+++ b/plugins/infra/misc/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/HyperLinkTab.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011, 2013 CEA LIST and others.
- *
+ * Copyright (c) 2011, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,6 +9,7 @@
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA LIST) - Consolidate all hyperlink helper contributions into one tab
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.ui;
@@ -24,6 +24,7 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.papyrus.infra.core.services.ServiceException;
@@ -33,22 +34,21 @@ import org.eclipse.papyrus.infra.hyperlink.helper.AbstractHyperLinkHelper;
import org.eclipse.papyrus.infra.hyperlink.helper.CompositeHyperlinkHelper;
import org.eclipse.papyrus.infra.hyperlink.messages.Messages;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
+import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkSpecificObject;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.infra.widgets.providers.CollectionContentProvider;
import org.eclipse.papyrus.infra.widgets.util.PopupButtonMenu;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
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.Display;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
/**
@@ -63,7 +63,7 @@ public class HyperLinkTab extends AbstractHyperLinkTab {
/**
* The Class DiagramContentProvider.
*/
- protected CTabItem hyperlinksTab;
+ protected TabItem hyperlinksTab;
protected Table hyperLinkListTable;
@@ -109,39 +109,25 @@ public class HyperLinkTab extends AbstractHyperLinkTab {
}
/**
- *
- * @return the list of hyperlink displayed in the tab
- */
- @Override
- public List<HyperLinkObject> getHyperlinkObjects() {
- return hyperlinkObjects;
- }
-
- /**
* set list of hyperlinks to display in the tab
*
* @param hyperlinkObjects
*/
public void setHyperlinkObjects(List<HyperLinkObject> hyperlinkObjects) {
- this.hyperlinkObjects = hyperlinkObjects;
+ getHyperlinkObjects().clear();
+ getHyperlinkObjects().addAll(hyperlinkObjects);
}
- /**
- *
- * @see org.eclipse.papyrus.infra.hyperlink.ui.AbstractHyperLinkTab#init(org.eclipse.swt.custom.CTabFolder, java.util.List, org.eclipse.emf.ecore.EObject)
- *
- * @param cTabFolder
- * @param hyperlinkObjects
- * @param element
- */
@Override
- public void init(CTabFolder cTabFolder, List<HyperLinkObject> hyperlinkObjects, EObject element/* , IHyperLinkShell parent */) {
- super.init(cTabFolder, hyperlinkObjects, element /* , parent */);
- CTabItem cTabItem2 = new CTabItem(cTabFolder, SWT.NONE);
- cTabItem2.setText(Messages.HyperLinkTab_title);
- Composite diagramComposite = new Composite(cTabFolder, SWT.NONE);
- cTabItem2.setControl(diagramComposite);
+ public void init(TabFolder tabFolder, List<HyperLinkObject> hyperlinkObjects, EObject element/* , IHyperLinkShell parent */) {
+ super.init(tabFolder, hyperlinkObjects, element /* , parent */);
+
+ hyperlinksTab = new TabItem(tabFolder, SWT.NONE);
+ hyperlinksTab.setText(Messages.HyperLinkTab_title);
+
+ Composite diagramComposite = new Composite(tabFolder, SWT.NONE);
+ hyperlinksTab.setControl(diagramComposite);
GridData gridData4 = new GridData();
gridData4.horizontalAlignment = GridData.FILL;
gridData4.verticalAlignment = GridData.CENTER;
@@ -161,12 +147,10 @@ public class HyperLinkTab extends AbstractHyperLinkTab {
gridLayout.numColumns = 2;
gridLayout.makeColumnsEqualWidth = false;
- diagramComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
diagramComposite.setLayout(gridLayout);
CLabel listLabel = new CLabel(diagramComposite, SWT.SHADOW_NONE);
listLabel.setText(Messages.HyperLinkTab_Listof);
listLabel.setEnabled(false);
- listLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
new Label(diagramComposite, SWT.NONE);
hyperLinkListTable = new Table(diagramComposite, SWT.BORDER | SWT.MULTI);
@@ -182,29 +166,33 @@ public class HyperLinkTab extends AbstractHyperLinkTab {
hyperLinkListTable.setToolTipText(Messages.HyperLinkTab_SetOf);
hyperLinkListTable.setLayoutData(gridData1);
hyperLinkListTable.setLinesVisible(false);
- modifyHyperLinkButton = new Button(diagramComposite, SWT.NONE);
+
+ modifyHyperLinkButton = new Button(diagramComposite, SWT.PUSH);
modifyHyperLinkButton.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("/icons/Edit_16x16.gif")); //$NON-NLS-1$
modifyHyperLinkButton.setToolTipText("Edit hyperlink");
- removeHyperLinkButton = new Button(diagramComposite, SWT.NONE);
+ removeHyperLinkButton = new Button(diagramComposite, SWT.PUSH);
removeHyperLinkButton.setText(""); //$NON-NLS-1$
removeHyperLinkButton.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("/icons/Delete_16x16.gif")); //$NON-NLS-1$
removeHyperLinkButton.setToolTipText("Remove hyperlink");
- upHyperLinkButton = new Button(diagramComposite, SWT.NONE);
+ upHyperLinkButton = new Button(diagramComposite, SWT.PUSH);
upHyperLinkButton.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("/icons/ArrowUp_16x16.gif")); //$NON-NLS-1$
upHyperLinkButton.setToolTipText("Move hyperlink up");
-
upHyperLinkButton.setLayoutData(gridData2);
- downHyperLinkButton = new Button(diagramComposite, SWT.NONE);
+
+ downHyperLinkButton = new Button(diagramComposite, SWT.PUSH);
downHyperLinkButton.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("/icons/ArrowDown_16x16.gif")); //$NON-NLS-1$
downHyperLinkButton.setToolTipText("Move hyperlink down");
-
downHyperLinkButton.setLayoutData(gridData3);
+
addListeners();
+
tableViewer.setContentProvider(CollectionContentProvider.instance);
- this.hyperlinkObjects = hyperLinkHelper.getFilteredObject(hyperlinkObjects);
+ setHyperlinkObjects(getHyperLinkHelper().getFilteredObject(hyperlinkObjects));
+
+ updateButtonEnablement(null);
ILabelProvider provider = null;
if (element != null) {
@@ -220,16 +208,35 @@ public class HyperLinkTab extends AbstractHyperLinkTab {
}
tableViewer.setLabelProvider(provider);
- getTableViewer().setInput(this.hyperlinkObjects);
+ getTableViewer().setInput(getHyperlinkObjects());
}
- protected void addListeners() {
- getRemoveHyperLinkButton().addMouseListener(new MouseListener() {
+ private void updateButtonEnablement(SelectionChangedEvent event) {
+ IStructuredSelection selection = (event == null)
+ ? (IStructuredSelection) tableViewer.getSelection()
+ : (IStructuredSelection) event.getSelection();
+
+ if (selection == null) {
+ // Disable everything
+ getRemoveHyperLinkButton().setEnabled(false);
+ getModifyHyperLinkButton().setEnabled(false);
+ getUpHyperLinkButton().setEnabled(false);
+ getDownHyperLinkButton().setEnabled(false);
+ } else {
+ int index = getTableViewer().getTable().getSelectionIndex();
+ getUpHyperLinkButton().setEnabled(index > 0);
+ getDownHyperLinkButton().setEnabled((index >= 0) && (index < (getHyperlinkObjects().size() - 1)));
+ getRemoveHyperLinkButton().setEnabled(true);
+ getModifyHyperLinkButton().setEnabled(!((List<?>) selection.toList()).stream().anyMatch(HyperLinkSpecificObject.class::isInstance));
+ }
+ }
- public void mouseUp(MouseEvent e) {
- }
+ protected void addListeners() {
+ getTableViewer().addSelectionChangedListener(this::updateButtonEnablement);
- public void mouseDown(MouseEvent e) {
+ getRemoveHyperLinkButton().addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
if (HyperLinkTab.this.getTableViewer().getTable().getSelection().length != 0) {
Iterator<?> iterator = ((IStructuredSelection) HyperLinkTab.this.getTableViewer().getSelection()).iterator();
while (iterator.hasNext()) {
@@ -239,17 +246,11 @@ public class HyperLinkTab extends AbstractHyperLinkTab {
}
}
}
-
- public void mouseDoubleClick(MouseEvent e) {
- }
});
- getUpHyperLinkButton().addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
+ getUpHyperLinkButton().addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
if (HyperLinkTab.this.getTableViewer().getTable().getSelection().length != 0) {
Object elt = ((IStructuredSelection) HyperLinkTab.this.getTableViewer().getSelection()).getFirstElement();
if (HyperLinkTab.this.getHyperlinkObjects().indexOf(elt) == 0) {
@@ -263,19 +264,14 @@ public class HyperLinkTab extends AbstractHyperLinkTab {
HyperLinkTab.this.getHyperlinkObjects().add(index - 1, currentHyperLinkDoc);
HyperLinkTab.this.getTableViewer().setInput(HyperLinkTab.this.getHyperlinkObjects());
}
+ updateButtonEnablement(null);
}
}
-
- public void mouseDoubleClick(MouseEvent e) {
- }
});
- getDownHyperLinkButton().addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
+ getDownHyperLinkButton().addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
if (HyperLinkTab.this.getTableViewer().getTable().getSelection().length != 0) {
Object[] block = ((IStructuredSelection) HyperLinkTab.this.getTableViewer().getSelection()).toArray();
if ((HyperLinkTab.this.getHyperlinkObjects().indexOf(block[block.length - 1])) == HyperLinkTab.this.getHyperlinkObjects().size() - 1) {
@@ -288,25 +284,24 @@ public class HyperLinkTab extends AbstractHyperLinkTab {
HyperLinkTab.this.getHyperlinkObjects().add(index + 1, currentobject);
HyperLinkTab.this.getTableViewer().setInput(HyperLinkTab.this.getHyperlinkObjects());
}
+ updateButtonEnablement(null);
}
}
-
- public void mouseDoubleClick(MouseEvent e) {
- }
});
final Runnable addHandler = new Runnable() {
+ @Override
public void run() {
- HyperLinkTab.this.hyperLinkHelper.executeNewMousePressed(HyperLinkTab.this.getHyperlinkObjects(), HyperLinkTab.this.element);
+ HyperLinkTab.this.getHyperLinkHelper().executeNewMousePressed(hyperlinksTab.getControl().getShell(),
+ HyperLinkTab.this.getHyperlinkObjects(), HyperLinkTab.this.getElement());
HyperLinkTab.this.setInput(HyperLinkTab.this.getHyperlinkObjects());
}
};
if (!isCompositeHelper()) {
- getNewHyperLinkbutton().addMouseListener(new MouseAdapter() {
-
+ getNewHyperLinkbutton().addSelectionListener(new SelectionAdapter() {
@Override
- public void mouseDown(MouseEvent e) {
+ public void widgetSelected(SelectionEvent e) {
addHandler.run();
}
});
@@ -314,33 +309,28 @@ public class HyperLinkTab extends AbstractHyperLinkTab {
addNewHyperLinkMenuActions(addHandler);
}
- getModifyHyperLinkButton().addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
+ getModifyHyperLinkButton().addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
if (HyperLinkTab.this.getTableViewer().getTable().getSelection().length != 0) {
HyperLinkObject hyperLinkObject = (HyperLinkObject) ((IStructuredSelection) HyperLinkTab.this.getTableViewer().getSelection()).getFirstElement();
- HyperLinkTab.this.hyperLinkHelper.executeEditMousePressed(HyperLinkTab.this.getHyperlinkObjects(), hyperLinkObject, HyperLinkTab.this.element);
+ HyperLinkTab.this.getHyperLinkHelper().executeEditMousePressed(hyperlinksTab.getControl().getShell(),
+ HyperLinkTab.this.getHyperlinkObjects(), hyperLinkObject, HyperLinkTab.this.getElement());
HyperLinkTab.this.setInput(HyperLinkTab.this.getHyperlinkObjects());
}
}
-
- public void mouseDoubleClick(MouseEvent e) {
- }
});
}
private void addNewHyperLinkMenuActions(final Runnable addNewHyperlinkHandler) {
PopupButtonMenu menu = new PopupButtonMenu(getNewHyperLinkbutton());
- for (final AbstractHyperLinkHelper helper : ((CompositeHyperlinkHelper) hyperLinkHelper).getHelpers()) {
+ for (final AbstractHyperLinkHelper helper : ((CompositeHyperlinkHelper) getHyperLinkHelper()).getHelpers()) {
IAction action = new Action(helper.getNameofManagedHyperLink()) {
@Override
public void run() {
- ((CompositeHyperlinkHelper) hyperLinkHelper).setActiveHelper(helper);
+ ((CompositeHyperlinkHelper) getHyperLinkHelper()).setActiveHelper(helper);
addNewHyperlinkHandler.run();
}
};
@@ -350,47 +340,26 @@ public class HyperLinkTab extends AbstractHyperLinkTab {
}
}
- /**
- *
- * @return get the button to create a hyperlinkObject
- */
private Button getNewHyperLinkbutton() {
return newHyperLinkbutton;
}
protected boolean isCompositeHelper() {
- return hyperLinkHelper instanceof CompositeHyperlinkHelper;
+ return getHyperLinkHelper() instanceof CompositeHyperlinkHelper;
}
- /**
- *
- * @return the button to edit a hyperlinkObject
- */
-
private Button getModifyHyperLinkButton() {
return modifyHyperLinkButton;
}
- /**
- *
- * @return the button to remove a hyperlinkObject
- */
private Button getRemoveHyperLinkButton() {
return removeHyperLinkButton;
}
- /**
- *
- * @return the button to move up a hyperlinkObject
- */
private Button getUpHyperLinkButton() {
return upHyperLinkButton;
}
- /**
- *
- * @return the button to move down the hyperlinkObject
- */
private Button getDownHyperLinkButton() {
return downHyperLinkButton;
}
@@ -404,8 +373,8 @@ public class HyperLinkTab extends AbstractHyperLinkTab {
@Override
public void setInput(List<HyperLinkObject> hyperlinkObjects) {
if (!getTableViewer().getControl().isDisposed()) {
- this.hyperlinkObjects = this.hyperLinkHelper.getFilteredObject(hyperlinkObjects);
- getTableViewer().setInput(this.hyperlinkObjects);
+ setHyperlinkObjects(this.getHyperLinkHelper().getFilteredObject(hyperlinkObjects));
+ getTableViewer().setInput(this.getHyperlinkObjects());
} else {
Activator.log.warn("This hyperlink tab has been disposed");
}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/EditorHelper.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/EditorHelper.java
index 4835ae0e764..446f7f1c756 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/EditorHelper.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/EditorHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
+ * Copyright (c) 2012, 2016 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,10 +9,13 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 488965
*
*****************************************************************************/
package org.eclipse.papyrus.infra.ui.util;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
@@ -33,6 +36,33 @@ public class EditorHelper {
// nothing to do
}
+
+ /**
+ *
+ * @return
+ * the current workbench window or <code>null</code> if not found
+ */
+ public static final Shell getActiveShell() {
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ if (workbench != null) {
+ return workbench.getActiveWorkbenchWindow().getShell();
+ }
+ return Display.getCurrent().getActiveShell();
+ }
+
+ /**
+ *
+ * @return
+ * the current workbench window or <code>null</code> if not found
+ */
+ public static final IWorkbenchWindow getActiveWindow() {
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ if (workbench != null) {
+ return workbench.getActiveWorkbenchWindow();
+ }
+ return null;
+ }
+
/**
*
* @return

Back to the top