summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis Windatt2013-08-06 11:41:13 (EDT)
committerCurtis Windatt2013-08-06 11:41:13 (EDT)
commit774fb838cad1a8fb4d66d52060553029141f5ddc (patch)
tree75c041924edaee0249b26008cb14455a93058c67
parent6ba1c02eae5ff0fc790d4b1a7bca0513142792e6 (diff)
downloadeclipse.pde.ui-774fb838cad1a8fb4d66d52060553029141f5ddc.zip
eclipse.pde.ui-774fb838cad1a8fb4d66d52060553029141f5ddc.tar.gz
eclipse.pde.ui-774fb838cad1a8fb4d66d52060553029141f5ddc.tar.bz2
Bug 414291 - PDE UI should only start UI job if really needed
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPlugin.java11
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java1
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetStatus.java45
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties1
4 files changed, 47 insertions, 11 deletions
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPlugin.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPlugin.java
index 5bb0f58..e3514d6 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPlugin.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPlugin.java
@@ -32,7 +32,6 @@ import org.eclipse.ui.forms.FormColors;
import org.eclipse.ui.internal.views.log.ILogFileProvider;
import org.eclipse.ui.internal.views.log.LogFilesManager;
import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.osgi.framework.BundleContext;
@@ -198,15 +197,7 @@ public class PDEPlugin extends AbstractUIPlugin implements IPDEUIConstants {
fLogFileProvider = new PDELogFileProvider();
LogFilesManager.addLogFileProvider(fLogFileProvider);
- UIJob job = new UIJob("Refresh Target Status") {
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- TargetStatus.refreshTargetStatus();
- return Status.OK_STATUS;
- }
- };
- job.setSystem(true);
- job.schedule();
+ TargetStatus.initializeTargetStatus();
}
/* (non-Javadoc)
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java
index 02eb015..6ec12b0 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java
@@ -126,6 +126,7 @@ public class Messages extends NLS {
public static String TargetContentsGroup_resolveCancelled;
public static String TargetLocationsGroup_1;
public static String TargetLocationsGroup_TargetUpdateErrorDialog;
+ public static String TargetStatus_NoActiveTargetPlatformStatus;
public static String TargetStatus_TargetStatusDefaultString;
public static String UpdateTargetJob_TargetUpdateFailedStatus;
public static String UpdateTargetJob_TargetUpdateSuccessStatus;
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetStatus.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetStatus.java
index b3e6c86..bee14ba 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetStatus.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetStatus.java
@@ -87,6 +87,8 @@ public class TargetStatus {
if (name != null && name.length() > 0) {
result = name;
}
+ } else {
+ result = Messages.TargetStatus_NoActiveTargetPlatformStatus;
}
} catch (CoreException e) {
PDEPlugin.log(e);
@@ -125,8 +127,49 @@ public class TargetStatus {
}
/**
+ * Adds the target status contribution to the status line manager if the value of
+ * preference {@link IPreferenceConstants#SHOW_TARGET_STATUS} is true. Will not remove
+ * an existing status contribution if the preference is false, to remove use
+ * {@link #refreshTargetStatus()}.
+ * <p>
+ * Does not have to be called from a UI thread.
+ * </p>
+ */
+ public static void initializeTargetStatus() {
+ PDEPreferencesManager prefs = PDEPlugin.getDefault().getPreferenceManager();
+ boolean showStatus = prefs.getBoolean(IPreferenceConstants.SHOW_TARGET_STATUS);
+
+ if (showStatus) {
+ UIJob updateStatus = new UIJob("") { //$NON-NLS-1$
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
+ for (int i = 0; i < windows.length; i++) {
+ IWorkbenchWindow window = windows[i];
+ // We are not in a view or editor so this is the only practical way of getting the status line manager at this time
+ if (window instanceof WorkbenchWindow) {
+ IStatusLineManager slManager = ((WorkbenchWindow) window).getStatusLineManager();
+ if (slManager != null) {
+ slManager.appendToGroup(StatusLineManager.BEGIN_GROUP, getContributionItem());
+ slManager.update(false);
+ break;
+ }
+ }
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ updateStatus.setSystem(true);
+ updateStatus.schedule();
+ }
+ }
+
+ /**
* Adds or removes the target status contribution from the status line manager depending on the
* value of preference {@link IPreferenceConstants#SHOW_TARGET_STATUS}.
+ * <p>
+ * Must be called from the UI Thread.
+ * </p>
*/
public static void refreshTargetStatus() {
PDEPreferencesManager prefs = PDEPlugin.getDefault().getPreferenceManager();
@@ -144,7 +187,7 @@ public class TargetStatus {
} else {
manager.remove(TARGET_STATUS_ID);
}
- manager.update(true);
+ manager.update(false);
break;
}
}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties
index 319e5c2..e21554e 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties
@@ -124,6 +124,7 @@ TargetContentsGroup_PluginMode=Pl&ug-ins
TargetContentsGroup_resolveCancelled=Resolve Cancelled
TargetLocationsGroup_1=&Show location content
TargetLocationsGroup_TargetUpdateErrorDialog=Problems Updating Target Definition
+TargetStatus_NoActiveTargetPlatformStatus=No active target platform
TargetStatus_TargetStatusDefaultString=Target Platform
UpdateTargetJob_TargetUpdateFailedStatus=The target definition did not update successfully
UpdateTargetJob_TargetUpdateSuccessStatus=Target definition update completed successfully