View | Details | Raw Unified | Return to bug 278102 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (+1 lines)
Lines 17-22 Link Here
17
 org.eclipse.ui.ide,
17
 org.eclipse.ui.ide,
18
 org.eclipse.ui.views,
18
 org.eclipse.ui.views,
19
 org.eclipse.ui.workbench.texteditor,
19
 org.eclipse.ui.workbench.texteditor,
20
 org.eclipse.ui.navigator,
20
 org.eclipse.mylyn.context.core;bundle-version="[3.0.0,4.0.0)",
21
 org.eclipse.mylyn.context.core;bundle-version="[3.0.0,4.0.0)",
21
 org.eclipse.mylyn.commons.core;bundle-version="[3.0.0,4.0.0)",
22
 org.eclipse.mylyn.commons.core;bundle-version="[3.0.0,4.0.0)",
22
 org.eclipse.mylyn.monitor.ui;bundle-version="[3.0.0,4.0.0)",
23
 org.eclipse.mylyn.monitor.ui;bundle-version="[3.0.0,4.0.0)",
(-)plugin.xml (-1 / +71 lines)
Lines 631-637 Link Here
631
               value="org.eclipse.mylyn.tasks.ui.views.tasks">
631
               value="org.eclipse.mylyn.tasks.ui.views.tasks">
632
         </parameter>
632
         </parameter>
633
      </key>
633
      </key>
634
  </extension>
634
     <key
635
        sequence="M1+M2+M3+."
636
        commandId="org.eclipse.mylyn.task.ui.actions.outline.related.tasks.dialog"
637
        schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
638
      </key>
639
   </extension>
635
  
640
  
636
   <extension
641
   <extension
637
         point="org.eclipse.ui.themes">
642
         point="org.eclipse.ui.themes">
Lines 828-833 Link Here
828
               style="push"
833
               style="push"
829
               toolbarPath="org.eclipse.search.searchActionSet/Search"
834
               toolbarPath="org.eclipse.search.searchActionSet/Search"
830
               tooltip="%OpenTaskAction.tooltip"/>
835
               tooltip="%OpenTaskAction.tooltip"/>
836
	     <action
837
               definitionId="org.eclipse.mylyn.task.ui.actions.outline.related.tasks.dialog"
838
               label="related Task Popup"
839
               class="org.eclipse.mylyn.internal.tasks.ui.actions.QuickOutlineTaskDataAction"
840
               menubarPath="navigate/showIn"
841
               id="org.eclipse.mylyn.task.ui.actions.outline.related.tasks.dialog">
842
         </action>
831
      </actionSet>
843
      </actionSet>
832
   </extension>
844
   </extension>
833
   
845
   
Lines 835-840 Link Here
835
      <command id="org.eclipse.mylyn.tasks.ui.command.previousTask"
847
      <command id="org.eclipse.mylyn.tasks.ui.command.previousTask"
836
               defaultHandler="org.eclipse.mylyn.internal.tasks.ui.TaskHistoryHandler"
848
               defaultHandler="org.eclipse.mylyn.internal.tasks.ui.TaskHistoryHandler"
837
               name="%command.previousTask.name"/>
849
               name="%command.previousTask.name"/>
850
      <command
851
            name="bbbb"
852
            description="aaaa"
853
            id="org.eclipse.mylyn.task.ui.actions.outline.related.tasks.dialog"
854
            categoryId="org.eclipse.mylyn.tasks.ui.commands">
855
      </command>
838
   </extension>
856
   </extension>
839
857
840
  <!-- command-based implementation of the previousTask/history dropdown, 
858
  <!-- command-based implementation of the previousTask/history dropdown, 
Lines 1903-1906 Link Here
1903
          </iterate>
1921
          </iterate>
1904
		</definition>       
1922
		</definition>       
1905
    </extension>
1923
    </extension>
1924
1925
<!--  TaskData Quick Outline   -->  
1926
1927
   <extension
1928
         point="org.eclipse.ui.navigator.viewer">
1929
      <viewer viewerId="org.eclipse.mylyn.internal.tasks.ui.taskdata.quick"/>
1930
      <viewerContentBinding viewerId="org.eclipse.mylyn.internal.tasks.ui.taskdata.quick">
1931
         <includes>
1932
            <contentExtension pattern="org.eclipse.mylyn.internal.tasks.ui.CommonViewerTaskDataContentProvider"/>
1933
            <contentExtension pattern="org.eclipse.ui.navigator.resources.filters.*"/> 
1934
         </includes>
1935
      </viewerContentBinding>
1936
      <viewerActionBinding viewerId="org.eclipse.mylyn.internal.tasks.ui.taskdata.quick">
1937
         <includes>
1938
            <actionExtension pattern="org.eclipse.ui.navigator.resources.*"/>
1939
         </includes>
1940
      </viewerActionBinding>
1941
   </extension>
1942
   <extension
1943
         point="org.eclipse.ui.navigator.navigatorContent">
1944
      <navigatorContent
1945
            activeByDefault="true"
1946
            contentProvider="org.eclipse.mylyn.internal.tasks.ui.CommonViewerTaskDataContentProvider"
1947
            id="org.eclipse.mylyn.internal.tasks.ui.navigatorContent1"
1948
            labelProvider="org.eclipse.mylyn.internal.tasks.ui.CommonViewerTaskDataLabelProvider"
1949
            name="NR Content" >
1950
         <triggerPoints>
1951
            <or>
1952
               <instanceof value="org.eclipse.mylyn.tasks.core.data.TaskData"/>
1953
            </or>
1954
         </triggerPoints>
1955
         <possibleChildren>
1956
            <or>
1957
               <instanceof value="org.eclipse.mylyn.tasks.core.data.TaskAttribute"/>
1958
                <instanceof value="org.eclipse.mylyn.tasks.core.data.TaskData"/>
1959
            </or>
1960
         </possibleChildren>
1961
      </navigatorContent>
1962
   </extension>
1963
1964
   <extension
1965
         point="org.eclipse.ui.navigator.viewer">
1966
      <viewerContentBinding viewerId="org.eclipse.mylyn.internal.tasks.ui.taskdata.quick">
1967
         <includes>
1968
            <contentExtension
1969
                  isRoot="false"
1970
                  pattern="org.eclipse.mylyn.internal.tasks.ui.navigatorContent1"/>
1971
         </includes>
1972
      </viewerContentBinding>
1973
   </extension>
1974
   
1975
    
