summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis Windatt2013-07-31 17:15:58 (EDT)
committer Curtis Windatt2013-08-01 17:06:51 (EDT)
commited9222f22ce96050d29fccd1d5f7e90eb285fcd1 (patch)
tree7eeb193142214a1c472414dc4f71ec7c8fdd348d
parent2c0abfd319750d3725a1f55b6c09b081165eaa7f (diff)
downloadeclipse.pde.ui-ed9222f22ce96050d29fccd1d5f7e90eb285fcd1.zip
eclipse.pde.ui-ed9222f22ce96050d29fccd1d5f7e90eb285fcd1.tar.gz
eclipse.pde.ui-ed9222f22ce96050d29fccd1d5f7e90eb285fcd1.tar.bz2
Bug 276981 - Active target and default baseline in PDE perspective
-rw-r--r--ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEPreferencesManager.java2
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/IPreferenceConstants.java6
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPlugin.java16
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java2
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties1
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java28
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/PreferenceInitializer.java4
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/TargetPlatformPreferencePage.java24
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java3
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetStatus.java153
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties3
11 files changed, 233 insertions, 9 deletions
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEPreferencesManager.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEPreferencesManager.java
index 4998214..8086590 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEPreferencesManager.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEPreferencesManager.java
@@ -61,7 +61,7 @@ public final class PDEPreferencesManager {
* @param key <code>key</code> whose associated value is to be returned as a
* <code>boolean</code>.
* @return the <code>boolean</code> value associated with <code>key</code>, or
- * <code>null</code> if the associated value does not exist in either scope or cannot
+ * <code>false</code> if the associated value does not exist in either scope or cannot
* be interpreted as a <code>boolean</code>.
* @see #setValue(String, boolean)
* @see #setValueOrRemove(String, boolean)
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/IPreferenceConstants.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/IPreferenceConstants.java
index f1eb63d..aca0fcb 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/IPreferenceConstants.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/IPreferenceConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation 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
@@ -28,6 +28,10 @@ public interface IPreferenceConstants extends ILaunchingPreferenceConstants {
public static final String OVERWRITE_BUILD_FILES_ON_EXPORT = "Preferences.MainPage.overwriteBuildFilesOnExport"; //$NON-NLS-1$
public static final String PROP_PROMPT_REMOVE_TARGET = "Preferences.MainPage.promptRemoveTarget"; //$NON-NLS-1$
public static final String ADD_TO_JAVA_SEARCH = "Preferences.MainPage.addToJavaSearch"; //$NON-NLS-1$
+ /**
+ * Boolean preference whether to display the active target platform in the main window status bar
+ */
+ public static final String SHOW_TARGET_STATUS = "Preferences.MainPage.showTargetStatus"; //$NON-NLS-1$
// Editor Outline
public static final String PROP_OUTLINE_SORTING = "PDEMultiPageContentOutline.SortingAction.isChecked"; //$NON-NLS-1$
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 f566a76..5bb0f58 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation 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
@@ -21,6 +21,7 @@ import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.pde.internal.core.PDEPreferencesManager;
import org.eclipse.pde.internal.ui.launcher.PDELogFileProvider;
+import org.eclipse.pde.internal.ui.shared.target.TargetStatus;
import org.eclipse.pde.internal.ui.util.SWTUtil;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
@@ -31,6 +32,7 @@ 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;
@@ -190,15 +192,27 @@ public class PDEPlugin extends AbstractUIPlugin implements IPDEUIConstants {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
*/
+ @Override
public void start(BundleContext context) throws Exception {
super.start(context);
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();
}
/* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
+ @Override
public void stop(BundleContext context) throws Exception {
if (fFormColors != null) {
fFormColors.dispose();
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java
index 32e395e..729c31c 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java
@@ -471,6 +471,8 @@ public class PDEUIMessages extends NLS {
public static String MainPreferencePage_runtimeWorkspaceGroup;
public static String MainPreferencePage_showSourceBundles;
+
+ public static String MainPreferencePage_ShowTargetStatus;
public static String MainPreferencePage_updateStale;
public static String ManifestStructureCreator_errorMessage;
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties
index 62b2f99..603c9e5 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties
@@ -343,6 +343,7 @@ MainPreferencePage_runtimeWorkspace_variables=&Variables...
MainPreferencePage_runtimeWorkspace_workspace=&Workspace...
MainPreferencePage_runtimeWorkspaceGroup=Workspace location for new Eclipse Application launch configurations
MainPreferencePage_showSourceBundles=Show &source plug-ins
+MainPreferencePage_ShowTargetStatus=S&how current target platform in status bar
MainPreferencePage_updateStale=&Update stale manifest files prior to launching
ManifestEditorContributor_externStringsActionName=Externalize Strings...
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java
index 4b213b7..f37ad46 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/MainPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation 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
@@ -11,19 +11,21 @@
*******************************************************************************/
package org.eclipse.pde.internal.ui.preferences;
-import org.eclipse.pde.core.target.ITargetHandle;
+import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.pde.core.target.ITargetHandle;
import org.eclipse.pde.internal.core.PDEPreferencesManager;
import org.eclipse.pde.internal.core.target.TargetPlatformService;
import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants;
import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
import org.eclipse.pde.internal.ui.*;
import org.eclipse.pde.internal.ui.launcher.BaseBlock;
+import org.eclipse.pde.internal.ui.shared.target.TargetStatus;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -66,10 +68,12 @@ public class MainPreferencePage extends PreferencePage implements IWorkbenchPref
createButtons(buttons, new String[] {PDEUIMessages.MainPreferencePage_runtimeWorkspace_workspace, PDEUIMessages.MainPreferencePage_runtimeWorkspace_fileSystem, PDEUIMessages.MainPreferencePage_runtimeWorkspace_variables});
}
+ @Override
protected String getName() {
return PDEUIMessages.WorkspaceDataBlock_name;
}
+ @Override
protected boolean isFile() {
return false;
}
@@ -102,10 +106,12 @@ public class MainPreferencePage extends PreferencePage implements IWorkbenchPref
createButtons(buttons, new String[] {PDEUIMessages.MainPreferencePage_junitWorkspace_workspace, PDEUIMessages.MainPreferencePage_junitWorkspace_fileSystem, PDEUIMessages.MainPreferencePage_junitWorkspace_variables});
}
+ @Override
protected String getName() {
return PDEUIMessages.DefaultJUnitWorkspaceBlock_name;
}
+ @Override
protected boolean isFile() {
return false;
}
@@ -120,6 +126,7 @@ public class MainPreferencePage extends PreferencePage implements IWorkbenchPref
private Button fShowSourceBundles;
private Button fPromptOnRemove;
private Button fAddToJavaSearch;
+ private Button fShowTargetStatus;
private Text fRuntimeWorkspaceLocation;
private Button fRuntimeWorkspaceLocationRadio;
@@ -137,6 +144,7 @@ public class MainPreferencePage extends PreferencePage implements IWorkbenchPref
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
+ @Override
protected Control createContents(Composite parent) {
IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore();
PDEPreferencesManager launchingStore = PDELaunchingPlugin.getDefault().getPreferenceManager();
@@ -160,6 +168,7 @@ public class MainPreferencePage extends PreferencePage implements IWorkbenchPref
fPromptOnRemove.setSelection(!MessageDialogWithToggle.ALWAYS.equals(store.getString(IPreferenceConstants.PROP_PROMPT_REMOVE_TARGET)));
fPromptOnRemove.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
PDEPlugin.getDefault().getPreferenceStore().setValue(IPreferenceConstants.PROP_PROMPT_REMOVE_TARGET, fPromptOnRemove.getSelection() ? MessageDialogWithToggle.PROMPT : MessageDialogWithToggle.ALWAYS);
@@ -171,6 +180,10 @@ public class MainPreferencePage extends PreferencePage implements IWorkbenchPref
fAddToJavaSearch.setText(PDEUIMessages.MainPreferencePage_addToJavaSearch);
fAddToJavaSearch.setSelection(store.getBoolean(IPreferenceConstants.ADD_TO_JAVA_SEARCH));
+ fShowTargetStatus = new Button(optionComp, SWT.CHECK);
+ fShowTargetStatus.setText(PDEUIMessages.MainPreferencePage_ShowTargetStatus);
+ fShowTargetStatus.setSelection(store.getBoolean(IPreferenceConstants.SHOW_TARGET_STATUS));
+
Group group = SWTFactory.createGroup(composite, PDEUIMessages.Preferences_MainPage_showObjects, 2, 1, GridData.FILL_HORIZONTAL);
fUseID = new Button(group, SWT.RADIO);
fUseID.setText(PDEUIMessages.Preferences_MainPage_useIds);
@@ -201,12 +214,14 @@ public class MainPreferencePage extends PreferencePage implements IWorkbenchPref
return composite;
}
+ @Override
public void createControl(Composite composite) {
super.createControl(composite);
Dialog.applyDialogFont(getControl());
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.MAIN_PREFERENCE_PAGE);
}
+ @Override
public boolean performOk() {
IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore();
if (fUseID.getSelection()) {
@@ -234,6 +249,12 @@ public class MainPreferencePage extends PreferencePage implements IWorkbenchPref
}
}
+ boolean showTarget = fShowTargetStatus.getSelection();
+ if (store.getBoolean(IPreferenceConstants.SHOW_TARGET_STATUS) != showTarget) {
+ store.setValue(IPreferenceConstants.SHOW_TARGET_STATUS, showTarget);
+ TargetStatus.refreshTargetStatus();
+ }
+
PDEPlugin.getDefault().getPreferenceManager().savePluginPreferences();
PDEPreferencesManager launchingStore = PDELaunchingPlugin.getDefault().getPreferenceManager();
@@ -251,6 +272,7 @@ public class MainPreferencePage extends PreferencePage implements IWorkbenchPref
return super.performOk();
}
+ @Override
protected void performDefaults() {
IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore();
if (store.getDefaultString(IPreferenceConstants.PROP_SHOW_OBJECTS).equals(IPreferenceConstants.VALUE_USE_IDS)) {
@@ -266,6 +288,7 @@ public class MainPreferencePage extends PreferencePage implements IWorkbenchPref
fPromptOnRemove.setSelection(true);
fAddToJavaSearch.setSelection(store.getDefaultBoolean(IPreferenceConstants.ADD_TO_JAVA_SEARCH));
+ fShowTargetStatus.setSelection(store.getDefaultBoolean(IPreferenceConstants.SHOW_TARGET_STATUS));
PDEPreferencesManager launchingStore = PDELaunchingPlugin.getDefault().getPreferenceManager();
boolean runtimeLocationIsContainer = launchingStore.getDefaultBoolean(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION_IS_CONTAINER);
@@ -282,6 +305,7 @@ public class MainPreferencePage extends PreferencePage implements IWorkbenchPref
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
*/
+ @Override
public void setVisible(boolean visible) {
fPromptOnRemove.setSelection(!MessageDialogWithToggle.ALWAYS.equals(PDEPlugin.getDefault().getPreferenceManager().getString(IPreferenceConstants.PROP_PROMPT_REMOVE_TARGET)));
super.setVisible(visible);
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/PreferenceInitializer.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/PreferenceInitializer.java
index 61d6f989..e0d34f5 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/PreferenceInitializer.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/PreferenceInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation 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
@@ -21,11 +21,13 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
+ @Override
public void initializeDefaultPreferences() {
IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore();
ColorManager.initializeDefaults(store);
store.setDefault(IPreferenceConstants.PROP_SHOW_OBJECTS, IPreferenceConstants.VALUE_USE_IDS);
store.setDefault(IPreferenceConstants.EDITOR_FOLDING_ENABLED, false);
+ store.setDefault(IPreferenceConstants.SHOW_TARGET_STATUS, false);
}
}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/TargetPlatformPreferencePage.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/TargetPlatformPreferencePage.java
index d1f6e92..6cf9b8f 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/TargetPlatformPreferencePage.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/TargetPlatformPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 EclipseSource Corporation and others.
+ * Copyright (c) 2009, 2013 EclipseSource Corporation 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
@@ -49,6 +49,12 @@ import org.osgi.framework.Version;
*/
public class TargetPlatformPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+ /**
+ * The ID of this preference page used to contribute via extension.<br>
+ * Value is: "org.eclipse.pde.ui.TargetPlatformPreferencePage"
+ */
+ public static final String PAGE_ID = "org.eclipse.pde.ui.TargetPlatformPreferencePage"; //$NON-NLS-1$
+
private static final String ORG_ECLIPSE_OSGI = "org.eclipse.osgi"; //$NON-NLS-1$
private class TargetLabelProvider extends StyledCellLabelProvider {
@@ -85,9 +91,11 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.StyledCellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
*/
+ @Override
public void update(ViewerCell cell) {
final Object element = cell.getElement();
Styler style = new Styler() {
+ @Override
public void applyStyles(TextStyle textStyle) {
if (element.equals(fActiveTarget)) {
textStyle.font = getBoldFont();
@@ -148,6 +156,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.StyledCellLabelProvider#dispose()
*/
+ @Override
public void dispose() {
PDEPlugin.getDefault().getLabelProvider().disconnect(this);
if (fTextFont != null) {
@@ -215,6 +224,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
+ @Override
public Control createContents(Composite parent) {
Composite container = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
createTargetProfilesGroup(container);
@@ -261,6 +271,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
}
});
fTableViewer.getTable().addKeyListener(new KeyAdapter() {
+ @Override
public void keyPressed(KeyEvent e) {
if (e.character == SWT.DEL) {
handleRemove();
@@ -284,6 +295,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
}
fTableViewer.setComparator(new ViewerComparator() {
+ @Override
public int compare(Viewer viewer, Object e1, Object e2) {
String name1 = ((TargetDefinition) e1).getName();
String name2 = ((TargetDefinition) e2).getName();
@@ -301,6 +313,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
fReloadButton = SWTFactory.createPushButton(buttonComposite, PDEUIMessages.TargetPlatformPreferencePage2_16, null);
fReloadButton.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
handleReload();
}
@@ -310,6 +323,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
fAddButton = SWTFactory.createPushButton(buttonComposite, PDEUIMessages.TargetPlatformPreferencePage2_3, null);
fAddButton.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
handleAdd();
}
@@ -317,6 +331,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
fEditButton = SWTFactory.createPushButton(buttonComposite, PDEUIMessages.TargetPlatformPreferencePage2_5, null);
fEditButton.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
handleEdit();
}
@@ -324,6 +339,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
fRemoveButton = SWTFactory.createPushButton(buttonComposite, PDEUIMessages.TargetPlatformPreferencePage2_7, null);
fRemoveButton.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
handleRemove();
}
@@ -331,6 +347,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
fMoveButton = SWTFactory.createPushButton(buttonComposite, PDEUIMessages.TargetPlatformPreferencePage2_13, null);
fMoveButton.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
handleMove();
}
@@ -409,6 +426,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
if (!selection.isEmpty()) {
isOutOfSynch = false;
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()) {
+ @Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText(PDEUIMessages.TargetPlatformPreferencePage2_12);
@@ -628,6 +646,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
*/
+ @Override
public void performDefaults() {
// add a default target platform and select it (or just select it if present)
ITargetPlatformService service = getTargetService();
@@ -659,6 +678,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#performOk()
*/
+ @Override
public boolean performOk() {
ITargetPlatformService service = getTargetService();
if (service == null) {
@@ -772,6 +792,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
// Warn about forward compatibility, synchronize java search
IJobChangeListener listener = new JobChangeAdapter() {
+ @Override
public void done(IJobChangeEvent event) {
if (event.getResult().getSeverity() == IStatus.OK) {
if (fActiveTarget != null) {
@@ -828,6 +849,7 @@ public class TargetPlatformPreferencePage extends PreferencePage implements IWor
private void runGC() {
Job job = new Job(PDEUIMessages.TargetPlatformPreferencePage2_26) {
+ @Override
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask(PDEUIMessages.TargetPlatformPreferencePage2_27, IProgressMonitor.UNKNOWN);
P2TargetUtils.garbageCollect();
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 a47cd01..02eb015 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation 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
@@ -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_TargetStatusDefaultString;
public static String UpdateTargetJob_TargetUpdateFailedStatus;
public static String UpdateTargetJob_TargetUpdateSuccessStatus;
public static String UpdateTargetJob_UpdateJobName;
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
new file mode 100644
index 0000000..b3e6c86
--- /dev/null
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetStatus.java
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.internal.ui.shared.target;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.preferences.*;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.pde.core.target.ITargetDefinition;
+import org.eclipse.pde.core.target.ITargetHandle;
+import org.eclipse.pde.internal.core.*;
+import org.eclipse.pde.internal.core.target.TargetPlatformService;
+import org.eclipse.pde.internal.ui.*;
+import org.eclipse.pde.internal.ui.preferences.TargetPlatformPreferencePage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.internal.WorkbenchWindow;
+import org.eclipse.ui.progress.UIJob;
+import org.eclipse.ui.texteditor.StatusLineContributionItem;
+
+/**
+ * Contributes a status control displaying information on the current target platform,
+ * similar to HeapStatus.
+ *
+ * @since 4.4 Luna
+ */
+public class TargetStatus {
+
+ private static final String TARGET_STATUS_ID = "targetStatus"; //$NON-NLS-1$
+ private static StatusLineContributionItem targetStatus;
+
+ /**
+ * The status line contribution that displays the current target platform. Uses the
+ * text editor's contribution item to keep the same look and feel.
+ */
+ private static class TargetStatusLineContributionItem extends StatusLineContributionItem {
+
+ public TargetStatusLineContributionItem() {
+ super(TARGET_STATUS_ID, true, 22);
+ PDEPlugin.getDefault().getLabelProvider().connect(this); // Needed to avoid disposing the image early
+ setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_TARGET_DEFINITION));
+ update();
+ setActionHandler(new Action() {
+ @Override
+ public void run() {
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(PDEPlugin.getActiveWorkbenchShell(), TargetPlatformPreferencePage.PAGE_ID, null, null);
+ dialog.open();
+ }
+ });
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(PDECore.PLUGIN_ID);
+ node.addPreferenceChangeListener(prefListener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.ContributionItem#dispose()
+ */
+ @Override
+ public void dispose() {
+ PDEPlugin.getDefault().getLabelProvider().disconnect(this);
+ super.dispose();
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(PDECore.PLUGIN_ID);
+ node.removePreferenceChangeListener(prefListener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.ContributionItem#update()
+ */
+ @Override
+ public void update() {
+ String result = Messages.TargetStatus_TargetStatusDefaultString;
+ try {
+ ITargetHandle handle = TargetPlatformService.getDefault().getWorkspaceTargetHandle();
+ if (handle != null) {
+ ITargetDefinition target = handle.getTargetDefinition();
+ String name = target.getName();
+ if (name != null && name.length() > 0) {
+ result = name;
+ }
+ }
+ } catch (CoreException e) {
+ PDEPlugin.log(e);
+ }
+ final String newValue = result;
+ UIJob job = new UIJob("") { //$NON-NLS-1$
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ targetStatus.setText(newValue);
+ setToolTipText(newValue);
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
+
+ private final IPreferenceChangeListener prefListener = new IPreferenceChangeListener() {
+ public void preferenceChange(PreferenceChangeEvent event) {
+ if (ICoreConstants.WORKSPACE_TARGET_HANDLE.equals(event.getKey())) {
+ update();
+ }
+
+ }
+ };
+ }
+
+ /**
+ * @return the existing target status contribution item or a new instance if one hasn't been created
+ */
+ private static StatusLineContributionItem getContributionItem() {
+ if (targetStatus == null) {
+ targetStatus = new TargetStatusLineContributionItem();
+ }
+ return targetStatus;
+ }
+
+ /**
+ * Adds or removes the target status contribution from the status line manager depending on the
+ * value of preference {@link IPreferenceConstants#SHOW_TARGET_STATUS}.
+ */
+ public static void refreshTargetStatus() {
+ PDEPreferencesManager prefs = PDEPlugin.getDefault().getPreferenceManager();
+ boolean showStatus = prefs.getBoolean(IPreferenceConstants.SHOW_TARGET_STATUS);
+
+ 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 manager = ((WorkbenchWindow) window).getStatusLineManager();
+ if (manager != null) {
+ if (showStatus) {
+ manager.appendToGroup(StatusLineManager.BEGIN_GROUP, getContributionItem());
+ } else {
+ manager.remove(TARGET_STATUS_ID);
+ }
+ manager.update(true);
+ 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 1b7366b..319e5c2 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
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2005, 2012 IBM Corporation and others.
+# Copyright (c) 2005, 2013 IBM Corporation 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
@@ -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_TargetStatusDefaultString=Target Platform
UpdateTargetJob_TargetUpdateFailedStatus=The target definition did not update successfully
UpdateTargetJob_TargetUpdateSuccessStatus=Target definition update completed successfully
UpdateTargetJob_UpdateJobName=Update Target Definition Job