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 250257 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java (+4 lines)
Lines 74-79 Link Here
74
74
75
	public static final String AUTO_EXPAND_TASK_LIST = "org.eclipse.mylyn.tasks.ui.auto.expand"; //$NON-NLS-1$
75
	public static final String AUTO_EXPAND_TASK_LIST = "org.eclipse.mylyn.tasks.ui.auto.expand"; //$NON-NLS-1$
76
76
77
	public static final String ATTACHMENT_SHOW_ID = "org.eclipse.mylyn.tasks.ui.attachment.showid"; //$NON-NLS-1$
78
79
	public static final String ATTACHMENT_COLUMN_TO_STD = "org.eclipse.mylyn.tasks.ui.attachment.column.to.std"; //$NON-NLS-1$
80
77
	/**
81
	/**
78
	 * Local subtasks are now enabled by default.
82
	 * Local subtasks are now enabled by default.
79
	 * 
83
	 * 
(-)src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java (-15 / +23 lines)
Lines 72-79 Link Here
72
import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
72
import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
73
import org.eclipse.mylyn.internal.tasks.core.TaskList;
73
import org.eclipse.mylyn.internal.tasks.core.TaskList;
74
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryDelta;
74
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryDelta;
75
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
76
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryDelta.Type;
75
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryDelta.Type;
76
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
77
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager;
77
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager;
78
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataStore;
78
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataStore;
79
import org.eclipse.mylyn.internal.tasks.core.externalization.ExternalizationManager;
79
import org.eclipse.mylyn.internal.tasks.core.externalization.ExternalizationManager;
Lines 91-102 Link Here
91
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
91
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
92
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
92
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
93
import org.eclipse.mylyn.tasks.core.ITask;
93
import org.eclipse.mylyn.tasks.core.ITask;
94
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
94
import org.eclipse.mylyn.tasks.core.ITaskActivationListener;
95
import org.eclipse.mylyn.tasks.core.ITaskActivationListener;
95
import org.eclipse.mylyn.tasks.core.ITaskContainer;
96
import org.eclipse.mylyn.tasks.core.ITaskContainer;
96
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
97
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
97
import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
98
import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
98
import org.eclipse.mylyn.tasks.core.TaskRepository;
99
import org.eclipse.mylyn.tasks.core.TaskRepository;
99
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
100
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
100
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
101
import org.eclipse.mylyn.tasks.ui.AbstractTaskRepositoryLinkProvider;
101
import org.eclipse.mylyn.tasks.ui.AbstractTaskRepositoryLinkProvider;
102
import org.eclipse.mylyn.tasks.ui.TasksUi;
102
import org.eclipse.mylyn.tasks.ui.TasksUi;
Lines 511-521 Link Here
511
			return;
511
			return;
512
		}
512
		}
513
513
514
		boolean enabled = TasksUiPlugin.getDefault().getPreferenceStore().getBoolean(
514
		boolean enabled = TasksUiPlugin.getDefault()
515
				ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED);
515
				.getPreferenceStore()
516
				.getBoolean(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED);
516
		if (enabled) {
517
		if (enabled) {
517
			long interval = TasksUiPlugin.getDefault().getPreferenceStore().getLong(
518
			long interval = TasksUiPlugin.getDefault()
518
					ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS);
519
					.getPreferenceStore()
520
					.getLong(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS);
519
			if (initial) {
521
			if (initial) {
520
				synchronizationScheduler.setInterval(DELAY_QUERY_REFRESH_ON_STARTUP, interval);
522
				synchronizationScheduler.setInterval(DELAY_QUERY_REFRESH_ON_STARTUP, interval);
521
			} else {
523
			} else {
Lines 889-903 Link Here
889
			}
891
			}
890
		}
892
		}
891
893
892
		if (!MonitorUiPlugin.getDefault().getPreferenceStore().getBoolean(
894
		if (!MonitorUiPlugin.getDefault()
893
				MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED + ".checked")) { //$NON-NLS-1$
895
				.getPreferenceStore()
896
				.getBoolean(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED + ".checked")) { //$NON-NLS-1$
894
			if (!taskActivityMonitor.getActivationHistory().isEmpty()) {
897
			if (!taskActivityMonitor.getActivationHistory().isEmpty()) {
895
				// tasks have been active before so fore preference enabled
898
				// tasks have been active before so fore preference enabled
896
				MonitorUiPlugin.getDefault().getPreferenceStore().setValue(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED,
899
				MonitorUiPlugin.getDefault()
897
						true);
900
						.getPreferenceStore()
898
			}
901
						.setValue(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED, true);
899
			MonitorUiPlugin.getDefault().getPreferenceStore().setValue(
902
			}
900
					MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED + ".checked", true); //$NON-NLS-1$
903
			MonitorUiPlugin.getDefault()
904
					.getPreferenceStore()
905
					.setValue(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED + ".checked", true); //$NON-NLS-1$
901
			MonitorUiPlugin.getDefault().savePluginPreferences();
906
			MonitorUiPlugin.getDefault().savePluginPreferences();
902
		}
907
		}
903
908
Lines 959-964 Link Here
959
		store.setDefault(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED, true);
964
		store.setDefault(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED, true);
960
965
961
		store.setDefault(ITasksUiPreferenceConstants.SERVICE_MESSAGE_URL, "http://eclipse.org/mylyn/message.xml"); //$NON-NLS-1$
966
		store.setDefault(ITasksUiPreferenceConstants.SERVICE_MESSAGE_URL, "http://eclipse.org/mylyn/message.xml"); //$NON-NLS-1$
967
		store.setDefault(ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID, false);
968
		store.setDefault(ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD, true);
962
	}
969
	}
963
970
964
	public static TaskActivityManager getTaskActivityManager() {
971
	public static TaskActivityManager getTaskActivityManager() {
Lines 977-984 Link Here
977
	}
984
	}
978
985
979
	public boolean groupSubtasks(ITaskContainer element) {
986
	public boolean groupSubtasks(ITaskContainer element) {
980
		boolean groupSubtasks = TasksUiPlugin.getDefault().getPreferenceStore().getBoolean(
987
		boolean groupSubtasks = TasksUiPlugin.getDefault()
981
				ITasksUiPreferenceConstants.GROUP_SUBTASKS);
988
				.getPreferenceStore()
989
				.getBoolean(ITasksUiPreferenceConstants.GROUP_SUBTASKS);
982
990
983
		if (element instanceof ITask) {
991
		if (element instanceof ITask) {
984
			AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(((ITask) element).getConnectorKind());
992
			AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(((ITask) element).getConnectorKind());
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider.java (-6 / +14 lines)
Lines 56-62 Link Here
56
56
57
	public Image getColumnImage(Object element, int columnIndex) {
57
	public Image getColumnImage(Object element, int columnIndex) {
58
		ITaskAttachment attachment = (ITaskAttachment) element;
58
		ITaskAttachment attachment = (ITaskAttachment) element;
59
		if (columnIndex == 0) {
59
		if (columnIndex == 1) {
60
			if (AttachmentUtil.isContext(attachment)) {
60
			if (AttachmentUtil.isContext(attachment)) {
61
				return CommonImages.getImage(TasksUiImages.CONTEXT_TRANSFER);
61
				return CommonImages.getImage(TasksUiImages.CONTEXT_TRANSFER);
62
			} else if (attachment.isPatch()) {
62
			} else if (attachment.isPatch()) {
Lines 76-82 Link Here
76
				}
76
				}
77
				return WorkbenchImages.getImage(ISharedImages.IMG_OBJ_FILE);
77
				return WorkbenchImages.getImage(ISharedImages.IMG_OBJ_FILE);
78
			}
78
			}
79
		} else if (columnIndex == 3) {
79
		} else if (columnIndex == 4) {
80
			return getAuthorImage(attachment.getAuthor(), attachment.getTaskRepository());
80
			return getAuthorImage(attachment.getAuthor(), attachment.getTaskRepository());
81
		}
81
		}
82
		return null;
82
		return null;
Lines 101-106 Link Here
101
		ITaskAttachment attachment = (ITaskAttachment) element;
101
		ITaskAttachment attachment = (ITaskAttachment) element;
102
		switch (columnIndex) {
102
		switch (columnIndex) {
103
		case 0:
103
		case 0:
104
			String a = attachment.getUrl();
105
			int i = a.indexOf("?id="); //$NON-NLS-1$
106
			if (i != -1) {
107
				return a.substring(i + 4);
108
			} else {
109
				return ""; //$NON-NLS-1$
110
			}
111
		case 1:
104
			if (AttachmentUtil.isContext(attachment)) {
112
			if (AttachmentUtil.isContext(attachment)) {
105
				return Messages.AttachmentTableLabelProvider_Task_Context;
113
				return Messages.AttachmentTableLabelProvider_Task_Context;
106
			} else if (attachment.isPatch()) {
114
			} else if (attachment.isPatch()) {
Lines 108-124 Link Here
108
			} else {
116
			} else {
109
				return " " + attachment.getFileName(); //$NON-NLS-1$
117
				return " " + attachment.getFileName(); //$NON-NLS-1$
110
			}
118
			}
111
		case 1:
112
			return attachment.getDescription();
113
		case 2:
119
		case 2:
120
			return attachment.getDescription();
121
		case 3:
114
			Long length = attachment.getLength();
122
			Long length = attachment.getLength();
115
			if (length < 0) {
123
			if (length < 0) {
116
				return "-"; //$NON-NLS-1$
124
				return "-"; //$NON-NLS-1$
117
			}
125
			}
118
			return sizeFormatter.format(length);
126
			return sizeFormatter.format(length);
119
		case 3:
120
			return (attachment.getAuthor() != null) ? attachment.getAuthor().toString() : ""; //$NON-NLS-1$
121
		case 4:
127
		case 4:
128
			return (attachment.getAuthor() != null) ? attachment.getAuthor().toString() : ""; //$NON-NLS-1$
129
		case 5:
122
			return (attachment.getCreationDate() != null) ? EditorUtil.formatDateTime(attachment.getCreationDate())
130
			return (attachment.getCreationDate() != null) ? EditorUtil.formatDateTime(attachment.getCreationDate())
123
					: ""; //$NON-NLS-1$
131
					: ""; //$NON-NLS-1$
124
		}
132
		}
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java (+2 lines)
Lines 113-118 Link Here
113
113
114
	public static String TaskEditorAttachmentPart_Description;
114
	public static String TaskEditorAttachmentPart_Description;
115
115
116
	public static String TaskEditorAttachmentPart_ID;
117
116
	public static String TaskEditorAttachmentPart_Name;
118
	public static String TaskEditorAttachmentPart_Name;
117
119
118
	public static String TaskEditorAttachmentPart_No_attachments;
120
	public static String TaskEditorAttachmentPart_No_attachments;
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java (-75 / +151 lines)
Lines 13-44 Link Here
13
13
14
package org.eclipse.mylyn.internal.tasks.ui.editors;
14
package org.eclipse.mylyn.internal.tasks.ui.editors;
15
15
16
import java.io.File;
16
import java.util.ArrayList;
17
import java.util.ArrayList;
17
import java.util.Date;
18
import java.util.Date;
18
import java.util.List;
19
import java.util.List;
19
20
21
import org.eclipse.core.runtime.IPath;
22
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.jface.action.Action;
23
import org.eclipse.jface.action.Action;
21
import org.eclipse.jface.action.IMenuListener;
22
import org.eclipse.jface.action.IMenuManager;
23
import org.eclipse.jface.action.MenuManager;
24
import org.eclipse.jface.action.MenuManager;
24
import org.eclipse.jface.action.ToolBarManager;
25
import org.eclipse.jface.action.ToolBarManager;
25
import org.eclipse.jface.layout.GridDataFactory;
26
import org.eclipse.jface.viewers.ArrayContentProvider;
26
import org.eclipse.jface.viewers.ArrayContentProvider;
27
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
27
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
28
import org.eclipse.jface.viewers.IOpenListener;
28
import org.eclipse.jface.viewers.IOpenListener;
29
import org.eclipse.jface.viewers.OpenEvent;
29
import org.eclipse.jface.viewers.OpenEvent;
30
import org.eclipse.jface.viewers.StructuredSelection;
30
import org.eclipse.jface.viewers.StructuredSelection;
31
import org.eclipse.jface.viewers.TableViewer;
32
import org.eclipse.jface.viewers.Viewer;
31
import org.eclipse.jface.viewers.Viewer;
33
import org.eclipse.jface.viewers.ViewerSorter;
32
import org.eclipse.jface.viewers.ViewerSorter;
34
import org.eclipse.jface.window.ToolTip;
33
import org.eclipse.jface.window.ToolTip;
35
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
34
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
36
import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
35
import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
36
import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
37
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
37
import org.eclipse.mylyn.internal.tasks.ui.commands.OpenTaskAttachmentHandler;
38
import org.eclipse.mylyn.internal.tasks.ui.commands.OpenTaskAttachmentHandler;
38
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiMenus;
39
import org.eclipse.mylyn.internal.tasks.ui.util.ColumnState;
40
import org.eclipse.mylyn.internal.tasks.ui.views.AbstractTableViewerConfigurator;
39
import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.Mode;
41
import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.Mode;
40
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
42
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
41
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
43
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
44
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
42
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
45
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
43
import org.eclipse.swt.SWT;
46
import org.eclipse.swt.SWT;
44
import org.eclipse.swt.events.SelectionAdapter;
47
import org.eclipse.swt.events.SelectionAdapter;
Lines 50-56 Link Here
50
import org.eclipse.swt.widgets.Label;
53
import org.eclipse.swt.widgets.Label;
51
import org.eclipse.swt.widgets.Menu;
54
import org.eclipse.swt.widgets.Menu;
52
import org.eclipse.swt.widgets.Table;
55
import org.eclipse.swt.widgets.Table;
53
import org.eclipse.swt.widgets.TableColumn;
54
import org.eclipse.ui.IWorkbenchPage;
56
import org.eclipse.ui.IWorkbenchPage;
55
import org.eclipse.ui.forms.events.ExpansionAdapter;
57
import org.eclipse.ui.forms.events.ExpansionAdapter;
56
import org.eclipse.ui.forms.events.ExpansionEvent;
58
import org.eclipse.ui.forms.events.ExpansionEvent;
Lines 66-77 Link Here
66
68
67
	private static final String ID_POPUP_MENU = "org.eclipse.mylyn.tasks.ui.editor.menu.attachments"; //$NON-NLS-1$
69
	private static final String ID_POPUP_MENU = "org.eclipse.mylyn.tasks.ui.editor.menu.attachments"; //$NON-NLS-1$
68
70
69
	private final String[] attachmentsColumns = { Messages.TaskEditorAttachmentPart_Name,
70
			Messages.TaskEditorAttachmentPart_Description, /*"Type", */Messages.TaskEditorAttachmentPart_Size,