1906
</plugin>
1976
</plugin>
(-)src/org/eclipse/mylyn/internal/tasks/ui/CommonViewerTaskDataContentProvider.java (+106 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Frank Becker and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Frank Becker - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.tasks.ui;
13
14
import org.eclipse.jface.viewers.ITreeContentProvider;
15
import org.eclipse.jface.viewers.Viewer;
16
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorOutlineNode;
17
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
18
import org.eclipse.mylyn.tasks.core.data.TaskData;
19
20
public class CommonViewerTaskDataContentProvider implements ITreeContentProvider {
21
22
	private boolean showTaskAttributes;
23
24
	public boolean isShowTaskAttributes() {
25
		return showTaskAttributes;
26
	}
27
28
	public void setShowTaskAttributes(boolean showTaskAttributes) {
29
		this.showTaskAttributes = showTaskAttributes;
30
	}
31
32
	public Object[] getChildren(Object parentElement) {
33
		Object[] result = {};
34
		if (parentElement instanceof TaskData) {
35
			TaskData node = (TaskData) parentElement;
36
			result = node.getRoot().getAttributes().values().toArray();
37
		} else if (parentElement instanceof TaskAttribute) {
38
			TaskAttribute node = (TaskAttribute) parentElement;
39
			result = node.getAttributes().values().toArray();
40
		} else if (parentElement instanceof TaskEditorOutlineNode) {
41
			result = ((TaskEditorOutlineNode) parentElement).getChildren();
42
		}
43
		return result;
44
	}
45
46
	public Object[] getElements(Object inputElement) {
47
		boolean b = TasksUiPlugin.getDefault()
48
				.getPreferenceStore()
49
				.getBoolean(ITasksUiPreferenceConstants.QUICKOUTLINE_TASKMODE_TASKDATA);
50
51
		if (inputElement instanceof TaskData) {
52
			if (b) {
53
				return getChildren(inputElement);
54
			} else {
55
				TaskEditorOutlineNode node = TaskEditorOutlineNode.parse((TaskData) inputElement);
56
				return node.getChildren();
57
			}
58
		}
59
		return null;
60
	}
61
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
64
	 */
65
	public Object getParent(Object element) {
66
		if (element instanceof TaskData) {
67
68
			return null;
69
		} else if (element instanceof TaskAttribute) {
70
			TaskAttribute node = (TaskAttribute) element;
71
			return node.getParentAttribute();
72
		} else if (element instanceof TaskEditorOutlineNode) {
73
			return ((TaskEditorOutlineNode) element).getParent();
74
		}
75
		return null;
76
	}
77
78
	/* (non-Javadoc)
79
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
80
	 */
81
	public boolean hasChildren(Object element) {
82
		if (element instanceof TaskData) {
83
			TaskData node = (TaskData) element;
84
			return node.getRoot().getAttributes().size() > 0;
85
		} else if (element instanceof TaskAttribute) {
86
			TaskAttribute node = (TaskAttribute) element;
87
			return node.getAttributes().size() > 0;
88
		} else if (element instanceof TaskEditorOutlineNode) {
89
			return ((TaskEditorOutlineNode) element).getChildren().length > 0;
90
		}
91
		return false;
92
	}
93
94
	/* (non-Javadoc)
95
	 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
96
	 */
97
	public void dispose() {
98
	}
99
100
	/* (non-Javadoc)
101
	 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
102
	 */
103
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
104
	}
105
106
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/CommonViewerTaskDataFilter.java (+51 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Frank Becker and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Frank Becker - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.tasks.ui;
13
14
import org.eclipse.jface.viewers.ILabelProvider;
15
import org.eclipse.jface.viewers.TreeViewer;
16
import org.eclipse.jface.viewers.Viewer;
17
import org.eclipse.jface.viewers.ViewerFilter;
18
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
19
import org.eclipse.ui.internal.misc.StringMatcher;
20
21
public class CommonViewerTaskDataFilter extends ViewerFilter {
22
23
	private StringMatcher stringMatcher;
24
25
	@Override
26
	public boolean select(Viewer viewer, Object parentElement, Object element) {
27
		if (element instanceof TaskAttribute) {
28
			TaskAttribute attribute = (TaskAttribute) element;
29
			String metaType = attribute.getMetaData().getType();
30
			if (TaskAttribute.TYPE_OPERATION.equals(metaType)) {
31
				return false;
32
			}
33
		}
34
		if ((stringMatcher == null) || ((viewer instanceof TreeViewer) == false)) {
35
			return true;
36
		}
37
		TreeViewer treeViewer = (TreeViewer) viewer;
38
		// Match the pattern against the label of the given element
39
		String matchName = ((ILabelProvider) treeViewer.getLabelProvider()).getText(element);
40
		// Element passes the filter if it matches the pattern
41
		if ((matchName != null) && stringMatcher.match(matchName)) {
42
			return true;
43
		}
44
		return false;
45
	}
46
47
	public void setStringMatcher(StringMatcher stringMatcher) {
48
		this.stringMatcher = stringMatcher;
49
	}
50
51
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/CommonViewerTaskDataLabelProvider.java (+95 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Frank Becker and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Frank Becker - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.tasks.ui;
13
14
import org.eclipse.jface.viewers.ILabelProviderListener;
15
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorOutlineNode;
16
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorOutlineNodeLabelProvider;
17
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
18
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData;
19
import org.eclipse.mylyn.tasks.core.data.TaskData;
20
import org.eclipse.swt.graphics.Image;
21
22
public class CommonViewerTaskDataLabelProvider extends TaskEditorOutlineNodeLabelProvider {
23
	@Override
24
	public String getText(Object element) {
25
		String result = ""; //$NON-NLS-1$
26
		if (element instanceof TaskData) {
27
			TaskData node = (TaskData) element;
28
			result = node.getTaskId();
29
		} else if (element instanceof TaskAttribute) {
30
			TaskAttribute node = (TaskAttribute) element;
31
			TaskAttributeMetaData meta = node.getMetaData();
32
			if (meta != null) {
33
				String lable = meta.getLabel();
34
				if (lable != null) {
35
					result = lable + " (" + node.getId() + ")";
36
				} else {
37
					if (TaskAttribute.TYPE_ATTACHMENT.equals(meta.getType())) {
38
						result = "Attachment: " + node.getValue(); //$NON-NLS-1$
39
					} else if (TaskAttribute.TYPE_COMMENT.equals(meta.getType())) {
40
						result = "Comment: " + node.getValue(); //$NON-NLS-1$
41
					} else {
42
						result = "<" + node.getId() + ">"; //$NON-NLS-1$//$NON-NLS-2$
43
					}
44
				}
45
			}
46
		} else if (element instanceof TaskEditorOutlineNode) {
47
			result = super.getText(element);
48
		} else if (element instanceof String) {
49
			result = (String) element;
50
		}
51
		return result;
52
	}
53
54
	/* (non-Javadoc)
55
	 * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
56
	 */
57
	@Override
58
	public Image getImage(Object element) {
59
		if (element instanceof TaskEditorOutlineNode) {
60
			return super.getImage(element);
61
		} else {
62
			return null;
63
		}
64
	}
65
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
68
	 */
69
	@Override
70
	public void addListener(ILabelProviderListener listener) {
71
	}
72
73
	/* (non-Javadoc)
74
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
75
	 */
76
	@Override
77
	public void dispose() {
78
	}
79
80
	/* (non-Javadoc)
81
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
82
	 */
83
	@Override
84
	public boolean isLabelProperty(Object element, String property) {
85
		return false;
86
	}
87
88
	/* (non-Javadoc)
89
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
90
	 */
91
	@Override
92
	public void removeListener(ILabelProviderListener listener) {
93
	}
94
95
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/CommonViewerTaskDataOpenListener.java (+162 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Frank Becker and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Frank Becker - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.tasks.ui;
13
14
import org.eclipse.jface.viewers.DoubleClickEvent;
15
import org.eclipse.jface.viewers.IDoubleClickListener;
16
import org.eclipse.jface.viewers.IOpenListener;
17
import org.eclipse.jface.viewers.OpenEvent;
18
import org.eclipse.jface.viewers.StructuredSelection;
19
import org.eclipse.jface.viewers.Viewer;
20
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonFormUtil;
21
import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
22
import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil;
23
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorAttributePart;
24
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorOutlineNode;
25
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
26
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
27
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
28
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
29
import org.eclipse.swt.events.MouseEvent;
30
import org.eclipse.swt.events.MouseListener;
31
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Control;
33
import org.eclipse.swt.widgets.TableItem;
34
import org.eclipse.swt.widgets.Tree;
35
import org.eclipse.ui.IEditorPart;
36
import org.eclipse.ui.PlatformUI;
37
import org.eclipse.ui.forms.IManagedForm;
38
import org.eclipse.ui.forms.editor.IFormPage;
39
import org.eclipse.ui.forms.widgets.ExpandableComposite;
40
import org.eclipse.ui.forms.widgets.ScrolledForm;
41
import org.eclipse.ui.forms.widgets.Section;
42
43
public class CommonViewerTaskDataOpenListener implements IOpenListener, IDoubleClickListener, MouseListener {
44
45
	private final Viewer viewer;
46
47
	public CommonViewerTaskDataOpenListener(Viewer viewer) {
48
		this.viewer = viewer;
49
	}
50
51
	public void mouseDoubleClick(MouseEvent e) {
52
		setSelection(e);
53
	}
54
55
	public void mouseDown(MouseEvent e) {
56
		setSelection(e);
57
	}
58
59
	public void mouseUp(MouseEvent e) {
60
		// ignore
61
62
	}
63
64
	public void doubleClick(DoubleClickEvent event) {
65
		open(null);
66
	}
67
68
	@SuppressWarnings("null")
69
	public void open(OpenEvent event) {
70
		StructuredSelection selection = (StructuredSelection) viewer.getSelection();
71
		Object object = selection.getFirstElement();
72
		IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
73
		AbstractTaskEditorPage taskEditorPage = null;
74
		if (editorPart instanceof TaskEditor) {
75
			TaskEditor taskEditor = (TaskEditor) editorPart;
76
			IFormPage formPage = taskEditor.getActivePageInstance();
77
			if (formPage instanceof AbstractTaskEditorPage) {
78
				taskEditorPage = (AbstractTaskEditorPage) formPage;
79
			}
80
		}
81
		if (object instanceof TaskAttribute) {
82
			TaskAttribute attribute = (TaskAttribute) object;
83
			if (TaskAttribute.TYPE_ATTACHMENT.equals(attribute.getMetaData().getType())) {
84
				AbstractTaskEditorPart actionPart = taskEditorPage.getPart(AbstractTaskEditorPage.ID_PART_ATTACHMENTS);
85
				if (actionPart != null && actionPart.getControl() instanceof ExpandableComposite) {
86
					CommonFormUtil.setExpanded((ExpandableComposite) actionPart.getControl(), true);
87
					if (actionPart.getControl() instanceof Section) {
88
						Control client = actionPart.getControl();
89
						if (client instanceof Composite) {
90
							for (Control control : ((Composite) client).getChildren()) {
91
								if (control instanceof Composite) {
92
									for (Control control1 : ((Composite) control).getChildren()) {
93
										if (control1 instanceof org.eclipse.swt.widgets.Table) {
94
											org.eclipse.swt.widgets.Table attachmentTable = ((org.eclipse.swt.widgets.Table) control1);
95
											TableItem[] attachments = attachmentTable.getItems();
96
											int index = 0;
97
											for (TableItem attachment : attachments) {
98
												TaskAttachment attachmentData = ((TaskAttachment) attachment.getData());
99
												if (attachmentData.getTaskAttribute() == attribute) {
100
													attachmentTable.deselectAll();
101
													attachmentTable.select(index);
102
													IManagedForm mform = actionPart.getManagedForm();
103
													ScrolledForm form = mform.getForm();
104
//													EditorUtil.focusOn(form, attachmentTable, 30);
105
													taskEditorPage.focusOn(attachmentTable);
106
													break;
107
												}
108
												index++;
109
											}
110
										}
111
									}
112
								}
113
							}
114
						}
115
					}
116
				}
117
			} else {
118
				if (TaskAttribute.TYPE_COMMENT.equals(attribute.getMetaData().getType())) {
119
					AbstractTaskEditorPart actionPart = taskEditorPage.getPart(AbstractTaskEditorPage.ID_PART_COMMENTS);
120
					if (actionPart != null && actionPart.getControl() instanceof ExpandableComposite) {
121
						CommonFormUtil.setExpanded((ExpandableComposite) actionPart.getControl(), true);
122
						if (actionPart.getControl() instanceof Section) {
123
							Control client = ((Section) actionPart.getControl()).getClient();
124
							if (client instanceof Composite) {
125
								for (Control control : ((Composite) client).getChildren()) {
126
									// toggle subsections
127
									if (control instanceof Section) {
128
										CommonFormUtil.setExpanded((Section) control, true);
129
									}
130
								}
131
							}
132
						}
133
					}
134
				} else {
135
					TaskEditorAttributePart actionPart = (TaskEditorAttributePart) taskEditorPage.getPart(AbstractTaskEditorPage.ID_PART_ATTRIBUTES);
136
					Section section = actionPart.getSection();
137
					boolean expanded = section.isExpanded();
138
					if (!expanded && actionPart != null && actionPart.getControl() instanceof ExpandableComposite) {
139
						CommonFormUtil.setExpanded((ExpandableComposite) actionPart.getControl(), true);
140
						if (!expanded) {
141
							CommonFormUtil.setExpanded((ExpandableComposite) actionPart.getControl(), false);
142
						}
143
					}
144
				}
145
				taskEditorPage.reveal(attribute.getId());
146
			}
147
		} else if (object instanceof TaskEditorOutlineNode) {
148
			EditorUtil.focusFromStructuredSelection(object, taskEditorPage);
149
		}
150
	}
151
152
	private void setSelection(MouseEvent event) {
153
		try {
154
			Object selection = ((Tree) event.getSource()).getSelection()[0].getData();
155
			viewer.setSelection(new StructuredSelection(selection));
156
			open(null);
157
		} catch (Exception e) {
158
			// ignore
159
		}
160
	}
161
162
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java (+2 lines)
Lines 87-90 Link Here
87
	public static final String PREF_DATA_DIR = "org.eclipse.mylyn.data.dir"; //$NON-NLS-1$
87
	public static final String PREF_DATA_DIR = "org.eclipse.mylyn.data.dir"; //$NON-NLS-1$
88
88
89
	public static final String DEFAULT_ATTACHMENTS_DIRECTORY = "org.eclipse.mylyn.tasks.ui.attachments.defaultDirectory"; //$NON-NLS-1$
89
	public static final String DEFAULT_ATTACHMENTS_DIRECTORY = "org.eclipse.mylyn.tasks.ui.attachments.defaultDirectory"; //$NON-NLS-1$
90
91
	public static final String QUICKOUTLINE_TASKMODE_TASKDATA = "org.eclipse.mylyn.tasks.ui.quick.outline.taskmode.taskdata"; //$NON-NLS-1$
90
}
92
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java (-15 / +22 lines)
Lines 69-76 Link Here
69
import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
69
import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
70
import org.eclipse.mylyn.internal.tasks.core.TaskList;
70
import org.eclipse.mylyn.internal.tasks.core.TaskList;
71
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryDelta;
71
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryDelta;
72
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
73
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryDelta.Type;
72
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryDelta.Type;
73
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
74
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager;
74
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager;
75
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataStore;
75
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataStore;
76
import org.eclipse.mylyn.internal.tasks.core.externalization.ExternalizationManager;
76
import org.eclipse.mylyn.internal.tasks.core.externalization.ExternalizationManager;
Lines 85-96 Link Here
85
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
85
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
86
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
86
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
87
import org.eclipse.mylyn.tasks.core.ITask;
87
import org.eclipse.mylyn.tasks.core.ITask;
88
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
88
import org.eclipse.mylyn.tasks.core.ITaskActivationListener;
89
import org.eclipse.mylyn.tasks.core.ITaskActivationListener;
89
import org.eclipse.mylyn.tasks.core.ITaskContainer;
90
import org.eclipse.mylyn.tasks.core.ITaskContainer;
90
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
91
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
91
import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
92
import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
92
import org.eclipse.mylyn.tasks.core.TaskRepository;
93
import org.eclipse.mylyn.tasks.core.TaskRepository;
93
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
94
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
94
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
95
import org.eclipse.mylyn.tasks.ui.AbstractTaskRepositoryLinkProvider;
95
import org.eclipse.mylyn.tasks.ui.AbstractTaskRepositoryLinkProvider;
96
import org.eclipse.mylyn.tasks.ui.TasksUi;
96
import org.eclipse.mylyn.tasks.ui.TasksUi;
Lines 466-476 Link Here
466
			return;
466
			return;
467
		}
467
		}
468
468
469
		boolean enabled = TasksUiPlugin.getDefault().getPreferenceStore().getBoolean(
469
		boolean enabled = TasksUiPlugin.getDefault()
470
				ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED);
470
				.getPreferenceStore()
471
				.getBoolean(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED);
471
		if (enabled) {
472
		if (enabled) {
472
			long interval = TasksUiPlugin.getDefault().getPreferenceStore().getLong(
473
			long interval = TasksUiPlugin.getDefault()
473
					ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS);
474
					.getPreferenceStore()
475
					.getLong(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS);
474
			if (initial) {
476
			if (initial) {
475
				synchronizationScheduler.setInterval(DELAY_QUERY_REFRESH_ON_STARTUP, interval);
477
				synchronizationScheduler.setInterval(DELAY_QUERY_REFRESH_ON_STARTUP, interval);
476
			} else {
478
			} else {
Lines 827-841 Link Here
827
			}
829
			}
828
		}
830
		}
829
831
830
		if (!MonitorUiPlugin.getDefault().getPreferenceStore().getBoolean(
832
		if (!MonitorUiPlugin.getDefault()
831
				MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED + ".checked")) { //$NON-NLS-1$
833
				.getPreferenceStore()
834
				.getBoolean(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED + ".checked")) { //$NON-NLS-1$
832
			if (!taskActivityMonitor.getActivationHistory().isEmpty()) {
835
			if (!taskActivityMonitor.getActivationHistory().isEmpty()) {
833
				// tasks have been active before so fore preference enabled
836
				// tasks have been active before so fore preference enabled
834
				MonitorUiPlugin.getDefault().getPreferenceStore().setValue(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED,
837
				MonitorUiPlugin.getDefault()
835
						true);
838
						.getPreferenceStore()
836
			}
839
						.setValue(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED, true);
837
			MonitorUiPlugin.getDefault().getPreferenceStore().setValue(
840
			}
838
					MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED + ".checked", true); //$NON-NLS-1$
841
			MonitorUiPlugin.getDefault()
842
					.getPreferenceStore()
843
					.setValue(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED + ".checked", true); //$NON-NLS-1$
839
			MonitorUiPlugin.getDefault().savePluginPreferences();
844
			MonitorUiPlugin.getDefault().savePluginPreferences();
840
		}
845
		}
841
846
Lines 894-899 Link Here
894
899
895
		store.setDefault(ITasksUiPreferenceConstants.AUTO_EXPAND_TASK_LIST, true);
900
		store.setDefault(ITasksUiPreferenceConstants.AUTO_EXPAND_TASK_LIST, true);
896
		store.setDefault(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED, true);
901
		store.setDefault(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED, true);
902
		store.setDefault(ITasksUiPreferenceConstants.QUICKOUTLINE_TASKMODE_TASKDATA, false);
897
	}
903
	}
898
904
899
	public static TaskActivityManager getTaskActivityManager() {
905
	public static TaskActivityManager getTaskActivityManager() {
Lines 912-919 Link Here
912
	}
918
	}
913
919
914
	public boolean groupSubtasks(ITaskContainer element) {
920
	public boolean groupSubtasks(ITaskContainer element) {
915
		boolean groupSubtasks = TasksUiPlugin.getDefault().getPreferenceStore().getBoolean(
921
		boolean groupSubtasks = TasksUiPlugin.getDefault()
916
				ITasksUiPreferenceConstants.GROUP_SUBTASKS);
922
				.getPreferenceStore()
923
				.getBoolean(ITasksUiPreferenceConstants.GROUP_SUBTASKS);
917
924
918
		if (element instanceof ITask) {
925
		if (element instanceof ITask) {
919
			AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(((ITask) element).getConnectorKind());
926
			AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(((ITask) element).getConnectorKind());
(-)src/org/eclipse/mylyn/internal/tasks/ui/actions/QuickOutlineTaskDataAction.java (+57 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Frank Becker and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Frank Becker - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.tasks.ui.actions;
13
14
import org.eclipse.jface.action.IAction;
15
import org.eclipse.jface.viewers.ISelection;
16
import org.eclipse.jface.viewers.StructuredSelection;
17
import org.eclipse.mylyn.internal.tasks.core.TaskTask;
18
import org.eclipse.mylyn.internal.tasks.ui.views.QuickOutlineTaskDataDialog;
19
import org.eclipse.swt.widgets.Shell;
20
import org.eclipse.ui.IWorkbenchWindow;
21
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
22
import org.eclipse.ui.PlatformUI;
23
24
public class QuickOutlineTaskDataAction implements IWorkbenchWindowActionDelegate {
25
26
	private QuickOutlineTaskDataDialog inplaceDialog;
27
28
	private TaskTask sel;
29
30
	public void run(IAction action) {
31
		Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
32
		inplaceDialog = new QuickOutlineTaskDataDialog(parent);
33
		inplaceDialog.open();
34
		inplaceDialog.setFocus();
35
	}
36
37
	public void selectionChanged(IAction action, ISelection selection) {
38
		// ignore
39
		if (selection instanceof StructuredSelection) {
40
			StructuredSelection a = (StructuredSelection) selection;
41
			if (a.size() > 0) {
42
				if (a.getFirstElement() instanceof TaskTask) {
43
					sel = (TaskTask) a.getFirstElement();
44
				}
45
			}
46
		}
47
	}
48
49
	public void dispose() {
50
		inplaceDialog = null;
51
	}
52
53
	public void init(IWorkbenchWindow window) {
54
		// ignore
55
	}
56
57
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/EditorUtil.java (-5 / +75 lines)
Lines 25-30 Link Here
25
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonTextSupport;
25
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonTextSupport;
26
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonThemes;
26
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonThemes;
27
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonUiUtil;
27
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonUiUtil;
28
import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
28
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
29
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
29
import org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizardDialog;
30
import org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizardDialog;
30
import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.Mode;
31
import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.Mode;
Lines 32-37 Link Here
32
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
33
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
33
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
34
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
34
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
35
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
36
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
35
import org.eclipse.mylyn.tasks.ui.editors.TaskFormPage;
37
import org.eclipse.mylyn.tasks.ui.editors.TaskFormPage;
36
import org.eclipse.swt.SWT;
38
import org.eclipse.swt.SWT;
37
import org.eclipse.swt.custom.CCombo;
39
import org.eclipse.swt.custom.CCombo;
Lines 58-63 Link Here
58
import org.eclipse.swt.widgets.Menu;
60
import org.eclipse.swt.widgets.Menu;
59
import org.eclipse.swt.widgets.ScrollBar;
61
import org.eclipse.swt.widgets.ScrollBar;
60
import org.eclipse.swt.widgets.Scrollable;
62
import org.eclipse.swt.widgets.Scrollable;
63
import org.eclipse.swt.widgets.TableItem;
61
import org.eclipse.swt.widgets.Widget;
64
import org.eclipse.swt.widgets.Widget;
62
import org.eclipse.ui.PlatformUI;
65
import org.eclipse.ui.PlatformUI;
63
import org.eclipse.ui.actions.ActionFactory;
66
import org.eclipse.ui.actions.ActionFactory;
Lines 153-159 Link Here
153
	 * @param control
156
	 * @param control
154
	 *            The StyledText to scroll to
157
	 *            The StyledText to scroll to
155
	 */
158
	 */
156
	private static void focusOn(ScrolledForm form, Control control) {
159
	public static void focusOn(ScrolledForm form, Control control) {
157
		int pos = 0;
160
		int pos = 0;
158
		control.setEnabled(true);
161
		control.setEnabled(true);
159
		control.setFocus();
162
		control.setFocus();
Lines 405-412 Link Here
405
		} else {
408
		} else {
406
			roundedBorder.setLayout(GridLayoutFactory.fillDefaults().margins(0, 6).create());
409
			roundedBorder.setLayout(GridLayoutFactory.fillDefaults().margins(0, 6).create());
407
		}
410
		}
408
		GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).hint(EditorUtil.MAXIMUM_WIDTH, SWT.DEFAULT).grab(
411
		GridDataFactory.fillDefaults()
409
				true, false).applyTo(roundedBorder);
412
				.align(SWT.FILL, SWT.BEGINNING)
413
				.hint(EditorUtil.MAXIMUM_WIDTH, SWT.DEFAULT)
414
				.grab(true, false)
415
				.applyTo(roundedBorder);
410
		return roundedBorder;
416
		return roundedBorder;
411
	}
417
	}
412
418
Lines 432-439 Link Here
432
				textFont.dispose();
438
				textFont.dispose();
433
			}
439
			}
434
		});
440
		});
