Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2016-10-19 09:13:33 +0000
committerGerrit Code Review @ Eclipse.org2016-10-24 11:34:58 +0000
commit8d461ef1b814327dc9763a754a749afdbb73ae2e (patch)
treeb322775c5cb20dddea969e3ec781290adb1ad008
parent1ea3700c9500431425fbf06d5047f44e8adf38e3 (diff)
downloadorg.eclipse.papyrus-8d461ef1b814327dc9763a754a749afdbb73ae2e.tar.gz
org.eclipse.papyrus-8d461ef1b814327dc9763a754a749afdbb73ae2e.tar.xz
org.eclipse.papyrus-8d461ef1b814327dc9763a754a749afdbb73ae2e.zip
Bug 505907 - [Model Explorer] Expand is failing with Package Import
https://bugs.eclipse.org/bugs/show_bug.cgi?id=505907 - Add max expand level preference, set to 15 by default. Change-Id: Ib0068d7176451f9b71bbff05ba47d8d8ec055b70 Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml3
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/Messages.java3
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/ExpandAllHandler.java12
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/messages.properties4
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/ExpandPreferenceInitializer.java39
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/ExpandPreferencesGroup.java71
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IExpandPreferenceConstants.java26
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IFilterPreferenceConstants.java4
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/ModelExplorerPreferencePage.java9
9 files changed, 163 insertions, 8 deletions
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml
index daf647e2b17..486a094776e 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml
@@ -303,6 +303,9 @@
<initializer
class="org.eclipse.papyrus.views.modelexplorer.preferences.FilterPreferenceInitializer">
</initializer>
+ <initializer
+ class="org.eclipse.papyrus.views.modelexplorer.preferences.ExpandPreferenceInitializer">
+ </initializer>
</extension>
<extension point="org.eclipse.ui.preferencePages">
<page category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory" class="org.eclipse.papyrus.views.modelexplorer.preferences.ModelExplorerPreferencePage" id="org.eclipse.papyrus.views.modelexplorer.preferences.NavigatorPreferencePage" name="Model Explorer">
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/Messages.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/Messages.java
index d71f4a8788d..09533739e64 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/Messages.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/Messages.java
@@ -16,6 +16,9 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.views.modelexplorer.messages"; //$NON-NLS-1$
+ public static String ExpandPreferencesGroup_ExpandGroupLabel;
+ public static String ExpandPreferencesGroup_ExpandGroupTooltip;
+ public static String ExpandPreferencesGroup_MaxLevelLabel;
public static String FilterFieldPreferencesGroup_groupTitle;
public static String FilterFieldPreferencesGroup_UseValidationPreferenceLabel;
public static String FilterFieldPreferencesGroup_ValidationDelayPreferenceLabel;
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/ExpandAllHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/ExpandAllHandler.java
index 749188e3627..3177475e617 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/ExpandAllHandler.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/ExpandAllHandler.java
@@ -13,12 +13,13 @@ package org.eclipse.papyrus.views.modelexplorer.handler;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.views.modelexplorer.Activator;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
import org.eclipse.papyrus.views.modelexplorer.core.ui.pagebookview.MultiViewPageBookView;
+import org.eclipse.papyrus.views.modelexplorer.preferences.IExpandPreferenceConstants;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.PlatformUI;
@@ -52,7 +53,7 @@ public class ExpandAllHandler extends AbstractHandler {
if (selection instanceof StructuredSelection && !selection.isEmpty()) {
// For each element
for (Object object : ((StructuredSelection) selection).toArray()) {
- commonViewer.expandToLevel(object, AbstractTreeViewer.ALL_LEVELS);
+ commonViewer.expandToLevel(object, getLevelToExpand());
}
} else {
// or expand all
@@ -63,6 +64,13 @@ public class ExpandAllHandler extends AbstractHandler {
}
/**
+ * @return the level to expand all levels of the tree.
+ */
+ protected int getLevelToExpand() {
+ return Activator.getDefault().getPreferenceStore().getInt(IExpandPreferenceConstants.PREF_MAX_LEVEL_TO_EXPAND);
+ }
+
+ /**
* Get the view 'References' if it's already opened.
*/
public static ModelExplorerView getOpenedModelExplorerView() {
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/messages.properties b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/messages.properties
index a72b6f7376d..eadf2761cc3 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/messages.properties
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/messages.properties
@@ -1,3 +1,4 @@
+
##########################################################################################
# Copyright (c) 2011 CEA LIST.
#
@@ -11,6 +12,9 @@
# Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
#
########################################################################################
+ExpandPreferencesGroup_ExpandGroupLabel=Expand
+ExpandPreferencesGroup_ExpandGroupTooltip=The expand function is available in model explorer with the + button
+ExpandPreferencesGroup_MaxLevelLabel=Max level (-1 for infinite)
FilterFieldPreferencesGroup_groupTitle=Filter field
FilterFieldPreferencesGroup_UseValidationPreferenceLabel=Use live validation
FilterFieldPreferencesGroup_ValidationDelayPreferenceLabel=Validation delay(ms)
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/ExpandPreferenceInitializer.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/ExpandPreferenceInitializer.java
new file mode 100644
index 00000000000..3f29c3223e4
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/ExpandPreferenceInitializer.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST, ALL4TEC 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:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.views.modelexplorer.Activator;
+
+/**
+ * This preference initializer for expand preferences.
+ */
+public class ExpandPreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /**
+ * Initialize default preferences for expand preferences.
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = getPreferenceStore();
+ store.setDefault(IExpandPreferenceConstants.PREF_MAX_LEVEL_TO_EXPAND, IExpandPreferenceConstants.DEFAULT_MAX_LEVEL_TO_EXPAND_VALUE);
+ }
+
+ /**
+ * Get the preference store.
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ return Activator.getDefault().getPreferenceStore();
+ }
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/ExpandPreferencesGroup.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/ExpandPreferencesGroup.java
new file mode 100644
index 00000000000..82d3791163b
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/ExpandPreferencesGroup.java
@@ -0,0 +1,71 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST, ALL4TEC 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:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer.preferences;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.papyrus.infra.ui.preferences.AbstractPreferenceGroup;
+import org.eclipse.papyrus.views.modelexplorer.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * Preference group for model explorer expand action.
+ */
+public class ExpandPreferencesGroup extends AbstractPreferenceGroup {
+
+ /** The group. */
+ private Group group;
+
+ /** The field editor for expand action preference. */
+ private FieldEditor expandLevelfieldEditor;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parent
+ * The parent.
+ * @param title
+ * The group title.
+ * @param dialogPage
+ * The dialog page.
+ */
+ public ExpandPreferencesGroup(final Composite parent, final String title, final DialogPage dialogPage) {
+ super(parent, title, dialogPage);
+ createContent(parent);
+ }
+
+ /**
+ * Creates the content.
+ *
+ * @param parent
+ * the parent
+ */
+ public void createContent(final Composite parent) {
+ group = new Group(parent, SWT.SCROLL_PAGE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ group.setLayout(layout);
+ group.setText(Messages.ExpandPreferencesGroup_ExpandGroupLabel);
+ group.setToolTipText(Messages.ExpandPreferencesGroup_ExpandGroupTooltip);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(group);
+ expandLevelfieldEditor = new IntegerFieldEditor(IExpandPreferenceConstants.PREF_MAX_LEVEL_TO_EXPAND, Messages.ExpandPreferencesGroup_MaxLevelLabel, group);
+ expandLevelfieldEditor.setPage(dialogPage);
+ addFieldEditor(expandLevelfieldEditor);
+ }
+} \ No newline at end of file
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IExpandPreferenceConstants.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IExpandPreferenceConstants.java
new file mode 100644
index 00000000000..02e02f06e4c
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IExpandPreferenceConstants.java
@@ -0,0 +1,26 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST, ALL4TEC 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:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer.preferences;
+
+/**
+ * Interface to define preference constants for the expand Action.
+ */
+public interface IExpandPreferenceConstants {
+
+ /** The max level to expand action preference. */
+ public static final String PREF_MAX_LEVEL_TO_EXPAND = "maxLevelToExpand"; //$NON-NLS-1$
+
+ /** The default value of the expand action preference. */
+ public static final int DEFAULT_MAX_LEVEL_TO_EXPAND_VALUE = 15;
+
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IFilterPreferenceConstants.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IFilterPreferenceConstants.java
index 677f7af3a7a..b96f415db7f 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IFilterPreferenceConstants.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IFilterPreferenceConstants.java
@@ -24,9 +24,9 @@ public interface IFilterPreferenceConstants {
public static final String PREF_FILTER_VALIDATION_DELAY = "validateDelay"; //$NON-NLS-1$
/** the default value for validation delay. */
- public static final String DEFAULT_VALIDATION_DELAY_VALUE = "600"; //$NON-NLS-1$
+ public static final int DEFAULT_VALIDATION_DELAY_VALUE = 600;
/** the default value for the use of live validation in filter. */
- public static final String DEFAULT_FILTER_LIVE_VALIDATION_VALUE = "true"; //$NON-NLS-1$
+ public static final boolean DEFAULT_FILTER_LIVE_VALIDATION_VALUE = true;
}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/ModelExplorerPreferencePage.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/ModelExplorerPreferencePage.java
index caa0bf17050..bc52974d5f3 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/ModelExplorerPreferencePage.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/ModelExplorerPreferencePage.java
@@ -41,14 +41,15 @@ public class ModelExplorerPreferencePage extends AbstractPapyrusPreferencePage {
@Override
protected void createPageContents(final Composite parent) {
// Add filter field preferences
- FilterFieldPreferencesGroup searchGroup = new FilterFieldPreferencesGroup(
- parent, getTitle(), this);
+ FilterFieldPreferencesGroup searchGroup = new FilterFieldPreferencesGroup(parent, getTitle(), this);
addPreferenceGroup(searchGroup);
// show popup dialog
- TransformCommandShowPopupDialogGroup groupComposite = new TransformCommandShowPopupDialogGroup(
- parent, getTitle(), this);
+ TransformCommandShowPopupDialogGroup groupComposite = new TransformCommandShowPopupDialogGroup(parent, getTitle(), this);
addPreferenceGroup(groupComposite);
+
+ ExpandPreferencesGroup groupExpand = new ExpandPreferencesGroup(parent, getTitle(), this);
+ addPreferenceGroup(groupExpand);
}
}

Back to the top