Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/messages.properties138
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractLookForEditorShell.java720
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java882
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/TreeViewContentProvider.java64
4 files changed, 938 insertions, 866 deletions
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/messages.properties b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/messages.properties
index 0a8a051f089..cd95b42ae52 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/messages.properties
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/messages/messages.properties
@@ -1,69 +1,69 @@
-# Copyright (c) 2011, 2013 CEA LIST and others.
-#
-# 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:
-# CEA LIST - Initial API and implementation
-# Christian W. Damus (CEA LIST) - Consolidate all hyperlink helper contributions into one tab
-
-EditorHyperLinkEditorShell_ICanFindTheHyperLinkEditorObject=I can't find the HyperlinkEditorObject for : {0}
-EditorHyperLinkEditorShell_View=View :
-EditorHyperLinkHelper_Editor=View
-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
-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 :
-DiagramNavigationDialog_ChooseHyperLinks=Choose hyperlink:
-DiagramNavigationDialog_WhichHyperLinksWouldYouToNavigateTo=Which hyperlinks would you like to navigate to?
-EditorHyperlinkDocumentShell_Open=Open
-EditorHyperLinkWebShell_Hyperlinks=Hyperlinks:
-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
-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
+# Copyright (c) 2011, 2013 CEA LIST and others.
+#
+# 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:
+# CEA LIST - Initial API and implementation
+# Christian W. Damus (CEA LIST) - Consolidate all hyperlink helper contributions into one tab
+
+EditorHyperLinkEditorShell_ICanFindTheHyperLinkEditorObject=I can't find the HyperlinkEditorObject for : {0}
+EditorHyperLinkEditorShell_View=View :
+EditorHyperLinkHelper_Editor=View
+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
+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 :
+DiagramNavigationDialog_ChooseHyperLinks=Choose hyperlink:
+DiagramNavigationDialog_WhichHyperLinksWouldYouToNavigateTo=Which hyperlinks would you like to navigate to?
+EditorHyperlinkDocumentShell_Open=Open
+EditorHyperLinkWebShell_Hyperlinks=Hyperlinks:
+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
+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/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractLookForEditorShell.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractLookForEditorShell.java
index cecb50306c9..3c6b413a37e 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractLookForEditorShell.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/AbstractLookForEditorShell.java
@@ -1,344 +1,376 @@
-/*****************************************************************************
- * 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.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.Point;
-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.Shell;
-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
- */
-public class AbstractLookForEditorShell {
-
- /** The lookfor shell. */
- private Shell lookforShell = null; // @jve:decl-index=0:visual-constraint="108,60"
-
- /** The c tab folder. */
- private CTabFolder cTabFolder = null;
-
- /** The diagram listcomposite. */
- private Composite diagramListcomposite = null;
-
- /** The tree viewcomposite. */
- private Composite treeViewcomposite = null;
-
- /** The modeltree. */
- private final Tree modeltree = null;
-
- /** The new diagrambutton. */
- private Button newDiagrambutton = null;
-
- /** 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;
-
- /** The diagramfiltered tree. */
- private FilteredTree diagramfilteredTree = null;
-
- /** The mode filtered tree. */
- private FilteredTree modeFilteredTree = null;
-
- /** The c label. */
- private CLabel cLabel = null;
-
- /**
- * This method initializes lookforShell.
- */
- 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);
- }
-
- /**
- * This method initializes cTabFolder.
- */
- 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);
- 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);
- }
-
- /**
- * This method initializes diagramListcomposite.
- */
- private void createDiagramListcomposite() {
- GridLayout gridLayout2 = new GridLayout();
- diagramListcomposite = new Composite(cTabFolder, SWT.BORDER);
- diagramListcomposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- createDiagramfilteredTree();
- diagramListcomposite.setLayout(gridLayout2);
- }
-
- /**
- * This method initializes treeViewcomposite.
- */
- private void createTreeViewcomposite() {
- GridData gridData5 = new GridData();
- gridData5.horizontalAlignment = GridData.FILL;
- gridData5.verticalAlignment = GridData.CENTER;
- GridData gridData4 = new GridData();
- gridData4.horizontalAlignment = GridData.FILL;
- gridData4.verticalAlignment = GridData.CENTER;
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- treeViewcomposite = new Composite(cTabFolder, SWT.NONE);
- treeViewcomposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- createModelFilteredTree();
- treeViewcomposite.setLayout(gridLayout);
- newDiagrambutton = new Button(treeViewcomposite, SWT.NONE);
- newDiagrambutton.setText(Messages.AbstractLookForEditorShell_New);
- newDiagrambutton.setLayoutData(gridData4);
- removeDiagrambutton = new Button(treeViewcomposite, SWT.NONE);
- removeDiagrambutton.setText(Messages.AbstractLookForEditorShell_Remove);
- removeDiagrambutton.setLayoutData(gridData5);
- cLabel = new CLabel(treeViewcomposite, SWT.NONE);
- cLabel.setText(" "); //$NON-NLS-1$
- cLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- }
-
- /**
- * Gets the modeltree.
- *
- * @return the modeltree
- */
- // @unused
- protected Tree getModeltree() {
- return modeltree;
- }
-
- /**
- * Gets the new diagrambutton.
- *
- * @return the newDiagrambutton
- */
- protected Button getNewDiagrambutton() {
- return newDiagrambutton;
- }
-
- /**
- * Sets the new diagrambutton.
- *
- * @param newDiagrambutton
- * the newDiagrambutton to set
- */
- // @unused
- protected void setNewDiagrambutton(Button newDiagrambutton) {
- this.newDiagrambutton = newDiagrambutton;
- }
-
- /**
- * Gets the remove diagrambutton.
- *
- * @return the removeDiagrambutton
- */
- protected Button getRemoveDiagrambutton() {
- return removeDiagrambutton;
- }
-
- /**
- * Sets the remove diagrambutton.
- *
- * @param removeDiagrambutton
- * the removeDiagrambutton to set
- */
- // @unused
- protected void setRemoveDiagrambutton(Button removeDiagrambutton) {
- this.removeDiagrambutton = removeDiagrambutton;
- }
-
- /**
- * 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
- */
- // @unused
- protected Tree getDiagramListtree() {
- return diagramListtree;
- }
-
- /**
- * 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() {
- GridData gridData6 = new GridData();
- gridData6.horizontalAlignment = GridData.FILL;
- gridData6.grabExcessHorizontalSpace = true;
- gridData6.grabExcessVerticalSpace = true;
- gridData6.verticalAlignment = GridData.FILL;
- diagramfilteredTree = new FilteredTree(diagramListcomposite, SWT.BORDER, new PatternFilter(), true);
- diagramfilteredTree.setLayoutData(gridData6);
- }
-
- /**
- * This method initializes filteredTree.
- */
- private void createModelFilteredTree() {
- GridData gridData3 = new GridData();
- gridData3.horizontalAlignment = GridData.FILL;
- gridData3.grabExcessHorizontalSpace = true;
- gridData3.grabExcessVerticalSpace = true;
- 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);
- }
-
- /**
- * Gets the diagramfiltered tree.
- *
- * @return the diagramfilteredTree
- */
- protected FilteredTree getDiagramfilteredTree() {
- return diagramfilteredTree;
- }
-
- /**
- * Gets the mode filtered tree.
- *
- * @return the modeFilteredTree
- */
- protected FilteredTree getModeFilteredTree() {
- return modeFilteredTree;
- }
-
-}
+/*****************************************************************************
+ * 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.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.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
+ */
+public class AbstractLookForEditorShell {
+
+ /** The lookfor shell. */
+ private Shell lookforShell = null; // @jve:decl-index=0:visual-constraint="108,60"
+
+ /** The c tab folder. */
+ private CTabFolder cTabFolder = null;
+
+ /** The diagram listcomposite. */
+ private Composite diagramListcomposite = null;
+
+ /** The tree viewcomposite. */
+ private Composite treeViewcomposite = null;
+
+ private Composite afterTreeViewComposite = null;
+
+ /** The modeltree. */
+ private final Tree modeltree = null;
+
+ /** The new diagrambutton. */
+ private Button newDiagrambutton = null;
+
+ /** 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;
+
+ /** The diagramfiltered tree. */
+ private FilteredTree diagramfilteredTree = null;
+
+ /** The mode filtered tree. */
+ private FilteredTree modeFilteredTree = null;
+
+ /** The c label. */
+ private CLabel cLabel = null;
+
+ /**
+ * This method initializes lookforShell.
+ */
+ 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);
+ }
+
+ /**
+ * This method initializes cTabFolder.
+ */
+ 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);
+ 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);
+ }
+
+ /**
+ * This method initializes diagramListcomposite.
+ */
+ private void createDiagramListcomposite() {
+ GridLayout gridLayout2 = new GridLayout();
+ diagramListcomposite = new Composite(cTabFolder, SWT.BORDER);
+ diagramListcomposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+ createDiagramfilteredTree();
+ diagramListcomposite.setLayout(gridLayout2);
+ }
+
+ /**
+ * This method initializes treeViewcomposite.
+ */
+ private void createTreeViewcomposite() {
+ GridData gridData4 = new GridData();
+ gridData4.horizontalAlignment = GridData.FILL;
+ gridData4.verticalAlignment = GridData.CENTER;
+ GridData gridData5 = new GridData();
+ gridData4.horizontalAlignment = GridData.FILL;
+ gridData4.verticalAlignment = GridData.CENTER;
+
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 2;
+ treeViewcomposite = new Composite(cTabFolder, SWT.NONE);
+ treeViewcomposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+
+ createModelFilteredTree();
+
+ treeViewcomposite.setLayout(gridLayout);
+ newDiagrambutton = new Button(treeViewcomposite, SWT.NONE);
+ newDiagrambutton.setText(Messages.AbstractLookForEditorShell_New);
+ newDiagrambutton.setLayoutData(gridData4);
+ removeDiagrambutton = new Button(treeViewcomposite, SWT.NONE);
+ removeDiagrambutton.setText(Messages.AbstractLookForEditorShell_Remove);
+ 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
+ */
+ 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);
+ }
+ }
+ }
+
+ /**
+ * Gets the modeltree.
+ *
+ * @return the modeltree
+ */
+ // @unused
+ protected Tree getModeltree() {
+ return modeltree;
+ }
+
+ /**
+ * Gets the new diagrambutton.
+ *
+ * @return the newDiagrambutton
+ */
+ protected Button getNewDiagrambutton() {
+ return newDiagrambutton;
+ }
+
+ /**
+ * Sets the new diagrambutton.
+ *
+ * @param newDiagrambutton
+ * the newDiagrambutton to set
+ */
+ // @unused
+ protected void setNewDiagrambutton(Button newDiagrambutton) {
+ this.newDiagrambutton = newDiagrambutton;
+ }
+
+ /**
+ * Gets the remove diagrambutton.
+ *
+ * @return the removeDiagrambutton
+ */
+ protected Button getRemoveDiagrambutton() {
+ return removeDiagrambutton;
+ }
+
+ /**
+ * Sets the remove diagrambutton.
+ *
+ * @param removeDiagrambutton
+ * the removeDiagrambutton to set
+ */
+ // @unused
+ protected void setRemoveDiagrambutton(Button removeDiagrambutton) {
+ this.removeDiagrambutton = removeDiagrambutton;
+ }
+
+ /**
+ * 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
+ */
+ // @unused
+ protected Tree getDiagramListtree() {
+ return diagramListtree;
+ }
+
+ /**
+ * 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() {
+ GridData gridData6 = new GridData();
+ gridData6.horizontalAlignment = GridData.FILL;
+ gridData6.grabExcessHorizontalSpace = true;
+ gridData6.grabExcessVerticalSpace = true;
+ gridData6.verticalAlignment = GridData.FILL;
+ diagramfilteredTree = new FilteredTree(diagramListcomposite, SWT.BORDER, new PatternFilter(), true);
+ diagramfilteredTree.setLayoutData(gridData6);
+ }
+
+ /**
+ * This method initializes filteredTree.
+ */
+ private void createModelFilteredTree() {
+ GridData gridData3 = new GridData();
+ gridData3.horizontalAlignment = GridData.FILL;
+ gridData3.grabExcessHorizontalSpace = true;
+ gridData3.grabExcessVerticalSpace = true;
+ 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);
+ }
+
+ /**
+ * Gets the diagramfiltered tree.
+ *
+ * @return the diagramfilteredTree
+ */
+ protected FilteredTree getDiagramfilteredTree() {
+ return diagramfilteredTree;
+ }
+
+ /**
+ * Gets the mode filtered tree.
+ *
+ * @return the modeFilteredTree
+ */
+ protected FilteredTree getModeFilteredTree() {
+ return modeFilteredTree;
+ }
+
+ protected Composite getAfterTreeViewComposite() {
+ return afterTreeViewComposite;
+ }
+}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java
index ba66d71d60b..d66d83b2d41 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java
@@ -1,453 +1,429 @@
-/*****************************************************************************
- * Copyright (c) 2011, 2014 CEA LIST and others.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- * Christian W. Damus (CEA) - bug 410346
- * Christian W. Damus (CEA) - bug 431397
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.hyperlink.ui;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-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.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.papyrus.commands.CreationCommandDescriptor;
-import org.eclipse.papyrus.commands.CreationCommandRegistry;
-import org.eclipse.papyrus.commands.ICreationCommand;
-import org.eclipse.papyrus.commands.ICreationCommandRegistry;
-import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
-import org.eclipse.papyrus.infra.core.extension.NotFoundException;
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.emf.providers.strategy.SemanticEMFContentProvider;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
-import org.eclipse.papyrus.infra.hyperlink.Activator;
-import org.eclipse.papyrus.infra.hyperlink.util.EditorListContentProvider;
-import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
-import org.eclipse.swt.SWT;
-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;
-
-//TODO: Refactor. Remove the diagram creation listener, and use a Dialog (Which is blocker) instead of a Shell
-public class EditorLookForEditorShell extends AbstractLookForEditorShell {
-
- /** The adapter factory. */
- protected AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
-
- /** The selected diagram. */
- protected Object selectedEditor;
-
- /**
- * Gets the selected editor.
- *
- * @return the selectedEditor
- */
- protected Object getSelectedEditor() {
- return selectedEditor;
- }
-
- /**
- * Sets the selected editor
- *
- * @param selectedEditor
- * the selectedEditor to set
- */
- protected void setSelectedEditor(Object selectedEditor) {
- this.selectedEditor = selectedEditor;
- }
-
- /** The model. */
- protected EObject model;
-
- /** The diagram menu button. */
- protected Menu diagramMenuButton;
-
- /** The diagram list tree viewer. */
- protected TreeViewer diagramListTreeViewer;
-
- /** The tree viewer. */
- protected TreeViewer treeViewer;
-
- /**
- * The listener interface for receiving diagramCreate events. The class that
- * is interested in processing a diagramCreate event implements this
- * interface, and the object created with that class is registered with a
- * component using the component's <code>addDiagramCreateListener<code> method. When
- * the diagramCreate event occurs, that object's appropriate
- * method is invoked.
- *
- * @see DiagramCreateEvent
- */
- public class DiagramCreateListener extends SelectionAdapter {
-
- /** The command descriptor. */
- private final CreationCommandDescriptor commandDescriptor;
-
- /** The container. */
- private EObject container;
-
- /** The i creation command registry. */
- private final ICreationCommandRegistry iCreationCommandRegistry;
-
- /**
- * {@inheritedDoc}.
- *
- * @param e
- * the e
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- if (treeViewer.getSelection().isEmpty()) {
- return;
- }
-
- IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
-
- EObject elt = EMFHelper.getEObject(selection.getFirstElement());
- if (elt == null) {
- return;
- }
-
- setContainer(elt);
- ModelSet modelSet = ServiceUtilsForEObject.getInstance().getModelSet(elt);
-
- ICreationCommand creationCommand = iCreationCommandRegistry.getCommand(commandDescriptor.getCommandId());
- creationCommand.createDiagram(modelSet, container, null);
-
- // refresh several filtered tree
- getDiagramfilteredTree().getViewer().refresh();
- getModeFilteredTree().getViewer().refresh();
- } catch (NotFoundException ex) {
- Activator.log.error(ex);
- } catch (ServiceException ex) {
- Activator.log.error(ex);
- }
- }
-
- /**
- * Instantiates a new diagram create listener.
- *
- * @param commandDescriptor
- * the command descriptor
- * @param backboneContext
- * the backbone context
- * @param container
- * the container
- * @param iCreationCommandRegistry
- * the i creation command registry
- */
- public DiagramCreateListener(CreationCommandDescriptor commandDescriptor, EObject container, ICreationCommandRegistry iCreationCommandRegistry) {
- super();
- this.commandDescriptor = commandDescriptor;
- this.container = container;
- this.iCreationCommandRegistry = iCreationCommandRegistry;
- }
-
- /**
- * Sets the container.
- *
- * @param container
- * the new container
- */
- public void setContainer(EObject container) {
- this.container = container;
- }
- }
-
-
-
-
- /**
- * Instantiates a new editor look for diagram.
- *
- * @param editorFactoryRegistry
- * the editor factory registry
- * @param amodel
- * the amodel
- */
- public EditorLookForEditorShell(IPageIconsRegistry editorFactoryRegistry, EObject amodel) {
- super();
- this.model = amodel;
- // create the shell
- createLookforShell();
-
- // 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;
-
- try {
- registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(model);
- labelProvider = registry.getService(LabelProviderService.class).getLabelProvider();
- } catch (ServiceException ex) {
- Activator.log.error(ex);
- labelProvider = new LabelProvider();
- }
-
- 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
- treeViewer.setContentProvider(new SemanticEMFContentProvider(null, null, new EObject[] { EcoreUtil.getRootContainer(amodel) }) {
-
- @Override
- public boolean hasChildren(Object element) {
- return super.getChildren(element).length > 0;
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.emf.providers.MoDiscoContentProvider#getChildren(java.lang.Object)
- *
- * @param parentElement
- * @return
- */
- // in some case we return diagram twice!
- // TODO the best correction we be able to manage applied facet, because if we get diagram twice it is probably because there are 2 facets with the same behavior applied
- @Override
- public Object[] getChildren(Object parentElement) {
- Set<Object> alreadyVisited = new HashSet<Object>();
- List<Object> returnedChildren = new ArrayList<Object>();
- Object[] children = super.getChildren(parentElement);
- for (Object current : children) {
- EObject el = EMFHelper.getEObject(current);
- if (el != null) {
- if (!alreadyVisited.contains(el)) {
- returnedChildren.add(current);
- alreadyVisited.add(el);
- }
- }
- }
- return returnedChildren.toArray();
- }
- });
- // treeViewer.setInput(model.eResource());
- treeViewer.setInput(registry);
-
- // install diagramlist
- diagramListTreeViewer = getDiagramfilteredTree().getViewer();
- diagramListTreeViewer.setUseHashlookup(true);
-
- // fill list of diagram
- // TODO
- // diagramListTreeViewer.setLabelProvider(new ObjectLabelProvider(null));
-
- // we can't reuse the same instance of the label provider see bug 385599: [Hyperlink] We can't select the diagram/table for referencing them
- diagramListTreeViewer.setLabelProvider(labelProvider);
-
-
- diagramListTreeViewer.setContentProvider(new EditorListContentProvider(model));
- diagramListTreeViewer.setInput(""); //$NON-NLS-1$
-
- // add listner on the new button to display menu for each diagram
- diagramMenuButton = new Menu(getNewDiagrambutton());
- getNewDiagrambutton().setMenu(diagramMenuButton);
- CreationCommandRegistry commandRegistry = CreationCommandRegistry.getInstance(org.eclipse.papyrus.infra.core.Activator.PLUGIN_ID);
- for (CreationCommandDescriptor desc : commandRegistry.getCommandDescriptors()) {
- MenuItem menuItem = new MenuItem(diagramMenuButton, SWT.PUSH);
- menuItem.addSelectionListener(new DiagramCreateListener(desc, null, commandRegistry));
- menuItem.setText(desc.getLabel());
- }
- getNewDiagrambutton().addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
-
- @Override
- public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
- diagramMenuButton.setVisible(true);
- }
- });
-
- // add listener to remove diagram
- getRemoveDiagrambutton().addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
-
- @Override
- public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
- IStructuredSelection iSelection = (IStructuredSelection) getModeFilteredTree().getViewer().getSelection();
- Iterator<?> iterator = iSelection.iterator();
-
- final IPageManager pageManager;
- try {
- pageManager = ServiceUtilsForEObject.getInstance().getIPageManager(model);
- } catch (ServiceException ex) {
- Activator.log.error(ex);
- return;
- }
-
- final List<Object> pagesToDelete = new LinkedList<Object>();
- while (iterator.hasNext()) {
- EObject selectedElement = EMFHelper.getEObject(iterator.next());
- if (pageManager.allPages().contains(selectedElement)) {
- pagesToDelete.add(selectedElement);
- }
- }
-
- if (pagesToDelete.isEmpty()) {
- return;
- }
-
- for (Object page : pagesToDelete) {
- pageManager.closeAllOpenedPages(page);
- }
-
- //getDiagramfilteredTree().getViewer().setInput(""); //$NON-NLS-1$
- getModeFilteredTree().getViewer().refresh();
- }
- });
-
- // add listener to keep the selected diagram in the list for the model
- // view
- getModeFilteredTree().getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- Object selection = ((IStructuredSelection) getModeFilteredTree().getViewer().getSelection()).getFirstElement();
- refresh(selection);
-
- }
- });
-
- // add listener to keep in mind the selected diagram in the list for the
- // view of digram list
- getDiagramfilteredTree().getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- Object selection = ((IStructuredSelection) getDiagramfilteredTree().getViewer().getSelection()).getFirstElement();
- refresh(selection);
- }
- });
-
- // add listener for the button ok, keep the selected diagram
- getOKbutton().addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- 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) {
- }
- });
-
- // dispose the adapter factory when the shell is closed
- getLookforShell().addDisposeListener(new DisposeListener() {
-
- public void widgetDisposed(DisposeEvent e) {
- // we created the adapter factory, so we should dispose it
- if (adapterFactory instanceof IDisposable) {
- ((IDisposable) adapterFactory).dispose();
- }
- }
- });
-
- }
-
- /**
- * 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();
- }
- }
- }
-
- protected void refresh(Object selectedElement) {
- selectedElement = EMFHelper.getEObject(selectedElement);
- Button but = getOKbutton();
- if (isAValidEditor(selectedElement)) {
- but = getOKbutton();
- but.setEnabled(true);
- selectedEditor = selectedElement;
- } else {
- but.setEnabled(false);
- selectedEditor = null;
- }
- }
-
- protected boolean isAValidEditor(final Object object) {
- if (!(object instanceof EObject)) {
- return false;
- }
-
- EObject eObject = (EObject) object;
-
- try {
- return ServiceUtilsForEObject.getInstance().getIPageMngr(eObject).allPages().contains(object);
- } catch (ServiceException ex) {
- return false;
- }
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2011, 2014 CEA LIST and others.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
+ * Christian W. Damus (CEA) - bug 431397
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.hyperlink.ui;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import org.eclipse.emf.common.notify.AdapterFactory;
+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.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.papyrus.commands.CreationCommandDescriptor;
+import org.eclipse.papyrus.commands.CreationCommandRegistry;
+import org.eclipse.papyrus.commands.ICreationCommand;
+import org.eclipse.papyrus.commands.ICreationCommandRegistry;
+import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
+import org.eclipse.papyrus.infra.core.extension.NotFoundException;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.emf.providers.EMFGraphicalContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.strategy.ContainmentBrowseStrategy;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.hyperlink.Activator;
+import org.eclipse.papyrus.infra.hyperlink.util.EditorListContentProvider;
+import org.eclipse.papyrus.infra.hyperlink.util.TreeViewContentProvider;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.infra.widgets.editors.ICommitListener;
+import org.eclipse.papyrus.infra.widgets.providers.IGraphicalContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
+import org.eclipse.swt.SWT;
+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;
+
+//TODO: Refactor. Remove the diagram creation listener, and use a Dialog (Which is blocker) instead of a Shell
+public class EditorLookForEditorShell extends AbstractLookForEditorShell {
+
+ /** The adapter factory. */
+ protected AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ /** The selected diagram. */
+ protected Object selectedEditor;
+
+ /**
+ * Gets the selected editor.
+ *
+ * @return the selectedEditor
+ */
+ protected Object getSelectedEditor() {
+ return selectedEditor;
+ }
+
+ /**
+ * Sets the selected editor
+ *
+ * @param selectedEditor
+ * the selectedEditor to set
+ */
+ protected void setSelectedEditor(Object selectedEditor) {
+ this.selectedEditor = selectedEditor;
+ }
+
+ /** The model. */
+ protected EObject model;
+
+ /** The diagram menu button. */
+ protected Menu diagramMenuButton;
+
+ /** The diagram list tree viewer. */
+ protected TreeViewer diagramListTreeViewer;
+
+ /** The tree viewer. */
+ protected TreeViewer treeViewer;
+
+ /**
+ * The listener interface for receiving diagramCreate events. The class that
+ * is interested in processing a diagramCreate event implements this
+ * interface, and the object created with that class is registered with a
+ * component using the component's <code>addDiagramCreateListener<code> method. When
+ * the diagramCreate event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @see DiagramCreateEvent
+ */
+ public class DiagramCreateListener extends SelectionAdapter {
+
+ /** The command descriptor. */
+ private final CreationCommandDescriptor commandDescriptor;
+
+ /** The container. */
+ private EObject container;
+
+ /** The i creation command registry. */
+ private final ICreationCommandRegistry iCreationCommandRegistry;
+
+ /**
+ * {@inheritedDoc}.
+ *
+ * @param e
+ * the e
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ if (treeViewer.getSelection().isEmpty()) {
+ return;
+ }
+
+ IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
+
+ EObject elt = EMFHelper.getEObject(selection.getFirstElement());
+ if (elt == null) {
+ return;
+ }
+
+ setContainer(elt);
+ ModelSet modelSet = ServiceUtilsForEObject.getInstance().getModelSet(elt);
+
+ ICreationCommand creationCommand = iCreationCommandRegistry.getCommand(commandDescriptor.getCommandId());
+ creationCommand.createDiagram(modelSet, container, null);
+
+ // refresh several filtered tree
+ getDiagramfilteredTree().getViewer().refresh();
+ getModeFilteredTree().getViewer().refresh();
+ } catch (NotFoundException ex) {
+ Activator.log.error(ex);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ }
+ }
+
+ /**
+ * Instantiates a new diagram create listener.
+ *
+ * @param commandDescriptor
+ * the command descriptor
+ * @param backboneContext
+ * the backbone context
+ * @param container
+ * the container
+ * @param iCreationCommandRegistry
+ * the i creation command registry
+ */
+ public DiagramCreateListener(CreationCommandDescriptor commandDescriptor, EObject container, ICreationCommandRegistry iCreationCommandRegistry) {
+ super();
+ this.commandDescriptor = commandDescriptor;
+ this.container = container;
+ this.iCreationCommandRegistry = iCreationCommandRegistry;
+ }
+
+ /**
+ * Sets the container.
+ *
+ * @param container
+ * the new container
+ */
+ public void setContainer(EObject container) {
+ this.container = container;
+ }
+ }
+
+
+
+
+ /**
+ * Instantiates a new editor look for diagram.
+ *
+ * @param editorFactoryRegistry
+ * the editor factory registry
+ * @param amodel
+ * the amodel
+ */
+ public EditorLookForEditorShell(IPageIconsRegistry editorFactoryRegistry, EObject amodel) {
+ super();
+ this.model = amodel;
+ // create the shell
+ createLookforShell();
+
+ // 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;
+
+ try {
+ registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(model);
+ labelProvider = registry.getService(LabelProviderService.class).getLabelProvider();
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ labelProvider = new LabelProvider();
+ }
+
+ 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) });
+ 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();
+ diagramListTreeViewer.setUseHashlookup(true);
+
+ // fill list of diagram
+ // TODO
+ // diagramListTreeViewer.setLabelProvider(new ObjectLabelProvider(null));
+
+ // we can't reuse the same instance of the label provider see bug 385599: [Hyperlink] We can't select the diagram/table for referencing them
+ diagramListTreeViewer.setLabelProvider(labelProvider);
+
+
+ diagramListTreeViewer.setContentProvider(new EditorListContentProvider(model));
+ diagramListTreeViewer.setInput(""); //$NON-NLS-1$
+
+ // add listner on the new button to display menu for each diagram
+ diagramMenuButton = new Menu(getNewDiagrambutton());
+ getNewDiagrambutton().setMenu(diagramMenuButton);
+ CreationCommandRegistry commandRegistry = CreationCommandRegistry.getInstance(org.eclipse.papyrus.infra.core.Activator.PLUGIN_ID);
+ for (CreationCommandDescriptor desc : commandRegistry.getCommandDescriptors()) {
+ MenuItem menuItem = new MenuItem(diagramMenuButton, SWT.PUSH);
+ menuItem.addSelectionListener(new DiagramCreateListener(desc, null, commandRegistry));
+ menuItem.setText(desc.getLabel());
+ }
+ getNewDiagrambutton().addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
+ diagramMenuButton.setVisible(true);
+ }
+ });
+
+ // add listener to remove diagram
+ getRemoveDiagrambutton().addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
+ IStructuredSelection iSelection = (IStructuredSelection) getModeFilteredTree().getViewer().getSelection();
+ Iterator<?> iterator = iSelection.iterator();
+
+ final IPageManager pageManager;
+ try {
+ pageManager = ServiceUtilsForEObject.getInstance().getIPageManager(model);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ return;
+ }
+
+ final List<Object> pagesToDelete = new LinkedList<Object>();
+ while (iterator.hasNext()) {
+ EObject selectedElement = EMFHelper.getEObject(iterator.next());
+ if (pageManager.allPages().contains(selectedElement)) {
+ pagesToDelete.add(selectedElement);
+ }
+ }
+
+ if (pagesToDelete.isEmpty()) {
+ return;
+ }
+
+ for (Object page : pagesToDelete) {
+ pageManager.closeAllOpenedPages(page);
+ }
+
+ //getDiagramfilteredTree().getViewer().setInput(""); //$NON-NLS-1$
+ getModeFilteredTree().getViewer().refresh();
+ }
+ });
+
+ // add listener to keep the selected diagram in the list for the model
+ // view
+ getModeFilteredTree().getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ Object selection = ((IStructuredSelection) getModeFilteredTree().getViewer().getSelection()).getFirstElement();
+ refresh(selection);
+ }
+ });
+
+ // add listener to keep in mind the selected diagram in the list for the
+ // view of digram list
+ getDiagramfilteredTree().getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ Object selection = ((IStructuredSelection) getDiagramfilteredTree().getViewer().getSelection()).getFirstElement();
+ 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) {
+ }
+ });
+
+ // dispose the adapter factory when the shell is closed
+ getLookforShell().addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ // we created the adapter factory, so we should dispose it
+ if (adapterFactory instanceof IDisposable) {
+ ((IDisposable) adapterFactory).dispose();
+ }
+ }
+ });
+
+ }
+
+ /**
+ * 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();
+ }
+ }
+ }
+
+ protected void refresh(Object selectedElement) {
+ selectedElement = EMFHelper.getEObject(selectedElement);
+ Button but = getOKbutton();
+ if (isAValidEditor(selectedElement)) {
+ but = getOKbutton();
+ but.setEnabled(true);
+ selectedEditor = selectedElement;
+ } else {
+ but.setEnabled(false);
+ selectedEditor = null;
+ }
+ }
+
+ protected boolean isAValidEditor(final Object object) {
+ if (!(object instanceof EObject)) {
+ return false;
+ }
+
+ EObject eObject = (EObject) object;
+
+ try {
+ return ServiceUtilsForEObject.getInstance().getIPageMngr(eObject).allPages().contains(object);
+ } catch (ServiceException ex) {
+ return false;
+ }
+ }
+
+}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/TreeViewContentProvider.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/TreeViewContentProvider.java
new file mode 100644
index 00000000000..3cf4100e961
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/TreeViewContentProvider.java
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.hyperlink.util;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.infra.emf.providers.strategy.SemanticEMFContentProvider;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+
+/**
+ * Specific content provider for the tree view of the "views" dialog to choose a diagram for a hyperlink
+ */
+public class TreeViewContentProvider extends SemanticEMFContentProvider {
+ public TreeViewContentProvider(EObject[] roots) {
+ super(null, null, roots);
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ return super.getChildren(element).length > 0;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.emf.providers.MoDiscoContentProvider#getChildren(java.lang.Object)
+ *
+ * @param parentElement
+ * @return
+ */
+ // in some case we return diagram twice!
+ // TODO the best correction we be able to manage applied facet, because if we get diagram twice it is probably because there are 2 facets with the same behavior applied
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ Set<Object> alreadyVisited = new HashSet<Object>();
+ List<Object> returnedChildren = new ArrayList<Object>();
+ Object[] children = super.getChildren(parentElement);
+ for (Object current : children) {
+ EObject el = EMFHelper.getEObject(current);
+ if (el != null) {
+ if (!alreadyVisited.contains(el)) {
+ returnedChildren.add(current);
+ alreadyVisited.add(el);
+ }
+ }
+ }
+ return returnedChildren.toArray();
+ }
+}

Back to the top