Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 72619 Details for
Bug 194510
[linux][mac] tooltip overlaps with context menu
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
rollback to old implementation (see comment)
clipboard.txt (text/plain), 27.30 KB, created by
Steffen Pingel
on 2007-06-27 12:47:55 EDT
(
hide
)
Description:
rollback to old implementation (see comment)
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2007-06-27 12:47:55 EDT
Size:
27.30 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java,v >retrieving revision 1.173 >diff -u -r1.173 TaskListView.java >--- src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java 27 Jun 2007 05:23:21 -0000 1.173 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java 27 Jun 2007 16:44:36 -0000 >@@ -878,10 +878,8 @@ > hookOpenAction(); > contributeToActionBars(); > >- if (!SWT.getPlatform().equals("carbon")) { >- TaskListToolTipHandler taskListToolTipHandler = new TaskListToolTipHandler(); >- taskListToolTipHandler.activateHoverHelp(getViewer().getControl()); >- } >+ TaskListToolTipHandler taskListToolTipHandler = new TaskListToolTipHandler(getViewer().getControl().getShell()); >+ taskListToolTipHandler.activateHoverHelp(getViewer().getControl()); > > // Set to empty string to disable native tooltips (windows only?) > // bug#160897 >Index: src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTipHandler.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTipHandler.java,v >retrieving revision 1.50 >diff -u -r1.50 TaskListToolTipHandler.java >--- src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTipHandler.java 26 Jun 2007 01:16:39 -0000 1.50 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTipHandler.java 27 Jun 2007 16:44:36 -0000 >@@ -11,13 +11,12 @@ > > package org.eclipse.mylyn.internal.tasks.ui.views; > >+import java.net.URL; > import java.text.DateFormat; >-import java.text.SimpleDateFormat; > import java.util.Calendar; > import java.util.Date; > > import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IStatus; > import org.eclipse.mylyn.internal.tasks.core.ScheduledTaskContainer; > import org.eclipse.mylyn.internal.tasks.ui.ITaskListNotification; > import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages; >@@ -56,14 +55,151 @@ > * @author Mik Kersten > * @author Eric Booth > * @author Leo Dos Santos - multi-monitor support >- * @author Steffen Pingel > */ > public class TaskListToolTipHandler { > >+ private static final String SEPARATOR = "\n\n"; >+ >+ private static final String UNITS_HOURS = " hours"; >+ >+ private static final String NO_MINUTES = "0 minutes"; >+ > private Shell tipShell; > >+ private Label tipLabelImage; >+ >+ private Label tipLabelText; >+ >+ private Label scheduledTipLabelImage; >+ >+ private Label scheduledTipLabelText; >+ >+ private Label incommingTipLabelImage; >+ >+ private Label incommingTipLabelText; >+ >+ private WorkweekProgressBar taskProgressBar; >+ > private Widget tipWidget; > >+ protected Point tipPosition; >+ >+ protected Point widgetPosition; >+ >+ public TaskListToolTipHandler(Shell parentShell) { >+ if (parentShell != null) { >+ tipShell = createTipShell(parentShell, null, true, true); >+ } >+ } >+ >+ 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; >+ gridLayout.marginWidth = 2; >+ gridLayout.marginHeight = 2; >+ tipShell.setLayout(gridLayout); >+ tipShell.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); >+ >+ tipLabelImage = new Label(tipShell, SWT.NONE); >+ tipLabelImage.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); >+ tipLabelImage.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); >+ >+ GridData imageGridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); >+ tipLabelImage.setLayoutData(imageGridData); >+ >+ tipLabelText = new Label(tipShell, SWT.NONE); >+ tipLabelText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); >+ tipLabelText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); >+ >+ 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); >+ } >+ >+ AbstractTaskContainer element = getTaskListElement(widget); >+ if (element != null) { >+ Composite progressComposite = new Composite(tipShell, SWT.NONE); >+ GridLayout progressLayout = new GridLayout(1, false); >+ progressLayout.marginWidth = 2; >+ progressLayout.marginHeight = 0; >+ progressLayout.marginBottom = 2; >+ progressLayout.horizontalSpacing = 0; >+ progressLayout.verticalSpacing = 0; >+ progressComposite.setLayout(progressLayout); >+ progressComposite.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 4, 1)); >+ >+ taskProgressBar = new WorkweekProgressBar(progressComposite); >+ taskProgressBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ } >+ >+ return tipShell; >+ } >+ >+ private String updateContainerProgressBar(WorkweekProgressBar taskProgressBar, Object object) { >+ if (taskProgressBar != null && !taskProgressBar.isDisposed() && object instanceof AbstractTaskContainer) { >+ String text = ""; >+ AbstractTaskContainer container = (AbstractTaskContainer) object; >+ >+ int total = container.getChildren().size(); >+ int completed = 0; >+ for (AbstractTask task : container.getChildren()) { >+ if (task.isCompleted()) { >+ completed++; >+ } >+ } >+ String suffix = ""; >+ if (container instanceof AbstractRepositoryQuery) { >+ AbstractRepositoryQuery query = ((AbstractRepositoryQuery) container); >+ total = 0; >+ completed = 0; >+ total += query.getChildren().size(); >+ for (AbstractTask hit : query.getChildren()) { >+ if (hit.isCompleted()) { >+ completed++; >+ } >+ } >+ // suffix = " (query max: " + query.getMaxHits() + ")"; >+ } >+ taskProgressBar.reset(completed, total); >+ text += "Completed " + completed + " of " + total + suffix; >+ return text; >+ } else { >+ return ""; >+ } >+ } >+ > private AbstractTaskContainer getTaskListElement(Object hoverObject) { > if (hoverObject instanceof Widget) { > Object data = ((Widget) hoverObject).getData(); >@@ -78,120 +214,124 @@ > return null; > } > >- private String getTitleText(AbstractTaskContainer element) { >- if (element instanceof ScheduledTaskContainer) { >- StringBuilder sb = new StringBuilder(); >- sb.append(element.getSummary()); >- Calendar start = ((ScheduledTaskContainer) element).getStart(); >- sb.append(" ["); >- sb.append(DateFormat.getDateInstance(DateFormat.LONG).format(start.getTime())); >- sb.append("]"); >- return sb.toString(); >- } else if (element instanceof AbstractRepositoryQuery) { >- AbstractRepositoryQuery query = (AbstractRepositoryQuery) element; >- StringBuilder sb = new StringBuilder(); >- sb.append(element.getSummary()); >- sb.append(" ["); >- sb.append(getRepositoryLabel(query.getRepositoryKind(), query.getRepositoryUrl())); >- sb.append("]"); >- return sb.toString(); >- } else { >- return element.getSummary(); >- } >- } >+ protected String getBasicToolTextTip(Object object) { >+ AbstractTaskContainer element = getTaskListElement(object); >+ String tooltip = ""; >+ String priority = ""; > >- private String getDetailsText(AbstractTaskContainer element) { > if (element instanceof ScheduledTaskContainer) { > ScheduledTaskContainer container = (ScheduledTaskContainer) element; >- StringBuilder sb = new StringBuilder(); >- sb.append("Estimate: "); >- sb.append(container.getTotalEstimated()); >- sb.append(" hours"); >- sb.append("\n"); >- sb.append("Elapsed: "); >- sb.append(DateUtil.getFormattedDurationShort(container.getTotalElapsed())); >- sb.append("\n"); >- return sb.toString(); >- } else if (element instanceof AbstractTask) { >- AbstractTask task = (AbstractTask) element; >- StringBuilder sb = new StringBuilder(); >- sb.append(TasksUiPlugin.getConnectorUi(task.getConnectorKind()).getTaskKindLabel(task)); >- String key = task.getTaskKey(); >- if (key != null) { >- sb.append(" "); >- sb.append(key); >- } >- sb.append(", "); >- sb.append(task.getPriority()); >- sb.append(" ["); >- sb.append(getRepositoryLabel(task.getConnectorKind(), task.getRepositoryUrl())); >- sb.append("]"); >- sb.append("\n"); >- return sb.toString(); >- } else { >- return null; >+ tooltip += "Estimate: " + container.getTotalEstimated() + UNITS_HOURS; >+ String elapsedTimeString = NO_MINUTES; >+ try { >+ elapsedTimeString = DateUtil.getFormattedDurationShort(container.getTotalElapsed()); >+ if (elapsedTimeString.equals("")) { >+ elapsedTimeString = NO_MINUTES; >+ } >+ } catch (RuntimeException e) { >+ // ignore >+ } >+ tooltip += " Elapsed: " + elapsedTimeString + "\n"; >+ return tooltip; > } >- } > >- private String getRepositoryLabel(String repositoryKind, String repositoryUrl) { >- TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(repositoryKind, repositoryUrl); >- if (repository != null) { >- String label = repository.getRepositoryLabel(); >- if (label.indexOf("//") != -1) { >- return label.substring((repository.getUrl().indexOf("//") + 2)); >+ if (element instanceof AbstractRepositoryQuery) { >+ AbstractRepositoryQuery query = (AbstractRepositoryQuery) element; >+ >+ try { >+ tooltip += new URL(query.getRepositoryUrl()).getHost(); >+ } catch (Exception e) { >+ // ignore >+ } >+ >+ String syncStamp = query.getLastSynchronizedTimeStamp(); >+ if (syncStamp != null) { >+ tooltip += " (synched: " + syncStamp + ")\n"; > } >- return label + ""; >+ if (query.getSynchronizationStatus() != null) { >+ tooltip += "\n" + "Last Error: " + query.getSynchronizationStatus().getMessage(); >+ if (query.getSynchronizationStatus() instanceof RepositoryStatus >+ && ((RepositoryStatus) query.getSynchronizationStatus()).isHtmlMessage()) { >+ tooltip += " Please synchronize manually for full error message."; >+ } >+ tooltip += "\n"; >+ } >+ return tooltip; > } >- return ""; >+ >+ if (element instanceof AbstractTask) { >+ >+ AbstractTask repositoryTask = (AbstractTask) element; >+ >+ tooltip += (element).getSummary(); >+ >+ String taskKindLabel = TasksUiPlugin.getConnectorUi(repositoryTask.getConnectorKind()) >+ .getTaskKindLabel(repositoryTask); >+ >+ tooltip += "\n" + taskKindLabel + ", " + repositoryTask.getPriority(); >+ >+ TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository( >+ repositoryTask.getConnectorKind(), repositoryTask.getRepositoryUrl()); >+ if (repository != null) { >+ tooltip += " [" + repository.getRepositoryLabel() + "]"; >+ } >+ >+ if (repositoryTask.getSynchronizationStatus() != null) { >+ tooltip += SEPARATOR + "Last Error: " + repositoryTask.getSynchronizationStatus().getMessage(); >+ } >+ return tooltip; >+ } else if (element != null) { >+ tooltip += (element).getSummary(); >+ return tooltip + priority; >+ } else if (object instanceof Control) { >+ return (String) ((Control) object).getData("TIP_TEXT"); >+ } >+ return null; > } > > private String getActivityText(AbstractTaskContainer element) { >- if (element instanceof AbstractTask) { >- AbstractTask task = (AbstractTask) element; > >- StringBuilder sb = new StringBuilder(); >- Date date = task.getScheduledForDate(); >- if (date != null) { >- sb.append("Scheduled for: "); >- sb.append(new SimpleDateFormat("E").format(date)).append(", "); >- sb.append(DateFormat.getDateInstance(DateFormat.LONG).format(date)); >- sb.append(" (").append(DateFormat.getTimeInstance(DateFormat.SHORT).format(date)).append(")\n"); >- } >- >- long elapsed = TasksUiPlugin.getTaskListManager().getElapsedTime(task); >- String elapsedTimeString = DateUtil.getFormattedDurationShort(elapsed); >- sb.append("Elapsed: "); >- sb.append(elapsedTimeString); >- sb.append("\n"); >+ if (element != null && element instanceof AbstractTask) { >+ try { >+ String result = ""; >+ Date date = ((AbstractTask) element).getScheduledForDate(); >+ if (date != null) { >+ result += "Scheduled for: " + DateFormat.getDateInstance(DateFormat.LONG).format(date) + " (" >+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(date) + ")\n"; >+ } > >- return sb.toString(); >+ long elapsed = TasksUiPlugin.getTaskListManager().getElapsedTime((AbstractTask) element); >+ String elapsedTimeString = DateUtil.getFormattedDurationShort(elapsed); >+ if (!elapsedTimeString.equals("")) { >+ result += "Elapsed: " + elapsedTimeString + "\n"; >+ } >+ return result; >+ } catch (Exception e) { >+ // ignore >+ } > } > return null; > } > > private String getIncommingText(AbstractTaskContainer element) { > if (element instanceof AbstractTask) { >- AbstractTask task = (AbstractTask) element; >- if (task.getSynchronizationState() == RepositoryTaskSyncState.INCOMING) { >+ >+ AbstractTask repositoryTask = (AbstractTask) element; >+ >+ if (repositoryTask.getSynchronizationState() == RepositoryTaskSyncState.INCOMING) { > AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector( >- task); >+ repositoryTask); > if (connector != null) { >- ITaskListNotification notification = TasksUiPlugin.getDefault().getIncommingNotification(connector, task); >+ ITaskListNotification notification = TasksUiPlugin.getDefault().getIncommingNotification(connector, repositoryTask); > if (notification != null) { >- String res = null; >+ String descriptionText = null; > if (notification.getDescription() != null) { >- String descriptionText = notification.getDescription(); >- if (descriptionText != null && descriptionText.length() > 0) { >- res = descriptionText; >- } >+ descriptionText = notification.getDescription(); > } >- if(notification.getDetails() !=null) { >- String details = notification.getDetails(); >- if (details != null && details.length() > 0) { >- res = res==null ? details : res + "\n" + details; >- } >+ >+ if (descriptionText != null && !descriptionText.equals("")) { >+ return descriptionText; > } >- return res; > } > } > } >@@ -199,48 +339,12 @@ > return null; > } > >- private String getStatusText(AbstractTaskContainer element) { >- IStatus status = null; >- if (element instanceof AbstractTask) { >- AbstractTask task = (AbstractTask) element; >- status = task.getSynchronizationStatus(); >+ protected Image getImage(Object object) { >+ AbstractTaskContainer element = getTaskListElement(object); >+ if (object instanceof Control) { >+ return (Image) ((Control) object).getData("TIP_IMAGE"); > } else if (element instanceof AbstractRepositoryQuery) { > AbstractRepositoryQuery query = (AbstractRepositoryQuery) element; >- status = query.getSynchronizationStatus(); >- } >- >- if (status != null) { >- StringBuilder sb = new StringBuilder(); >- sb.append(status.getMessage()); >- if (status instanceof RepositoryStatus && ((RepositoryStatus) status).isHtmlMessage()) { >- sb.append(" Please synchronize manually for full error message."); >- } >- return sb.toString(); >- } >- >- return null; >- } >- >- private ProgressData getProgressData(AbstractTaskContainer element) { >- if (element instanceof AbstractTask) { >- return null; >- } >- >- int total = element.getChildren().size(); >- int completed = 0; >- for (AbstractTask task : element.getChildren()) { >- if (task.isCompleted()) { >- completed++; >- } >- } >- >- String text = "Total: " + total + " (Complete: " + completed + ", Incomplete: " + (total - completed) + ")"; >- return new ProgressData(completed, total, text); >- } >- >- private Image getImage(AbstractTaskContainer element) { >- if (element instanceof AbstractRepositoryQuery) { >- AbstractRepositoryQuery query = (AbstractRepositoryQuery) element; > AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector( > query.getRepositoryKind()); > if (connector != null) { >@@ -253,8 +357,13 @@ > if (connector != null) { > return TasksUiPlugin.getDefault().getBrandingIcon(connector.getConnectorKind()); > } >- } else if (element instanceof ScheduledTaskContainer) { >- return TasksUiImages.getImage(TasksUiImages.CALENDAR); >+ } >+ return null; >+ } >+ >+ protected Object getToolTipHelp(Object object) { >+ if (object instanceof Control) { >+ return ((Control) object).getData("TIP_HELPTEXT"); > } > return null; > } >@@ -265,45 +374,62 @@ > * @control the control on which to enable hoverhelp > */ > public void activateHoverHelp(final Control control) { >- // hide tooltip if any window is deactivated >+ > PlatformUI.getWorkbench().addWindowListener(new IWindowListener() { > > public void windowActivated(IWorkbenchWindow window) { >+ // ignore >+ > } > > public void windowClosed(IWorkbenchWindow window) { >+ // ignore >+ > } > > public void windowDeactivated(IWorkbenchWindow window) { > hideTooltip(); >+ > } > > public void windowOpened(IWorkbenchWindow window) { >+ // ignore >+ > } > }); > >- // hide tooltip if control underneath is activated >+ /* >+ * Get out of the way if we attempt to activate the control underneath >+ * the tooltip >+ */ > control.addMouseListener(new MouseAdapter() { > > @Override > public void mouseDown(MouseEvent e) { > hideTooltip(); >- tipWidget = null; > } > }); >- >- // trap hover events to pop-up tooltip >+ /* >+ * Trap hover events to pop-up tooltip >+ */ > control.addMouseTrackListener(new MouseTrackAdapter() { > > @Override > public void mouseExit(MouseEvent e) { >- hideTooltip(); >+ // TODO: can these conditions be simplified? see bug 131776 >+ if (tipShell != null && !tipShell.isDisposed() && tipShell.getDisplay() != null >+ && !tipShell.getDisplay().isDisposed() && tipShell.isVisible()) { >+ tipShell.setVisible(false); >+ } > tipWidget = null; > } > > @Override > public void mouseHover(MouseEvent event) { >- Point widgetPosition = new Point(event.x, event.y); >+ if (tipShell.isDisposed()) { >+ return; >+ } >+ widgetPosition = new Point(event.x, event.y); > Widget widget = event.widget; > if (widget instanceof ToolBar) { > ToolBar w = (ToolBar) widget; >@@ -317,22 +443,63 @@ > Tree w = (Tree) widget; > widget = w.getItem(widgetPosition); > } >- >- if (widget == null) { >- hideTooltip(); >+ if (widget == null && !tipShell.isDisposed()) { >+ tipShell.setVisible(false); > tipWidget = null; > return; > } >- >- if (widget == tipWidget) { >- // already displaying tooltip >+ if (widget == tipWidget) >+ return; >+ tipWidget = widget; >+ tipPosition = control.toDisplay(widgetPosition); >+ 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; > } > >- tipWidget = widget; >- showTooltip(control.toDisplay(widgetPosition)); >- } >+ if (!tipShell.isDisposed() && tipShell.getShell() != null >+ && PlatformUI.getWorkbench().getDisplay().getActiveShell() != null) { >+ tipShell.close(); >+ tipShell = createTipShell(PlatformUI.getWorkbench().getDisplay().getActiveShell(), widget, >+ scheduledText != null, incommingText != null); >+ } > >+ AbstractTaskContainer element = getTaskListElement(widget); >+ String progressText = updateContainerProgressBar(taskProgressBar, element); >+ >+ String dateText = ""; >+ if (element instanceof ScheduledTaskContainer) { >+ Calendar start = ((ScheduledTaskContainer) element).getStart(); >+ dateText += DateFormat.getDateInstance(DateFormat.LONG).format(start.getTime()) + "\n"; >+ } >+ >+ tipLabelText.setText(dateText + 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); >+ } > }); > } > >@@ -374,143 +541,7 @@ > } > > private void hideTooltip() { >- // TODO: can these conditions be simplified? see bug 131776 >- if (tipShell != null && !tipShell.isDisposed() && tipShell.getDisplay() != null >- && !tipShell.getDisplay().isDisposed() && tipShell.isVisible()) { >-// tipShell.setVisible(false); >- tipShell.close(); >- tipShell = null; >- } >- } >- >- private void showTooltip(Point location) { >- hideTooltip(); >- >- AbstractTaskContainer element = getTaskListElement(tipWidget); >- >- Shell parent = PlatformUI.getWorkbench().getDisplay().getActiveShell(); >- if (parent == null) { >- return; >- } >- >- tipShell = new Shell(parent.getDisplay(), SWT.TOOL | SWT.NO_FOCUS | SWT.MODELESS | SWT.ON_TOP); >- GridLayout gridLayout = new GridLayout(); >- gridLayout.numColumns = 2; >- gridLayout.marginWidth = 5; >- gridLayout.marginHeight = 2; >- tipShell.setLayout(gridLayout); >- tipShell.setBackground(tipShell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); >- >- addIconAndLabel(tipShell, getImage(element), getTitleText(element)); >- >- String detailsText = getDetailsText(element); >- if (detailsText != null) { >- addIconAndLabel(tipShell, null, detailsText); >- } >- >- String synchText = getSynchText(element); >- if (synchText != null) { >- addIconAndLabel(tipShell, TasksUiImages.getImage(TasksUiImages.REPOSITORY_SYNCHRONIZE), synchText); >- } >- >- String activityText = getActivityText(element); >- if (activityText != null) { >- addIconAndLabel(tipShell, TasksUiImages.getImage(TasksUiImages.CALENDAR), activityText); >- } >- >- String incommingText = getIncommingText(element); >- if (incommingText != null) { >- addIconAndLabel(tipShell, TasksUiImages.getImage(TasksUiImages.OVERLAY_INCOMMING), incommingText); >- } >- >- ProgressData progress = getProgressData(element); >- if (progress != null) { >- addIconAndLabel(tipShell, null, progress.text); >- >- // label height need to be set to 0 to remove gap below the progress bar >- Label label = new Label(tipShell, SWT.NONE); >- GridData labelGridData = new GridData(SWT.FILL, SWT.TOP, true, false); >- labelGridData.heightHint = 0; >- label.setLayoutData(labelGridData); >- >- Composite progressComposite = new Composite(tipShell, SWT.NONE); >- GridLayout progressLayout = new GridLayout(1, false); >- progressLayout.marginWidth = 0; >- progressLayout.marginHeight = 0; >- progressComposite.setLayout(progressLayout); >- progressComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); >- >- WorkweekProgressBar taskProgressBar = new WorkweekProgressBar(progressComposite); >- taskProgressBar.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); >- taskProgressBar.reset(progress.completed, progress.total); >- >- // do we really need custom canvas? code below renders the same >-// IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager(); >-// Color color = themeManager.getCurrentTheme().getColorRegistry().get( >-// TaskListColorsAndFonts.THEME_COLOR_TASK_TODAY_COMPLETED); >-// ProgressBar bar = new ProgressBar(tipShell, SWT.SMOOTH); >-// bar.setForeground(color); >-// bar.setSelection((int) (100d * progress.completed / progress.total)); >-// GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); >-// gridData.heightHint = 5; >-// bar.setLayoutData(gridData); >- } >- >- String statusText = getStatusText(element); >- if (statusText != null) { >- addIconAndLabel(tipShell, TasksUiImages.getImage(TasksUiImages.WARNING), statusText); >- } >- >- tipShell.pack(); >- setHoverLocation(tipShell, location); >- tipShell.setVisible(true); >- } >- >- private String getSynchText(AbstractTaskContainer element) { >- if (element instanceof AbstractRepositoryQuery) { >- String syncStamp = ((AbstractRepositoryQuery) element).getLastSynchronizedTimeStamp(); >- if (syncStamp != null) { >- return "Synchronized: " + syncStamp; >- } >- } >- return null; >- } >- >- private String removeTrailingNewline(String text) { >- if (text.endsWith("\n")) { >- return text.substring(0, text.length() - 1); >- } >- return text; >+ if (tipShell != null && !tipShell.isDisposed() && tipShell.isVisible()) >+ tipShell.setVisible(false); > } >- >- private void addIconAndLabel(Composite parent, Image image, String text) { >- Label imageLabel = new Label(parent, SWT.NONE); >- imageLabel.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); >- imageLabel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); >- imageLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING)); >- imageLabel.setImage(image); >- >- Label textLabel = new Label(parent, SWT.NONE); >- textLabel.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); >- textLabel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); >- textLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER)); >- textLabel.setText(removeTrailingNewline(text)); >- } >- >- private static class ProgressData { >- >- int completed; >- >- int total; >- >- String text; >- >- public ProgressData(int completed, int total, String text) { >- this.completed = completed; >- this.total = total; >- this.text = text; >- } >- >- } >- > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 194510
: 72619