Author: snjeza
Date: 2012-04-17 15:56:31 -0400 (Tue, 17 Apr 2012)
New Revision: 40253
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IRuntimePathChangeListener.java
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
Log:
JBIDE-11566 - After runtime download the Paths table is not refreshed
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IRuntimePathChangeListener.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IRuntimePathChangeListener.java
(rev 0)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IRuntimePathChangeListener.java 2012-04-17
19:56:31 UTC (rev 40253)
@@ -0,0 +1,7 @@
+package org.jboss.tools.runtime.ui;
+
+public interface IRuntimePathChangeListener {
+
+ void changed();
+
+}
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java 2012-04-17
18:47:10 UTC (rev 40252)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java 2012-04-17
19:56:31 UTC (rev 40253)
@@ -22,11 +22,14 @@
import java.util.List;
import java.util.Set;
+import org.eclipse.core.internal.preferences.PrefsMessages;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import
org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.PreferenceDialog;
@@ -115,6 +118,7 @@
private List<RuntimeDefinition> serverDefinitions;
+ private ListenerList runtimePathChangeChangeListeners;
/**
* The constructor
*/
@@ -383,6 +387,13 @@
String runtimes = writer.toString();
getPreferences().put(RUNTIME_PATHS, runtimes);
getPreferences().flush();
+ if (runtimePathChangeChangeListeners != null) {
+ Object[] listeners = runtimePathChangeChangeListeners.getListeners();
+ for (Object listener:listeners ) {
+ IRuntimePathChangeListener runtimePathChangeChangeListener =
(IRuntimePathChangeListener) listener;
+ runtimePathChangeChangeListener.changed();
+ }
+ }
} catch (Exception e) {
log(e);
} finally {
@@ -497,4 +508,17 @@
return (created);
}
+ public void addRuntimePathChangeListener(IRuntimePathChangeListener listener) {
+ if (runtimePathChangeChangeListeners == null)
+ runtimePathChangeChangeListeners = new ListenerList();
+ runtimePathChangeChangeListeners.add(listener);
+ }
+
+ public void removeRuntimePathChangeListener(IRuntimePathChangeListener listener) {
+ if (runtimePathChangeChangeListeners == null)
+ return;
+ runtimePathChangeChangeListeners.remove(listener);
+ if (runtimePathChangeChangeListeners.size() == 0)
+ runtimePathChangeChangeListeners = null;
+ }
}
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java 2012-04-17
18:47:10 UTC (rev 40252)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java 2012-04-17
19:56:31 UTC (rev 40253)
@@ -61,6 +61,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
@@ -73,6 +74,7 @@
import org.jboss.tools.runtime.core.model.IRuntimeDetector;
import org.jboss.tools.runtime.core.model.RuntimePath;
import org.jboss.tools.runtime.ui.IDownloadRuntimes;
+import org.jboss.tools.runtime.ui.IRuntimePathChangeListener;
import org.jboss.tools.runtime.ui.RuntimeUIActivator;
import org.jboss.tools.runtime.ui.dialogs.AutoResizeTableLayout;
import org.jboss.tools.runtime.ui.dialogs.EditRuntimePathDialog;
@@ -98,6 +100,7 @@
private TableViewer detectorViewer;
private Button searchButton;
private Button downloadButton;
+ private IRuntimePathChangeListener runtimePathChangeListener;
/*
* (non-Javadoc)
@@ -252,6 +255,27 @@
viewer.setInput(runtimePaths);
createRuntimePathsButtons(parent, viewer);
+ runtimePathChangeListener = new IRuntimePathChangeListener() {
+
+ @Override
+ public void changed() {
+
+ Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ if (runtimePathChangeListener == null || errorIcon == null ||
errorIcon.isDisposed()) {
+ return;
+ }
+ runtimePaths = RuntimeUIActivator.getDefault().getRuntimePaths();
+ viewer.setInput(runtimePaths);
+ viewer.refresh();
+ }
+ });
+
+ }
+ };
+ RuntimeUIActivator.getDefault().addRuntimePathChangeListener(runtimePathChangeListener);
return viewer;
}
@@ -465,6 +489,10 @@
@Override
public void dispose() {
+ if (runtimePathChangeListener != null) {
+ RuntimeUIActivator.getDefault().removeRuntimePathChangeListener(runtimePathChangeListener);
+ runtimePathChangeListener = null;
+ }
if (checkboxOff != null) {
checkboxOff.dispose();
}
Show replies by date