diff options
author | Vaughan Hilts | 2015-11-25 00:43:49 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2015-12-05 00:02:07 +0000 |
commit | 338621720668be556f677c6f85ad46934cf7dfaa (patch) | |
tree | 26ad3a9e9886dbb8e2960a06f0991608b772191e | |
parent | 0db4f0fe1f7028115aa1fb7620818a821e16a4cf (diff) | |
download | org.eclipse.mylyn.tasks-338621720668be556f677c6f85ad46934cf7dfaa.tar.gz org.eclipse.mylyn.tasks-338621720668be556f677c6f85ad46934cf7dfaa.tar.xz org.eclipse.mylyn.tasks-338621720668be556f677c6f85ad46934cf7dfaa.zip |
481800: [UCOSP] Remove task affordances from the review artifact editor,
if an artifact
Change-Id: Iabf4d96982c78ae5c6629c029d5bdaddc6c14e84
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=481800
Signed-off-by: Vaughan Hilts <hilts.vaughan@gmail.com>
5 files changed, 85 insertions, 23 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/plugin.xml b/org.eclipse.mylyn.tasks.ui/plugin.xml index fbad1a170..06f31f24d 100644 --- a/org.eclipse.mylyn.tasks.ui/plugin.xml +++ b/org.eclipse.mylyn.tasks.ui/plugin.xml @@ -1889,7 +1889,7 @@ class="org.eclipse.mylyn.internal.tasks.ui.util.TaskPropertyTester" id="org.eclipse.mylyn.tasks.ui.propertyTester.task" namespace="org.eclipse.mylyn.task" - properties="canGetAttachment,canGetHistory,canPostAttachment,connectorKind,hasActiveTime,hasEdits,hasLocalContext,hasLocalCompletionState,hasRepositoryContext,isCompleted,isLocal," + properties="canGetAttachment,canGetHistory,canPostAttachment,connectorKind,hasActiveTime,hasEdits,hasLocalContext,hasLocalCompletionState,hasRepositoryContext,isCompleted,isLocal,isArtifact," type="org.eclipse.mylyn.tasks.core.ITask"> </propertyTester> <propertyTester @@ -2221,7 +2221,11 @@ <iterate> <adapt type="org.eclipse.mylyn.tasks.core.ITask"> - </adapt> + </adapt> + <test + property="org.eclipse.mylyn.task.isArtifact" + value="false"> + </test> </iterate> </and> </or> diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ScheduleTaskMenuContributor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ScheduleTaskMenuContributor.java index e1fd95485..29503c64d 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ScheduleTaskMenuContributor.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ScheduleTaskMenuContributor.java @@ -26,6 +26,7 @@ import org.eclipse.mylyn.commons.workbench.forms.DatePicker; import org.eclipse.mylyn.commons.workbench.forms.DateSelectionDialog; import org.eclipse.mylyn.internal.tasks.core.AbstractTask; import org.eclipse.mylyn.internal.tasks.core.DateRange; +import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants; import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil; import org.eclipse.mylyn.internal.tasks.core.WeekDateRange; import org.eclipse.mylyn.tasks.core.IRepositoryElement; @@ -52,6 +53,12 @@ public class ScheduleTaskMenuContributor implements IDynamicSubMenuContributor { IRepositoryElement selectedElement = selectedElements.get(0); if (selectedElement instanceof ITask) { singleTaskSelection = (AbstractTask) selectedElement; + + // Tasks artifacts are not able to be scheduled; we'll simply mark them as not supported here + String artifactFlag = singleTaskSelection.getAttribute(ITasksCoreConstants.ATTRIBUTE_ARTIFACT); + if (Boolean.valueOf(artifactFlag)) { + return null; + } } } @@ -206,8 +213,7 @@ public class ScheduleTaskMenuContributor implements IDynamicSubMenuContributor { } private boolean isThisWeek(AbstractTask task) { - return task != null && task.getScheduledForDate() != null - && task.getScheduledForDate() instanceof WeekDateRange + return task != null && task.getScheduledForDate() != null && task.getScheduledForDate() instanceof WeekDateRange && task.getScheduledForDate().isBefore(TaskActivityUtil.getCurrentWeek()); } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/RepositoryElementActionGroup.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/RepositoryElementActionGroup.java index c81f8b4ff..dd54305b4 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/RepositoryElementActionGroup.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/RepositoryElementActionGroup.java @@ -265,7 +265,8 @@ public class RepositoryElementActionGroup { for (final IDynamicSubMenuContributor contributor : dynamicMenuMap.get(menuPath)) { SafeRunnable.run(new ISafeRunnable() { public void handleException(Throwable e) { - StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Menu contributor failed")); //$NON-NLS-1$ + StatusHandler + .log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Menu contributor failed")); //$NON-NLS-1$ } public void run() throws Exception { @@ -306,8 +307,8 @@ public class RepositoryElementActionGroup { if (container instanceof TaskCategory) { hasCategory = true; } - if (container instanceof UncategorizedTaskContainer - && !LocalRepositoryConnector.CONNECTOR_KIND.equals(((AbstractTask) element).getConnectorKind())) { + if (container instanceof UncategorizedTaskContainer && !LocalRepositoryConnector.CONNECTOR_KIND + .equals(((AbstractTask) element).getConnectorKind())) { hasCategory = true; } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskPropertyTester.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskPropertyTester.java index 5a5f9c775..7138d4fb4 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskPropertyTester.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskPropertyTester.java @@ -13,6 +13,7 @@ package org.eclipse.mylyn.internal.tasks.ui.util; import org.eclipse.core.expressions.PropertyTester; import org.eclipse.mylyn.internal.tasks.core.AbstractTask; +import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants; import org.eclipse.mylyn.internal.tasks.ui.actions.ClearOutgoingAction; import org.eclipse.mylyn.tasks.core.ITask; @@ -43,6 +44,8 @@ public class TaskPropertyTester extends PropertyTester { private static final String PROPERTY_LOCAL_COMPLETION_STATE = "hasLocalCompletionState"; //$NON-NLS-1$ + private static final String PROPERTY_IS_ARTIFACT = "isArtifact"; //$NON-NLS-1$ + private boolean equals(boolean value, Object expectedValue) { return new Boolean(value).equals(expectedValue); } @@ -73,6 +76,9 @@ public class TaskPropertyTester extends PropertyTester { return (task instanceof AbstractTask) && equals(((AbstractTask) task).isLocal(), expectedValue); } else if (PROPERTY_LOCAL_COMPLETION_STATE.equals(property)) { return equals(TasksUiInternal.hasLocalCompletionState(task), expectedValue); + } else if (PROPERTY_IS_ARTIFACT.equals(property)) { + String artifactFlag = task.getAttribute(ITasksCoreConstants.ATTRIBUTE_ARTIFACT); + return Boolean.valueOf(artifactFlag); } } return false; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/TaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/TaskEditor.java index 3348aefca..8f01cd634 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/TaskEditor.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/TaskEditor.java @@ -186,6 +186,10 @@ public class TaskEditor extends SharedHeaderFormEditor { OpenWithBrowserAction openWithBrowserAction; + private boolean needsScheduling = true; + + private boolean needsContext = true; + private static boolean toolBarFailureLogged; public TaskEditor() { @@ -266,8 +270,8 @@ public class TaskEditor extends SharedHeaderFormEditor { } } catch (Exception e) { if (!toolBarFailureLogged) { - StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, - "Failed to obtain busy label toolbar", e)); //$NON-NLS-1$ + StatusHandler.log( + new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Failed to obtain busy label toolbar", e)); //$NON-NLS-1$ } if (titleLabel != null) { titleLabel.dispose(); @@ -337,8 +341,8 @@ public class TaskEditor extends SharedHeaderFormEditor { return busyLabel; } catch (Exception e) { if (!toolBarFailureLogged) { - StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, - "Failed to obtain busy label toolbar", e)); //$NON-NLS-1$ + StatusHandler.log( + new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Failed to obtain busy label toolbar", e)); //$NON-NLS-1$ } busyLabel = null; } @@ -365,8 +369,8 @@ public class TaskEditor extends SharedHeaderFormEditor { // center align title text in title region Point size = titleLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); int y = (titleLabel.getParent().getSize().y - size.y) / 2; - titleLabel.setBounds(busyLabel.getLocation().x + LEFT_TOOLBAR_HEADER_TOOLBAR_PADDING + leftToolBarSize.x, - y, size.x, size.y); + titleLabel.setBounds(busyLabel.getLocation().x + LEFT_TOOLBAR_HEADER_TOOLBAR_PADDING + leftToolBarSize.x, y, + size.x, size.y); } } @@ -390,6 +394,7 @@ public class TaskEditor extends SharedHeaderFormEditor { } } } + for (Iterator<AbstractTaskEditorPageFactory> it = pageFactories.iterator(); it.hasNext();) { if (conflictingIds.contains(it.next().getId())) { it.remove(); @@ -614,7 +619,7 @@ public class TaskEditor extends SharedHeaderFormEditor { this.taskEditorInput = (TaskEditorInput) input; this.task = taskEditorInput.getTask(); - // initialize selection + // initialize selection site.getSelectionProvider().setSelection(new StructuredSelection(task)); setPartName(input.getName()); @@ -674,7 +679,7 @@ public class TaskEditor extends SharedHeaderFormEditor { /** * Refresh editor pages with new contents. - * + * * @since 3.0 */ public void refreshPages() { @@ -768,7 +773,7 @@ public class TaskEditor extends SharedHeaderFormEditor { size.x += titleSize.x + LEFT_TOOLBAR_HEADER_TOOLBAR_PADDING; size.y = Math.max(titleSize.y, size.y); - // padding between toolbar and image, ensure image is at least one pixel wide to avoid SWT error + // padding between toolbar and image, ensure image is at least one pixel wide to avoid SWT error final int padding = (size.x > 0 && !noExtraPadding) ? 10 : 1; final Rectangle imageBounds = (image != null) ? image.getBounds() : new Rectangle(0, 0, 0, 0); int tempHeight = (image != null) ? Math.max(size.y + 1, imageBounds.height) : size.y + 1; @@ -791,7 +796,7 @@ public class TaskEditor extends SharedHeaderFormEditor { }; Image newHeaderImage = descriptor.createImage(); - // directly set on busyLabel since getHeaderForm().getForm().setImage() does not update + // directly set on busyLabel since getHeaderForm().getForm().setImage() does not update // the image if a message is currently displayed busyLabel.setImage(newHeaderImage); @@ -831,6 +836,41 @@ public class TaskEditor extends SharedHeaderFormEditor { }); } + /** + * Sets whether or not this editor supports scheduling affordances. + * + * @since 3.18 + */ + public void setNeedsScheduling(boolean needsScheduling) { + this.needsScheduling = needsScheduling; + } + + /** + * @since 3.18 + * @return Returns true if this editor supports scheduling affordances, otherwise returns false. If this returns + * false, then no scheduling is available to the UI. + */ + public boolean needsScheduling() { + return this.needsScheduling; + } + + /** + * Sets whether or not this editor supports context affordances. + * + * @since 3.18 + */ + public void setNeedsContext(boolean needsContext) { + this.needsContext = needsContext; + } + + /** + * @since 3.18 Returns true if this editor supports displaying context information, otherwise returns false. If this + * returns false, no context information will be available to the UI. + */ + public boolean needsContext() { + return this.needsContext; + } + @Override public void showBusy(boolean busy) { if (editorBusyIndicator != null) { @@ -846,7 +886,7 @@ public class TaskEditor extends SharedHeaderFormEditor { if (!isHeaderFormDisposed()) { Form form = getHeaderForm().getForm().getForm(); if (form != null && !form.isDisposed()) { - // TODO consider only disabling certain actions + // TODO consider only disabling certain actions IToolBarManager toolBarManager = form.getToolBarManager(); if (toolBarManager instanceof ToolBarManager) { ToolBar control = ((ToolBarManager) toolBarManager).getControl(); @@ -969,8 +1009,11 @@ public class TaskEditor extends SharedHeaderFormEditor { toolBarManager.add(new Separator("planning")); //$NON-NLS-1$ disposeScheduleAction(); - scheduleAction = new TaskEditorScheduleAction(task); - toolBarManager.add(scheduleAction); + + if (needsScheduling()) { + scheduleAction = new TaskEditorScheduleAction(task); + toolBarManager.add(scheduleAction); + } toolBarManager.add(new GroupMarker("page")); //$NON-NLS-1$ for (IFormPage page : getPages()) { @@ -1046,7 +1089,9 @@ public class TaskEditor extends SharedHeaderFormEditor { // initialLeftToolbarSize = leftToolBarManager.getSize(); - leftToolBarManager.add(activateAction); + if (needsContext) { + leftToolBarManager.add(activateAction); + } // for (IFormPage page : getPages()) { // if (page instanceof AbstractTaskEditorPage) { @@ -1115,7 +1160,7 @@ public class TaskEditor extends SharedHeaderFormEditor { // noExtraPadding = true; // } - // fix size of toolbar on Gtk with Eclipse 3.3 + // fix size of toolbar on Gtk with Eclipse 3.3 Point size = leftToolBar.getSize(); if (size.x == 0 && size.y == 0) { size = leftToolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); @@ -1191,7 +1236,7 @@ public class TaskEditor extends SharedHeaderFormEditor { /** * Update the title of the editor. - * + * * @deprecated use {@link #updateHeaderToolBar()} instead */ @Deprecated |