435
		Color color = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().get(
441
		Color color = PlatformUI.getWorkbench()
436
				CommonThemes.COLOR_COMPLETED);
442
				.getThemeManager()
443
				.getCurrentTheme()
444
				.getColorRegistry()
445
				.get(CommonThemes.COLOR_COMPLETED);
437
		text.setForeground(color);
446
		text.setForeground(color);
438
		return textFont;
447
		return textFont;
439
	}
448
	}
Lines 590-593 Link Here
590
		}
599
		}
591
	}
600
	}
592
601
602
	public static void focusFromStructuredSelection(Object select, AbstractTaskEditorPage taskEditorPage) {
603
		if (select instanceof TaskEditorOutlineNode) {
604
			TaskEditorOutlineNode node = (TaskEditorOutlineNode) select;
605
			TaskAttribute attribute = node.getData();
606
			if (attribute != null) {
607
				if (TaskAttribute.TYPE_COMMENT.equals(attribute.getMetaData().getType())) {
608
					AbstractTaskEditorPart actionPart = taskEditorPage.getPart(AbstractTaskEditorPage.ID_PART_COMMENTS);
609
					if (actionPart != null && actionPart.getControl() instanceof ExpandableComposite) {
610
						CommonFormUtil.setExpanded((ExpandableComposite) actionPart.getControl(), true);
611
						if (actionPart.getControl() instanceof Section) {
612
							Control client = ((Section) actionPart.getControl()).getClient();
613
							if (client instanceof Composite) {
614
								for (Control control : ((Composite) client).getChildren()) {
615
									// toggle subsections
616
									if (control instanceof Section) {
617
										CommonFormUtil.setExpanded((Section) control, true);
618
									}
619
								}
620
							}
621
						}
622
					}
623
					taskEditorPage.reveal(attribute.getId());
624
				} else if (TaskAttribute.TYPE_ATTACHMENT.equals(attribute.getMetaData().getType())) {
625
					AbstractTaskEditorPart actionPart = taskEditorPage.getPart(AbstractTaskEditorPage.ID_PART_ATTACHMENTS);
626
					if (actionPart != null && actionPart.getControl() instanceof ExpandableComposite) {
627
						CommonFormUtil.setExpanded((ExpandableComposite) actionPart.getControl(), true);
628
						if (actionPart.getControl() instanceof Section) {
629
							Control client = actionPart.getControl();
630
							if (client instanceof Composite) {
631
								for (Control control : ((Composite) client).getChildren()) {
632
									if (control instanceof Composite) {
633
										for (Control control1 : ((Composite) control).getChildren()) {
634
											if (control1 instanceof org.eclipse.swt.widgets.Table) {
635
												org.eclipse.swt.widgets.Table attachmentTable = ((org.eclipse.swt.widgets.Table) control1);
636
												TableItem[] attachments = attachmentTable.getItems();
637
												int index = 0;
638
												for (TableItem attachment : attachments) {
639
													TaskAttachment attachmentData = ((TaskAttachment) attachment.getData());
640
													if (attachmentData.getTaskAttribute() == attribute) {
641
														attachmentTable.deselectAll();
642
														attachmentTable.select(index);
643
														IManagedForm mform = actionPart.getManagedForm();
644
														ScrolledForm form = mform.getForm();
645
														EditorUtil.focusOn(form, attachmentTable);
646
														break;
647
													}
648
													index++;
649
												}
650
											}
651
										}
652
									}
653
								}
654
							}
655
						}
656
					}
657
				}
658
			} else {
659
				taskEditorPage.reveal(node.getLabel());
660
			}
661
		}
662
	}