71
			Messages.TaskEditorAttachmentPart_Creator, Messages.TaskEditorAttachmentPart_Created };
72
73
	private final int[] attachmentsColumnWidths = { 130, 150, /*100,*/70, 100, 100 };
74
75
	private List<TaskAttribute> attachments;
71
	private List<TaskAttribute> attachments;
76
72
77
	private boolean hasIncoming;
73
	private boolean hasIncoming;
Lines 80-158 Link Here
80
76
81
	private Composite attachmentsComposite;
77
	private Composite attachmentsComposite;
82
78
79
	private class AttachmentTableViewer extends AbstractTableViewerConfigurator {
80
		public AttachmentTableViewer(File stateFile) {
81
			super(stateFile);
82
			// ignore
83
		}
84
85
		@Override
86
		protected void adjustColumInfos() {
87
			boolean showAttachmentID = TasksUiPlugin.getDefault()
88
					.getPreferenceStore()
89
					.getBoolean(ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID);
90
			int idWidth = columnInfos.get(0).getWidths();
91
			if (!showAttachmentID && idWidth > 0) {
92
				columnInfos.get(0).setWidths(0);
93
			} else if (showAttachmentID && idWidth == 0) {
94
				columnInfos.get(0).setWidths(70);
95
			}
96
		}
97
98
		@Override
99
		protected void setDefaultColumnInfos() {
100
			columnInfos.add(new ColumnState(Messages.TaskEditorAttachmentPart_ID, 70));
101
			columnInfos.add(new ColumnState(Messages.TaskEditorAttachmentPart_Name, 130));
102
			columnInfos.add(new ColumnState(Messages.TaskEditorAttachmentPart_Description, 150));
103
			ColumnState columnState = new ColumnState(Messages.TaskEditorAttachmentPart_Size, 70);
104
			columnState.setAlignment(SWT.RIGHT);
105
			columnInfos.add(columnState);
106
			columnInfos.add(new ColumnState(Messages.TaskEditorAttachmentPart_Creator, 100));
107
			columnInfos.add(new ColumnState(Messages.TaskEditorAttachmentPart_Created, 100));
108
109
			orderArray = new int[6];
110
			for (int i = 0; i < 6; i++) {
111
				orderArray[i] = i;
112
			}
113
114
		}
115
116
		@Override
117
		protected void setupTableViewer() {
118
			tableViewer.setUseHashlookup(true);
119
			ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);
120
121
			tableViewer.setSorter(new ViewerSorter() {
122
				@Override
123
				public int compare(Viewer viewer, Object e1, Object e2) {
124
					ITaskAttachment attachment1 = (ITaskAttachment) e1;
125
					ITaskAttachment attachment2 = (ITaskAttachment) e2;
126
					Date created1 = attachment1.getCreationDate();
127
					Date created2 = attachment2.getCreationDate();
128
					if (created1 != null && created2 != null) {
129
						return created1.compareTo(created2);
130
					} else if (created1 == null && created2 != null) {
131
						return -1;
132
					} else if (created1 != null && created2 == null) {
133
						return 1;
134
					} else {
135
						return 0;
136
					}
137
				}
138
			});
139
			List<ITaskAttachment> attachmentList = new ArrayList<ITaskAttachment>(attachments.size());
140
			for (TaskAttribute attribute : attachments) {
141
				TaskAttachment taskAttachment = new TaskAttachment(getModel().getTaskRepository(),
142
						getModel().getTask(), attribute);
143
				getTaskData().getAttributeMapper().updateTaskAttachment(taskAttachment, attribute);
144
				attachmentList.add(taskAttachment);
145
146
				tableViewer.setContentProvider(new ArrayContentProvider());
147
				tableViewer.setLabelProvider(new AttachmentTableLabelProvider(getModel(),
148
						getTaskEditorPage().getAttributeEditorToolkit()));
149
				tableViewer.addOpenListener(new IOpenListener() {
150
					public void open(OpenEvent event) {
151
						if (!event.getSelection().isEmpty()) {
152
							StructuredSelection selection = (StructuredSelection) event.getSelection();
153
							ITaskAttachment attachment = (ITaskAttachment) selection.getFirstElement();
154
							TasksUiUtil.openUrl(attachment.getUrl());
155
						}
156
					}
157
				});
158
				tableViewer.addSelectionChangedListener(getTaskEditorPage());
159
				tableViewer.setInput(attachmentList.toArray());
160
			}
161
		}
