diff options
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
5 files changed, 112 insertions, 21 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorOutlineNode.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorOutlineNode.java index 44489a945..405c7f18b 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorOutlineNode.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorOutlineNode.java @@ -133,11 +133,11 @@ public class TaskEditorOutlineNode { ITask task = taskList.getTask(taskData.getRepositoryUrl(), taskRelation.getTaskId()); String label; if (task != null) { - label = NLS.bind(Messages.TaskEditorOutlineNode_TaskRelation_Label, - new Object[] { taskRelation.getTaskId(), task.getSummary() }); + label = NLS.bind(Messages.TaskEditorOutlineNode_TaskRelation_Label, new Object[] { + taskRelation.getTaskId(), task.getSummary() }); } else { - label = NLS.bind(Messages.TaskEditorOutlineNode_TaskRelation_Label, - new Object[] { taskRelation.getTaskId(), Messages.TaskEditorOutlineNode_unknown_Label }); + label = NLS.bind(Messages.TaskEditorOutlineNode_TaskRelation_Label, new Object[] { + taskRelation.getTaskId(), Messages.TaskEditorOutlineNode_unknown_Label }); } TaskEditorOutlineNode childNode = new TaskEditorOutlineNode(label); @@ -231,6 +231,17 @@ public class TaskEditorOutlineNode { children.add(node); } + public TaskEditorOutlineNode getChild(String label) { + if (children != null) { + for (TaskEditorOutlineNode child : children) { + if (child.getLabel().equals(label)) { + return child; + } + } + } + return null; + } + /** * @return <code>true</code> if the given object is another node representing the same piece of data in the editor. */ diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorOutlineNodeLabelProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorOutlineNodeLabelProvider.java index 379ded4c4..0c6a52faf 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorOutlineNodeLabelProvider.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorOutlineNodeLabelProvider.java @@ -22,6 +22,7 @@ import org.eclipse.mylyn.tasks.ui.TasksUi; import org.eclipse.mylyn.tasks.ui.TasksUiImages; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.WorkbenchImages; /** @@ -82,9 +83,13 @@ public class TaskEditorOutlineNodeLabelProvider extends LabelProvider { } } else if (node.getParent() == null) { return CommonImages.getImage(TasksUiImages.TASK); + } else if (TaskEditorOutlineNode.LABEL_RELATED_TASKS.equals(node.getLabel()) + || TaskEditorOutlineNode.LABEL_ATTRIBUTES.equals(node.getLabel())) { + return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); } + return CommonImages.getImage(TasksUiImages.TASK); } - return super.getImage(element); + return null; } @Override diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/QuickOutlineDialog.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/QuickOutlineDialog.java index 0baf6ad75..bedb97704 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/QuickOutlineDialog.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/outline/QuickOutlineDialog.java @@ -20,6 +20,7 @@ import org.eclipse.jface.dialogs.PopupDialog; import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControlExtension; import org.eclipse.jface.text.IInformationControlExtension2; +import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.IOpenListener; @@ -172,6 +173,10 @@ public class QuickOutlineDialog extends PopupDialog implements IInformationContr TaskEditorOutlineNode root = TaskEditorOutlineNode.parse(taskEditorPage.getModel().getTaskData(), true); viewer.setInput(new TaskEditorOutlineModel(root)); viewer.expandAll(); + TaskEditorOutlineNode attributesNode = root.getChild(TaskEditorOutlineNode.LABEL_ATTRIBUTES); + if (attributesNode != null) { + viewer.collapseToLevel(attributesNode, AbstractTreeViewer.ALL_LEVELS); + } } finally { viewer.getControl().setRedraw(true); } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java index fffa47edf..4cdbc49f8 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java @@ -33,10 +33,14 @@ import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.SafeRunner; import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuCreator; import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.dialogs.PopupDialog; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.util.SafeRunnable; import org.eclipse.jface.viewers.ISelection; @@ -88,10 +92,10 @@ import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; import org.eclipse.mylyn.tasks.core.IRepositoryElement; import org.eclipse.mylyn.tasks.core.ITask; -import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState; import org.eclipse.mylyn.tasks.core.ITaskAttachment; import org.eclipse.mylyn.tasks.core.RepositoryStatus; import org.eclipse.mylyn.tasks.core.TaskRepository; +import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState; import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy; import org.eclipse.mylyn.tasks.core.data.TaskAttribute; import org.eclipse.mylyn.tasks.core.data.TaskData; @@ -126,6 +130,7 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.ToolItem; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorSite; import org.eclipse.ui.PlatformUI; @@ -355,6 +360,65 @@ public abstract class AbstractTaskEditorPage extends TaskFormPage implements ISe }; + private class AdditionalMenuAction extends Action { + + public AdditionalMenuAction() { + setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(PopupDialog.POPUP_IMG_MENU)); + setDisabledImageDescriptor(JFaceResources.getImageRegistry().getDescriptor( + PopupDialog.POPUP_IMG_MENU_DISABLED)); + + } + + @Override + public void runWithEvent(Event event) { + ToolItem toolItem = (ToolItem) event.widget; + Menu menu = getMenuCreator().getMenu(toolItem.getControl()); + Rectangle bounds = toolItem.getParent().getBounds(); + Point topLeft = new Point(bounds.x, bounds.y + bounds.height); + topLeft = toolItem.getControl().getShell().toDisplay(topLeft); + menu.setLocation(topLeft.x, topLeft.y); + menu.setVisible(true); + } + + } + + private class MenuCreator implements IMenuCreator { + + private MenuManager menuManager; + + private Menu menu; + + public MenuCreator() { + } + + public void dispose() { + if (menu != null) { + menu.dispose(); + menu = null; + } + if (menuManager != null) { + menuManager.dispose(); + menuManager = null; + } + } + + public Menu getMenu(Control parent) { + if (menuManager == null) { + menuManager = new MenuManager(); + initialize(menuManager); + } + return menuManager.createContextMenu(parent); + } + + public Menu getMenu(Menu parent) { + return null; + } + + protected void initialize(MenuManager menuManager) { + } + + } + private static final String ERROR_NOCONNECTIVITY = Messages.AbstractTaskEditorPage_Unable_to_submit_at_this_time; public static final String ID_PART_ACTIONS = "org.eclipse.mylyn.tasks.ui.editors.parts.actions"; //$NON-NLS-1$ @@ -962,16 +1026,26 @@ public abstract class AbstractTaskEditorPage extends TaskFormPage implements ISe if (connectorUi != null) { final String historyUrl = connectorUi.getTaskHistoryUrl(taskRepository, task); if (historyUrl != null) { - Action historyAction = new Action() { + final Action historyAction = new Action() { @Override public void run() { TasksUiUtil.openUrl(historyUrl); } }; + historyAction.setText(Messages.AbstractTaskEditorPage_History); historyAction.setImageDescriptor(TasksUiImages.TASK_REPOSITORY_HISTORY); historyAction.setToolTipText(Messages.AbstractTaskEditorPage_History); - toolBarManager.prependToGroup("open", historyAction); //$NON-NLS-1$ + if (getEditor().openWithBrowserAction != null) { + getEditor().openWithBrowserAction.setMenuCreator(new MenuCreator() { + @Override + protected void initialize(MenuManager menuManager) { + menuManager.add(historyAction); + }; + }); + } else { + toolBarManager.prependToGroup("open", historyAction); //$NON-NLS-1$ + } } } } @@ -1217,21 +1291,15 @@ public abstract class AbstractTaskEditorPage extends TaskFormPage implements ISe if (part.getControl() != null) { if (ID_PART_ACTIONS.equals(part.getPartId())) { // do not expand horizontally - GridDataFactory.fillDefaults() - .align(SWT.FILL, SWT.FILL) - .grab(false, false) - .applyTo(part.getControl()); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(false, false).applyTo( + part.getControl()); } else { if (part.getExpandVertically()) { - GridDataFactory.fillDefaults() - .align(SWT.FILL, SWT.FILL) - .grab(true, true) - .applyTo(part.getControl()); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo( + part.getControl()); } else { - GridDataFactory.fillDefaults() - .align(SWT.FILL, SWT.TOP) - .grab(true, false) - .applyTo(part.getControl()); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo( + part.getControl()); } } // for outline 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 e46484638..035f8f009 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 @@ -183,6 +183,8 @@ public class TaskEditor extends SharedHeaderFormEditor { private TaskEditorScheduleAction scheduleAction; + Action openWithBrowserAction; + private static boolean toolBarFailureLogged; public TaskEditor() { @@ -927,7 +929,7 @@ public class TaskEditor extends SharedHeaderFormEditor { final String taskUrl = TasksUiInternal.getAuthenticatedUrl(taskRepository, task); if (taskUrl != null && taskUrl.length() > 0) { - Action openWithBrowserAction = new Action() { + openWithBrowserAction = new Action() { @Override public void run() { TasksUiUtil.openWithBrowser(taskRepository, task); |