blob: ede936c463324c2ed65eff8604b780321dfe99f2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/*******************************************************************************
* Copyright (c) 2004, 2009 Frank Becker and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Frank Becker - initial API and implementation
* Tasktop Technologies - improvements
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.ui.dialogs;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListSorter;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListSorter.GroupBy;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
/**
* @author Frank Becker
* @author Steffen Pingel
*/
public class TaskListSortDialog extends TaskCompareDialog {
private Combo modeCombo;
private final TaskListView taskListView;
public TaskListSortDialog(IShellProvider parentShell, TaskListView taskListView) {
super(parentShell, taskListView.getSorter().getComparator());
this.taskListView = taskListView;
setTitle(Messages.TaskListSortDialog_Title);
}
@Override
protected Control createContentArea(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(GridLayoutFactory.fillDefaults().create());
Group groupByComposite = new Group(container, SWT.NONE);
groupByComposite.setLayout(new GridLayout(2, false));
groupByComposite.setText(Messages.TaskListSortDialog_Queries_and_Categories);
GridDataFactory.fillDefaults().grab(true, false).applyTo(groupByComposite);
Label numberLabel = new Label(groupByComposite, SWT.NULL);
numberLabel.setText(Messages.TaskListSortDialog_Grouped_by);
modeCombo = new Combo(groupByComposite, SWT.READ_ONLY);
modeCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GroupBy[] values = TaskListSorter.GroupBy.values();
for (GroupBy groupBy : values) {
modeCombo.add(groupBy.getLabel());
}
modeCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
markDirty();
}
});
modeCombo.select(taskListView.getSorter().getGroupBy().ordinal());
Control child = super.createContentArea(container);
GridDataFactory.fillDefaults().grab(true, false).applyTo(child);
return container;
}
@Override
protected void okPressed() {
if (isDirty()) {
int selectionIndex = modeCombo.getSelectionIndex();
if (selectionIndex != -1) {
taskListView.getSorter().setGroupBy(TaskListSorter.GroupBy.values()[selectionIndex]);
}
}
super.okPressed();
}
}
|