Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-10-02 04:43:17 +0000
committerspingel2010-10-02 04:43:17 +0000
commit27be7847881965d8a83f45e41692837466ceb763 (patch)
treeeb4c5824ab1d40631c6df3dcd92f54bb09cebe0c /org.eclipse.mylyn.tasks.ui
parent727ab9c770e168f53795a5a535e33207812eeed4 (diff)
downloadorg.eclipse.mylyn.tasks-27be7847881965d8a83f45e41692837466ceb763.tar.gz
org.eclipse.mylyn.tasks-27be7847881965d8a83f45e41692837466ceb763.tar.xz
org.eclipse.mylyn.tasks-27be7847881965d8a83f45e41692837466ceb763.zip
NEW - bug 326761: [patch] The service message control for the tasks view should use the commons version
https://bugs.eclipse.org/bugs/show_bug.cgi?id=326761
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java280
1 files changed, 48 insertions, 232 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java
index 123c57b60..5ce157b56 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskListServiceMessageControl.java
@@ -7,10 +7,10 @@
*
* Contributors:
* Tasktop Technologies - initial API and implementation
+ * Itema AS - bug 326761: switched to use common service message control
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.ui.notifications;
-
import java.util.Collections;
import java.util.Date;
@@ -20,8 +20,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
-import org.eclipse.mylyn.internal.provisional.commons.ui.GradientCanvas;
+import org.eclipse.mylyn.internal.provisional.commons.ui.ServiceMessageControl;
import org.eclipse.mylyn.internal.tasks.core.notifications.IServiceMessageListener;
import org.eclipse.mylyn.internal.tasks.core.notifications.ServiceMessage;
import org.eclipse.mylyn.internal.tasks.core.notifications.ServiceMessageEvent;
@@ -32,208 +31,26 @@ import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.internal.tasks.ui.wizards.Messages;
import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.FormColors;
-import org.eclipse.ui.forms.IFormColors;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.widgets.ImageHyperlink;
-import org.eclipse.ui.forms.widgets.TableWrapData;
-import org.eclipse.ui.forms.widgets.TableWrapLayout;
import org.eclipse.ui.handlers.IHandlerService;
import org.osgi.framework.Version;
+
/**
* @author Robert Elves
* @author Steffen Pingel
+ * @author Torkild U. Resheim
*/
-public class TaskListServiceMessageControl implements IServiceMessageListener {
-
- private Label imageLabel;
-
- private Label titleLabel;
-
- private Link descriptionLabel;
-
- private GridData headData;
-
- private final Composite parent;
-
- private GradientCanvas head;
-
- private ImageHyperlink closeLink;
-
- private ImageHyperlink settingsLink;
-
+public class TaskListServiceMessageControl extends ServiceMessageControl implements IServiceMessageListener {
private ServiceMessage currentMessage;
public TaskListServiceMessageControl(Composite parent) {
- this.parent = parent;
- }
-
- private void setTitleImage(Image image) {
- imageLabel.setImage(image);
- }
-
- private void setTitle(String title) {
- titleLabel.setText(title);
- }
-
- private void setDescription(String description) {
- descriptionLabel.setText(description);
- }
-
- public Control createControl(Composite parent) {
- FormColors colors = TasksUiPlugin.getDefault().getFormColors(parent.getDisplay());
- head = new GradientCanvas(parent, SWT.NONE);
- GridLayout headLayout = new GridLayout();
- headLayout.marginHeight = 0;
- headLayout.marginWidth = 0;
- headLayout.horizontalSpacing = 0;
- headLayout.verticalSpacing = 0;
- headLayout.numColumns = 1;
- head.setLayout(headLayout);
- headData = new GridData(SWT.FILL, SWT.TOP, true, false);
- head.setLayoutData(headData);
-
- Color top = colors.getColor(IFormColors.H_GRADIENT_END);
- Color bot = colors.getColor(IFormColors.H_GRADIENT_START);
- head.setBackgroundGradient(new Color[] { bot, top }, new int[] { 100 }, true);
- head.setSeparatorVisible(true);
- head.setSeparatorAlignment(SWT.TOP);
-
- head.putColor(IFormColors.H_BOTTOM_KEYLINE1, colors.getColor(IFormColors.H_BOTTOM_KEYLINE1));
- head.putColor(IFormColors.H_BOTTOM_KEYLINE2, colors.getColor(IFormColors.H_BOTTOM_KEYLINE2));
- head.putColor(IFormColors.H_HOVER_LIGHT, colors.getColor(IFormColors.H_HOVER_LIGHT));
- head.putColor(IFormColors.H_HOVER_FULL, colors.getColor(IFormColors.H_HOVER_FULL));
- head.putColor(IFormColors.TB_TOGGLE, colors.getColor(IFormColors.TB_TOGGLE));
- head.putColor(IFormColors.TB_TOGGLE_HOVER, colors.getColor(IFormColors.TB_TOGGLE_HOVER));
-
- TableWrapLayout layout = new TableWrapLayout();
- layout.numColumns = 3;
- head.setLayout(layout);
-
- imageLabel = new Label(head, SWT.NONE);
-
- titleLabel = new Label(head, SWT.NONE);
-
- setHeaderFontSizeAndStyle(titleLabel);
-
- Composite buttonsComp = new Composite(head, SWT.NONE);
- TableWrapData data = new TableWrapData();
- data.align = TableWrapData.RIGHT;
- buttonsComp.setLayoutData(data);
- GridLayout gLayout = new GridLayout(2, false);
- gLayout.horizontalSpacing = 0;
- gLayout.verticalSpacing = 0;
- gLayout.marginHeight = 0;
- gLayout.marginWidth = 0;
- gLayout.verticalSpacing = 0;
-
- buttonsComp.setLayout(gLayout);
-
- // Disabled for initial 3.4 release as per bug#263528
-// settingsLink = new ImageHyperlink(buttonsComp, SWT.NONE);
-// settingsLink.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_PREFERENCES));
-// settingsLink.addHyperlinkListener(new HyperlinkAdapter() {
-// @Override
-// public void linkActivated(HyperlinkEvent e) {
-// PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
-// TaskListServiceMessageControl.this.parent.getShell(),
-// "org.eclipse.mylyn.tasks.ui.preferences", null, null); //$NON-NLS-1$
-// if (pref != null) {
-// pref.open();
-// }
-// }
-//
-// @Override
-// public void linkEntered(HyperlinkEvent e) {
-// settingsLink.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_PREFERENCES_HOVER));
-// }
-//
-// @Override
-// public void linkExited(HyperlinkEvent e) {
-// settingsLink.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_PREFERENCES));
-// }
-// });
-
- closeLink = new ImageHyperlink(buttonsComp, SWT.NONE);
- closeLink.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_CLOSE));
-// data = new TableWrapData();
-// data.align = TableWrapData.RIGHT;
-// closeLink.setLayoutData(data);
- closeLink.addHyperlinkListener(new HyperlinkAdapter() {
- @Override
- public void linkActivated(HyperlinkEvent e) {
- closeMessage();
- }
-
- @Override
- public void linkEntered(HyperlinkEvent e) {
- closeLink.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_CLOSE_HOVER));
- }
-
- @Override
- public void linkExited(HyperlinkEvent e) {
- closeLink.setImage(CommonImages.getImage(CommonImages.NOTIFICATION_CLOSE));
- }
- });
-
- // spacer
- new Label(head, SWT.NONE).setText(" "); //$NON-NLS-1$
-
- descriptionLabel = new Link(head, SWT.WRAP);
- descriptionLabel.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (e.text != null) {
- if (e.text.toLowerCase().equals("connect")) { //$NON-NLS-1$
- closeMessage();
- new AddRepositoryAction().run();
- } else if (e.text.toLowerCase().equals("discovery")) { //$NON-NLS-1$
- closeMessage();
- final Command discoveryWizardCommand = TasksUiInternal.getConfiguredDiscoveryWizardCommand();
- if (discoveryWizardCommand != null && discoveryWizardCommand.isEnabled()) {
- IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(
- IHandlerService.class);
- try {
- discoveryWizardCommand.executeWithChecks(TaskListServiceMessageControl.createExecutionEvent(
- discoveryWizardCommand, handlerService));
- } catch (Exception e1) {
- IStatus status = new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, NLS.bind(
- Messages.SelectRepositoryConnectorPage_discoveryProblemMessage,
- new Object[] { e1.getMessage() }), e1);
- TasksUiInternal.logAndDisplayStatus(
- Messages.SelectRepositoryConnectorPage_discoveryProblemTitle, status);
- }
- }
- }
- }
- }
- });
-
- data = new TableWrapData();
- data.colspan = 2;
- data.grabHorizontal = true;
- descriptionLabel.setLayoutData(data);
-
- return head;
+ super(parent);
}
static ExecutionEvent createExecutionEvent(Command command, IHandlerService handlerService) {
@@ -241,40 +58,14 @@ public class TaskListServiceMessageControl implements IServiceMessageListener {
TasksUiInternal.createDiscoveryWizardEvaluationContext(handlerService));
}
- private void closeMessage() {
+ @Override
+ protected void closeMessage() {
if (currentMessage != null) {
- TasksUiPlugin.getDefault().getPreferenceStore().setValue(
- ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ID, currentMessage.getId());
- }
- if (head != null && !head.isDisposed()) {
- head.dispose();
- }
- if (!parent.isDisposed()) {
- parent.layout(true);
+ TasksUiPlugin.getDefault()
+ .getPreferenceStore()
+ .setValue(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ID, currentMessage.getId());
}
- }
-
- // From EditorUtil
- private static Font setHeaderFontSizeAndStyle(Control text) {
- float sizeFactor = 1.2f;
- Font initialFont = text.getFont();
- FontData[] fontData = initialFont.getFontData();
- for (FontData element : fontData) {
- element.setHeight((int) (element.getHeight() * sizeFactor));
- element.setStyle(element.getStyle() | SWT.BOLD);
- }
- final Font textFont = new Font(text.getDisplay(), fontData);
- text.setFont(textFont);
- text.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- textFont.dispose();
- }
- });
- Color color = TasksUiPlugin.getDefault().getFormColors(text.getDisplay()).getColor(IFormColors.TITLE);
-// Color color = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().get(
-// CommonThemes.COLOR_COMPLETED);
- text.setForeground(color);
- return textFont;
+ close();
}
public void handleEvent(final ServiceMessageEvent event) {
@@ -299,12 +90,7 @@ public class TaskListServiceMessageControl implements IServiceMessageListener {
}
break;
case STOP:
- if (head != null && !head.isDisposed()) {
- head.dispose();
- }
- if (parent != null && !parent.isDisposed()) {
- parent.layout(true);
- }
+ close();
break;
}
}
@@ -316,7 +102,7 @@ public class TaskListServiceMessageControl implements IServiceMessageListener {
try {
VersionRange version = new VersionRange(message.getVersion());
- String versionString = (String) TasksUiPlugin.getDefault().getBundle().getHeaders().get("Bundle-Version"); //$NON-NLS-1$
+ String versionString = TasksUiPlugin.getDefault().getBundle().getHeaders().get("Bundle-Version"); //$NON-NLS-1$
return version.isIncluded(new Version(versionString));
} catch (IllegalArgumentException e) {
// invalid version range
@@ -325,8 +111,8 @@ public class TaskListServiceMessageControl implements IServiceMessageListener {
}
public void setMessage(ServiceMessage message) {
- if (!parent.isDisposed() && message != null && (head == null || head.isDisposed())) {
- createControl(parent);
+ if (message != null) {
+ ensureControl();
if (message.getETag() != null && message.getLastModified() != null) {
IPreferenceStore preferenceStore = TasksUiPlugin.getDefault().getPreferenceStore();
preferenceStore.setValue(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ETAG, message.getETag());
@@ -339,8 +125,38 @@ public class TaskListServiceMessageControl implements IServiceMessageListener {
setTitle(message.getTitle());
setDescription(message.getDescription());
setTitleImage(Dialog.getImage(message.getImage()));
- parent.layout(true);
}
}
+ @Override
+ public SelectionListener getLinkListener() {
+ return new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (e.text != null) {
+ if (e.text.toLowerCase().equals("connect")) { //$NON-NLS-1$
+ closeMessage();
+ new AddRepositoryAction().run();
+ } else if (e.text.toLowerCase().equals("discovery")) { //$NON-NLS-1$
+ closeMessage();
+ final Command discoveryWizardCommand = TasksUiInternal.getConfiguredDiscoveryWizardCommand();
+ if (discoveryWizardCommand != null && discoveryWizardCommand.isEnabled()) {
+ IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(
+ IHandlerService.class);
+ try {
+ discoveryWizardCommand.executeWithChecks(TaskListServiceMessageControl.createExecutionEvent(
+ discoveryWizardCommand, handlerService));
+ } catch (Exception e1) {
+ IStatus status = new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, NLS.bind(
+ Messages.SelectRepositoryConnectorPage_discoveryProblemMessage,
+ new Object[] { e1.getMessage() }), e1);
+ TasksUiInternal.logAndDisplayStatus(
+ Messages.SelectRepositoryConnectorPage_discoveryProblemTitle, status);
+ }
+ }
+ }
+ }
+ }
+ };
+ }
}

Back to the top