162
	}
163
164
	private AttachmentTableViewer attachmentsViewer;
165
166
	private boolean propertyListenerIstalled = false;
167
83
	public TaskEditorAttachmentPart() {
168
	public TaskEditorAttachmentPart() {
84
		setPartName(Messages.TaskEditorAttachmentPart_Attachments);
169
		setPartName(Messages.TaskEditorAttachmentPart_Attachments);
85
	}
170
	}
86
171
87
	private void createAttachmentTable(FormToolkit toolkit, final Composite attachmentsComposite) {
172
	private final org.eclipse.jface.util.IPropertyChangeListener PROPERTY_LISTENER = new org.eclipse.jface.util.IPropertyChangeListener() {
88
		Table attachmentsTable = toolkit.createTable(attachmentsComposite, SWT.MULTI | SWT.FULL_SELECTION);
89
		attachmentsTable.setLinesVisible(true);
90
		attachmentsTable.setHeaderVisible(true);
91
		attachmentsTable.setLayout(new GridLayout());
92
		GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).hint(500, SWT.DEFAULT).applyTo(
93
				attachmentsTable);
94
		attachmentsTable.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
95
96
		for (int i = 0; i < attachmentsColumns.length; i++) {
97
			TableColumn column = new TableColumn(attachmentsTable, SWT.LEFT, i);
98
			column.setText(attachmentsColumns[i]);
99
			column.setWidth(attachmentsColumnWidths[i]);
100
		}
101
		// size column
102
		attachmentsTable.getColumn(2).setAlignment(SWT.RIGHT);
103
104
		TableViewer attachmentsViewer = new TableViewer(attachmentsTable);
105
		attachmentsViewer.setUseHashlookup(true);
106
		attachmentsViewer.setColumnProperties(attachmentsColumns);
107
		ColumnViewerToolTipSupport.enableFor(attachmentsViewer, ToolTip.NO_RECREATE);
108
173
109
		attachmentsViewer.setSorter(new ViewerSorter() {
174
		public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
110
			@Override
175
			if (event.getProperty().equals(ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD)) {
111
			public int compare(Viewer viewer, Object e1, Object e2) {
176
				if (TasksUiPlugin.getDefault()
112
				ITaskAttachment attachment1 = (ITaskAttachment) e1;
177
						.getPreferenceStore()
113
				ITaskAttachment attachment2 = (ITaskAttachment) e2;
178
						.getBoolean(ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD)) {
114
				Date created1 = attachment1.getCreationDate();
179
					if (attachmentsViewer != null) {
115
				Date created2 = attachment2.getCreationDate();
180
						attachmentsViewer.resetColumnInfosToDefault();
116
				if (created1 != null && created2 != null) {
181
						Table table = attachmentsViewer.getTable();
117
					return created1.compareTo(created2);
182
						if (!table.isDisposed()) {
118
				} else if (created1 == null && created2 != null) {
183
							if (TasksUiPlugin.getDefault()
119
					return -1;
184
									.getPreferenceStore()
120
				} else if (created1 != null && created2 == null) {
185
									.getBoolean(ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID)) {
121
					return 1;
186
								table.getColumn(0).setWidth(70);
122
				} else {
187
							} else {
123
					return 0;
188
								table.getColumn(0).setWidth(0);
189
							}
190
						}
191
					} else {
192
						IPath stateLocation = Platform.getStateLocation(TasksUiPlugin.getDefault().getBundle());
193
						File attachmentStateFile = stateLocation.append("TaskEditorAttachment.obj").toFile(); //$NON-NLS-1$
194
						attachmentStateFile.delete();
195
					}
196
				}
197
			} else if (event.getProperty().equals(ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID)) {
198
				if (attachmentsViewer != null) {
199
					Table table = attachmentsViewer.getTable();
200
					if (!table.isDisposed()) {
201
						if (TasksUiPlugin.getDefault()
202
								.getPreferenceStore()
203
								.getBoolean(ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID)) {
204
							table.getColumn(0).setWidth(70);
205
						} else {
206
							table.getColumn(0).setWidth(0);
207
						}
208
					}
124
				}
209
				}
125
			}
210
			}
126
		});
211
		}