593
}
663
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java (+2 lines)
Lines 151-156 Link Here
151
151
152
	public static String TaskEditorNewCommentPart_New_Comment;
152
	public static String TaskEditorNewCommentPart_New_Comment;
153
153
154
	public static String TaskEditorOutlineNode_Attachments;
155
154
	public static String TaskEditorOutlineNode_Comments;
156
	public static String TaskEditorOutlineNode_Comments;
155
157
156
	public static String TaskEditorOutlineNode_Description;
158
	public static String TaskEditorOutlineNode_Description;
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorOutlineNode.java (+43 lines)
Lines 17-23 Link Here
17
17
18
import org.eclipse.core.runtime.Assert;
18
import org.eclipse.core.runtime.Assert;
19
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
19
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
20
import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
20
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
21
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
22
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
21
import org.eclipse.mylyn.tasks.core.ITaskComment;
23
import org.eclipse.mylyn.tasks.core.ITaskComment;
22
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
24
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
23
import org.eclipse.mylyn.tasks.core.data.TaskData;
25
import org.eclipse.mylyn.tasks.core.data.TaskData;
Lines 35-40 Link Here
35
37
36
	public static final String LABEL_NEW_COMMENT = Messages.TaskEditorOutlineNode_New_Comment;
38
	public static final String LABEL_NEW_COMMENT = Messages.TaskEditorOutlineNode_New_Comment;
37
39
40
	public static final String LABEL_ATTACHMENTS = Messages.TaskEditorOutlineNode_Attachments;
