Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 228993 Details for
Bug 403202
[Navigation Service] The Navigation Service shall be configured with a Preferences Page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch For bug 403202
org.eclipse.papyrus.infra.services.navigation_25032013_Bug 403202.patch (text/plain), 13.87 KB, created by
N G
on 2013-03-25 06:45:29 EDT
(
hide
)
Description:
Patch For bug 403202
Filename:
MIME Type:
Creator:
N G
Created:
2013-03-25 06:45:29 EDT
Size:
13.87 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.papyrus.infra.services.navigation >Index: src/org/eclipse/papyrus/infra/services/navigation/service/impl/NavigationServiceImpl.java >=================================================================== >--- src/org/eclipse/papyrus/infra/services/navigation/service/impl/NavigationServiceImpl.java (revision 10667) >+++ src/org/eclipse/papyrus/infra/services/navigation/service/impl/NavigationServiceImpl.java (working copy) >@@ -17,6 +17,7 @@ > > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.preference.IPreferenceStore; > import org.eclipse.jface.viewers.ColumnLabelProvider; > import org.eclipse.papyrus.infra.core.services.ServiceException; > import org.eclipse.papyrus.infra.core.services.ServicesRegistry; >@@ -32,8 +33,8 @@ > import org.eclipse.swt.widgets.Control; > > /** >- * Base implementation of the NavigationService. It is based on >- * the navigationContributor extension point. >+ * Base implementation of the NavigationService. It is based on the >+ * navigationContributor extension point. > * > * @author Camille Letavernier > */ >@@ -41,16 +42,22 @@ > > public static final String EXTENSION_ID = Activator.PLUGIN_ID + ".navigationContributor"; > >+ /** >+ * The isActive property suffix (For preferences) >+ */ >+ public static final String IS_ACTIVE_KEY = "isActive"; //$NON-NLS-1$ >+ > public void init(ServicesRegistry servicesRegistry) throws ServiceException { >- //Nothing >+ // Nothing > } > > public void startService() throws ServiceException { > createNavigationContributors(); >+ > } > > protected void createNavigationContributors() { >- navigationContributors = new LinkedList<NavigationContributor>(); >+ navigationContributors = new LinkedList<NavigationContributorWrapper>(); > > IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID); > >@@ -59,9 +66,10 @@ > Object instance = e.createExecutableExtension("contributor"); > if(instance instanceof NavigationContributor) { > NavigationContributorWrapper wrapper = new NavigationContributorWrapper((NavigationContributor)instance); >- wrapper.id = e.getAttribute("id"); >- wrapper.label = e.getAttribute("label"); >- wrapper.description = e.getAttribute("description"); >+ wrapper.setId(e.getAttribute("id")); >+ wrapper.setLabel(e.getAttribute("label")); >+ wrapper.setDescription(e.getAttribute("description")); >+ wrapper.init(); > navigationContributors.add(wrapper); > } > } catch (Exception ex) { >@@ -71,14 +79,16 @@ > } > > public void disposeService() throws ServiceException { >- //Nothing >+ // Nothing > } > > public List<NavigableElement> getNavigableElements(Object fromElement) { > List<NavigableElement> navigableElements = new LinkedList<NavigableElement>(); > >- for(NavigationContributor contributor : navigationContributors) { >- navigableElements.addAll(contributor.getNavigableElements(fromElement)); >+ for(NavigationContributorWrapper contributor : navigationContributors) { >+ if(contributor.isActive()) { >+ navigableElements.addAll(contributor.getNavigableElements(fromElement)); >+ } > } > > return navigableElements; >@@ -88,29 +98,74 @@ > > private final NavigationContributor contributor; > >- private boolean isActive = true; >- > private String label; > > private String description; > > private String id; > >+ private final IPreferenceStore preferences; >+ > public NavigationContributorWrapper(NavigationContributor contributor) { > this.contributor = contributor; >+ >+ preferences = Activator.getDefault().getPreferenceStore(); > } > >+ public void init() { >+ String isActiveKey = getIsActiveKey(this); >+ preferences.setDefault(isActiveKey, true); >+ } >+ > public List<NavigableElement> getNavigableElements(Object fromElement) { >- if(isActive) { >+ if(isActive()) { > return contributor.getNavigableElements(fromElement); > } else { > return Collections.emptyList(); > } > } >+ >+ public String getLabel() { >+ return label; >+ } >+ >+ public void setLabel(String label) { >+ this.label = label; >+ } >+ >+ public String getDescription() { >+ return description; >+ } >+ >+ public void setDescription(String description) { >+ this.description = description; >+ } >+ >+ public String getId() { >+ return id; >+ } >+ >+ public void setId(String id) { >+ this.id = id; >+ } >+ >+ public boolean isActive() { /* NavigationContributorWrapper strategy */ >+ String preferenceKey = getIsActiveKey(this); >+ return preferences.getBoolean(preferenceKey); >+ } >+ >+ public static String getIsActiveKey(NavigationContributorWrapper strategy) { >+ return strategy.getId() + "." + IS_ACTIVE_KEY; >+ } >+ > } > >- private List<NavigationContributor> navigationContributors; >+ private List<NavigationContributorWrapper> navigationContributors; > >+ public List<NavigationContributorWrapper> getNavigationContributors() { >+ return navigationContributors; >+ } >+ > public SelectionMenu createNavigationList(Object fromElement, final Control parent) { > List<NavigableElement> navigableElements = getNavigableElements(fromElement); > if(navigableElements.isEmpty()) { >@@ -163,6 +218,4 @@ > > return selectionMenu; > } >- >- > } >Index: src/org/eclipse/papyrus/infra/services/navigation/preferences/NavigationServicePreferencesPage.java >=================================================================== >--- src/org/eclipse/papyrus/infra/services/navigation/preferences/NavigationServicePreferencesPage.java (revision 0) >+++ src/org/eclipse/papyrus/infra/services/navigation/preferences/NavigationServicePreferencesPage.java (working copy) >@@ -0,0 +1,199 @@ >+/***************************************************************************** >+ * Copyright (c) 2013 CEA LIST. >+ * >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Nizar GUEDIDI (CEA LIST) - Initial API and implementation >+ *****************************************************************************/ >+package org.eclipse.papyrus.infra.services.navigation.preferences; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.preferences.IEclipsePreferences; >+import org.eclipse.core.runtime.preferences.InstanceScope; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.preference.PreferencePage; >+import org.eclipse.jface.viewers.ColumnLabelProvider; >+import org.eclipse.jface.viewers.ColumnWeightData; >+import org.eclipse.jface.viewers.TableLayout; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.jface.viewers.ViewerCell; >+import org.eclipse.papyrus.infra.core.services.ServiceException; >+import org.eclipse.papyrus.infra.services.navigation.Activator; >+import org.eclipse.papyrus.infra.services.navigation.service.impl.NavigationServiceImpl; >+import org.eclipse.papyrus.infra.services.navigation.service.impl.NavigationServiceImpl.NavigationContributorWrapper; >+import org.eclipse.papyrus.infra.widgets.providers.CollectionContentProvider; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.TableEditor; >+import org.eclipse.swt.graphics.Image; >+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.TableColumn; >+import org.eclipse.swt.widgets.TableItem; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPreferencePage; >+import org.osgi.service.prefs.BackingStoreException; >+ >+public class NavigationServicePreferencesPage extends PreferencePage implements IWorkbenchPreferencePage { >+ >+ public static final int ACTIVATION_COLUMN = 0; >+ >+ private Map<NavigationContributorWrapper, Button> checkboxes; >+ >+ private NavigationServiceImpl navigation = new NavigationServiceImpl(); >+ >+ /** >+ * >+ * Constructor. >+ * >+ */ >+ public NavigationServicePreferencesPage() { >+ super("Navigation Services", org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImageDescriptor("/icons/papyrus.png")); >+ } >+ >+ public void init(IWorkbench workbench) { >+ setPreferenceStore(Activator.getDefault().getPreferenceStore()); >+ setDescription("Papyrus navigation services configuration.\nSelect the strategies you wish to activate."); >+ } >+ >+ @Override >+ protected Control createContents(Composite parent) { >+ >+ Composite self = new Composite(parent, SWT.NONE); >+ self.setLayout(new GridLayout(1, true)); >+ >+ final TableViewer tableViewer = new TableViewer(self); >+ GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false); >+ tableViewer.getTable().setLayoutData(gridData); >+ >+ tableViewer.setContentProvider(CollectionContentProvider.instance); >+ >+ // NavigationServiceImpl navigation = new NavigationServiceImpl(); >+ try { >+ navigation.startService(); >+ } catch (ServiceException ex) { >+ return self; >+ } >+ >+ tableViewer.setLabelProvider(new ColumnLabelProvider() { >+ >+ @Override >+ public void update(ViewerCell cell) { >+ if(cell.getColumnIndex() == 1) { >+ super.update(cell); >+ } else { >+ return; >+ } >+ } >+ >+ @Override >+ public Image getImage(Object element) { >+ if(element instanceof NavigationContributorWrapper) { >+ return null; >+ } >+ >+ return super.getImage(element); >+ } >+ >+ @Override >+ public String getText(Object element) { >+ if(element instanceof NavigationContributorWrapper) { >+ return ((NavigationContributorWrapper)element).getLabel(); >+ } >+ return super.getText(element); >+ } >+ }); >+ >+ TableLayout layout = new TableLayout(); >+ >+ new TableColumn(tableViewer.getTable(), SWT.LEFT); >+ layout.addColumnData(new ColumnWeightData(10, 25, false)); >+ >+ new TableColumn(tableViewer.getTable(), SWT.LEFT); >+ layout.addColumnData(new ColumnWeightData(100, 250, true)); >+ >+ tableViewer.getTable().setLayout(layout); >+ tableViewer.getTable().setHeaderVisible(false); >+ >+ tableViewer.setInput(navigation.getNavigationContributors()); >+ >+ // Adds a checkbox for each service navigation, to toggle it >+ checkboxes = new HashMap<NavigationContributorWrapper, Button>(); >+ >+ for(TableItem item : tableViewer.getTable().getItems()) { >+ if(item.getData() instanceof NavigationContributorWrapper) { >+ TableEditor editor = new TableEditor(tableViewer.getTable()); >+ >+ final Button button = new Button(tableViewer.getTable(), SWT.CHECK); >+ final TableItem currentItem = item; >+ >+ final NavigationContributorWrapper strategy = (NavigationContributorWrapper)currentItem.getData(); >+ >+ checkboxes.put(strategy, button); >+ >+ button.setSelection(strategy.isActive()); >+ >+ editor.setEditor(button, item, ACTIVATION_COLUMN); >+ editor.horizontalAlignment = SWT.CENTER; >+ editor.grabHorizontal = true; >+ >+ } >+ } >+ >+ return self; >+ } >+ >+ @Override >+ protected void performDefaults() { >+ restoreDefaults(); >+ super.performDefaults(); >+ } >+ >+ @Override >+ protected void performApply() { >+ IPreferenceStore preferences = Activator.getDefault().getPreferenceStore(); >+ >+ for(Map.Entry<NavigationContributorWrapper, Button> entry : checkboxes.entrySet()) { >+ boolean checked = entry.getValue().getSelection(); >+ String isActiveKey = NavigationContributorWrapper.getIsActiveKey(entry.getKey()); >+ preferences.setValue(isActiveKey, checked); >+ } >+ >+ try { >+ IEclipsePreferences preferenceStore = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID); >+ preferenceStore.flush(); >+ } catch (BackingStoreException ex) { >+ Activator.log.error(ex); >+ } >+ } >+ >+ @Override >+ public boolean performOk() { >+ performApply(); >+ return super.performOk(); >+ } >+ >+ /** >+ * Restores the default preferences >+ */ >+ >+ public void restoreDefaults() { >+ IPreferenceStore preferences = Activator.getDefault().getPreferenceStore(); >+ >+ for (Map.Entry<NavigationContributorWrapper, Button> entry : checkboxes.entrySet()){ >+ String isActiveKey = NavigationContributorWrapper.getIsActiveKey(entry.getKey()); >+ boolean selected = preferences.getDefaultBoolean(isActiveKey); >+ >+ entry.getValue().setSelection(selected); >+ } >+ } >+} >Index: META-INF/MANIFEST.MF >=================================================================== >--- META-INF/MANIFEST.MF (revision 10667) >+++ META-INF/MANIFEST.MF (working copy) >@@ -10,8 +10,10 @@ > org.eclipse.papyrus.infra.core;bundle-version="0.10.0", > org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0", > org.eclipse.papyrus.infra.widgets;bundle-version="0.10.0", >- org.eclipse.jdt.ui;bundle-version="3.9.0" >+ org.eclipse.jdt.ui;bundle-version="3.9.0", >+ org.eclipse.jface > Bundle-RequiredExecutionEnvironment: J2SE-1.5 > Bundle-ActivationPolicy: lazy > Export-Package: org.eclipse.papyrus.infra.services.navigation, > org.eclipse.papyrus.infra.services.navigation.service >+Import-Package: org.eclipse.papyrus.infra.gmfdiag.preferences.pages.internal >Index: plugin.xml >=================================================================== >--- plugin.xml (revision 10667) >+++ plugin.xml (working copy) >@@ -11,5 +11,14 @@ > startKind="lazy"> > </service> > </extension> >+ <extension >+ point="org.eclipse.ui.preferencePages"> >+ <page >+ category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory" >+ class="org.eclipse.papyrus.infra.services.navigation.preferences.NavigationServicePreferencesPage" >+ id="org.eclipse.papyrus.infra.services.navigation.preferences" >+ name="Service Navigation"> >+ </page> >+ </extension> > > </plugin>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
cletavernier
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 403202
: 228993