127
212
	};
128
		List<ITaskAttachment> attachmentList = new ArrayList<ITaskAttachment>(attachments.size());
129
		for (TaskAttribute attribute : attachments) {
130
			TaskAttachment taskAttachment = new TaskAttachment(getModel().getTaskRepository(), getModel().getTask(),
131
					attribute);
132
			getTaskData().getAttributeMapper().updateTaskAttachment(taskAttachment, attribute);
133
			attachmentList.add(taskAttachment);
134
		}
135
		attachmentsViewer.setContentProvider(new ArrayContentProvider());
136
		attachmentsViewer.setLabelProvider(new AttachmentTableLabelProvider(getModel(),
137
				getTaskEditorPage().getAttributeEditorToolkit()));
138
		attachmentsViewer.addOpenListener(new IOpenListener() {
139
			public void open(OpenEvent event) {
140
				openAttachments(event);
141
			}
142
		});
143
		attachmentsViewer.addSelectionChangedListener(getTaskEditorPage());
144
		attachmentsViewer.setInput(attachmentList.toArray());
145
213
214
	private void createAttachmentTable(FormToolkit toolkit, final Composite attachmentsComposite) {
215
		IPath stateLocation = Platform.getStateLocation(TasksUiPlugin.getDefault().getBundle());
216
		File attachmentStateFile = stateLocation.append("TaskEditorAttachment.obj").toFile(); //$NON-NLS-1$
217
		attachmentsViewer = new AttachmentTableViewer(attachmentStateFile);
218
		attachmentsViewer.create(toolkit, attachmentsComposite, 5);
146
		menuManager = new MenuManager();
219
		menuManager = new MenuManager();
147
		menuManager.setRemoveAllWhenShown(true);
220
		menuManager.setRemoveAllWhenShown(true);
148
		menuManager.addMenuListener(new IMenuListener() {
221
149
			public void menuAboutToShow(IMenuManager manager) {
222
		Menu menu = menuManager.createContextMenu(attachmentsViewer.getTable());
150
				TasksUiMenus.fillTaskAttachmentMenu(manager);
223
		attachmentsViewer.getTable().setMenu(menu);
151
			}
152
		});
153
		getTaskEditorPage().getEditorSite().registerContextMenu(ID_POPUP_MENU, menuManager, attachmentsViewer, true);
154
		Menu menu = menuManager.createContextMenu(attachmentsTable);
155
		attachmentsTable.setMenu(menu);
156
	}
224
	}
157
225
158
	private void createButtons(Composite attachmentsComposite, FormToolkit toolkit) {
226
	private void createButtons(Composite attachmentsComposite, FormToolkit toolkit) {
Lines 227-232 Link Here
227
295
228
	@Override
296
	@Override
229
	public void dispose() {
297
	public void dispose() {
298
		if (propertyListenerIstalled) {
299
			TasksUiPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(PROPERTY_LISTENER);
300
			propertyListenerIstalled = false;
301
		}
230
		if (menuManager != null) {
302
		if (menuManager != null) {
231
			menuManager.dispose();
303
			menuManager.dispose();
232
		}
304
		}
Lines 242-247 Link Here
242
				break;
314
				break;
243
			}
315
			}
244
		}
316
		}
317
		if (!propertyListenerIstalled) {
318
			TasksUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(PROPERTY_LISTENER);
319
			propertyListenerIstalled = true;
320
		}
245
	}
321
	}
246
322
247
	@Override
