Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2009-01-28 01:09:45 -0500
committerspingel2009-01-28 01:09:45 -0500
commita0901ef51a8bea7f9d2bbc03368ba8a9e91437cd (patch)
treec6cbfab65012746815bf0d0596c72139edc5004e
parentdbc797550296c92f02a9fdff50b8d02d48a678bc (diff)
downloadorg.eclipse.mylyn.tasks-a0901ef51a8bea7f9d2bbc03368ba8a9e91437cd.tar.gz
org.eclipse.mylyn.tasks-a0901ef51a8bea7f9d2bbc03368ba8a9e91437cd.tar.xz
org.eclipse.mylyn.tasks-a0901ef51a8bea7f9d2bbc03368ba8a9e91437cd.zip
NEW - bug 239729: add option to copy commenter's email address out of task editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=239729
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CommentActionGroup.java69
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyCommentDetailsAction.java56
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java44
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractReplyToCommentAction.java1
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/EditorUtil.java12
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java108
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties1
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/ClipboardCopier.java72
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/SelectionProviderAdapter.java30
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiMenus.java3
11 files changed, 325 insertions, 73 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CommentActionGroup.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CommentActionGroup.java
new file mode 100644
index 000000000..0b7835552
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CommentActionGroup.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Tasktop Technologies 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.actions;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionGroup;
+
+/**
+ * @author Steffen Pingel
+ */
+public class CommentActionGroup extends ActionGroup {
+
+ private CopyCommentDetailsAction copyDetailsAction;
+
+ private boolean initialized;
+
+ private void initialize() {
+ if (initialized) {
+ return;
+ }
+ initialized = true;
+ copyDetailsAction = new CopyCommentDetailsAction();
+ }
+
+ @Override
+ public void fillContextMenu(IMenuManager manager) {
+ updateActions();
+ manager.add(copyDetailsAction);
+ }
+
+ private void updateActions() {
+ initialize();
+ IStructuredSelection selection = getStructuredSelection();
+ copyDetailsAction.selectionChanged(selection);
+ }
+
+ public IStructuredSelection getStructuredSelection() {
+ ActionContext context = getContext();
+ if (context != null) {
+ ISelection selection = context.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ return (IStructuredSelection) selection;
+ }
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ if (copyDetailsAction != null) {
+ copyDetailsAction.dispose();
+ }
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyCommentDetailsAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyCommentDetailsAction.java
new file mode 100644
index 000000000..317c91e2a
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyCommentDetailsAction.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Tasktop Technologies 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.actions;
+
+import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
+import org.eclipse.mylyn.internal.tasks.ui.util.ClipboardCopier;
+import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
+import org.eclipse.mylyn.tasks.core.ITaskComment;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+/**
+ * @author Steffen Pingel
+ */
+public class CopyCommentDetailsAction extends BaseSelectionListenerAction {
+
+ private final ClipboardCopier copier;
+
+ public CopyCommentDetailsAction() {
+ super("Copy Details");
+ setToolTipText("Copy User ID To Clipboard");
+ setImageDescriptor(CommonImages.COPY);
+ copier = new ClipboardCopier() {
+ @Override
+ protected String getTextForElement(Object element) {
+ if (element instanceof ITaskComment) {
+ ITaskComment comment = (ITaskComment) element;
+ IRepositoryPerson author = comment.getAuthor();
+ if (author != null) {
+ return author.toString();
+ }
+ }
+ return null;
+ }
+ };
+ }
+
+ @Override
+ public void run() {
+ copier.copy(getStructuredSelection());
+ }
+
+ public void dispose() {
+ copier.dispose();
+
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java
index 5837175d4..afa336899 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java
@@ -11,20 +11,14 @@
package org.eclipse.mylyn.internal.tasks.ui.actions;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
+import org.eclipse.mylyn.internal.tasks.ui.util.ClipboardCopier;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
/**
@@ -34,36 +28,28 @@ public class CopyTaskDetailsAction extends BaseSelectionListenerAction {
public static final String ID = "org.eclipse.mylyn.tasklist.actions.copy"; //$NON-NLS-1$
- private final Clipboard clipboard;
-
- private static String lineSeparator = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ private final ClipboardCopier copier;
public CopyTaskDetailsAction() {
super(Messages.CopyTaskDetailsAction_Copy_Details);
setToolTipText(Messages.CopyTaskDetailsAction_Copy_Details);
setId(ID);
setImageDescriptor(CommonImages.COPY);
- // FIXME the clipboard is not disposed
- Display display = PlatformUI.getWorkbench().getDisplay();
- clipboard = new Clipboard(display);
+ this.copier = new ClipboardCopier() {
+ @Override
+ protected String getTextForElement(Object element) {
+ return getTextForTask(element);
+ }
+ };
}
@Override
public void run() {
- ISelection selection = getStructuredSelection();
- StringBuilder sb = new StringBuilder();
- Object[] seletedElements = ((IStructuredSelection) selection).toArray();
- for (int i = 0; i < seletedElements.length; i++) {
- if (i > 0) {
- sb.append(lineSeparator);
- sb.append(lineSeparator);
- }
- sb.append(getTextForTask(seletedElements[i]));
- }
- if (sb.length() > 0) {
- TextTransfer textTransfer = TextTransfer.getInstance();
- clipboard.setContents(new Object[] { sb.toString() }, new Transfer[] { textTransfer });
- }
+ copier.copy(getStructuredSelection());
+ }
+
+ public void dispose() {
+ copier.dispose();
}
// TODO move to TasksUiUtil / into core
@@ -78,14 +64,14 @@ public class CopyTaskDetailsAction extends BaseSelectionListenerAction {
sb.append(task.getSummary());
if (TasksUiInternal.isValidUrl(task.getUrl())) {
- sb.append(lineSeparator);
+ sb.append(ClipboardCopier.LINE_SEPARATOR);
sb.append(task.getUrl());
}
} else if (object instanceof IRepositoryQuery) {
RepositoryQuery query = (RepositoryQuery) object;
sb.append(query.getSummary());
if (TasksUiInternal.isValidUrl(query.getUrl())) {
- sb.append(lineSeparator);
+ sb.append(ClipboardCopier.LINE_SEPARATOR);
sb.append(query.getUrl());
}
} else if (object instanceof IRepositoryElement) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractReplyToCommentAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractReplyToCommentAction.java
index d22afdf7d..f04fe1a45 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractReplyToCommentAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractReplyToCommentAction.java
@@ -32,6 +32,7 @@ public abstract class AbstractReplyToCommentAction extends Action {
this.editor = editor;
this.taskComment = taskComment;
setImageDescriptor(TasksUiImages.COMMENT_REPLY);
+ setText(Messages.AbstractReplyToCommentAction_Reply);
setToolTipText(Messages.AbstractReplyToCommentAction_Reply);
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/EditorUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/EditorUtil.java
index f07d4299d..ca403f1d0 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/EditorUtil.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/EditorUtil.java
@@ -11,6 +11,7 @@
package org.eclipse.mylyn.internal.tasks.ui.editors;
+import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.DateFormat;
import java.util.Date;
@@ -32,6 +33,7 @@ import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
@@ -398,4 +400,14 @@ public class EditorUtil {
}
}
+ // TODO e3.4 replace reflection by assignment to RowLayout.center
+ public static void center(RowLayout rowLayout) {
+ try {
+ Field field = RowLayout.class.getDeclaredField("center"); //$NON-NLS-1$
+ field.set(rowLayout, Boolean.TRUE);
+ } catch (Throwable e) {
+ // ignore
+ }
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java
index 0a93f630b..c63dd2b27 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java
@@ -135,8 +135,6 @@ public class Messages extends NLS {
public static String TaskEditorCommentPart_Expand_Comments;
- public static String TaskEditorCommentPart_Reply;
-
public static String TaskEditorDescriptionPart_Description;
public static String TaskEditorDescriptionPart_Detector;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java
index 3e1f8b5c7..7ac04631d 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java
@@ -16,16 +16,22 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.tasks.core.TaskComment;
+import org.eclipse.mylyn.internal.tasks.ui.actions.CommentActionGroup;
import org.eclipse.mylyn.internal.tasks.ui.editors.CommentGroupStrategy.CommentGroup;
+import org.eclipse.mylyn.internal.tasks.ui.util.SelectionProviderAdapter;
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
import org.eclipse.mylyn.tasks.core.ITaskComment;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
-import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
import org.eclipse.swt.SWT;
@@ -36,6 +42,8 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.forms.IFormColors;
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
@@ -53,6 +61,8 @@ import org.eclipse.ui.forms.widgets.Section;
*/
public class TaskEditorCommentPart extends AbstractTaskEditorPart {
+ private static final String ID_POPUP_MENU = "org.eclipse.mylyn.tasks.ui.editor.menu.comments"; //$NON-NLS-1$
+
private class CommentGroupViewer {
private final CommentGroup commentGroup;
@@ -301,35 +311,6 @@ public class TaskEditorCommentPart extends AbstractTaskEditorPart {
return commentComposite;
}
- private ImageHyperlink createReplyHyperlink(Composite composite, FormToolkit toolkit,
- final ITaskComment taskComment) {
- final ImageHyperlink replyLink = new ImageHyperlink(composite, SWT.NULL);
- toolkit.adapt(replyLink, false, false);
- replyLink.setImage(CommonImages.getImage(TasksUiImages.COMMENT_REPLY));
- replyLink.setToolTipText(LABEL_REPLY);
- // no need for the background - transparency will take care of it
- replyLink.setBackground(null);
- // replyLink.setBackground(section.getTitleBarGradientBackground());
- replyLink.addHyperlinkListener(new HyperlinkAdapter() {
- @Override
- public void linkActivated(HyperlinkEvent e) {
- AbstractReplyToCommentAction.reply(getTaskEditorPage(), taskComment, taskComment.getText());
- }
-
- @Override
- public void linkEntered(HyperlinkEvent e) {
- replyLink.setUnderlined(true);
- }
-
- @Override
- public void linkExited(HyperlinkEvent e) {
- replyLink.setUnderlined(false);
- }
-
- });
- return replyLink;
- }
-
private Composite createTitle(final ExpandableComposite commentComposite, final FormToolkit toolkit) {
// always visible
Composite titleComposite = toolkit.createComposite(commentComposite);
@@ -339,6 +320,7 @@ public class TaskEditorCommentPart extends AbstractTaskEditorPart {
rowLayout.marginLeft = 0;
rowLayout.marginBottom = 0;
rowLayout.marginTop = 0;
+ EditorUtil.center(rowLayout);
titleComposite.setLayout(rowLayout);
titleComposite.setBackground(null);
@@ -360,7 +342,11 @@ public class TaskEditorCommentPart extends AbstractTaskEditorPart {
buttonComposite.setBackground(null);
buttonComposite.setVisible(commentComposite.isExpanded());
- createReplyHyperlink(buttonComposite, toolkit, taskComment);
+ ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
+ ReplyToCommentAction replyAction = new ReplyToCommentAction(taskComment);
+ toolBarManager.add(replyAction);
+ toolBarManager.createControl(buttonComposite);
+
return buttonComposite;
}
@@ -443,13 +429,41 @@ public class TaskEditorCommentPart extends AbstractTaskEditorPart {
}
+ private class ReplyToCommentAction extends AbstractReplyToCommentAction implements IMenuCreator {
+
+ private final ITaskComment taskComment;
+
+ public ReplyToCommentAction(ITaskComment taskComment) {
+ super(TaskEditorCommentPart.this.getTaskEditorPage(), taskComment);
+ this.taskComment = taskComment;
+ setMenuCreator(this);
+ }
+
+ @Override
+ protected String getReplyText() {
+ return taskComment.getText();
+ }
+
+ public Menu getMenu(Control parent) {
+ selectionProvider.setSelection(new StructuredSelection(taskComment));
+ return commentMenu;
+ }
+
+ public void dispose() {
+ }
+
+ public Menu getMenu(Menu parent) {
+ selectionProvider.setSelection(new StructuredSelection(taskComment));
+ return commentMenu;
+ }
+
+ }
+
/** Expandable composites are indented by 6 pixels by default. */
private static final int INDENT = -6;
private static final String KEY_EDITOR = "viewer"; //$NON-NLS-1$
- private static final String LABEL_REPLY = Messages.TaskEditorCommentPart_Reply;
-
private List<TaskAttribute> commentAttributes;
private CommentGroupStrategy commentGroupStrategy;
@@ -462,6 +476,12 @@ public class TaskEditorCommentPart extends AbstractTaskEditorPart {
protected Section section;
+ private SelectionProviderAdapter selectionProvider;
+
+ private Menu commentMenu;
+
+ private CommentActionGroup actionGroup;
+
public TaskEditorCommentPart() {
this.commentGroupStrategy = new CommentGroupStrategy() {
@Override
@@ -506,6 +526,20 @@ public class TaskEditorCommentPart extends AbstractTaskEditorPart {
public void createControl(Composite parent, final FormToolkit toolkit) {
initialize();
+ selectionProvider = new SelectionProviderAdapter();
+ actionGroup = new CommentActionGroup();
+
+ MenuManager menuManager = new MenuManager();
+ menuManager.setRemoveAllWhenShown(true);
+ menuManager.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ actionGroup.setContext(new ActionContext(selectionProvider.getSelection()));
+ actionGroup.fillContextMenu(manager);
+ }
+ });
+ getTaskEditorPage().getEditorSite().registerContextMenu(ID_POPUP_MENU, menuManager, selectionProvider, false);
+ commentMenu = menuManager.createContextMenu(parent);
+
section = createSection(parent, toolkit, hasIncoming);
section.setText(section.getText() + " (" + commentAttributes.size() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -534,6 +568,14 @@ public class TaskEditorCommentPart extends AbstractTaskEditorPart {
setSection(toolkit, section);
}
+ @Override
+ public void dispose() {
+ super.dispose();
+ if (actionGroup != null) {
+ actionGroup.dispose();
+ }
+ }
+
private void expandAllComments() {
try {
expandAllInProgress = true;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties
index 7a23a356c..999f560d6 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties
@@ -66,7 +66,6 @@ TaskEditorCommentPart_1=)
TaskEditorCommentPart_Collapse_Comments=Collapse Comments
TaskEditorCommentPart_Comments=Comments
TaskEditorCommentPart_Expand_Comments=Expand Comments
-TaskEditorCommentPart_Reply=Reply
TaskEditorDescriptionPart_Description=Description
TaskEditorDescriptionPart_Detector=Detector:
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/ClipboardCopier.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/ClipboardCopier.java
new file mode 100644
index 000000000..895fe6ce1
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/ClipboardCopier.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Tasktop Technologies 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.util;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Steffen Pingel
+ */
+public abstract class ClipboardCopier {
+
+ private Clipboard clipboard;
+
+ public static String LINE_SEPARATOR = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ public ClipboardCopier() {
+ }
+
+ public void copy(IStructuredSelection selection) {
+ if (!selection.isEmpty()) {
+ StringBuilder sb = new StringBuilder();
+ for (Iterator<?> it = selection.iterator(); it.hasNext();) {
+ Object item = it.next();
+ String textForElement = getTextForElement(item);
+ if (textForElement != null) {
+ if (sb.length() > 0) {
+ sb.append(LINE_SEPARATOR);
+ sb.append(LINE_SEPARATOR);
+ }
+ sb.append(textForElement);
+ }
+ }
+ copy(sb.toString());
+ }
+ }
+
+ protected abstract String getTextForElement(Object element);
+
+ public void copy(String text) {
+ if (clipboard == null) {
+ Display display = PlatformUI.getWorkbench().getDisplay();
+ clipboard = new Clipboard(display);
+ }
+
+ TextTransfer textTransfer = TextTransfer.getInstance();
+ clipboard.setContents(new Object[] { text }, new Transfer[] { textTransfer });
+ }
+
+ public void dispose() {
+ if (clipboard != null) {
+ clipboard.dispose();
+ clipboard = null;
+ }
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/SelectionProviderAdapter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/SelectionProviderAdapter.java
index 06dd964b6..501d5a569 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/SelectionProviderAdapter.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/SelectionProviderAdapter.java
@@ -11,30 +11,48 @@
package org.eclipse.mylyn.internal.tasks.ui.util;
+import org.eclipse.core.commands.common.EventManager;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
/**
* @author Steffen Pingel
*/
-public class SelectionProviderAdapter implements ISelectionProvider {
+public class SelectionProviderAdapter extends EventManager implements ISelectionProvider {
+
+ private ISelection selection;
public void addSelectionChangedListener(ISelectionChangedListener listener) {
- // ignore
+ addListenerObject(listener);
}
public ISelection getSelection() {
- // ignore
- return null;
+ return selection;
}
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- // ignore
+ removeListenerObject(listener);
+ }
+
+ protected void selectionChanged(final SelectionChangedEvent event) {
+ Object[] listeners = getListeners();
+ for (int i = 0; i < listeners.length; ++i) {
+ final ISelectionChangedListener listener = (ISelectionChangedListener) listeners[i];
+ SafeRunner.run(new SafeRunnable() {
+ public void run() {
+ listener.selectionChanged(event);
+ }
+ });
+ }
}
public void setSelection(ISelection selection) {
- // ignore
+ this.selection = selection;
+ selectionChanged(new SelectionChangedEvent(this, selection));
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiMenus.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiMenus.java
index 28425e15c..d16de4315 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiMenus.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiMenus.java
@@ -80,8 +80,7 @@ public class TasksUiMenus {
File file = new File(filePath);
if (file.exists()) {
- if (!MessageDialog.openConfirm(TasksUiInternal.getShell(),
- Messages.TasksUiMenus_File_exists_,
+ if (!MessageDialog.openConfirm(TasksUiInternal.getShell(), Messages.TasksUiMenus_File_exists_,
Messages.TasksUiMenus_Overwrite_existing_file_ + file.getName())) {
return;
}

Back to the top