41
38
	private static TaskEditorOutlineNode createNode(TaskData taskData, String attributeId, String label) {
42
	private static TaskEditorOutlineNode createNode(TaskData taskData, String attributeId, String label) {
39
		TaskAttribute taskAttribute = taskData.getRoot().getMappedAttribute(attributeId);
43
		TaskAttribute taskAttribute = taskData.getRoot().getMappedAttribute(attributeId);
40
		if (taskAttribute != null) {
44
		if (taskAttribute != null) {
Lines 69-74 Link Here
69
				node.setTaskComment(taskComment);
73
				node.setTaskComment(taskComment);
70
				return node;
74
				return node;
71
			}
75
			}
76
		} else if (TaskAttribute.TYPE_ATTACHMENT.equals(type)) {
77
			ITaskAttachment taskAttachment = TasksUiPlugin.getRepositoryModel().createTaskAttachment(taskAttribute);
78
			if (taskAttachment != null) {
79
				taskAttribute.getTaskData().getAttributeMapper().updateTaskAttachment(taskAttachment, taskAttribute);
80
				StringBuilder sb = new StringBuilder();
81
				sb.append(taskAttribute.getTaskData().getAttributeMapper().getValueLabel(taskAttribute));
82
				sb.append(": "); //$NON-NLS-1$
83
				if (AttachmentUtil.isContext(taskAttachment)) {
84
					sb.append(Messages.AttachmentTableLabelProvider_Task_Context);
85
				} else if (taskAttachment.isPatch()) {
86
					sb.append(Messages.AttachmentTableLabelProvider_Patch);
87
				} else {
88
					sb.append(taskAttachment.getFileName());
89
				}
90
				TaskEditorOutlineNode node = new TaskEditorOutlineNode(sb.toString(), taskAttribute);
91
				node.setTaskAttachment(taskAttachment);
92
				return node;
93
			}
72
		} else {
94
		} else {
73
			String label = taskAttribute.getTaskData().getAttributeMapper().getValueLabel(taskAttribute);
95
			String label = taskAttribute.getTaskData().getAttributeMapper().getValueLabel(taskAttribute);
74
			return new TaskEditorOutlineNode(label, taskAttribute);
96
			return new TaskEditorOutlineNode(label, taskAttribute);
Lines 82-87 Link Here
82
			rootNode = new TaskEditorOutlineNode(Messages.TaskEditorOutlineNode_Task_ + taskData.getTaskId());
104
			rootNode = new TaskEditorOutlineNode(Messages.TaskEditorOutlineNode_Task_ + taskData.getTaskId());
83
		}
105
		}
84
		addNode(rootNode, taskData, TaskAttribute.DESCRIPTION, LABEL_DESCRIPTION);
106
		addNode(rootNode, taskData, TaskAttribute.DESCRIPTION, LABEL_DESCRIPTION);
107
		List<TaskAttribute> attachments = taskData.getAttributeMapper().getAttributesByType(taskData,
108
				TaskAttribute.TYPE_ATTACHMENT);
109
		if (attachments.size() > 0) {
110
			TaskEditorOutlineNode attachmentNode = new TaskEditorOutlineNode(LABEL_ATTACHMENTS);
111
			rootNode.addChild(attachmentNode);
112
			for (TaskAttribute attachmentAttribute : attachments) {
113
				TaskEditorOutlineNode node = createNode(attachmentAttribute);
114
				if (node != null) {
115
					attachmentNode.addChild(node);
116
				}
117
			}
118
		}
85
		List<TaskAttribute> comments = taskData.getAttributeMapper().getAttributesByType(taskData,
119
		List<TaskAttribute> comments = taskData.getAttributeMapper().getAttributesByType(taskData,
86
				TaskAttribute.TYPE_COMMENT);
120
				TaskAttribute.TYPE_COMMENT);
87
		if (comments.size() > 0) {
121
		if (comments.size() > 0) {
Lines 118-123 Link Here
118
152
119
	private ITaskComment taskComment;
153
	private ITaskComment taskComment;
120
154
155
	private ITaskAttachment taskAttachment;
156
121
	public TaskEditorOutlineNode(String label) {
157
	public TaskEditorOutlineNode(String label) {
122
		this(label, null);
158
		this(label, null);
123
	}
159
	}
Lines 183-186 Link Here
183
		return getLabel();
219
		return getLabel();
184
	}
220
	}
185
221
222
	public ITaskAttachment getTaskAttachment() {
223
		return taskAttachment;
224
	}
225
226
	public void setTaskAttachment(ITaskAttachment taskAttachment) {
227
		this.taskAttachment = taskAttachment;
228
	}
