diff options
author | rsuen | 2008-03-02 19:24:02 +0000 |
---|---|---|
committer | rsuen | 2008-03-02 19:24:02 +0000 |
commit | 7f561cb934168c9c190e4d5c5676c60770b823f5 (patch) | |
tree | 3a9f23a0a12c0f280715ab521aeac198f46a26cd /incubation | |
parent | cdb80a4b0156704b96ed08938473088b4b23cbd2 (diff) | |
download | org.eclipse.ecf-7f561cb934168c9c190e4d5c5676c60770b823f5.tar.gz org.eclipse.ecf-7f561cb934168c9c190e4d5c5676c60770b823f5.tar.xz org.eclipse.ecf-7f561cb934168c9c190e4d5c5676c60770b823f5.zip |
Adapted to Mylyn's notification popup.
Diffstat (limited to 'incubation')
-rwxr-xr-x | incubation/bundles/org.eclipse.ecf.mylyn.ui/src/org/eclipse/ecf/internal/mylyn/ui/IncomingSharedTaskNotificationPopup.java | 105 |
1 files changed, 29 insertions, 76 deletions
diff --git a/incubation/bundles/org.eclipse.ecf.mylyn.ui/src/org/eclipse/ecf/internal/mylyn/ui/IncomingSharedTaskNotificationPopup.java b/incubation/bundles/org.eclipse.ecf.mylyn.ui/src/org/eclipse/ecf/internal/mylyn/ui/IncomingSharedTaskNotificationPopup.java index afe8100f9..ae8e52f1c 100755 --- a/incubation/bundles/org.eclipse.ecf.mylyn.ui/src/org/eclipse/ecf/internal/mylyn/ui/IncomingSharedTaskNotificationPopup.java +++ b/incubation/bundles/org.eclipse.ecf.mylyn.ui/src/org/eclipse/ecf/internal/mylyn/ui/IncomingSharedTaskNotificationPopup.java @@ -13,111 +13,64 @@ package org.eclipse.ecf.internal.mylyn.ui; import org.eclipse.ecf.internal.mylyn.ui.CompoundContextActivationContributionItem.ActivateTaskAction; -import org.eclipse.jface.dialogs.PopupDialog; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.viewers.DecoratingLabelProvider; +import org.eclipse.mylyn.internal.tasks.ui.TaskListHyperlink; +import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages; +import org.eclipse.mylyn.internal.tasks.ui.notifications.AbstractNotificationPopup; +import org.eclipse.mylyn.internal.tasks.ui.views.TaskElementLabelProvider; import org.eclipse.mylyn.tasks.core.AbstractTask; import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; -import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.events.HyperlinkAdapter; import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.widgets.*; -class IncomingSharedTaskNotificationPopup extends PopupDialog { +class IncomingSharedTaskNotificationPopup extends AbstractNotificationPopup { - private FormToolkit toolkit; - - private Form form; - - private Composite sectionClient; + private static final DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(new TaskElementLabelProvider(true), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()); private AbstractTask task; - IncomingSharedTaskNotificationPopup(Shell parent) { - super(parent, PopupDialog.INFOPOPUP_SHELLSTYLE | SWT.ON_TOP, false, false, false, false, null, null); + IncomingSharedTaskNotificationPopup(Widget widget) { + super(widget.getDisplay()); } - public boolean close() { - toolkit.dispose(); - return super.close(); + protected String getPopupShellTitle() { + return "Incoming Task Context"; } void setTask(AbstractTask task) { this.task = task; } - protected Control createContents(Composite parent) { - getShell().setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); - toolkit = new FormToolkit(parent.getDisplay()); - form = toolkit.createForm(parent); - form.getBody().setLayout(new FillLayout()); - - Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR); - section.setText("Incoming Shared Task"); - section.setLayout(new FillLayout()); + protected void createContentArea(Composite parent) { + Composite notificationComposite = new Composite(parent, SWT.NO_FOCUS); + notificationComposite.setLayout(new GridLayout(2, false)); + notificationComposite.setBackground(parent.getBackground()); - sectionClient = toolkit.createComposite(section); - sectionClient.setLayout(new GridLayout()); + final Label notificationLabelIcon = new Label(notificationComposite, SWT.LEAD); + notificationLabelIcon.setBackground(parent.getBackground()); + notificationLabelIcon.setImage(TasksUiImages.getImage(TasksUiImages.OVERLAY_INCOMMING)); - Hyperlink link = toolkit.createHyperlink(sectionClient, task.getTaskId(), SWT.NONE); - link.addHyperlinkListener(new HyperlinkAdapter() { + final TaskListHyperlink itemLink = new TaskListHyperlink(notificationComposite, SWT.BEGINNING | SWT.WRAP | SWT.NO_FOCUS); + itemLink.setText(task.getTaskId()); + itemLink.setImage(labelProvider.getImage(task)); + itemLink.setBackground(parent.getBackground()); + itemLink.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { ActivateTaskAction action = new CompoundContextActivationContributionItem.ActivateTaskAction(); action.setTask(task); action.run(); - } - }); - - toolkit.createLabel(sectionClient, task.getSummary(), SWT.WRAP); - - section.setClient(sectionClient); - - ImageHyperlink hyperlink = toolkit.createImageHyperlink(section, SWT.NONE); - hyperlink.setBackground(null); - hyperlink.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE)); - hyperlink.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { close(); } }); - section.setTextClient(hyperlink); - - form.pack(); - return parent; - } - - /** - * Initialize the shell's bounds. - */ - public void initializeBounds() { - getShell().setBounds(restoreBounds()); - } - - private Rectangle restoreBounds() { - Rectangle bounds = form.getBounds(); - Rectangle maxBounds = getShell().getMonitor().getClientArea(); - - if (bounds.width > -1 && bounds.height > -1) { - if (maxBounds != null) { - bounds.width = Math.min(bounds.width, maxBounds.width); - bounds.height = Math.min(bounds.height, maxBounds.height); - } - // Enforce an absolute minimal size - bounds.width = Math.max(bounds.width, 30); - bounds.height = Math.max(bounds.height, 30); - } - - if (bounds.x > -1 && bounds.y > -1 && maxBounds != null) { - if (bounds.width > -1 && bounds.height > -1) { - bounds.x = maxBounds.x + maxBounds.width - bounds.width; - bounds.y = maxBounds.y + maxBounds.height - bounds.height; - } - } - - return bounds; + String descriptionText = task.getSummary(); + Label descriptionLabel = new Label(notificationComposite, SWT.NO_FOCUS); + descriptionLabel.setText(descriptionText); + descriptionLabel.setBackground(parent.getBackground()); + GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).applyTo(descriptionLabel); } } |