Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2007-12-04 20:00:08 -0500
committerSusan Franklin2007-12-04 20:00:08 -0500
commitd866d6e4bff89ca043db10bfbd5db7a9ac633b5e (patch)
tree19dd773dd1bb09477b5603497ba0bb9367f088cc
parentd44c3f3af44da671457c9173a5b078f10dc2a5b4 (diff)
downloadrt.equinox.p2-d866d6e4bff89ca043db10bfbd5db7a9ac633b5e.tar.gz
rt.equinox.p2-d866d6e4bff89ca043db10bfbd5db7a9ac633b5e.tar.xz
rt.equinox.p2-d866d6e4bff89ca043db10bfbd5db7a9ac633b5e.zip
Bug 207493 - [prov] [ui] - "Remind me Later" for auto updates <handle deactivate during hide>
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin.rcp/src/org/eclipse/equinox/p2/ui/admin/rcp/ApplicationWorkbenchWindowAdvisor.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/StatusLineCLabelContribution.java133
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdatesPopup.java92
3 files changed, 214 insertions, 13 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin.rcp/src/org/eclipse/equinox/p2/ui/admin/rcp/ApplicationWorkbenchWindowAdvisor.java b/bundles/org.eclipse.equinox.p2.ui.admin.rcp/src/org/eclipse/equinox/p2/ui/admin/rcp/ApplicationWorkbenchWindowAdvisor.java
index ff81fb715..3c6a84a22 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin.rcp/src/org/eclipse/equinox/p2/ui/admin/rcp/ApplicationWorkbenchWindowAdvisor.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin.rcp/src/org/eclipse/equinox/p2/ui/admin/rcp/ApplicationWorkbenchWindowAdvisor.java
@@ -32,7 +32,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
PlatformUI.getWorkbench().getProgressService();
configurer.setInitialSize(new Point(800, 600));
configurer.setShowCoolBar(false);
- configurer.setShowStatusLine(false);
+ configurer.setShowStatusLine(true);
configurer.setShowProgressIndicator(true);
configurer.setTitle(ProvAdminUIMessages.ApplicationWindowTitle);
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/StatusLineCLabelContribution.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/StatusLineCLabelContribution.java
new file mode 100644
index 000000000..7d222a03a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/StatusLineCLabelContribution.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.equinox.internal.p2.ui.sdk;
+
+import org.eclipse.jface.action.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Listener;
+
+/**
+ * @since 3.4
+ */
+public class StatusLineCLabelContribution extends ContributionItem {
+
+ public final static int DEFAULT_CHAR_WIDTH = 40;
+
+ private int charWidth;
+ private CLabel label;
+ private Image image;
+ private String text = ""; //$NON-NLS-1$
+ private int widthHint = -1;
+ private int heightHint = -1;
+
+ private Listener listener;
+ private int eventType;
+ private String tooltip;
+
+ public StatusLineCLabelContribution(String id, int charWidth) {
+ super(id);
+ this.charWidth = charWidth;
+ setVisible(false); // no text to start with
+ }
+
+ public void fill(Composite parent) {
+ label = new CLabel(parent, SWT.DEFAULT);
+ StatusLineLayoutData statusLineLayoutData = new StatusLineLayoutData();
+
+ if (widthHint < 0) {
+ GC gc = new GC(parent);
+ gc.setFont(parent.getFont());
+ FontMetrics fm = gc.getFontMetrics();
+ widthHint = fm.getAverageCharWidth() * charWidth;
+ heightHint = fm.getHeight();
+ gc.dispose();
+ }
+
+ statusLineLayoutData.widthHint = widthHint;
+ label.setLayoutData(statusLineLayoutData);
+ label.setText(text);
+ label.setImage(image);
+ if (listener != null) {
+ label.addListener(eventType, listener);
+ }
+ if (tooltip != null) {
+ label.setToolTipText(tooltip);
+ }
+
+ statusLineLayoutData = new StatusLineLayoutData();
+ statusLineLayoutData.heightHint = heightHint;
+ }
+
+ public void addListener(int type, Listener labelListener) {
+ this.eventType = type;
+ this.listener = labelListener;
+ }
+
+ public void setText(String text) {
+ if (text == null)
+ throw new NullPointerException();
+
+ this.text = text;
+
+ if (label != null && !label.isDisposed())
+ label.setText(this.text);
+
+ if (this.text.length() == 0) {
+ if (isVisible()) {
+ setVisible(false);
+ IContributionManager contributionManager = getParent();
+
+ if (contributionManager != null)
+ contributionManager.update(true);
+ }
+ } else {
+ if (!isVisible()) {
+ setVisible(true);
+ IContributionManager contributionManager = getParent();
+
+ if (contributionManager != null)
+ contributionManager.update(true);
+ }
+ }
+ }
+
+ public void setTooltip(String tooltip) {
+ if (tooltip == null)
+ throw new NullPointerException();
+
+ this.tooltip = tooltip;
+
+ if (label != null && !label.isDisposed()) {
+ label.setToolTipText(this.tooltip);
+ }
+ }
+
+ public void setImage(Image image) {
+ if (image == null)
+ throw new NullPointerException();
+
+ this.image = image;
+
+ if (label != null && !label.isDisposed())
+ label.setImage(this.image);
+
+ if (!isVisible()) {
+ setVisible(true);
+ IContributionManager contributionManager = getParent();
+
+ if (contributionManager != null)
+ contributionManager.update(true);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdatesPopup.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdatesPopup.java
index 2bf53cc3d..6acb56d60 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdatesPopup.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdatesPopup.java
@@ -14,12 +14,13 @@ import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKMessages;
-import org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKUIActivator;
+import org.eclipse.equinox.internal.p2.ui.sdk.*;
import org.eclipse.equinox.internal.p2.ui.sdk.prefs.PreferenceConstants;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.ui.ProvUIImages;
import org.eclipse.equinox.p2.ui.dialogs.UpdateDialog;
+import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.PopupDialog;
import org.eclipse.jface.preference.PreferenceDialog;
@@ -30,6 +31,7 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.*;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.progress.WorkbenchJob;
@@ -42,18 +44,20 @@ import org.eclipse.ui.progress.WorkbenchJob;
public class AutomaticUpdatesPopup extends PopupDialog {
public static final String[] ELAPSED = {ProvSDKMessages.AutomaticUpdateScheduler_5Minutes, ProvSDKMessages.AutomaticUpdateScheduler_15Minutes, ProvSDKMessages.AutomaticUpdateScheduler_30Minutes, ProvSDKMessages.AutomaticUpdateScheduler_60Minutes};
private static final long MINUTE = 60 * 1000L;
+ private static final String REMIND_HREF = "RMD"; //$NON-NLS-1$
+ private static final String PREFS_HREF = "PREFS"; //$NON-NLS-1$
+ public static final String AUTO_UPDATE_STATUS_ITEM = "AutomaticUpdatesPopup"; //$NON-NLS-1$
+ private static final String DIALOG_SETTINGS_SECTION = "AutomaticUpdatesPopup"; //$NON-NLS-1$
+
Preferences prefs;
long remindDelay = -1L;
IPropertyChangeListener listener;
WorkbenchJob remindJob;
-
- private static final String REMIND_HREF = "RMD"; //$NON-NLS-1$
- private static final String PREFS_HREF = "PREFS"; //$NON-NLS-1$
- private static final String DIALOG_SETTINGS_SECTION = "AutomaticUpdatesPopup"; //$NON-NLS-1$
IInstallableUnit[] toUpdate;
Profile profile;
boolean downloaded;
boolean hidden = false;
+ StatusLineCLabelContribution item;
public AutomaticUpdatesPopup(IInstallableUnit[] toUpdate, Profile profile, boolean alreadyDownloaded, Preferences prefs) {
super((Shell) null, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE | SWT.MODELESS, true, true, false, false, ProvSDKMessages.AutomaticUpdatesDialog_UpdatesAvailableTitle, null);
@@ -72,6 +76,7 @@ public class AutomaticUpdatesPopup extends PopupDialog {
}
};
prefs.addPropertyChangeListener(listener);
+ createStatusLineItem();
}
@@ -103,14 +108,12 @@ public class AutomaticUpdatesPopup extends PopupDialog {
if (REMIND_HREF.equals(e.text)) {
if (prefs.getBoolean(PreferenceConstants.PREF_REMIND_SCHEDULE)) {
// We are already on a remind schedule, so just set up the reminder
- hidden = true;
- getShell().setVisible(false);
+ hide();
scheduleRemindJob();
} else {
// We were not on a schedule. Setting the pref value
// will activate our listener and start the remind job
- hidden = true;
- getShell().setVisible(false);
+ hide();
prefs.setValue(PreferenceConstants.PREF_REMIND_SCHEDULE, true);
}
}
@@ -142,6 +145,13 @@ public class AutomaticUpdatesPopup extends PopupDialog {
cancelRemindJob();
remindJob = null;
listener = null;
+ IStatusLineManager manager = getStatusLineManager();
+ if (manager != null) {
+ manager.remove(item);
+ }
+ manager.update(true);
+ item.dispose();
+ item = null;
return super.close();
}
@@ -158,8 +168,7 @@ public class AutomaticUpdatesPopup extends PopupDialog {
public IStatus runInUIThread(IProgressMonitor monitor) {
Shell shell = getShell();
if (shell != null && !shell.isDisposed()) {
- shell.setVisible(true);
- hidden = false;
+ show();
}
return Status.OK_STATUS;
}
@@ -207,4 +216,63 @@ public class AutomaticUpdatesPopup extends PopupDialog {
super.configureShell(newShell);
newShell.setText(ProvSDKMessages.AutomaticUpdatesDialog_UpdatesAvailableTitle);
}
+
+ private void createStatusLineItem() {
+ item = new StatusLineCLabelContribution(AUTO_UPDATE_STATUS_ITEM, 5);
+ item.addListener(SWT.MouseDown, new Listener() {
+ public void handleEvent(Event event) {
+ show();
+ }
+ });
+ item.setTooltip(ProvSDKMessages.AutomaticUpdatesDialog_UpdatesAvailableTitle);
+ item.setImage(ProvUIImages.getImage(ProvUIImages.IMG_TOOL_UPDATE));
+ IStatusLineManager manager = getStatusLineManager();
+ if (manager != null) {
+ manager.add(item);
+ }
+ item.setVisible(false);
+
+ }
+
+ IStatusLineManager getStatusLineManager() {
+ // TODO YUCK! Am I missing an easier way to do this??
+ IWorkbenchPartSite site = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite();
+ if (site instanceof IViewSite) {
+ return ((IViewSite) site).getActionBars().getStatusLineManager();
+ } else if (site instanceof IEditorSite) {
+ return ((IViewSite) site).getActionBars().getStatusLineManager();
+ }
+ return null;
+ }
+
+ public void hide() {
+ hidden = true;
+ Shell shell = getShell();
+ if (shell != null && !shell.isDisposed())
+ shell.setVisible(false);
+ if (item != null) {
+ item.setVisible(true);
+ updateStatusLine();
+ }
+ }
+
+ public void show() {
+ Shell shell = getShell();
+ if (shell != null && !shell.isDisposed()) {
+ shell.setVisible(true);
+ hidden = false;
+ if (item != null) {
+ item.setVisible(false);
+ updateStatusLine();
+ }
+
+ }
+ }
+
+ void updateStatusLine() {
+ IStatusLineManager manager = getStatusLineManager();
+ if (manager != null)
+ manager.update(true);
+ }
+
}

Back to the top