Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
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 / +93 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.views">
1929
      <view
1930
            allowMultiple="false"
1931
            class="org.eclipse.ui.navigator.CommonNavigator"
1932
            id="org.eclipse.mylyn.internal.tasks.ui.taskdata.quick"
1933
            name="Non-Resources Viewer!!!!!"/>
1934
   </extension>
1935
-->
1936
   <extension
1937
         point="org.eclipse.ui.navigator.viewer">
1938
      <viewer viewerId="org.eclipse.mylyn.internal.tasks.ui.taskdata.quick"/>
1939
      <viewerContentBinding viewerId="org.eclipse.mylyn.internal.tasks.ui.taskdata.quick">
1940
         <includes>
1941
            <contentExtension pattern="org.eclipse.mylyn.internal.tasks.ui.CommonViewerTaskDataContentProvider"/>
1942
            <contentExtension pattern="org.eclipse.ui.navigator.resources.filters.*"/> 
1943
<!--
1944
            <contentExtension pattern="org.eclipse.mylyn.internal.tasks.ui.CommonViewerTaskDataFilter.NoOper"/>
1945
-->
1946
         </includes>
1947
      </viewerContentBinding>
1948
      <viewerActionBinding viewerId="org.eclipse.mylyn.internal.tasks.ui.taskdata.quick">
1949
         <includes>
1950
            <actionExtension pattern="org.eclipse.ui.navigator.resources.*"/>
1951
         </includes>
1952
      </viewerActionBinding>
1953
   </extension>
1954
   <extension
1955
         point="org.eclipse.ui.navigator.navigatorContent">
1956
      <navigatorContent
1957
            activeByDefault="true"
1958
            contentProvider="org.eclipse.mylyn.internal.tasks.ui.CommonViewerTaskDataContentProvider"
1959
            id="org.eclipse.mylyn.internal.tasks.ui.navigatorContent1"
1960
            labelProvider="org.eclipse.mylyn.internal.tasks.ui.CommonViewerTaskDataLabelProvider"
1961
            name="NR Content">
1962
         <triggerPoints>
1963
            <or>
1964
               <instanceof value="org.eclipse.mylyn.tasks.core.data.TaskData"/>
1965
            </or>
1966
         </triggerPoints>
1967
         <possibleChildren>
1968
            <or>
1969
               <instanceof value="org.eclipse.mylyn.tasks.core.data.TaskAttribute"/>
1970
                <instanceof value="org.eclipse.mylyn.tasks.core.data.TaskData"/>
1971
            </or>
1972
         </possibleChildren>
1973
      </navigatorContent>
1974
   </extension>
1975
<!--
1976
   <extension
1977
         point="org.eclipse.ui.navigator.navigatorContent">
1978
      <commonFilter
1979
         class="org.eclipse.mylyn.internal.tasks.ui.CommonViewerTaskDataFilter"
1980
         description="Filter Operation of TaskData"
1981
         id="org.eclipse.mylyn.internal.tasks.ui.CommonViewerTaskDataFilter.NoOper"
1982
         name="No Operation">
1983
      </commonFilter> 
1984
   </extension>
1985
-->
1986
   <extension
1987
         point="org.eclipse.ui.navigator.viewer">
1988
      <viewerContentBinding viewerId="org.eclipse.mylyn.internal.tasks.ui.taskdata.quick">
1989
         <includes>
1990
            <contentExtension
1991
                  isRoot="false"
1992
                  pattern="org.eclipse.mylyn.internal.tasks.ui.navigatorContent1"/>
1993
         </includes>
1994
      </viewerContentBinding>
1995
   </extension>
1996
   
1997
    
