Author: rob.stryker(a)jboss.com
Date: 2008-08-26 17:31:20 -0400 (Tue, 26 Aug 2008)
New Revision: 9911
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/PrefsInitializer.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java
Log:
JBIDE-2692 - refreshing archives view after preference change
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/PrefsInitializer.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/PrefsInitializer.java 2008-08-26
19:18:26 UTC (rev 9910)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/PrefsInitializer.java 2008-08-26
21:31:20 UTC (rev 9911)
@@ -1,5 +1,8 @@
package org.jboss.ide.eclipse.archives.ui;
+import java.util.ArrayList;
+import java.util.Iterator;
+
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
@@ -18,7 +21,12 @@
public static final String PREF_SHOW_FULL_FILESET_ROOT_DIR =
"showFullFilesetRootDir";
public static final String PREF_SHOW_PROJECT_ROOT = "showProjectRoot";
public static final String PREF_SHOW_ALL_PROJECTS = "showAllProjects";
+ public static final ArrayList<IArchivesPreferenceListener> listeners = new
ArrayList<IArchivesPreferenceListener>();
+ public static interface IArchivesPreferenceListener {
+ public void preferenceChanged(String key, boolean val);
+ }
+
public void initializeDefaultPreferences() {
IEclipsePreferences prefs = new DefaultScope().getNode(PackagesUIPlugin.PLUGIN_ID);
prefs.putBoolean(PREF_SHOW_FULL_FILESET_ROOT_DIR, true);
@@ -52,9 +60,25 @@
try {
prefs.flush();
} catch (org.osgi.service.prefs.BackingStoreException e) { } // swallow
-
+ fireChanged(key, val);
}
+ protected static void fireChanged(String key, boolean val) {
+ Iterator<IArchivesPreferenceListener> i = listeners.iterator();
+ while(i.hasNext()) {
+ i.next().preferenceChanged(key, val);
+ }
+ }
+
+ public static void addListener(IArchivesPreferenceListener listener) {
+ if( !listeners.contains(listener))
+ listeners.add(listener);
+ }
+
+ public static void removeListener(IArchivesPreferenceListener listener) {
+ listeners.remove(listener);
+ }
+
/**
* Get the global pref value for this key
* @param key
@@ -65,20 +89,7 @@
}
/**
- * Get the *effective* value of this preference upon this adaptable / resource
- * Effective values are the stored value if project-specific prefs are turned on.
- * Effective values are the global value if project-specific prefs are *NOT* turned on.
*
- * @param key
- * @param adaptable
- * @return
- */
-// public static boolean getBoolean(String key, IAdaptable adaptable) {
-// return getBoolean(key, adaptable, true);
-// }
-
- /**
- *
* @param key the preference to be gotten
* @param adaptable the project / resource where the pref might be stored
* @param effective whether or not to get the raw pref value or the effective value
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java 2008-08-26
19:18:26 UTC (rev 9910)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/preferences/MainPreferencePage.java 2008-08-26
21:31:20 UTC (rev 9911)
@@ -182,10 +182,6 @@
PrefsInitializer.setBoolean(PrefsInitializer.PREF_SHOW_FULL_FILESET_ROOT_DIR,
showFullFilesetRootDir.getSelection(), getElement());
PrefsInitializer.setBoolean(PrefsInitializer.PREF_SHOW_PROJECT_ROOT,
showProjectRoot.getSelection(), getElement());
PrefsInitializer.setBoolean(PrefsInitializer.PREF_SHOW_ALL_PROJECTS,
showAllProjects.getSelection(), getElement());
- // TODO FIX THIS
-// if( ProjectArchivesCommonView.getInstance() != null )
-// ProjectArchivesCommonView.getInstance().refreshViewer(null);
-
return true;
}
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java 2008-08-26
19:18:26 UTC (rev 9910)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesCommonView.java 2008-08-26
21:31:20 UTC (rev 9911)
@@ -27,9 +27,10 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
+import org.jboss.ide.eclipse.archives.ui.PrefsInitializer.IArchivesPreferenceListener;
import
org.jboss.ide.eclipse.archives.ui.providers.ArchivesContentProviderDelegate.WrappedProject;
-public class ProjectArchivesCommonView extends CommonNavigator {
+public class ProjectArchivesCommonView extends CommonNavigator implements
IArchivesPreferenceListener {
protected static ProjectArchivesCommonView instance;
protected ISelectionListener selectionListener;
protected IProject currentProject;
@@ -47,6 +48,7 @@
public void createPartControl(Composite aParent) {
super.createPartControl(aParent);
addBuildActionToSite();
+ PrefsInitializer.addListener(this);
}
public void init(IViewSite site) throws PartInitException {
@@ -57,6 +59,7 @@
public void dispose() {
super.dispose();
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removePostSelectionListener(selectionListener);
+ PrefsInitializer.removeListener(this);
}
protected ISelectionListener createSelectionListener() {
@@ -71,13 +74,7 @@
IProject project = getProject(element);
if( project != null && project != currentProject ) {
currentProject = project;
- if( showProjectRoot()) {
- // if we're showing all projects, then the view is already set.
- if( !showAllProjects() ||
!getCommonViewer().getInput().equals(ResourcesPlugin.getWorkspace().getRoot()))
- getCommonViewer().setInput(ResourcesPlugin.getWorkspace().getRoot());
- } else {
- getCommonViewer().setInput(currentProject);
- }
+ jiggleViewerInput();
}
}
@@ -106,6 +103,16 @@
public IProject getCurrentProject() {
return currentProject;
}
+
+ protected void jiggleViewerInput() {
+ if( showProjectRoot()) {
+ // if we're showing all projects, then the view is already set.
+ if( !showAllProjects() ||
!getCommonViewer().getInput().equals(ResourcesPlugin.getWorkspace().getRoot()))
+ getCommonViewer().setInput(ResourcesPlugin.getWorkspace().getRoot());
+ } else {
+ getCommonViewer().setInput(currentProject);
+ }
+ }
private boolean showProjectRoot() {
return PrefsInitializer.getBoolean(PrefsInitializer.PREF_SHOW_PROJECT_ROOT);
@@ -156,4 +163,8 @@
return new PropertySheetPage();
return super.getAdapter(adapter);
}
+
+ public void preferenceChanged(String key, boolean val) {
+ jiggleViewerInput();
+ }
}
Show replies by date