186
}
229
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorOutlineNodeLabelProvider.java (+96 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Frank Beckers and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Frank Becker - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.tasks.ui.editors;
13
14
import org.eclipse.jface.viewers.LabelProvider;
15
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
16
import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
17
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
18
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
19
import org.eclipse.mylyn.tasks.core.TaskRepository;
20
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
21
import org.eclipse.mylyn.tasks.ui.TasksUi;
22
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
23
import org.eclipse.swt.graphics.Image;
24
import org.eclipse.ui.ISharedImages;
25
import org.eclipse.ui.internal.WorkbenchImages;
26
27
public class TaskEditorOutlineNodeLabelProvider extends LabelProvider {
28
	private static final String[] IMAGE_EXTENSIONS = { "jpg", "gif", "png", "tiff", "tif", "bmp" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$	@Override
29
30
	@Override
31
	public Image getImage(Object element) {
32
		if (element instanceof TaskEditorOutlineNode) {
33
			TaskEditorOutlineNode node = (TaskEditorOutlineNode) element;
34
			if (TaskEditorOutlineNode.LABEL_COMMENTS.equals(node.getLabel())
35
					|| TaskEditorOutlineNode.LABEL_NEW_COMMENT.equals(node.getLabel())) {
36
				return CommonImages.getImage(TasksUiImages.COMMENT);
37
			}
38
			if (TaskEditorOutlineNode.LABEL_DESCRIPTION.equals(node.getLabel())) {
39
				return CommonImages.getImage(TasksUiImages.TASK_NOTES);
40
			} else if (node.getTaskComment() != null) {
41
				IRepositoryPerson author = node.getTaskComment().getAuthor();
42
				TaskAttribute taskAttribute = node.getData();
43
				String repositoryUrl = taskAttribute.getTaskData().getRepositoryUrl();
44
				String connectorKind = null;
45
				TaskRepository taskRepository = null;
46
				if (repositoryUrl != null) {
47
					connectorKind = taskAttribute.getTaskData().getConnectorKind();
48
					if (connectorKind != null) {
49
						taskRepository = TasksUi.getRepositoryManager().getRepository(connectorKind, repositoryUrl);
50
					}
51
				}
52
				if (taskRepository != null && author != null
53
						&& author.getPersonId().equals(taskRepository.getUserName())) {
54
					return CommonImages.getImage(CommonImages.PERSON_ME);
55
				} else {
56
					return CommonImages.getImage(CommonImages.PERSON);
57
				}
58
			} else if (node.getTaskAttachment() != null) {
59
				ITaskAttachment attachment = node.getTaskAttachment();
60
				if (AttachmentUtil.isContext(attachment)) {
61
					return CommonImages.getImage(TasksUiImages.CONTEXT_TRANSFER);
62
				} else if (attachment.isPatch()) {
63
					return CommonImages.getImage(TasksUiImages.TASK_ATTACHMENT_PATCH);
64
				} else {
65
					String filename = attachment.getFileName();
66
					if (filename != null) {
67
						int dotIndex = filename.lastIndexOf('.');
68
						if (dotIndex != -1) {
69
							String fileType = filename.substring(dotIndex + 1);
70
							for (String element2 : IMAGE_EXTENSIONS) {
71
								if (element2.equalsIgnoreCase(fileType)) {
72
									return CommonImages.getImage(CommonImages.IMAGE_FILE);
73
								}
74
							}
75
						}
76
					}
77
					return WorkbenchImages.getImage(ISharedImages.IMG_OBJ_FILE);
78
				}
79
			} else {
80
				return CommonImages.getImage(TasksUiImages.TASK);
81
			}
82
		} else {
83
			return super.getImage(element);
84
		}
85
	}
86
87
	@Override
88
	public String getText(Object element) {
89
		if (element instanceof TaskEditorOutlineNode) {
90
			TaskEditorOutlineNode node = (TaskEditorOutlineNode) element;
91
			return node.getLabel();
92
		}
93
		return super.getText(element);
94
	}
95
96
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorOutlinePage.java (-41 / +1 lines)
Lines 12-26 Link Here
12
package org.eclipse.mylyn.internal.tasks.ui.editors;
12
package org.eclipse.mylyn.internal.tasks.ui.editors;
13
13
14
import org.eclipse.jface.viewers.ITreeContentProvider;
14
import org.eclipse.jface.viewers.ITreeContentProvider;
15
import org.eclipse.jface.viewers.LabelProvider;
16
import org.eclipse.jface.viewers.TreeViewer;
15
import org.eclipse.jface.viewers.TreeViewer;
17
import org.eclipse.jface.viewers.Viewer;
16
import org.eclipse.jface.viewers.Viewer;
18
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
19
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
20
import org.eclipse.mylyn.tasks.core.TaskRepository;
17
import org.eclipse.mylyn.tasks.core.TaskRepository;
21
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
22
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
18
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
23
import org.eclipse.swt.graphics.Image;
24
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
20
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
26
21
Lines 113-154 Link Here
113
		super.createControl(parent);
108
		super.createControl(parent);
114
		viewer = getTreeViewer();
109
		viewer = getTreeViewer();
115
		viewer.setContentProvider(new TaskEditorOutlineContentProvider());
110
		viewer.setContentProvider(new TaskEditorOutlineContentProvider());
116
		viewer.setLabelProvider(new LabelProvider() {
111
		viewer.setLabelProvider(new TaskEditorOutlineNodeLabelProvider());
117
			@Override
118
			public Image getImage(Object element) {
119
				if (element instanceof TaskEditorOutlineNode) {
120
					TaskEditorOutlineNode node = (TaskEditorOutlineNode) element;
121
					if (TaskEditorOutlineNode.LABEL_COMMENTS.equals(node.getLabel())
122
							|| TaskEditorOutlineNode.LABEL_NEW_COMMENT.equals(node.getLabel())) {
123
						return CommonImages.getImage(TasksUiImages.COMMENT);
124
					}
125
					if (TaskEditorOutlineNode.LABEL_DESCRIPTION.equals(node.getLabel())) {
126
						return CommonImages.getImage(TasksUiImages.TASK_NOTES);
127
					} else if (node.getTaskComment() != null) {
128
						IRepositoryPerson author = node.getTaskComment().getAuthor();
129
						if (taskRepository != null && author != null
130
								&& author.getPersonId().equals(taskRepository.getUserName())) {
131
							return CommonImages.getImage(CommonImages.PERSON_ME);
132
						} else {
133
							return CommonImages.getImage(CommonImages.PERSON);
134
						}
135
					} else {
136
						return CommonImages.getImage(TasksUiImages.TASK);
137
					}
138
				} else {
139
					return super.getImage(element);
140
				}
141
			}
142
143
			@Override
144
			public String getText(Object element) {
145
				if (element instanceof TaskEditorOutlineNode) {
146
					TaskEditorOutlineNode node = (TaskEditorOutlineNode) element;
147
					return node.getLabel();
148
				}
149
				return super.getText(element);
150
			}
151
		});
152
		viewer.setInput(model);
112
		viewer.setInput(model);
153
		viewer.expandAll();
113
		viewer.expandAll();
154
	}
114
	}
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties (+1 lines)
Lines 83-88 Link Here
83
TaskEditorDescriptionPart_Search=Search
83
TaskEditorDescriptionPart_Search=Search
84
84
85
TaskEditorNewCommentPart_New_Comment=New Comment
85
TaskEditorNewCommentPart_New_Comment=New Comment
86
TaskEditorOutlineNode_Attachments=Attachments
86
TaskEditorOutlineNode_Comments=Comments
87
TaskEditorOutlineNode_Comments=Comments
87
TaskEditorOutlineNode_Description=Description
88
TaskEditorOutlineNode_Description=Description
88
TaskEditorOutlineNode_New_Comment=New Comment
89
TaskEditorOutlineNode_New_Comment=New Comment
(-)src/org/eclipse/mylyn/internal/tasks/ui/views/Messages.java (+4 lines)
Lines 29-34 Link Here
29
29
30
	public static String PriorityDropDownAction_Filter_Priority_Lower_Than;
30
	public static String PriorityDropDownAction_Filter_Priority_Lower_Than;
31
31
32
	public static String QuickOutlineTaskDataDialog_InfoText;
33
34
	public static String QuickOutlineTaskDataDialog_ShowRawData;
35
32
	public static String RepositoryElementActionGroup_Copy_Detail_Menu_Label;
36
	public static String RepositoryElementActionGroup_Copy_Detail_Menu_Label;
33
37
34
	public static String RepositoryElementActionGroup_New;
38
	public static String RepositoryElementActionGroup_New;
(-)src/org/eclipse/mylyn/internal/tasks/ui/views/QuickOutlineTaskDataDialog.java (+508 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Frank Becker and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Frank Becker - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.tasks.ui.views;
13
14
import org.eclipse.jface.action.IMenuManager;
15
import org.eclipse.jface.action.Separator;
16
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.jface.dialogs.PopupDialog;
18
import org.eclipse.jface.text.IInformationControl;
19
import org.eclipse.jface.text.IInformationControlExtension;
20
import org.eclipse.jface.text.IInformationControlExtension2;
21
import org.eclipse.jface.viewers.ILabelProvider;
22
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.jface.viewers.StructuredSelection;
24
import org.eclipse.mylyn.internal.tasks.ui.CommonViewerTaskDataFilter;
25
import org.eclipse.mylyn.internal.tasks.ui.CommonViewerTaskDataOpenListener;
26
import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
27
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
28
import org.eclipse.mylyn.tasks.core.data.TaskData;
29
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
30
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
31
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.events.DisposeEvent;
33
import org.eclipse.swt.events.DisposeListener;
34
import org.eclipse.swt.events.FocusListener;
35
import org.eclipse.swt.events.KeyEvent;
36
import org.eclipse.swt.events.KeyListener;
37
import org.eclipse.swt.events.ModifyEvent;
38
import org.eclipse.swt.events.ModifyListener;
39
import org.eclipse.swt.events.MouseAdapter;
40
import org.eclipse.swt.events.MouseEvent;
41
import org.eclipse.swt.events.SelectionEvent;
42
import org.eclipse.swt.events.SelectionListener;
43
import org.eclipse.swt.graphics.Color;
44
import org.eclipse.swt.graphics.FontMetrics;
45
import org.eclipse.swt.graphics.GC;
46
import org.eclipse.swt.graphics.Point;
47
import org.eclipse.swt.layout.GridData;
48
import org.eclipse.swt.layout.GridLayout;
49
import org.eclipse.swt.widgets.Button;
50
import org.eclipse.swt.widgets.Composite;
51
import org.eclipse.swt.widgets.Control;
52
import org.eclipse.swt.widgets.Shell;
53
import org.eclipse.swt.widgets.Text;
54
import org.eclipse.swt.widgets.Tree;
55
import org.eclipse.swt.widgets.TreeItem;
56
import org.eclipse.ui.IEditorPart;
57
import org.eclipse.ui.PlatformUI;
58
import org.eclipse.ui.forms.editor.IFormPage;
59
import org.eclipse.ui.internal.misc.StringMatcher;
60
import org.eclipse.ui.navigator.CommonViewer;
61
62
public class QuickOutlineTaskDataDialog extends PopupDialog implements IInformationControl,
63
		IInformationControlExtension, IInformationControlExtension2, DisposeListener {
64
65
	public static final String ID_VIEWER = "org.eclipse.mylyn.internal.tasks.ui.taskdata.quick"; //$NON-NLS-1$
66
67
	private CommonViewer commonViewer;
68
69
	private Text fFilterText;
70
71
	private StringMatcher fStringMatcher;
72
73
	private CommonViewerTaskDataFilter namePatternFilter;
74
75
	private CommonViewerTaskDataOpenListener openListener;
76
77
	public QuickOutlineTaskDataDialog(Shell parent) {
78
		super(parent, SWT.RESIZE, true, true, true, true, true, null, Messages.QuickOutlineTaskDataDialog_InfoText);
79
		create();
80
	}
81
82
	@Override
83
	public boolean close() {
84
		// nothing additional to dispose
85
		return super.close();
86
	}
87
88
	@Override
89
	protected Control createDialogArea(Composite parent) {
90
		createViewer(parent);
91
		createUIListenersTreeViewer();
92
		addDisposeListener(this);
93
94
		return commonViewer.getControl();
95
	}
96
97
	private void createViewer(Composite parent) {
98
		Control composite = super.createDialogArea(parent);
99
		commonViewer = createCommonViewer((Composite) composite);
100
		openListener = new CommonViewerTaskDataOpenListener(commonViewer);
101
102
		commonViewer.addOpenListener(openListener);
103
		commonViewer.getTree().addMouseListener(openListener);
104
105
		namePatternFilter = new CommonViewerTaskDataFilter();
106
		commonViewer.addFilter(namePatternFilter);
107
		try {
108
			commonViewer.getControl().setRedraw(false);
109
			IEditorPart activeEditor = PlatformUI.getWorkbench()
110
					.getActiveWorkbenchWindow()
111
					.getActivePage()
112
					.getActiveEditor();
113
			if (activeEditor instanceof TaskEditor) {
114
				TaskEditor taskEditor = (TaskEditor) activeEditor;
115
				IFormPage pageInstance = taskEditor.getActivePageInstance();
116
				if (pageInstance instanceof AbstractTaskEditorPage) {
117
					AbstractTaskEditorPage taskEditorPage = (AbstractTaskEditorPage) pageInstance;
118
					TaskData taskData = taskEditorPage.getModel().getTaskData();
119
					commonViewer.setInput(taskData);
120
				}
121
			}
122
			commonViewer.expandAll();
123
		} finally {
124
			commonViewer.getControl().setRedraw(true);
125
		}
126
	}
127
128
	protected CommonViewer createCommonViewer(Composite parent) {
129
		CommonViewer viewer = new CommonViewer(ID_VIEWER, parent, SWT.H_SCROLL | SWT.V_SCROLL);
130
		viewer.setUseHashlookup(true);
131
		viewer.getControl().setLayoutData(new GridData(500, 400));
132
		return viewer;
133
	}
134
135
	@Override
136
	protected void fillDialogMenu(IMenuManager dialogMenu) {
137
		dialogMenu.add(new Separator());
138
		super.fillDialogMenu(dialogMenu);
139
	}
140
141
	private void createUIListenersTreeViewer() {
142
		final Tree tree = commonViewer.getTree();
143
		tree.addKeyListener(new KeyListener() {
144
			public void keyPressed(KeyEvent e) {
145
				if (e.character == 0x1B) {
146
					// Dispose on ESC key press
147
					dispose();
148
				}
149
			}
150
151
			public void keyReleased(KeyEvent e) {
152
				// ignore
153
			}
154
		});
155
156
		tree.addMouseListener(new MouseAdapter() {
157
			@Override
158
			public void mouseUp(MouseEvent e) {
159
				handleTreeViewerMouseUp(tree, e);
160
			}
161
		});
162
163
		tree.addSelectionListener(new SelectionListener() {
164
			public void widgetSelected(SelectionEvent e) {
165
				// ignore
166
			}
167
168
			public void widgetDefaultSelected(SelectionEvent e) {
169
				gotoSelectedElement();
170
			}
171
		});
172
	}
173
174
	private void handleTreeViewerMouseUp(final Tree tree, MouseEvent e) {
175
		if ((tree.getSelectionCount() < 1) || (e.button != 1) || (tree.equals(e.getSource()) == false)) {
176
			return;
177
		}
178
		// Selection is made in the selection changed listener
179
		Object object = tree.getItem(new Point(e.x, e.y));
180
		TreeItem selection = tree.getSelection()[0];
181
		if (selection.equals(object)) {
182
			gotoSelectedElement();
183
		}
184
	}
185
186
	private Object getSelectedElement() {
187
		if (commonViewer == null) {
188
			return null;
189
		}
190
		return ((IStructuredSelection) commonViewer.getSelection()).getFirstElement();
191
	}
192
193
	public void addDisposeListener(DisposeListener listener) {
194
		getShell().addDisposeListener(listener);
195
	}
196
197
	public void addFocusListener(FocusListener listener) {
198
		getShell().addFocusListener(listener);
199
	}
200
201
	public Point computeSizeHint() {
202
		// Note that it already has the persisted size if persisting is enabled.
203
		return getShell().getSize();
204
	}
205
206
	public void dispose() {
207
		close();
208
	}
209
210
	public boolean isFocusControl() {
211
		if (commonViewer.getControl().isFocusControl() || fFilterText.isFocusControl()) {
212
			return true;
213
		}
214
		return false;
215
	}
216
217
	public void removeDisposeListener(DisposeListener listener) {
218
		getShell().removeDisposeListener(listener);
219
	}
220
221
	public void removeFocusListener(FocusListener listener) {
222
		getShell().removeFocusListener(listener);
223
	}
224
225
	public void setBackgroundColor(Color background) {
226
		applyBackgroundColor(background, getContents());
227
	}
228
229
	public void setFocus() {
230
		getShell().forceFocus();
231
		fFilterText.setFocus();
232
	}
233
234
	public void setForegroundColor(Color foreground) {
235
		applyForegroundColor(foreground, getContents());
236
	}
237
238
	public void setInformation(String information) {
239
		// See IInformationControlExtension2
240
	}
241
242
	public void setLocation(Point location) {
243
		/*
244
		 * If the location is persisted, it gets managed by PopupDialog - fine. Otherwise, the location is
245
		 * computed in Window#getInitialLocation, which will center it in the parent shell / main
246
		 * monitor, which is wrong for two reasons:
247
		 * - we want to center over the editor / subject control, not the parent shell
248
		 * - the center is computed via the initalSize, which may be also wrong since the size may 
249
		 *   have been updated since via min/max sizing of AbstractInformationControlManager.
250
		 * In that case, override the location with the one computed by the manager. Note that
251
		 * the call to constrainShellSize in PopupDialog.open will still ensure that the shell is
252
		 * entirely visible.
253
		 */
254
		if (getPersistLocation() == false || getDialogSettings() == null) {
255
			getShell().setLocation(location);
256
		}
257
	}
258
259
	public void setSize(int width, int height) {
260
		getShell().setSize(width, height);
261
	}
262
263
	public void setSizeConstraints(int maxWidth, int maxHeight) {
264
		// Ignore
265
	}
266
267
	public void setVisible(boolean visible) {
268
		if (visible) {
269
			open();
270
		} else {
271
			saveDialogBounds(getShell());
272
			getShell().setVisible(false);
273
		}
274
	}
275
276
	public boolean hasContents() {
277
		if ((commonViewer == null) || (commonViewer.getInput() == null)) {
278
			return false;
279
		}
280
		return true;
281
	}
282
283
	public void setInput(Object input) {
284
		// Input comes from PDESourceInfoProvider.getInformation2()
285
		// The input should be a model object of some sort
286
		// Turn it into a structured selection and set the selection in the tree
287
		if (input != null) {
288
			commonViewer.setSelection(new StructuredSelection(input));
289
		}
290
	}
291
292
	public void widgetDisposed(DisposeEvent e) {
293
		// Note: We do not reuse the dialog
294
		commonViewer = null;
295
		fFilterText = null;
296
	}
297
298
	@Override
299
	protected Control createTitleControl(Composite parent) {
300
		Composite control = new Composite(parent, SWT.NONE);
301
		GridLayout layout = new GridLayout(1, false);
302
		layout.marginHeight = 0;
303
		control.setLayout(layout);
304
		control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
305
306
		// Applies only to dialog title - not body.  See createDialogArea
307
		// Create the text widget
308
		createUIWidgetFilterText(control);
309
		// Add listeners to the text widget
310
		createUIListenersFilterText();
311
		final Button showTaskDataButton = new Button(control, SWT.CHECK);
312
		showTaskDataButton.setText(Messages.QuickOutlineTaskDataDialog_ShowRawData);
313
		showTaskDataButton.setSelection(TasksUiPlugin.getDefault()
314
				.getPreferenceStore()
315
				.getBoolean(ITasksUiPreferenceConstants.QUICKOUTLINE_TASKMODE_TASKDATA));
316
		showTaskDataButton.addSelectionListener(new SelectionListener() {
317
318
			public void widgetSelected(SelectionEvent e) {
319
				// ignore
320
				boolean selection = showTaskDataButton.getSelection();
321
				TasksUiPlugin.getDefault()
322
						.getPreferenceStore()
323
						.setValue(ITasksUiPreferenceConstants.QUICKOUTLINE_TASKMODE_TASKDATA, selection);
324
				IEditorPart activeEditor = PlatformUI.getWorkbench()
325
						.getActiveWorkbenchWindow()
326
						.getActivePage()
327
						.getActiveEditor();
328
				if (activeEditor instanceof TaskEditor) {
329
					TaskEditor taskEditor = (TaskEditor) activeEditor;
330
					IFormPage pageInstance = taskEditor.getActivePageInstance();
331
					if (pageInstance instanceof AbstractTaskEditorPage) {
332
						AbstractTaskEditorPage taskEditorPage = (AbstractTaskEditorPage) pageInstance;
333
						TaskData taskData = taskEditorPage.getModel().getTaskData();
334
						commonViewer.setInput(taskData);
335
						if (!selection) {
336
							commonViewer.expandAll();
337
						}
338
					}
339
				}
340
341
			}
342
343
			public void widgetDefaultSelected(SelectionEvent e) {
344
				// ignore
345
346
			}
347
		});
348
349
		// Return the text widget
350
		return control;
351
	}
352
353
	private void createUIWidgetFilterText(Composite parent) {
354
		// Create the widget
355
		fFilterText = new Text(parent, SWT.NONE);
356
		// Set the font 
357
		GC gc = new GC(parent);
358
		gc.setFont(parent.getFont());
359
		FontMetrics fontMetrics = gc.getFontMetrics();
360
		gc.dispose();
361
		// Create the layout
362
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
363
		data.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 1);
364
		data.horizontalAlignment = GridData.FILL;
365
		data.verticalAlignment = GridData.CENTER;
366
		fFilterText.setLayoutData(data);
367
	}
368
369
	/**
370
	 * 
371
	 */
372
	private void gotoSelectedElement() {
373
		Object selectedElement = getSelectedElement();
374
		if (selectedElement == null) {
375
			return;
376
		}
377
		dispose();
378
	}
379
380
	private void createUIListenersFilterText() {
381
		fFilterText.addKeyListener(new KeyListener() {
382
			public void keyPressed(KeyEvent e) {
383
				if (e.keyCode == 0x0D) {
384
					// Return key was pressed
385
					gotoSelectedElement();
386
				} else if (e.keyCode == SWT.ARROW_DOWN) {
387
					// Down key was pressed
388
					commonViewer.getTree().setFocus();
389
				} else if (e.keyCode == SWT.ARROW_UP) {
390
					// Up key was pressed
391
					commonViewer.getTree().setFocus();
392
				} else if (e.character == 0x1B) {
393
					// Escape key was pressed
394
					dispose();
395
				}
396
			}
397
398
			public void keyReleased(KeyEvent e) {
399
				// NO-OP
400
			}
401
		});
402
		// Handle text modify events
403
		fFilterText.addModifyListener(new ModifyListener() {
404
			public void modifyText(ModifyEvent e) {
405
				String text = ((Text) e.widget).getText();
406
				int length = text.length();
407
				if (length > 0) {
408
					// Append a '*' pattern to the end of the text value if it
409
					// does not have one already
410
					if (text.charAt(length - 1) != '*') {
411
						text = text + '*';
412
					}
413
					// Prepend a '*' pattern to the beginning of the text value
414
					// if it does not have one already
415
					if (text.charAt(0) != '*') {
416
						text = '*' + text;
417
					}
418
				}
419
				// Set and update the pattern
420
				setMatcherString(text, true);
421
			}
422
		});
423
	}
424
425
	/**
426
	 * Sets the patterns to filter out for the receiver.
427
	 * <p>
428
	 * The following characters have special meaning: ? => any character * => any string
429
	 * </p>
430
	 * 
431
	 * @param pattern
432
	 *            the pattern
433
	 * @param update
434
	 *            <code>true</code> if the viewer should be updated
435
	 */
436
	private void setMatcherString(String pattern, boolean update) {
437
		if (pattern.length() == 0) {
438
			fStringMatcher = null;
439
		} else {
440
			fStringMatcher = new StringMatcher(pattern, true, false);
441
		}
442
		// Update the name pattern filter on the tree viewer
443
		namePatternFilter.setStringMatcher(fStringMatcher);
444
		// Update the tree viewer according to the pattern
445
		if (update) {
446
			stringMatcherUpdated();
447
		}
448
	}
449
450
	/**
451
	 * The string matcher has been modified. The default implementation refreshes the view and selects the first matched
452
	 * element
453
	 */
454
	private void stringMatcherUpdated() {
455
		// Refresh the tree viewer to re-filter
456
		commonViewer.getControl().setRedraw(false);
457
		commonViewer.refresh();
458
		commonViewer.expandAll();
459
		selectFirstMatch();
460
		commonViewer.getControl().setRedraw(true);
461
	}
462
463
	/**
464
	 * Selects the first element in the tree which matches the current filter pattern.
465
	 */
466
	private void selectFirstMatch() {
467
		Tree tree = commonViewer.getTree();
468
		Object element = findFirstMatchToPattern(tree.getItems());
469
		if (element != null) {
470
			commonViewer.setSelection(new StructuredSelection(element), true);
471
		} else {
472
			commonViewer.setSelection(StructuredSelection.EMPTY);
473
		}
474
	}
475
476
	/**
477
	 * @param items
478
	 * @return
479
	 */
480
	private Object findFirstMatchToPattern(TreeItem[] items) {
481
		// Match the string pattern against labels
482
		ILabelProvider labelProvider = (ILabelProvider) commonViewer.getLabelProvider();
483
		// Process each item in the tree
484
		for (TreeItem item : items) {
485
			Object element = item.getData();
486
			// Return the first element if no pattern is set
487
			if (fStringMatcher == null) {
488
				return element;
489
			}
490
			// Return the element if it matches the pattern
491
			if (element != null) {
492
				String label = labelProvider.getText(element);
493
				if (fStringMatcher.match(label)) {
494
					return element;
495
				}
496
			}
497
			// Recursively check the elements children for a match
498
			element = findFirstMatchToPattern(item.getItems());
499
			// Return the child element match if found
500
			if (element != null) {
501
				return element;
502
			}
503
		}
504
		// No match found
505
		return null;
506
	}
507
508
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/views/messages.properties (+2 lines)
Lines 11-16 Link Here
11
DisconnectRepositoryAction_Disconnected=Disconnected
11
DisconnectRepositoryAction_Disconnected=Disconnected
12
12
13
PriorityDropDownAction_Filter_Priority_Lower_Than=Hide Priority Lower Than
13
PriorityDropDownAction_Filter_Priority_Lower_Than=Hide Priority Lower Than
14
QuickOutlineTaskDataDialog_InfoText=TaskDetail
15
QuickOutlineTaskDataDialog_ShowRawData=show raw Data
14
RepositoryElementActionGroup_Copy_Detail_Menu_Label=Copy Details
16
RepositoryElementActionGroup_Copy_Detail_Menu_Label=Copy Details
15
RepositoryElementActionGroup_New=New
17
RepositoryElementActionGroup_New=New
16
18
(-)src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java (-35 / +27 lines)
Lines 92-98 Link Here
92
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
92
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
93
import org.eclipse.mylyn.tasks.core.TaskRepository;
93
import org.eclipse.mylyn.tasks.core.TaskRepository;
94
import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
94
import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
95
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
96
import org.eclipse.mylyn.tasks.core.data.TaskData;
95
import org.eclipse.mylyn.tasks.core.data.TaskData;
97
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
96
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
98
import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent;
97
import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent;
Lines 136-142 Link Here
136
import org.eclipse.ui.forms.widgets.ExpandableComposite;
135
import org.eclipse.ui.forms.widgets.ExpandableComposite;
137
import org.eclipse.ui.forms.widgets.FormToolkit;
136
import org.eclipse.ui.forms.widgets.FormToolkit;
138
import org.eclipse.ui.forms.widgets.ScrolledForm;
137
import org.eclipse.ui.forms.widgets.ScrolledForm;
139
import org.eclipse.ui.forms.widgets.Section;
140
import org.eclipse.ui.handlers.IHandlerService;
138
import org.eclipse.ui.handlers.IHandlerService;
141
import org.eclipse.ui.services.IDisposable;
139
import org.eclipse.ui.services.IDisposable;
142
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
140
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
Lines 1033-1065 Link Here
1033
					ISelection selection = event.getSelection();
1031
					ISelection selection = event.getSelection();
1034
					if (selection instanceof StructuredSelection) {
1032
					if (selection instanceof StructuredSelection) {
1035
						Object select = ((StructuredSelection) selection).getFirstElement();
1033
						Object select = ((StructuredSelection) selection).getFirstElement();
1036
						if (select instanceof TaskEditorOutlineNode) {
1034
						EditorUtil.focusFromStructuredSelection(select, AbstractTaskEditorPage.this);
1037
							TaskEditorOutlineNode node = (TaskEditorOutlineNode) select;
1035
						getEditor().setActivePage(getId());
1038
							TaskAttribute attribute = node.getData();
1039
							if (attribute != null) {
1040
								if (TaskAttribute.TYPE_COMMENT.equals(attribute.getMetaData().getType())) {
1041
									AbstractTaskEditorPart actionPart = getPart(ID_PART_COMMENTS);
1042
									if (actionPart != null && actionPart.getControl() instanceof ExpandableComposite) {
1043
										CommonFormUtil.setExpanded((ExpandableComposite) actionPart.getControl(), true);
1044
										if (actionPart.getControl() instanceof Section) {
1045
											Control client = ((Section) actionPart.getControl()).getClient();
1046
											if (client instanceof Composite) {
1047
												for (Control control : ((Composite) client).getChildren()) {
1048
													// toggle subsections
1049
													if (control instanceof Section) {
1050
														CommonFormUtil.setExpanded((Section) control, true);
1051
													}
1052
												}
1053
											}
1054
										}
1055
									}
1056
								}
1057
								EditorUtil.reveal(form, attribute.getId());
1058
							} else {
1059
								EditorUtil.reveal(form, node.getLabel());
1060
							}
1061
							getEditor().setActivePage(getId());
1062
						}
1063
					}
1036
					}
1064
				}
1037
				}