323
	@Override
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties (+1 lines)
Lines 60-65 Link Here
60
TaskEditorAttachmentPart_Created=Created
60
TaskEditorAttachmentPart_Created=Created
61
TaskEditorAttachmentPart_Creator=Creator
61
TaskEditorAttachmentPart_Creator=Creator
62
TaskEditorAttachmentPart_Description=Description
62
TaskEditorAttachmentPart_Description=Description
63
TaskEditorAttachmentPart_ID=ID
63
TaskEditorAttachmentPart_Name=Name
64
TaskEditorAttachmentPart_Name=Name
64
TaskEditorAttachmentPart_No_attachments=No attachments
65
TaskEditorAttachmentPart_No_attachments=No attachments
65
TaskEditorAttachmentPart_Size=Size
66
TaskEditorAttachmentPart_Size=Size
(-)src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java (+6 lines)
Lines 57-62 Link Here
57
57
58
	public static String TasksUiPreferencePage_highlight_current_line;
58
	public static String TasksUiPreferencePage_highlight_current_line;
59
59
60
	public static String TasksUiPreferencePage_reset_to_standard_Column;
61
60
	public static String TasksUiPreferencePage_Rich_Editor__Recommended_;
62
	public static String TasksUiPreferencePage_Rich_Editor__Recommended_;
61
63
62
	public static String TasksUiPreferencePage_Scheduling;
64
	public static String TasksUiPreferencePage_Scheduling;
Lines 65-70 Link Here
65
67
66
	public static String TasksUiPreferencePage_show_service_messages;
68
	public static String TasksUiPreferencePage_show_service_messages;
67
69
70
	public static String TasksUiPreferencePage_Show_Attachment_ID;
71
68
	public static String TasksUiPreferencePage_Show_tooltip_on_hover_Label;
72
	public static String TasksUiPreferencePage_Show_tooltip_on_hover_Label;
69
73
70
	public static String TasksUiPreferencePage_Specify_the_folder_for_tasks;
74
	public static String TasksUiPreferencePage_Specify_the_folder_for_tasks;
Lines 85-90 Link Here
85
89
86
	public static String TasksUiPreferencePage_Task_Editing;
90
	public static String TasksUiPreferencePage_Task_Editing;
87
91
92
	public static String TasksUiPreferencePage_Task_Editor_Attachment_Table;
93
88
	public static String TasksUiPreferencePage_Task_List_Group;
94
	public static String TasksUiPreferencePage_Task_List_Group;
89
95
90
	public static String TasksUiPreferencePage_Task_Timing;
96
	public static String TasksUiPreferencePage_Task_Timing;
(-)src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java (-26 / +73 lines)
Lines 112-117 Link Here
112
	// Disabled for initial 3.4 release as per bug#263528
112
	// Disabled for initial 3.4 release as per bug#263528
113
//	private Button taskListServiceMessageEnabledButton;
113
//	private Button taskListServiceMessageEnabledButton;
114
114
115
	private Button attachmentShowID;
116
117
	private Button attachmentColumnUseStdWidth;
118
115
	public TasksUiPreferencePage() {
119
	public TasksUiPreferencePage() {
116
		super();
120
		super();
117
		setPreferenceStore(TasksUiPlugin.getDefault().getPreferenceStore());
121
		setPreferenceStore(TasksUiPlugin.getDefault().getPreferenceStore());
Lines 140-145 Link Here
140
		}
144
		}
141
145
142
		createLinks(advanced);
146
		createLinks(advanced);
147
		createAttachmentTable(advanced);
143
		updateRefreshGroupEnablements();
148
		updateRefreshGroupEnablements();
144
		applyDialogFont(container);
149
		applyDialogFont(container);
145
		return container;
150
		return container;
Lines 218-230 Link Here
218
		getPreferenceStore().setValue(ITasksUiPreferenceConstants.WEEK_START_DAY, getWeekStartValue());
223
		getPreferenceStore().setValue(ITasksUiPreferenceConstants.WEEK_START_DAY, getWeekStartValue());
219
		//getPreferenceStore().setValue(TasksUiPreferenceConstants.PLANNING_STARTHOUR, hourDayStart.getSelection());
224
		//getPreferenceStore().setValue(TasksUiPreferenceConstants.PLANNING_STARTHOUR, hourDayStart.getSelection());
220
//		getPreferenceStore().setValue(TasksUiPreferenceConstants.PLANNING_ENDHOUR, hourDayEnd.getSelection());
225
//		getPreferenceStore().setValue(TasksUiPreferenceConstants.PLANNING_ENDHOUR, hourDayEnd.getSelection());
221
		MonitorUiPlugin.getDefault().getPreferenceStore().setValue(ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED,
226
		MonitorUiPlugin.getDefault()
222
				timeoutEnabledButton.getSelection());
227
				.getPreferenceStore()
223
		MonitorUiPlugin.getDefault().getPreferenceStore().setValue(ActivityContextManager.ACTIVITY_TIMEOUT,
228
				.setValue(ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED, timeoutEnabledButton.getSelection());
224
				timeoutMinutes.getSelection() * (60 * 1000));
229
		MonitorUiPlugin.getDefault()
225
230
				.getPreferenceStore()
226
		MonitorUiPlugin.getDefault().getPreferenceStore().setValue(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED,
231
				.setValue(ActivityContextManager.ACTIVITY_TIMEOUT, timeoutMinutes.getSelection() * (60 * 1000));
227
				activityTrackingEnabledButton.getSelection());
232
233
		MonitorUiPlugin.getDefault()
234
				.getPreferenceStore()
235
				.setValue(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED, activityTrackingEnabledButton.getSelection());
228
236
229
		String taskDirectory = taskDirectoryText.getText();
237
		String taskDirectory = taskDirectoryText.getText();
230
		taskDirectory = taskDirectory.replaceAll(BACKSLASH_MULTI, FORWARDSLASH);
238
		taskDirectory = taskDirectory.replaceAll(BACKSLASH_MULTI, FORWARDSLASH);
Lines 254-259 Link Here
254
				return false;
262
				return false;
255
			}
263
			}
256
		}
264
		}
265
		getPreferenceStore().setValue(ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID, attachmentShowID.getSelection());
266
		getPreferenceStore().setValue(ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD,
267
				attachmentColumnUseStdWidth.getSelection());
268
		getPreferenceStore().setValue(ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD, false);
269
270
		attachmentColumnUseStdWidth.setSelection(false);
257
271
258
		return true;
272
		return true;
259
	}
273
	}
Lines 294-304 Link Here
294
		int minutes = MonitorUiPlugin.getDefault().getPreferenceStore().getInt(ActivityContextManager.ACTIVITY_TIMEOUT)
308
		int minutes = MonitorUiPlugin.getDefault().getPreferenceStore().getInt(ActivityContextManager.ACTIVITY_TIMEOUT)