1906
</plugin>
1998
</plugin>
(-)src/org/eclipse/mylyn/internal/tasks/ui/CommonViewerTaskDataContentProvider.java (+62 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Tasktop Technologies 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
 *     Tasktop Technologies - 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.tasks.core.data.TaskData;
17
18
public class CommonViewerTaskDataContentProvider implements ITreeContentProvider {
19
20
	public Object[] getChildren(Object parentElement) {
21
		Object[] result = {};
22
		if (parentElement instanceof TaskData) {
23
			TaskData node = (TaskData) parentElement;
24
			result = node.getRoot().getAttributes().values().toArray();
25
//		} else if (parentElement instanceof TaskAttribute) {
26
//			TaskAttribute node = (TaskAttribute) parentElement;
27
//			result = node.getAttributes().values().toArray();
28
		}
29
		return result;
30
	}
31
32
	public Object[] getElements(Object inputElement) {
33
		return getChildren(inputElement);
34
	}
35
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
38
	 */
39
	public Object getParent(Object element) {
40
		return null;
41
	}
42
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
45
	 */
46
	public boolean hasChildren(Object element) {
47
		return true;
48
	}
49
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
52
	 */
53
	public void dispose() {
54
	}
55
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
58
	 */
59
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
60
	}
61
62
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/CommonViewerTaskDataFilter.java (+51 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Tasktop Technologies 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
 *     Tasktop Technologies - 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 (+82 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Tasktop Technologies 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
 *     Tasktop Technologies - 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.ILabelProviderListener;
16
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
17
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData;
18
import org.eclipse.mylyn.tasks.core.data.TaskData;
19
import org.eclipse.swt.graphics.Image;
20
21
public class CommonViewerTaskDataLabelProvider implements ILabelProvider {
22
	public String getText(Object element) {
23
		String result = ""; //$NON-NLS-1$
24
		if (element instanceof TaskData) {
25
			TaskData node = (TaskData) element;
26
			result = node.getTaskId();
27
		} else if (element instanceof TaskAttribute) {
28
			TaskAttribute node = (TaskAttribute) element;
29
			TaskAttributeMetaData meta = node.getMetaData();
30
			if (meta != null) {
31
				String lable = meta.getLabel();
32
				if (lable != null) {
33
					result = lable + " (" + node.getId() + ")";
34
				} else {
35
					if (TaskAttribute.TYPE_ATTACHMENT.equals(meta.getType())) {
36
						result = "Attachment: " + node.getValue(); //$NON-NLS-1$
37
					} else if (TaskAttribute.TYPE_COMMENT.equals(meta.getType())) {
38
						result = "Comment: " + node.getValue(); //$NON-NLS-1$
39
					} else {
40
						result = "<" + node.getId() + ">"; //$NON-NLS-1$//$NON-NLS-2$
41
					}
42
				}
43
			}
44
		} else if (element instanceof String) {
45
			result = (String) element;
46
		}
47
		return result;
48
	}
49
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
52
	 */
53
	public Image getImage(Object element) {
54
		return null;
55
	}
56
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
59
	 */
60
	public void addListener(ILabelProviderListener listener) {
61
	}
62
63
	/* (non-Javadoc)
64
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
65
	 */
66
	public void dispose() {
67
	}
68
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
71
	 */
72
	public boolean isLabelProperty(Object element, String property) {
73
		return false;
74
	}
75
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
78
	 */
79
	public void removeListener(ILabelProviderListener listener) {
80
	}
81
82
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/CommonViewerTaskDataOpenListener.java (+160 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Tasktop Technologies 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
 *     Tasktop Technologies - 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.TaskEditorAttributePart;
23
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
24
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
25
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
26
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
27
import org.eclipse.swt.events.MouseEvent;
28
import org.eclipse.swt.events.MouseListener;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Control;
31
import org.eclipse.swt.widgets.TableItem;
32
import org.eclipse.swt.widgets.Tree;
33
import org.eclipse.ui.IEditorPart;
34
import org.eclipse.ui.PlatformUI;
35
import org.eclipse.ui.forms.IManagedForm;
36
import org.eclipse.ui.forms.editor.IFormPage;
37
import org.eclipse.ui.forms.widgets.ExpandableComposite;
38
import org.eclipse.ui.forms.widgets.ScrolledForm;
39
import org.eclipse.ui.forms.widgets.Section;
40
41
public class CommonViewerTaskDataOpenListener implements IOpenListener, IDoubleClickListener, MouseListener {
42
43
	private final Viewer viewer;
44
45
	public CommonViewerTaskDataOpenListener(Viewer viewer) {
46
		this.viewer = viewer;
47
	}
48
49
	public void mouseDoubleClick(MouseEvent e) {
50
		setSelection(e);
51
	}
52
53
	public void mouseDown(MouseEvent e) {
54
		setSelection(e);
55
	}
56
57
	public void mouseUp(MouseEvent e) {
58
		// ignore
59
60
	}
61
62
	public void doubleClick(DoubleClickEvent event) {
63
		open(null);
64
	}
65
66
	public void open(OpenEvent event) {
67
		StructuredSelection selection = (StructuredSelection) viewer.getSelection();
68
		Object object = selection.getFirstElement();
69
		if (object instanceof TaskAttribute) {
70
			TaskAttribute attribute = (TaskAttribute) object;
71
			IEditorPart editorPart = PlatformUI.getWorkbench()
72
					.getActiveWorkbenchWindow()
73
					.getActivePage()
74
					.getActiveEditor();
75
			AbstractTaskEditorPage taskEditorPage = null;
76
			if (editorPart instanceof TaskEditor) {
77
				TaskEditor taskEditor = (TaskEditor) editorPart;
78
				IFormPage formPage = taskEditor.getActivePageInstance();
79
				if (formPage instanceof AbstractTaskEditorPage) {
80
					taskEditorPage = (AbstractTaskEditorPage) formPage;
81
				}
82
			}
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
		}
148
	}
149
150
	private void setSelection(MouseEvent event) {
151
		try {
152
			Object selection = ((Tree) event.getSource()).getSelection()[0].getData();
153
			viewer.setSelection(new StructuredSelection(selection));
154
			open(null);
155
		} catch (Exception e) {
156
			// ignore
157
		}
158
	}
159
160
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/actions/QuickOutlineTaskDataAction.java (+57 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Tasktop Technologies 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
 *     Tasktop Technologies - 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 / +11 lines)
Lines 153-159 Link Here
153
	 * @param control
153
	 * @param control
154
	 *            The StyledText to scroll to
154
	 *            The StyledText to scroll to
155
	 */
155
	 */
156
	private static void focusOn(ScrolledForm form, Control control) {
156
	public static void focusOn(ScrolledForm form, Control control) {
157
		int pos = 0;
157
		int pos = 0;
158
		control.setEnabled(true);
158
		control.setEnabled(true);
159
		control.setFocus();
159
		control.setFocus();
Lines 405-412 Link Here
405
		} else {
405
		} else {
406
			roundedBorder.setLayout(GridLayoutFactory.fillDefaults().margins(0, 6).create());
406
			roundedBorder.setLayout(GridLayoutFactory.fillDefaults().margins(0, 6).create());
407
		}
407
		}
408
		GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).hint(EditorUtil.MAXIMUM_WIDTH, SWT.DEFAULT).grab(
408
		GridDataFactory.fillDefaults()
409
				true, false).applyTo(roundedBorder);
409
				.align(SWT.FILL, SWT.BEGINNING)
410
				.hint(EditorUtil.MAXIMUM_WIDTH, SWT.DEFAULT)
411
				.grab(true, false)
412
				.applyTo(roundedBorder);
410
		return roundedBorder;
413
		return roundedBorder;
411
	}
414
	}
412
415
Lines 432-439 Link Here
432
				textFont.dispose();
435
				textFont.dispose();
433
			}
436
			}
434
		});