1065
			});
1038
			});
Lines 1239-1253 Link Here
1239
			if (part.getControl() != null) {
1212
			if (part.getControl() != null) {
1240
				if (ID_PART_ACTIONS.equals(part.getPartId())) {
1213
				if (ID_PART_ACTIONS.equals(part.getPartId())) {
1241
					// do not expand horizontally
1214
					// do not expand horizontally
1242
					GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(false, false).applyTo(
1215
					GridDataFactory.fillDefaults()
1243
							part.getControl());
1216
							.align(SWT.FILL, SWT.FILL)
1217
							.grab(false, false)
1218
							.applyTo(part.getControl());
1244
				} else {
1219
				} else {
1245
					if (part.getExpandVertically()) {
1220
					if (part.getExpandVertically()) {
1246
						GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(
1221
						GridDataFactory.fillDefaults()
1247
								part.getControl());
1222
								.align(SWT.FILL, SWT.FILL)
1223
								.grab(true, true)
1224
								.applyTo(part.getControl());
1248
					} else {
1225
					} else {
1249
						GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(
1226
						GridDataFactory.fillDefaults()
1250
								part.getControl());
1227
								.align(SWT.FILL, SWT.TOP)
1228
								.grab(true, false)
1229
								.applyTo(part.getControl());
1251
					}
1230
					}
1252
				}
1231
				}
1253
				// for outline
1232
				// for outline
Lines 1670-1673 Link Here
1670
//		}
1649
//		}
1671
//	}
1650
//	}
1672
1651
1652
	/**
1653
	 * @since 3.4
1654
	 */
1655
	public boolean reveal(String key) {
1656
		return EditorUtil.reveal(form, key);
1657
	}
1658
1659
	/**
1660
	 * @since 3.4
1661
	 */
1662
	public void focusOn(Control control) {
1663
		EditorUtil.focusOn(form, control);
1664
	}
1673
}
1665
}

Return to bug 278102