295
				/ MS_MINUTES;
309
				/ MS_MINUTES;
296
		timeoutMinutes.setSelection(minutes);
310
		timeoutMinutes.setSelection(minutes);
297
		timeoutEnabledButton.setSelection(MonitorUiPlugin.getDefault().getPreferenceStore().getBoolean(
311
		timeoutEnabledButton.setSelection(MonitorUiPlugin.getDefault()
298
				ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED));
312
				.getPreferenceStore()
299
313
				.getBoolean(ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED));
300
		activityTrackingEnabledButton.setSelection(MonitorUiPlugin.getDefault().getPreferenceStore().getBoolean(
314
301
				MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED));
315
		activityTrackingEnabledButton.setSelection(MonitorUiPlugin.getDefault()
316
				.getPreferenceStore()
317
				.getBoolean(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED));
318
		attachmentShowID.setSelection(getPreferenceStore().getBoolean(ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID));
319
		attachmentColumnUseStdWidth.setSelection(getPreferenceStore().getBoolean(
320
				ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD));
302
321
303
		return true;
322
		return true;
304
	}
323
	}
Lines 337-351 Link Here
337
		weekStartCombo.select(getPreferenceStore().getDefaultInt(ITasksUiPreferenceConstants.WEEK_START_DAY) - 1);
356
		weekStartCombo.select(getPreferenceStore().getDefaultInt(ITasksUiPreferenceConstants.WEEK_START_DAY) - 1);
338
		//	hourDayStart.setSelection(getPreferenceStore().getDefaultInt(TasksUiPreferenceConstants.PLANNING_STARTHOUR));
357
		//	hourDayStart.setSelection(getPreferenceStore().getDefaultInt(TasksUiPreferenceConstants.PLANNING_STARTHOUR));
339
//		hourDayEnd.setSelection(getPreferenceStore().getDefaultInt(TasksUiPreferenceConstants.PLANNING_ENDHOUR));
358
//		hourDayEnd.setSelection(getPreferenceStore().getDefaultInt(TasksUiPreferenceConstants.PLANNING_ENDHOUR));
340
		int activityTimeoutMinutes = MonitorUiPlugin.getDefault().getPreferenceStore().getDefaultInt(
359
		int activityTimeoutMinutes = MonitorUiPlugin.getDefault()
341
				ActivityContextManager.ACTIVITY_TIMEOUT)
360
				.getPreferenceStore()
361
				.getDefaultInt(ActivityContextManager.ACTIVITY_TIMEOUT)
342
				/ MS_MINUTES;
362
				/ MS_MINUTES;
343
		timeoutMinutes.setSelection(activityTimeoutMinutes);
363
		timeoutMinutes.setSelection(activityTimeoutMinutes);
344
		timeoutEnabledButton.setSelection(MonitorUiPlugin.getDefault().getPreferenceStore().getDefaultBoolean(
364
		timeoutEnabledButton.setSelection(MonitorUiPlugin.getDefault()
345
				ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED));
365
				.getPreferenceStore()
346
366
				.getDefaultBoolean(ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED));
347
		activityTrackingEnabledButton.setSelection(MonitorUiPlugin.getDefault().getPreferenceStore().getDefaultBoolean(
367
348
				MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED));
368
		activityTrackingEnabledButton.setSelection(MonitorUiPlugin.getDefault()
369
				.getPreferenceStore()
370
				.getDefaultBoolean(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED));
371
		attachmentShowID.setSelection(getPreferenceStore().getDefaultBoolean(
372
				ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID));
373
		attachmentColumnUseStdWidth.setSelection(getPreferenceStore().getDefaultBoolean(
374
				ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD));
349
375
350
		updateRefreshGroupEnablements();
376
		updateRefreshGroupEnablements();
351
	}
377
	}
Lines 509-519 Link Here
509
		group.setLayout(new GridLayout(3, false));
535
		group.setLayout(new GridLayout(3, false));
510
		group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
536
		group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
511
537
512
		boolean activityTrackingEnabled = MonitorUiPlugin.getDefault().getPreferenceStore().getBoolean(
538
		boolean activityTrackingEnabled = MonitorUiPlugin.getDefault()
513
				MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED);
539
				.getPreferenceStore()
514
540
				.getBoolean(MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED);
515
		boolean timeoutEnabled = MonitorUiPlugin.getDefault().getPreferenceStore().getBoolean(
541
516
				ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED);
542
		boolean timeoutEnabled = MonitorUiPlugin.getDefault()
543
				.getPreferenceStore()
544
				.getBoolean(ActivityContextManager.ACTIVITY_TIMEOUT_ENABLED);
517
545
518
		activityTrackingEnabledButton = new Button(group, SWT.CHECK);
546
		activityTrackingEnabledButton = new Button(group, SWT.CHECK);
519
		activityTrackingEnabledButton.setText(Messages.TasksUiPreferencePage_Enable_Time_Tracking);
547
		activityTrackingEnabledButton.setText(Messages.TasksUiPreferencePage_Enable_Time_Tracking);
Lines 546-553 Link Here
546
		timeoutMinutes.setIncrement(5);
574
		timeoutMinutes.setIncrement(5);
547
		timeoutMinutes.setMaximum(60);
575
		timeoutMinutes.setMaximum(60);
548
		timeoutMinutes.setMinimum(1);
576
		timeoutMinutes.setMinimum(1);
549
		long minutes = MonitorUiPlugin.getDefault().getPreferenceStore().getLong(
577
		long minutes = MonitorUiPlugin.getDefault()
550
				ActivityContextManager.ACTIVITY_TIMEOUT)
578
				.getPreferenceStore()
579
				.getLong(ActivityContextManager.ACTIVITY_TIMEOUT)
551
				/ MS_MINUTES;
580
				/ MS_MINUTES;
552
		timeoutMinutes.setSelection((int) minutes);
581
		timeoutMinutes.setSelection((int) minutes);
553
		timeoutMinutes.addSelectionListener(new SelectionAdapter() {
582
		timeoutMinutes.addSelectionListener(new SelectionAdapter() {
Lines 639-642 Link Here
639
		}
668
		}
640
		super.dispose();
669
		super.dispose();
641
	}
670
	}
671
672
	private void createAttachmentTable(Composite parent) {
673
		Group attachmentContainer = new Group(parent, SWT.SHADOW_ETCHED_IN);
674
		attachmentContainer.setLayout(new GridLayout(2, false));
675
		attachmentContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
676
		attachmentContainer.setText(Messages.TasksUiPreferencePage_Task_Editor_Attachment_Table);
677
678
		attachmentColumnUseStdWidth = new Button(attachmentContainer, SWT.CHECK);
679
		attachmentColumnUseStdWidth.setText(Messages.TasksUiPreferencePage_reset_to_standard_Column);
680
		attachmentColumnUseStdWidth.setSelection(getPreferenceStore().getBoolean(
681
				ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD));
682
683
		attachmentShowID = new Button(attachmentContainer, SWT.CHECK);
684
		attachmentShowID.setText(Messages.TasksUiPreferencePage_Show_Attachment_ID);
685
		attachmentShowID.setSelection(getPreferenceStore().getBoolean(ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID));
686
687
	}