437
		});
435
		Color color = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().get(
438
		Color color = PlatformUI.getWorkbench()
436
				CommonThemes.COLOR_COMPLETED);
439
				.getThemeManager()
440
				.getCurrentTheme()
441
				.getColorRegistry()
442
				.get(CommonThemes.COLOR_COMPLETED);
437
		text.setForeground(color);
443
		text.setForeground(color);
438
		return textFont;
444
		return textFont;
439
	}
445
	}
(-)src/org/eclipse/mylyn/internal/tasks/ui/views/Messages.java (+2 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
32
	public static String RepositoryElementActionGroup_Copy_Detail_Menu_Label;
34
	public static String RepositoryElementActionGroup_Copy_Detail_Menu_Label;
33
35
34
	public static String RepositoryElementActionGroup_New;
36
	public static String RepositoryElementActionGroup_New;
(-)src/org/eclipse/mylyn/internal/tasks/ui/views/QuickOutlineTaskDataDialog.java (+462 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Tasktop Technologies 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
 *     Tasktop Technologies - 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.tasks.core.data.TaskData;
27
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
28
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.events.DisposeEvent;
31
import org.eclipse.swt.events.DisposeListener;
32
import org.eclipse.swt.events.FocusListener;
33
import org.eclipse.swt.events.KeyEvent;
34
import org.eclipse.swt.events.KeyListener;
35
import org.eclipse.swt.events.ModifyEvent;
36
import org.eclipse.swt.events.ModifyListener;
37
import org.eclipse.swt.events.MouseAdapter;
38
import org.eclipse.swt.events.MouseEvent;
39
import org.eclipse.swt.events.SelectionEvent;
40
import org.eclipse.swt.events.SelectionListener;
41
import org.eclipse.swt.graphics.Color;
42
import org.eclipse.swt.graphics.FontMetrics;
43
import org.eclipse.swt.graphics.GC;
44
import org.eclipse.swt.graphics.Point;
45
import org.eclipse.swt.layout.GridData;
46
import org.eclipse.swt.widgets.Composite;
47
import org.eclipse.swt.widgets.Control;
48
import org.eclipse.swt.widgets.Shell;
49
import org.eclipse.swt.widgets.Text;
50
import org.eclipse.swt.widgets.Tree;
51
import org.eclipse.swt.widgets.TreeItem;
52
import org.eclipse.ui.IEditorPart;
53
import org.eclipse.ui.PlatformUI;
54
import org.eclipse.ui.forms.editor.IFormPage;
55
import org.eclipse.ui.internal.misc.StringMatcher;
56
import org.eclipse.ui.navigator.CommonViewer;
57
58
public class QuickOutlineTaskDataDialog extends PopupDialog implements IInformationControl,
59
		IInformationControlExtension, IInformationControlExtension2, DisposeListener {
60
61
	public static final String ID_VIEWER = "org.eclipse.mylyn.internal.tasks.ui.taskdata.quick"; //$NON-NLS-1$
62
63
	private CommonViewer commonViewer;
64
65
	private Text fFilterText;
66
67
	private StringMatcher fStringMatcher;
68
69
	private CommonViewerTaskDataFilter namePatternFilter;
70
71
	private CommonViewerTaskDataOpenListener openListener;
72
73
	public QuickOutlineTaskDataDialog(Shell parent) {
74
		super(parent, SWT.RESIZE, true, true, true, true, true, null, Messages.QuickOutlineTaskDataDialog_InfoText);
75
		create();
76
	}
77
78
	@Override
79
	public boolean close() {
80
		// nothing additional to dispose
81
		return super.close();
82
	}
83
84
	@Override
85
	protected Control createDialogArea(Composite parent) {
86
		createViewer(parent);
87
		createUIListenersTreeViewer();
88
		addDisposeListener(this);
89
90
		return commonViewer.getControl();
91
	}
92
93
	private void createViewer(Composite parent) {
94
		Control composite = super.createDialogArea(parent);
95
		commonViewer = createCommonViewer((Composite) composite);
96
97
		openListener = new CommonViewerTaskDataOpenListener(commonViewer);
98
99
		commonViewer.addOpenListener(openListener);
100
		commonViewer.getTree().addMouseListener(openListener);
101
102
		namePatternFilter = new CommonViewerTaskDataFilter();
103
		commonViewer.addFilter(namePatternFilter);
104
105
		try {
106
			commonViewer.getControl().setRedraw(false);
107
			IEditorPart activeEditor = PlatformUI.getWorkbench()
108
					.getActiveWorkbenchWindow()
109
					.getActivePage()
110
					.getActiveEditor();
111
			if (activeEditor instanceof TaskEditor) {
112
				TaskEditor taskEditor = (TaskEditor) activeEditor;
113
				IFormPage pageInstance = taskEditor.getActivePageInstance();
114
				if (pageInstance instanceof AbstractTaskEditorPage) {
115
					AbstractTaskEditorPage taskEditorPage = (AbstractTaskEditorPage) pageInstance;
116
					TaskData taskData = taskEditorPage.getModel().getTaskData();
117
					commonViewer.setInput(taskData);
118
				}
119
			}
120
			commonViewer.expandAll();
121
		} finally {
122
			commonViewer.getControl().setRedraw(true);
123
		}
124
	}
125
126
	protected CommonViewer createCommonViewer(Composite parent) {
127
		CommonViewer viewer = new CommonViewer(ID_VIEWER, parent, SWT.H_SCROLL | SWT.V_SCROLL);
128
		viewer.setUseHashlookup(true);
129
		viewer.getControl().setLayoutData(new GridData(500, 400));
130
		return viewer;
131
	}
132
133
	@Override
134
	protected void fillDialogMenu(IMenuManager dialogMenu) {
135
		dialogMenu.add(new Separator());
136
		super.fillDialogMenu(dialogMenu);
137
	}
138
139
	private void createUIListenersTreeViewer() {
140
		final Tree tree = commonViewer.getTree();
141
		tree.addKeyListener(new KeyListener() {
142
			public void keyPressed(KeyEvent e) {
143
				if (e.character == 0x1B) {
144
					// Dispose on ESC key press
145
					dispose();
146
				}
147
			}
148
149
			public void keyReleased(KeyEvent e) {
150
				// ignore
151
			}
152
		});
153
154
		tree.addMouseListener(new MouseAdapter() {
155
			@Override
156
			public void mouseUp(MouseEvent e) {
157
				handleTreeViewerMouseUp(tree, e);
158
			}
159
		});
160
161
		tree.addSelectionListener(new SelectionListener() {
162
			public void widgetSelected(SelectionEvent e) {
163
				// ignore
164
			}
165
166
			public void widgetDefaultSelected(SelectionEvent e) {
167
				gotoSelectedElement();
168
			}
169
		});
170
	}
171
172
	private void handleTreeViewerMouseUp(final Tree tree, MouseEvent e) {
173
		if ((tree.getSelectionCount() < 1) || (e.button != 1) || (tree.equals(e.getSource()) == false)) {
174
			return;
175
		}
176
		// Selection is made in the selection changed listener
177
		Object object = tree.getItem(new Point(e.x, e.y));
178
		TreeItem selection = tree.getSelection()[0];
179
		if (selection.equals(object)) {
180
			gotoSelectedElement();
181
		}
182
	}
183
184
	private Object getSelectedElement() {
185
		if (commonViewer == null) {
186
			return null;
187
		}
188
		return ((IStructuredSelection) commonViewer.getSelection()).getFirstElement();
189
	}
190
191
	public void addDisposeListener(DisposeListener listener) {
192
		getShell().addDisposeListener(listener);
193
	}
194
195
	public void addFocusListener(FocusListener listener) {
196
		getShell().addFocusListener(listener);
197
	}
198
199
	public Point computeSizeHint() {
200
		// Note that it already has the persisted size if persisting is enabled.
201
		return getShell().getSize();
202
	}
203
204
	public void dispose() {
205
		close();
206
	}
207
208
	public boolean isFocusControl() {
209
		if (commonViewer.getControl().isFocusControl() || fFilterText.isFocusControl()) {
210
			return true;
211
		}
212
		return false;
213
	}
214
215
	public void removeDisposeListener(DisposeListener listener) {
216
		getShell().removeDisposeListener(listener);
217
	}
218
219
	public void removeFocusListener(FocusListener listener) {
220
		getShell().removeFocusListener(listener);
221
	}
222
223
	public void setBackgroundColor(Color background) {
224
		applyBackgroundColor(background, getContents());
225
	}
226
227
	public void setFocus() {
228
		getShell().forceFocus();
229
		fFilterText.setFocus();
230
	}
231
232
	public void setForegroundColor(Color foreground) {
233
		applyForegroundColor(foreground, getContents());
234
	}
235
236
	public void setInformation(String information) {
237
		// See IInformationControlExtension2
238
	}
239
240
	public void setLocation(Point location) {
241
		/*
242
		 * If the location is persisted, it gets managed by PopupDialog - fine. Otherwise, the location is
243
		 * computed in Window#getInitialLocation, which will center it in the parent shell / main
244
		 * monitor, which is wrong for two reasons:
245
		 * - we want to center over the editor / subject control, not the parent shell
246
		 * - the center is computed via the initalSize, which may be also wrong since the size may 
247
		 *   have been updated since via min/max sizing of AbstractInformationControlManager.
248
		 * In that case, override the location with the one computed by the manager. Note that
249
		 * the call to constrainShellSize in PopupDialog.open will still ensure that the shell is
250
		 * entirely visible.
251
		 */
252
		if (getPersistLocation() == false || getDialogSettings() == null) {
253
			getShell().setLocation(location);
254
		}
255
	}
256
257
	public void setSize(int width, int height) {
258
		getShell().setSize(width, height);
259
	}
260
261
	public void setSizeConstraints(int maxWidth, int maxHeight) {
262
		// Ignore
263
	}
264
265
	public void setVisible(boolean visible) {
266
		if (visible) {
267
			open();
268
		} else {
269
			saveDialogBounds(getShell());
270
			getShell().setVisible(false);
271
		}
272
	}
273
274
	public boolean hasContents() {
275
		if ((commonViewer == null) || (commonViewer.getInput() == null)) {
276
			return false;
277
		}
278
		return true;
279
	}
280
281
	public void setInput(Object input) {
282
		// Input comes from PDESourceInfoProvider.getInformation2()
283
		// The input should be a model object of some sort
284
		// Turn it into a structured selection and set the selection in the tree
285
		if (input != null) {
286
			commonViewer.setSelection(new StructuredSelection(input));
287
		}
288
	}
289
290
	public void widgetDisposed(DisposeEvent e) {
291
		// Note: We do not reuse the dialog
292
		commonViewer = null;
293
		fFilterText = null;
294
	}
295
296
	@Override
297
	protected Control createTitleControl(Composite parent) {
298
		// Applies only to dialog title - not body.  See createDialogArea
299
		// Create the text widget
300
		createUIWidgetFilterText(parent);
301
		// Add listeners to the text widget
302
		createUIListenersFilterText();
303
		// Return the text widget
304
		return fFilterText;
305
	}
306
307
	private void createUIWidgetFilterText(Composite parent) {
308
		// Create the widget
309
		fFilterText = new Text(parent, SWT.NONE);
310
		// Set the font 
311
		GC gc = new GC(parent);
312
		gc.setFont(parent.getFont());
313
		FontMetrics fontMetrics = gc.getFontMetrics();
314
		gc.dispose();
315
		// Create the layout
316
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
317
		data.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 1);
318
		data.horizontalAlignment = GridData.FILL;
319
		data.verticalAlignment = GridData.CENTER;
320
		fFilterText.setLayoutData(data);
321
	}
322
323
	/**
324
	 * 
325
	 */
326
	private void gotoSelectedElement() {
327
		Object selectedElement = getSelectedElement();
328
		if (selectedElement == null) {
329
			return;
330
		}
331
		dispose();
332
	}
333
334
	private void createUIListenersFilterText() {
335
		fFilterText.addKeyListener(new KeyListener() {
336
			public void keyPressed(KeyEvent e) {
337
				if (e.keyCode == 0x0D) {
338
					// Return key was pressed
339
					gotoSelectedElement();
340
				} else if (e.keyCode == SWT.ARROW_DOWN) {
341
					// Down key was pressed
342
					commonViewer.getTree().setFocus();
343
				} else if (e.keyCode == SWT.ARROW_UP) {
344
					// Up key was pressed
345
					commonViewer.getTree().setFocus();
346
				} else if (e.character == 0x1B) {
347
					// Escape key was pressed
348
					dispose();
349
				}
350
			}
351
352
			public void keyReleased(KeyEvent e) {
353
				// NO-OP
354
			}
355
		});
356
		// Handle text modify events
357
		fFilterText.addModifyListener(new ModifyListener() {
358
			public void modifyText(ModifyEvent e) {
359
				String text = ((Text) e.widget).getText();
360
				int length = text.length();
361
				if (length > 0) {
362
					// Append a '*' pattern to the end of the text value if it
363
					// does not have one already
364
					if (text.charAt(length - 1) != '*') {
365
						text = text + '*';
366
					}
367
					// Prepend a '*' pattern to the beginning of the text value
368
					// if it does not have one already
369
					if (text.charAt(0) != '*') {
370
						text = '*' + text;
371
					}
372
				}
373
				// Set and update the pattern
374
				setMatcherString(text, true);
375
			}
376
		});
377
	}
378
379
	/**
380
	 * Sets the patterns to filter out for the receiver.
381
	 * <p>
382
	 * The following characters have special meaning: ? => any character * => any string
383
	 * </p>
384
	 * 
385
	 * @param pattern
386
	 *            the pattern
387
	 * @param update
388
	 *            <code>true</code> if the viewer should be updated
389
	 */
390
	private void setMatcherString(String pattern, boolean update) {
391
		if (pattern.length() == 0) {
392
			fStringMatcher = null;
393
		} else {
394
			fStringMatcher = new StringMatcher(pattern, true, false);
395
		}
396
		// Update the name pattern filter on the tree viewer
397
		namePatternFilter.setStringMatcher(fStringMatcher);
398
		// Update the tree viewer according to the pattern
399
		if (update) {
400
			stringMatcherUpdated();
401
		}
402
	}
403
404
	/**
405
	 * The string matcher has been modified. The default implementation refreshes the view and selects the first matched
406
	 * element
407
	 */
408
	private void stringMatcherUpdated() {
409
		// Refresh the tree viewer to re-filter
410
		commonViewer.getControl().setRedraw(false);
411
		commonViewer.refresh();
412
		commonViewer.expandAll();
413
		selectFirstMatch();
414
		commonViewer.getControl().setRedraw(true);
415
	}
416
417
	/**
418
	 * Selects the first element in the tree which matches the current filter pattern.
419
	 */
420
	private void selectFirstMatch() {
421
		Tree tree = commonViewer.getTree();
422
		Object element = findFirstMatchToPattern(tree.getItems());
423
		if (element != null) {
424
			commonViewer.setSelection(new StructuredSelection(element), true);
425
		} else {
426
			commonViewer.setSelection(StructuredSelection.EMPTY);
427
		}
428
	}
429
430
	/**
431
	 * @param items
432
	 * @return
433
	 */
434
	private Object findFirstMatchToPattern(TreeItem[] items) {
435
		// Match the string pattern against labels
436
		ILabelProvider labelProvider = (ILabelProvider) commonViewer.getLabelProvider();
437
		// Process each item in the tree
438
		for (TreeItem item : items) {
439
			Object element = item.getData();
440
			// Return the first element if no pattern is set
441
			if (fStringMatcher == null) {
442
				return element;
443
			}
444
			// Return the element if it matches the pattern
445
			if (element != null) {
446
				String label = labelProvider.getText(element);
447
				if (fStringMatcher.match(label)) {
448
					return element;
449
				}
450
			}
451
			// Recursively check the elements children for a match
452
			element = findFirstMatchToPattern(item.getItems());
453
			// Return the child element match if found
454
			if (element != null) {
455
				return element;
456
			}
457
		}
458
		// No match found
459
		return null;
460
	}
461
462
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/views/messages.properties (+1 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
14
RepositoryElementActionGroup_Copy_Detail_Menu_Label=Copy Details
15
RepositoryElementActionGroup_Copy_Detail_Menu_Label=Copy Details
15
RepositoryElementActionGroup_New=New
16
RepositoryElementActionGroup_New=New
16
17
(-)src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java (-6 / +18 lines)
Lines 1239-1253 Link Here
1239
			if (part.getControl() != null) {
1239
			if (part.getControl() != null) {
1240
				if (ID_PART_ACTIONS.equals(part.getPartId())) {
1240
				if (ID_PART_ACTIONS.equals(part.getPartId())) {
1241
					// do not expand horizontally
1241
					// do not expand horizontally
1242
					GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(false, false).applyTo(
1242
					GridDataFactory.fillDefaults()
1243
							part.getControl());
1243
							.align(SWT.FILL, SWT.FILL)
1244
							.grab(false, false)
1245
							.applyTo(part.getControl());
1244
				} else {
1246
				} else {
1245
					if (part.getExpandVertically()) {
1247
					if (part.getExpandVertically()) {
1246
						GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(
1248
						GridDataFactory.fillDefaults()
1247
								part.getControl());
1249
								.align(SWT.FILL, SWT.FILL)
1250
								.grab(true, true)
1251
								.applyTo(part.getControl());
1248
					} else {
1252
					} else {
1249
						GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(
1253
						GridDataFactory.fillDefaults()
1250
								part.getControl());
1254
								.align(SWT.FILL, SWT.TOP)
1255
								.grab(true, false)
1256
								.applyTo(part.getControl());
1251
					}
1257
					}
1252
				}
1258
				}
1253
				// for outline
1259
				// for outline
Lines 1669-1673 Link Here
1669
//			toolBarManager.add(submitButtonContribution);
1675
//			toolBarManager.add(submitButtonContribution);
1670
//		}
1676
//		}
1671
//	}
1677
//	}
1678
	public boolean reveal(String key) {
1679
		return EditorUtil.reveal(form, key);
1680
	}
1672
1681
1682
	public void focusOn(Control control) {
1683
		EditorUtil.focusOn(form, control);
1684
	}
1673
}
1685
}

Return to bug 278102