Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2007-05-11 23:21:54 +0000
committermkersten2007-05-11 23:21:54 +0000
commit74380e53e3c81ffb2f8ef319687305088f30caf2 (patch)
tree001ce0632b8682e98dab09ec3e106fd55105c06a
parente37470ade86b6a24e293f3797218218b886c016f (diff)
downloadorg.eclipse.mylyn.tasks-74380e53e3c81ffb2f8ef319687305088f30caf2.tar.gz
org.eclipse.mylyn.tasks-74380e53e3c81ffb2f8ef319687305088f30caf2.tar.xz
org.eclipse.mylyn.tasks-74380e53e3c81ffb2f8ef319687305088f30caf2.zip
RESOLVED - bug 185380: add task incoming change information to tooltip
https://bugs.eclipse.org/bugs/show_bug.cgi?id=185380
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListNotificationPopup.java5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTipHandler.java144
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java116
3 files changed, 210 insertions, 55 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListNotificationPopup.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListNotificationPopup.java
index fd1885834..59fe5e6eb 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListNotificationPopup.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListNotificationPopup.java
@@ -109,10 +109,7 @@ public class TaskListNotificationPopup extends PopupDialog {
});
String descriptionText = null;
- if (notification.getDescription() != null && notification.getDescription().length() > 40) {
- String truncated = notification.getDescription().substring(0, 35);
- descriptionText = truncated + "...";
- } else if (notification.getDescription() != null) {
+ if (notification.getDescription() != null) {
descriptionText = notification.getDescription();
}
if (descriptionText != null) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTipHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTipHandler.java
index 6ea6ba2c5..ac8253e51 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTipHandler.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTipHandler.java
@@ -20,6 +20,8 @@ import java.util.Date;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.mylar.internal.core.util.DateUtil;
+import org.eclipse.mylar.internal.tasks.ui.ITaskListNotification;
+import org.eclipse.mylar.internal.tasks.ui.TasksUiImages;
import org.eclipse.mylar.tasks.core.AbstractQueryHit;
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
@@ -30,6 +32,7 @@ import org.eclipse.mylar.tasks.core.ITask;
import org.eclipse.mylar.tasks.core.ITaskListElement;
import org.eclipse.mylar.tasks.core.MylarStatus;
import org.eclipse.mylar.tasks.core.TaskRepository;
+import org.eclipse.mylar.tasks.core.AbstractRepositoryTask.RepositoryTaskSyncState;
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
@@ -72,6 +75,14 @@ public class TaskListToolTipHandler {
private Label tipLabelText;
+ private Label scheduledTipLabelImage;
+
+ private Label scheduledTipLabelText;
+
+ private Label incommingTipLabelImage;
+
+ private Label incommingTipLabelText;
+
private WorkweekProgressBar taskProgressBar;
private Widget tipWidget;
@@ -82,11 +93,11 @@ public class TaskListToolTipHandler {
public TaskListToolTipHandler(Shell parentShell) {
if (parentShell != null) {
- tipShell = createTipShell(parentShell, null);
+ tipShell = createTipShell(parentShell, null, true, true);
}
}
- private Shell createTipShell(Shell parent, Widget widget) {
+ private Shell createTipShell(Shell parent, Widget widget, boolean showScheduled, boolean showIncomming) {
Shell tipShell = new Shell(parent.getDisplay(), SWT.TOOL | SWT.NO_FOCUS | SWT.MODELESS | SWT.ON_TOP);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
@@ -108,7 +119,43 @@ public class TaskListToolTipHandler {
GridData textGridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
tipLabelText.setLayoutData(textGridData);
-
+
+
+ if(showScheduled){
+
+ scheduledTipLabelImage = new Label(tipShell, SWT.NONE);
+ scheduledTipLabelImage.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+ scheduledTipLabelImage.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+
+ imageGridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+ scheduledTipLabelImage.setLayoutData(imageGridData);
+
+ scheduledTipLabelText = new Label(tipShell, SWT.NONE);
+ scheduledTipLabelText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+ scheduledTipLabelText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+
+ textGridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
+ scheduledTipLabelText.setLayoutData(textGridData);
+ }
+
+
+
+ if(showIncomming){
+ incommingTipLabelImage = new Label(tipShell, SWT.NONE);
+ incommingTipLabelImage.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+ incommingTipLabelImage.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+
+ imageGridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+ incommingTipLabelImage.setLayoutData(imageGridData);
+
+ incommingTipLabelText = new Label(tipShell, SWT.NONE);
+ incommingTipLabelText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+ incommingTipLabelText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+
+ textGridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
+ incommingTipLabelText.setLayoutData(textGridData);
+ }
+
ITaskListElement element = getTaskListElement(widget);
if (element instanceof AbstractTaskContainer) {
Composite progressComposite = new Composite(tipShell, SWT.NONE);
@@ -172,7 +219,7 @@ public class TaskListToolTipHandler {
return null;
}
- protected String getToolTipText(Object object) {
+ protected String getBasicToolTextTip(Object object) {
ITaskListElement element = getTaskListElement(object);
String tooltip = "";
String priority = "";
@@ -229,6 +276,7 @@ public class TaskListToolTipHandler {
}
if (element instanceof AbstractRepositoryTask || element instanceof AbstractQueryHit) {
+
AbstractRepositoryTask repositoryTask;
if (element instanceof AbstractQueryHit) {
repositoryTask = ((AbstractQueryHit) element).getCorrespondingTask();
@@ -238,14 +286,16 @@ public class TaskListToolTipHandler {
tooltip += (element).getSummary();
if (repositoryTask != null) {
+ String taskKindLabel = TasksUiPlugin.getRepositoryUi(repositoryTask.getRepositoryKind()).getTaskKindLabel(repositoryTask);
+
+ tooltip += "\n" + taskKindLabel + ", " + repositoryTask.getPriority();
+
TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
repositoryTask.getRepositoryKind(), repositoryTask.getRepositoryUrl());
if (repository != null) {
tooltip += "\n" + repository.getRepositoryLabel();
}
- tooltip += SEPARATOR;
- tooltip += formatActivityInformation(repositoryTask);
-
+
if (repositoryTask.getStatus() != null) {
tooltip += SEPARATOR + "Last Error: " + repositoryTask.getStatus().getMessage();
}
@@ -253,8 +303,6 @@ public class TaskListToolTipHandler {
return tooltip;
} else if (element != null) {
tooltip += (element).getSummary();
- tooltip += SEPARATOR;
- tooltip += formatActivityInformation(element);
return tooltip + priority;
} else if (object instanceof Control) {
return (String) ((Control) object).getData("TIP_TEXT");
@@ -262,29 +310,62 @@ public class TaskListToolTipHandler {
return null;
}
- private String formatActivityInformation(ITaskListElement element) {
- String result = "";
- if (element instanceof ITask) {
+ private String getActivityText(ITaskListElement element) {
+ if(element instanceof AbstractQueryHit){
+ element = ((AbstractQueryHit)element).getCorrespondingTask();
+ }
+ if (element != null && element instanceof ITask) {
try {
+ String result = "";
Date date = ((ITask) element).getScheduledForDate();
if (date != null) {
result += "Scheduled for: " + DateFormat.getDateInstance(DateFormat.LONG).format(date) + " ("
- + DateFormat.getTimeInstance(DateFormat.SHORT).format(date) + ")";
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(date) + ")\n";
}
long elapsed = TasksUiPlugin.getTaskListManager().getElapsedTime((ITask) element);
String elapsedTimeString = DateUtil.getFormattedDurationShort(elapsed);
if (!elapsedTimeString.equals("")) {
- result += "\nElapsed: " + elapsedTimeString + "\n";
+ result += "Elapsed: " + elapsedTimeString + "\n";
}
+ return result;
} catch (Exception e) {
// ignore
}
}
- return result;
+ return null;
+ }
+
+ private String getIncommingText(ITaskListElement element){
+ if (element instanceof AbstractRepositoryTask || element instanceof AbstractQueryHit) {
+
+ AbstractRepositoryTask repositoryTask;
+ if (element instanceof AbstractQueryHit) {
+ repositoryTask = ((AbstractQueryHit) element).getCorrespondingTask();
+ } else {
+ repositoryTask = (AbstractRepositoryTask) element;
+ }
+ if(repositoryTask != null && repositoryTask.getSyncState() == RepositoryTaskSyncState.INCOMING){
+ AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repositoryTask);
+ if(connector != null){
+ ITaskListNotification notification = TasksUiPlugin.getIncommingNotification(connector, repositoryTask);
+ if(notification != null){
+ String descriptionText = null;
+ if (notification.getDescription() != null) {
+ descriptionText = notification.getDescription();
+ }
+
+ if(descriptionText != null && !descriptionText.equals("")){
+ return descriptionText;
+ }
+ }
+ }
+ }
+ }
+ return null;
}
- protected Image getToolTipImage(Object object) {
+ protected Image getImage(Object object) {
ITaskListElement element = getTaskListElement(object);
if (object instanceof Control) {
return (Image) ((Control) object).getData("TIP_IMAGE");
@@ -378,6 +459,7 @@ public class TaskListToolTipHandler {
@Override
public void mouseHover(MouseEvent event) {
+
widgetPosition = new Point(event.x, event.y);
Widget widget = event.widget;
if (widget instanceof ToolBar) {
@@ -401,23 +483,41 @@ public class TaskListToolTipHandler {
return;
tipWidget = widget;
tipPosition = control.toDisplay(widgetPosition);
- String text = getToolTipText(widget);
- Image image = getToolTipImage(widget);
- if (text == null) { // HACK: don't check length
+ String baseText = getBasicToolTextTip(widget);
+ String scheduledText = getActivityText(getTaskListElement(widget));
+ String incommingText = getIncommingText(getTaskListElement(widget));
+
+ Image repositoryImage = getImage(widget);
+ Image activityImage = TasksUiImages.getImage(TasksUiImages.CALENDAR); // TODO Fixme
+ Image incommingImage = TasksUiImages.getImage(TasksUiImages.OVERLAY_INCOMMING);
+
+ if (baseText == null) { // HACK: don't check length
return;
}
if (!tipShell.isDisposed() && tipShell.getShell() != null
&& PlatformUI.getWorkbench().getDisplay().getActiveShell() != null) {
tipShell.close();
- tipShell = createTipShell(PlatformUI.getWorkbench().getDisplay().getActiveShell(), widget);
+ tipShell = createTipShell(PlatformUI.getWorkbench().getDisplay().getActiveShell(), widget, scheduledText != null, incommingText != null);
}
String progressText = updateContainerProgressBar(taskProgressBar, getTaskListElement(widget));
- tipLabelText.setText(text + progressText);
- tipLabelImage.setImage(image); // accepts null
+
+ tipLabelText.setText(baseText + progressText);
+ tipLabelImage.setImage(repositoryImage); // accepts null
+
+ if(scheduledText != null){
+ scheduledTipLabelText.setText(scheduledText);
+ scheduledTipLabelImage.setImage(activityImage); // accepts null
+ }
+
+ if(incommingText != null){
+ incommingTipLabelText.setText(incommingText);
+ incommingTipLabelImage.setImage(incommingImage); // accepts null
+ }
+
tipShell.pack();
setHoverLocation(tipShell, tipPosition);
tipShell.setVisible(true);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java
index 51164e936..d9c1f177d 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java
@@ -287,35 +287,8 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup {
.getRepositoryTasks(repository.getUrl())) {
if (repositoryTask.getSyncState() == RepositoryTaskSyncState.INCOMING
&& repositoryTask.isNotified() == false) {
- TaskListNotificationIncoming notification = new TaskListNotificationIncoming(repositoryTask);
-
- RepositoryTaskData taskData = getDefault().getTaskDataManager().getNewTaskData(
- repositoryTask.getHandleIdentifier());
-
- if (taskData != null) {
- List<TaskComment> taskComments = taskData.getComments();
- if (taskComments != null && taskComments.size() > 0) {
- TaskComment lastComment = taskComments.get(taskComments.size() - 1);
- if (lastComment != null) {
- notification.setDescription(lastComment.getText());
- }
- } else {
- String description = taskData.getDescription();
- if (description != null) {
- notification.setDescription(description);
- }
- }
-
- if (connector != null) {
- ITaskDataHandler offlineHandler = connector.getTaskDataHandler();
- if (offlineHandler != null && taskData.getLastModified() != null) {
- Date modified = taskData.getAttributeFactory().getDateForAttributeType(
- RepositoryTaskAttribute.DATE_MODIFIED, taskData.getLastModified());
- notification.setDate(modified);
- }
- }
-
- }
+ TaskListNotificationIncoming notification = getIncommingNotification(connector,
+ repositoryTask);
notifications.add(notification);
repositoryTask.setNotified(true);
}
@@ -935,4 +908,89 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup {
return getTaskDataManager().getNewRepositoryTaskId();
}
+ public static TaskListNotificationIncoming getIncommingNotification(AbstractRepositoryConnector connector,
+ AbstractRepositoryTask repositoryTask) {
+
+ TaskListNotificationIncoming notification = new TaskListNotificationIncoming(repositoryTask);
+
+ RepositoryTaskData newTaskData = getDefault().getTaskDataManager().getNewTaskData(
+ repositoryTask.getHandleIdentifier());
+
+ RepositoryTaskData oldTaskData = getDefault().getTaskDataManager().getOldTaskData(
+ repositoryTask.getHandleIdentifier());
+
+
+ if (newTaskData != null && oldTaskData != null) {
+
+ String descriptionText = getChangedDescription(newTaskData, oldTaskData);
+ if(descriptionText != null){
+ notification.setDescription(descriptionText);
+ }
+
+ if (connector != null) {
+ ITaskDataHandler offlineHandler = connector.getTaskDataHandler();
+ if (offlineHandler != null && newTaskData.getLastModified() != null) {
+ Date modified = newTaskData.getAttributeFactory().getDateForAttributeType(
+ RepositoryTaskAttribute.DATE_MODIFIED, newTaskData.getLastModified());
+ notification.setDate(modified);
+ }
+ }
+
+ } else {
+ notification.setDescription("Open to view changes");
+ }
+ return notification;
+ }
+
+ private static String getChangedDescription(RepositoryTaskData newTaskData, RepositoryTaskData oldTaskData){
+
+ String descriptionText = "";
+
+ if(newTaskData.getComments().size() > oldTaskData.getComments().size()){
+ List<TaskComment> taskComments = newTaskData.getComments();
+ if (taskComments != null && taskComments.size() > 0) {
+ TaskComment lastComment = taskComments.get(taskComments.size() - 1);
+ if (lastComment != null) {
+ descriptionText += "Comment by " + lastComment.getAuthor() + ":\n ";
+ String commentText = lastComment.getText();
+ if (commentText.length() > 60) {
+ commentText = commentText.substring(0, 55) + "...";
+ }
+ descriptionText += commentText;
+ }
+ }
+ }
+
+ boolean attributeChanged = false;
+
+ for(RepositoryTaskAttribute newAttribute: newTaskData.getAttributes()){
+ RepositoryTaskAttribute oldAttribute = oldTaskData.getAttribute(newAttribute.getID());
+ if (oldAttribute == null){
+ attributeChanged = true;
+ break;
+ }
+ if (oldAttribute.getValue() != null && !oldAttribute.getValue().equals(newAttribute.getValue())) {
+ attributeChanged = true;
+ break;
+ } else if (oldAttribute.getValues() != null && !oldAttribute.getValues().equals(newAttribute.getValues())) {
+ attributeChanged = true;
+ break;
+ }
+ }
+
+ if(attributeChanged){
+ if (descriptionText.equals("")){
+ descriptionText += "Attributes changed";
+ }
+ }
+// else {
+// String description = taskData.getDescription();
+// if (description != null) {
+// notification.setDescription(description);
+// }
+// }
+
+ return descriptionText;
+ }
+
}

Back to the top