688
642
}
689
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties (+3 lines)
Lines 24-33 Link Here
24
TasksUiPreferencePage_minutes_of_inactivity=minutes of inactivity.
24
TasksUiPreferencePage_minutes_of_inactivity=minutes of inactivity.
25
TasksUiPreferencePage_A_new_empty_Task_List_will_be_created_in_the_chosen_directory_if_one_does_not_already_exists=A new empty Task List will be created in the chosen directory if one does not already exists. Your previous directory and its contents will not be deleted.\n\nProceed?
25
TasksUiPreferencePage_A_new_empty_Task_List_will_be_created_in_the_chosen_directory_if_one_does_not_already_exists=A new empty Task List will be created in the chosen directory if one does not already exists. Your previous directory and its contents will not be deleted.\n\nProceed?
26
TasksUiPreferencePage_highlight_current_line=Highlight current line
26
TasksUiPreferencePage_highlight_current_line=Highlight current line
27
TasksUiPreferencePage_reset_to_standard_Column=reset to standard Column
27
TasksUiPreferencePage_Rich_Editor__Recommended_=Rich Editor (Recommended)
28
TasksUiPreferencePage_Rich_Editor__Recommended_=Rich Editor (Recommended)
28
TasksUiPreferencePage_Scheduling=Scheduling
29
TasksUiPreferencePage_Scheduling=Scheduling
29
TasksUiPreferencePage_See_X_for_configuring_Task_List_colors=See <a>''{0}''</a> for configuring Task List colors.
30
TasksUiPreferencePage_See_X_for_configuring_Task_List_colors=See <a>''{0}''</a> for configuring Task List colors.
30
TasksUiPreferencePage_show_service_messages=Show service messages
31
TasksUiPreferencePage_show_service_messages=Show service messages
32
TasksUiPreferencePage_Show_Attachment_ID=Show Attachment ID
31
TasksUiPreferencePage_Show_tooltip_on_hover_Label=Show task overview popups on hover
33
TasksUiPreferencePage_Show_tooltip_on_hover_Label=Show task overview popups on hover
32
TasksUiPreferencePage_Specify_the_folder_for_tasks=Specify the folder for tasks
34
TasksUiPreferencePage_Specify_the_folder_for_tasks=Specify the folder for tasks
33
TasksUiPreferencePage_Stop_time_accumulation_after=Stop time accumulation after
35
TasksUiPreferencePage_Stop_time_accumulation_after=Stop time accumulation after
Lines 38-43 Link Here
38
TasksUiPreferencePage_Task_Data=Task Data
40
TasksUiPreferencePage_Task_Data=Task Data
39
TasksUiPreferencePage_Task_Data_Directory_Error=Task Data Directory Error
41
TasksUiPreferencePage_Task_Data_Directory_Error=Task Data Directory Error
40
TasksUiPreferencePage_Task_Editing=Task Editing
42
TasksUiPreferencePage_Task_Editing=Task Editing
43
TasksUiPreferencePage_Task_Editor_Attachment_Table=Task Editor Attachment Table
41
TasksUiPreferencePage_Task_List_Group=Task List
44
TasksUiPreferencePage_Task_List_Group=Task List
42
TasksUiPreferencePage_Task_Timing=Time Tracking
45
TasksUiPreferencePage_Task_Timing=Time Tracking
43
TasksUiPreferencePage_Track_Time_Spent=Track time spent within Eclipse when a task is active
46
TasksUiPreferencePage_Track_Time_Spent=Track time spent within Eclipse when a task is active
(-)src/org/eclipse/mylyn/internal/tasks/ui/util/ColumnState.java (+74 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.util;
13
14
import java.io.Serializable;
15
16
import org.eclipse.swt.SWT;
17
import org.eclipse.ui.IMemento;
18
19
public class ColumnState implements Serializable {
20
21
	private static final long serialVersionUID = 6303376618126218826L;
22
23
	private String name;
24
25
	private int widths;
26
27
	private int alignment;
28
29
	public ColumnState(String name, int widths) {
30
		super();
31
		this.name = name;
32
		this.widths = widths;
33
		alignment = SWT.LEFT;
34
	}
35
36
	public String getName() {
37
		return name;
38
	}
39
40
	public void setName(String name) {
41
		this.name = name;
42
	}
43
44
	public int getWidths() {
45
		return widths;
46
	}
47
48
	public void setWidths(int widths) {
49
		this.widths = widths;
50
	}
51
52
	public int getAlignment() {
53
		return alignment;
54
	}
55
56
	public void setAlignment(int alignment) {
57
		this.alignment = alignment;
58
	}
59
60
	public void saveState(IMemento memento) {
61
		IMemento child = memento.createChild("ColumnState"); //$NON-NLS-1$
62
		child.putString("name", name); //$NON-NLS-1$
63
		child.putInteger("widths", widths); //$NON-NLS-1$
64
		child.putInteger("alignment", alignment); //$NON-NLS-1$
65
66
	}
67
68
	public static ColumnState createState(IMemento memento) {
69
		ColumnState erg;
70
		erg = new ColumnState(memento.getString("name"), memento.getInteger("widths"));
71
		erg.setAlignment(memento.getInteger("alignment"));
72
		return erg;
73
	}
74
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/views/AbstractTableViewerConfigurator.java (+226 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 java.io.File;
15
import java.io.FileReader;
16
import java.io.FileWriter;
17
import java.io.IOException;
18
import java.util.ArrayList;
19
20
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.Status;
22
import org.eclipse.jface.layout.GridDataFactory;
23
import org.eclipse.jface.viewers.ISelection;
24
import org.eclipse.jface.viewers.ISelectionChangedListener;
25
import org.eclipse.jface.viewers.ISelectionProvider;
26
import org.eclipse.jface.viewers.TableViewer;
27
import org.eclipse.mylyn.commons.core.StatusHandler;
28
import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
29
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
30
import org.eclipse.mylyn.internal.tasks.ui.util.ColumnState;
31
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.events.ControlEvent;
33
import org.eclipse.swt.events.ControlListener;
34
import org.eclipse.swt.layout.GridLayout;
35
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.swt.widgets.Table;
37
import org.eclipse.swt.widgets.TableColumn;
38
import org.eclipse.ui.IMemento;
39
import org.eclipse.ui.WorkbenchException;
40
import org.eclipse.ui.XMLMemento;
41
import org.eclipse.ui.forms.widgets.FormToolkit;
42
43
public abstract class AbstractTableViewerConfigurator implements ISelectionProvider {
44
	protected TableViewer tableViewer;
45
46
	protected Table table;
47
48
	private final File stateFile;
49
50
	protected ArrayList<ColumnState> columnInfos;
51
52
	protected int[] orderArray;
53
54
	public AbstractTableViewerConfigurator(File stateFile) {
55
		super();
56
		this.stateFile = stateFile;
57
	}
58
59
	abstract protected void setDefaultColumnInfos();
60
61
	abstract protected void setupTableViewer();
62
63
	private void readStateFile() {
64
		if (stateFile.exists()) {
65
			try {
66
				FileReader reader = new FileReader(stateFile);
67
				try {
68
					XMLMemento memento = XMLMemento.createReadRoot(reader);
69
					IMemento child = memento.getChild("Columns"); //$NON-NLS-1$
70
					int size = child.getInteger("count"); //$NON-NLS-1$
71
					IMemento[] children = memento.getChildren("ColumnState"); //$NON-NLS-1$
72
					for (int i = 0; i < size; i++) {
73
						columnInfos.add(ColumnState.createState(children[i]));
74
					}
75
					String orderString = child.getString("order"); //$NON-NLS-1$
76
					String[] orderStringArray = orderString.split(","); //$NON-NLS-1$
77
					orderArray = new int[orderStringArray.length];
78
					for (int i = 0; i < orderStringArray.length; i++) {
79
						orderArray[i] = Integer.parseInt(orderStringArray[i]);
80
					}
81
				} catch (WorkbenchException e) {
82
					StatusHandler.log(new Status(IStatus.WARNING, TasksUiPlugin.ID_PLUGIN,
83
							"The TableViewerState cache could not be read", e)); //$NON-NLS-1$
84
				} finally {
85
					reader.close();
86
				}
87
			} catch (IOException e) {
88
				StatusHandler.log(new Status(IStatus.WARNING, TasksUiPlugin.ID_PLUGIN,
89
						"The TableViewerState cache could not be read", e)); //$NON-NLS-1$
90
			}
91
		}
92
93
	}
94
95
	protected void writeStateFile() {
96
97
		if (stateFile == null) {
98
			return;
99
		}
100
101
		XMLMemento memento = XMLMemento.createWriteRoot("TableViewerState"); //$NON-NLS-1$
102
		IMemento child = memento.createChild("Columns"); //$NON-NLS-1$
103
		child.putInteger("count", columnInfos.size()); //$NON-NLS-1$
104
		for (ColumnState col : columnInfos) {
105
			col.saveState(memento);
106
		}
107
108
		int[] colOrder = table.getColumnOrder();
109
		String orderString = ""; //$NON-NLS-1$
110
		for (int colPos : colOrder) {
111
			if (orderString.length() > 0) {
112
				orderString += ","; //$NON-NLS-1$
113
			}
114
			orderString += colPos;
115
		}
116
		child.putString("order", orderString); //$NON-NLS-1$
117
118
		try {
119
			FileWriter writer = new FileWriter(stateFile);
120
			try {
121
				memento.save(writer);
122
			} finally {
123
				writer.close();
124
			}
125
		} catch (IOException e) {
126
			StatusHandler.log(new Status(IStatus.WARNING, TasksUiPlugin.ID_PLUGIN,
127
					"The TaskEditorAttachment cache could not be written", e)); //$NON-NLS-1$
128
		}
129
	}
130
131
	protected void adjustColumInfos() {
132
133
	}
134
135
	public void create(FormToolkit toolkit, Composite parent, int initialColumnCount) {
136
		table = createTable(parent, toolkit);
137
		columnInfos = new ArrayList<ColumnState>(initialColumnCount);
138
		readStateFile();
139
		if (columnInfos.size() == 0) {
140
			setDefaultColumnInfos();
141
		}
142
		adjustColumInfos();
143
		for (int index = 0; index < columnInfos.size(); index++) {
144
			ColumnState colState = columnInfos.get(index);
145
			final TableColumn column = new TableColumn(table, colState.getAlignment(), index);
146
			column.setText(colState.getName());
147
			column.setWidth(colState.getWidths());
148
			column.setMoveable(true);
149
			column.addControlListener(createColumnControlListener(table, column, index));
150
		}
151
152
		tableViewer = new TableViewer(table);
153
		table.setColumnOrder(orderArray);
154
		setupTableViewer();
155
	}
156
157
	protected ControlListener createColumnControlListener(Table table, final TableColumn column, final int index) {
158
		return new ControlListener() {
159
160
			public void controlResized(ControlEvent e) {
161
				if (!TasksUiPlugin.getDefault()
162
						.getPreferenceStore()
163
						.getBoolean(ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD)) {
164
					columnInfos.get(index).setWidths(column.getWidth());
165
					writeStateFile();
166
				}
167
			}
168
169
			public void controlMoved(ControlEvent e) {
170
				writeStateFile();
171
			}
172
		};
173
174
	}
175
176
	protected Table createTable(Composite parent, FormToolkit toolkit) {
177
		Table table = toolkit.createTable(parent, SWT.MULTI | SWT.FULL_SELECTION);
178
		table.setLinesVisible(true);
179
		table.setHeaderVisible(true);
180
		table.setLayout(new GridLayout());
181
		GridDataFactory.fillDefaults()
182
				.align(SWT.FILL, SWT.FILL)
183
				.grab(true, false)
184
				.hint(500, SWT.DEFAULT)
185
				.applyTo(table);
186
		table.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
187
188
		return table;
189
	}
190
191
	public Table getTable() {
192
		return table;
193
	}
194
195
	public void resetColumnInfosToDefault() {
196
		columnInfos.clear();
197
		setDefaultColumnInfos();
198
		if (!table.isDisposed()) {
199
			for (int index = 0; index < columnInfos.size(); index++) {
200
				TableColumn col = table.getColumn(index);
201
				ColumnState colState = columnInfos.get(index);
202
				col.setAlignment(colState.getAlignment());
203
				col.setWidth(colState.getWidths());
204
				col.setText(colState.getName());
205
			}
206
			table.setColumnOrder(orderArray);
207
		}
208
	}
209
210
	public void addSelectionChangedListener(ISelectionChangedListener listener) {
211
		tableViewer.addSelectionChangedListener(listener);
212
	}
213
214
	public ISelection getSelection() {
215
		return tableViewer.getSelection();
216
	}
217
218
	public void removeSelectionChangedListener(ISelectionChangedListener listener) {
219
		tableViewer.removeSelectionChangedListener(listener);
220
	}
221
222
	public void setSelection(ISelection selection) {
223
		tableViewer.setSelection(selection);
224
	}
225
226
}

Return to bug 250257