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

Collapse All | Expand All

(-).refactorings/2007/11/48/refactorings.history (-1 / +1 lines)
Lines 1-3 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<session version="1.0">&#x0A;<refactoring comment="Extract local variable &apos;activeTask2&apos; from expression &apos;TasksUiPlugin.getTaskListManager().getTaskList().getActiveTask()&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Variable name: &apos;activeTask2&apos;&#x0A;- Destination method: &apos;org.eclipse.mylyn.internal.tasks.ui.TaskTrimWidget.createStatusComposite().new MouseAdapter() {...}.mouseDown()&apos;&#x0A;- Variable expression: &apos;TasksUiPlugin.getTaskListManager().getTaskList().getActiveTask()&apos;&#x0A;- Replace occurrences of expression with variable" description="Extract local variable &apos;activeTask2&apos;" final="false" id="org.eclipse.jdt.ui.extract.temp" input="/src&lt;org.eclipse.mylyn.internal.tasks.ui{TaskTrimWidget.java" name="activeTask2" replace="true" selection="7622 71" stamp="1196284515789" version="1.0"/>&#x0A;<refactoring comment="Extract local variable &apos;fromActivePerspective&apos; from expression &apos;TaskListView.getFromActivePerspective()&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Variable name: &apos;fromActivePerspective&apos;&#x0A;- Destination method: &apos;org.eclipse.mylyn.internal.tasks.ui.TaskTrimWidget.createStatusComposite().new MouseAdapter() {...}.mouseDown()&apos;&#x0A;- Variable expression: &apos;TaskListView.getFromActivePerspective()&apos;&#x0A;- Replace occurrences of expression with variable" description="Extract local variable &apos;fromActivePerspective&apos;" final="false" id="org.eclipse.jdt.ui.extract.temp" input="/src&lt;org.eclipse.mylyn.internal.tasks.ui{TaskTrimWidget.java" name="fromActivePerspective" replace="true" selection="7288 39" stamp="1196284610386" version="1.0"/>&#x0A;<refactoring comment="Extract constant &apos;org.eclipse.mylyn.internal.tasks.ui.editors.TaskPlanningEditor.WIDTH_SUMMARY&apos; from expression &apos;500&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Constant name: &apos;WIDTH_SUMMARY&apos;&#x0D;&#x0A;- Constant expression: &apos;500&apos;&#x0D;&#x0A;- Declared visibility: &apos;private&apos;" description="Extract constant &apos;WIDTH_SUMMARY&apos;" flags="786432" id="org.eclipse.jdt.ui.extract.constant" input="/src&lt;org.eclipse.mylyn.internal.tasks.ui.editors{TaskPlanningEditor.java" name="WIDTH_SUMMARY" qualify="false" replace="false" selection="14226 3" stamp="1196392562365" version="1.0" visibility="2"/>
2
<session version="1.0">&#x0A;<refactoring comment="Extract local variable &apos;activeTask2&apos; from expression &apos;TasksUiPlugin.getTaskListManager().getTaskList().getActiveTask()&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Variable name: &apos;activeTask2&apos;&#x0A;- Destination method: &apos;org.eclipse.mylyn.internal.tasks.ui.TaskTrimWidget.createStatusComposite().new MouseAdapter() {...}.mouseDown()&apos;&#x0A;- Variable expression: &apos;TasksUiPlugin.getTaskListManager().getTaskList().getActiveTask()&apos;&#x0A;- Replace occurrences of expression with variable" description="Extract local variable &apos;activeTask2&apos;" final="false" id="org.eclipse.jdt.ui.extract.temp" input="/src&lt;org.eclipse.mylyn.internal.tasks.ui{TaskTrimWidget.java" name="activeTask2" replace="true" selection="7622 71" stamp="1196284515789" version="1.0"/>&#x0A;<refactoring comment="Extract local variable &apos;fromActivePerspective&apos; from expression &apos;TaskListView.getFromActivePerspective()&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Variable name: &apos;fromActivePerspective&apos;&#x0A;- Destination method: &apos;org.eclipse.mylyn.internal.tasks.ui.TaskTrimWidget.createStatusComposite().new MouseAdapter() {...}.mouseDown()&apos;&#x0A;- Variable expression: &apos;TaskListView.getFromActivePerspective()&apos;&#x0A;- Replace occurrences of expression with variable" description="Extract local variable &apos;fromActivePerspective&apos;" final="false" id="org.eclipse.jdt.ui.extract.temp" input="/src&lt;org.eclipse.mylyn.internal.tasks.ui{TaskTrimWidget.java" name="fromActivePerspective" replace="true" selection="7288 39" stamp="1196284610386" version="1.0"/>&#x0A;<refactoring comment="Extract constant &apos;org.eclipse.mylyn.internal.tasks.ui.editors.TaskPlanningEditor.WIDTH_SUMMARY&apos; from expression &apos;500&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Constant name: &apos;WIDTH_SUMMARY&apos;&#x0D;&#x0A;- Constant expression: &apos;500&apos;&#x0D;&#x0A;- Declared visibility: &apos;private&apos;" description="Extract constant &apos;WIDTH_SUMMARY&apos;" flags="786432" id="org.eclipse.jdt.ui.extract.constant" input="/src&lt;org.eclipse.mylyn.internal.tasks.ui.editors{TaskPlanningEditor.java" name="WIDTH_SUMMARY" qualify="false" replace="false" selection="14226 3" stamp="1196392562365" version="1.0" visibility="2"/>&#x0A;<refactoring comment="Extract method &apos;private void createFiles(StructuredSelection selection)&apos; from &apos;org.eclipse.mylyn.internal.tasks.ui.views.TaskListDragSourceListener.dragStart()&apos; to &apos;org.eclipse.mylyn.internal.tasks.ui.views.TaskListDragSourceListener&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Method name: &apos;createFiles&apos;&#x0A;- Destination type: &apos;org.eclipse.mylyn.internal.tasks.ui.views.TaskListDragSourceListener&apos;&#x0A;- Declared visibility: &apos;private&apos;" comments="false" description="Extract method &apos;createFiles&apos;" destination="0" exceptions="false" flags="786434" id="org.eclipse.jdt.ui.extract.method" input="/src&lt;org.eclipse.mylyn.internal.tasks.ui.views{TaskListDragSourceListener.java" name="createFiles" replace="false" selection="2183 2399" stamp="1196450524200" version="1.0" visibility="2"/>
3
</session>
3
</session>
(-).refactorings/2007/11/48/refactorings.index (+1 lines)
Lines 1-3 Link Here
1
1196284515789	Extract local variable 'activeTask2'
1
1196284515789	Extract local variable 'activeTask2'
2
1196284610386	Extract local variable 'fromActivePerspective'
2
1196284610386	Extract local variable 'fromActivePerspective'
3
1196392562365	Extract constant 'WIDTH_SUMMARY'
3
1196392562365	Extract constant 'WIDTH_SUMMARY'
4
1196450524200	Extract method 'createFiles'
(-)src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java (-2 / +1 lines)
Lines 101-108 Link Here
101
					String path = names[0];
101
					String path = names[0];
102
					File file = new File(path);
102
					File file = new File(path);
103
					if (ContextCorePlugin.getContextManager().isValidContextFile(file)) {
103
					if (ContextCorePlugin.getContextManager().isValidContextFile(file)) {
104
						ContextCorePlugin.getContextManager().copyContext(
104
						ContextCorePlugin.getContextManager().copyContext(targetTask.getHandleIdentifier(), file);
105
								targetTask.getHandleIdentifier(), file);
106
						new TaskActivateAction().run(targetTask);
105
						new TaskActivateAction().run(targetTask);
107
					}
106
					}
108
				}
107
				}
(-)src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDragSourceListener.java (-65 / +78 lines)
Lines 42-49 Link Here
42
	private final TaskListView view;
42
	private final TaskListView view;
43
43
44
	private File[] queryTempFiles;
44
	private File[] queryTempFiles;
45
45
	private File[] taskTempFiles;
46
	private File[] taskTempFiles;
46
47
48
	private StructuredSelection selection;
49
47
//	static final String ID_DATA_TASK_DRAG = "task-drag";
50
//	static final String ID_DATA_TASK_DRAG = "task-drag";
48
51
49
	/**
52
	/**
Lines 56-142 Link Here
56
	public void dragStart(DragSourceEvent event) {
59
	public void dragStart(DragSourceEvent event) {
57
		StructuredSelection selection = (StructuredSelection) this.view.getViewer().getSelection();
60
		StructuredSelection selection = (StructuredSelection) this.view.getViewer().getSelection();
58
		if (selection.isEmpty()) {
61
		if (selection.isEmpty()) {
62
			this.selection = null;
59
			event.doit = false;
63
			event.doit = false;
60
		} else {
64
		} else {
61
			// prepare temporary directory 
65
			this.selection = selection;
62
			File tempDir = new File(TasksUiPlugin.getDefault().getDataDirectory() + File.separator + "temp");
66
		}
63
			if (!tempDir.exists()) {
67
	}
64
				tempDir.mkdir();
68
65
			}
69
	private void createFiles(StructuredSelection selection) {
66
			
70
		// prepare temporary directory 
67
			// prepare query files
71
		File tempDir = new File(TasksUiPlugin.getDefault().getDataDirectory() + File.separator + "temp");
68
			List<AbstractRepositoryQuery> queries = new ArrayList<AbstractRepositoryQuery>();
72
		if (!tempDir.exists()) {
69
			List<AbstractTask> tasks = new ArrayList<AbstractTask>();
73
			tempDir.mkdir();
70
			
74
		}
71
			for (Iterator<?> it = selection.iterator(); it.hasNext();) {
75
72
				Object element = it.next();
76
		// prepare query files
73
				if (element instanceof AbstractRepositoryQuery) {
77
		List<AbstractRepositoryQuery> queries = new ArrayList<AbstractRepositoryQuery>();
74
					queries.add((AbstractRepositoryQuery) element);
78
		List<AbstractTask> tasks = new ArrayList<AbstractTask>();
75
				} else if (element instanceof AbstractTask) {
79
76
					tasks.add((AbstractTask) element);
80
		for (Iterator<?> it = selection.iterator(); it.hasNext();) {
77
				}
81
			Object element = it.next();
82
			if (element instanceof AbstractRepositoryQuery) {
83
				queries.add((AbstractRepositoryQuery) element);
84
			} else if (element instanceof AbstractTask) {
85
				tasks.add((AbstractTask) element);
78
			}
86
			}
87
		}
88
89
		try {
79
90
80
			try {
91
			// queries
81
				
92
			{
82
				// queries
93
				int counter = 0;
83
				{
94
				queryTempFiles = new File[queries.size()];
84
					int counter = 0;
95
				for (AbstractRepositoryQuery query : queries) {
85
					queryTempFiles = new File[queries.size()];
96
					List<AbstractRepositoryQuery> queryList = new ArrayList<AbstractRepositoryQuery>();
86
					for (AbstractRepositoryQuery query : queries) {
97
					queryList.add(query);
87
						List<AbstractRepositoryQuery> queryList = new ArrayList<AbstractRepositoryQuery>();
98
88
						queryList.add(query);
99
					String encodedName = "query";
89
100
					try {
90
						String encodedName = "query";
101
						encodedName = URLEncoder.encode(query.getHandleIdentifier(),
91
						try {
102
								ITasksUiConstants.FILENAME_ENCODING);
92
							encodedName = URLEncoder.encode(query.getHandleIdentifier(),
103
					} catch (UnsupportedEncodingException e) {
93
									ITasksUiConstants.FILENAME_ENCODING);
104
						StatusHandler.fail(e, "Could not determine path for context", false);
94
						} catch (UnsupportedEncodingException e) {
95
							StatusHandler.fail(e, "Could not determine path for context", false);
96
						}
97
98
						queryTempFiles[counter] = File.createTempFile(encodedName, ITasksUiConstants.FILE_EXTENSION,
99
								tempDir);
100
						queryTempFiles[counter].deleteOnExit();
101
						TasksUiPlugin.getTaskListManager().getTaskListWriter().writeQueries(queryList,
102
								queryTempFiles[counter]);
103
						counter++;
104
					}
105
					}
106
107
					queryTempFiles[counter] = File.createTempFile(encodedName, ITasksUiConstants.FILE_EXTENSION,
108
							tempDir);
109
					queryTempFiles[counter].deleteOnExit();
110
					TasksUiPlugin.getTaskListManager().getTaskListWriter().writeQueries(queryList,
111
							queryTempFiles[counter]);
112
					counter++;
105
				}
113
				}
114
			}
106
115
107
				// tasks
116
			// tasks
108
				{
117
			{
109
					int counter = 0;
118
				int counter = 0;
110
					taskTempFiles = new File[tasks.size()];
119
				taskTempFiles = new File[tasks.size()];
111
					for (AbstractTask task : tasks) {
120
				for (AbstractTask task : tasks) {
112
						String encodedName = "task" + counter;
121
					String encodedName = "task" + counter;
113
						try {
122
					try {
114
							encodedName = URLEncoder.encode(task.getHandleIdentifier(),
123
						encodedName = URLEncoder.encode(task.getHandleIdentifier(), ITasksUiConstants.FILENAME_ENCODING);
115
									ITasksUiConstants.FILENAME_ENCODING);
124
					} catch (UnsupportedEncodingException e) {
116
						} catch (UnsupportedEncodingException e) {
125
						StatusHandler.fail(e, "Could not determine path for context", false);
117
							StatusHandler.fail(e, "Could not determine path for context", false);
118
						}
119
120
						taskTempFiles[counter] = File.createTempFile(encodedName, ITasksUiConstants.FILE_EXTENSION,
121
								tempDir);
122
						taskTempFiles[counter].deleteOnExit();
123
						TasksUiPlugin.getTaskListManager().getTaskListWriter().writeTask(task, taskTempFiles[counter]);
124
						counter++;
125
					}
126
					}
127
128
					taskTempFiles[counter] = File.createTempFile(encodedName, ITasksUiConstants.FILE_EXTENSION, tempDir);
129
					taskTempFiles[counter].deleteOnExit();
130
					TasksUiPlugin.getTaskListManager().getTaskListWriter().writeTask(task, taskTempFiles[counter]);
131
					counter++;
126
				}
132
				}
127
			} catch (IOException e) {
128
				StatusHandler.fail(e, "Cannot create a temp query file for Drag&Drop", true);
129
			}
133
			}
134
		} catch (IOException e) {
135
			StatusHandler.fail(e, "Cannot create a temp query file for Drag&Drop", true);
130
		}
136
		}
131
	}
137
	}
132
138
133
	public void dragSetData(DragSourceEvent event) {
139
	public void dragSetData(DragSourceEvent event) {
134
		StructuredSelection selection = (StructuredSelection) this.view.getViewer().getSelection();
140
		if (selection == null || selection.isEmpty()) {
141
			event.doit = false;
142
			return;
143
		}
144
145
		//StructuredSelection selection = (StructuredSelection) this.view.getViewer().getSelection();
135
		AbstractTaskContainer selectedElement = null;
146
		AbstractTaskContainer selectedElement = null;
136
		if (((IStructuredSelection) selection).getFirstElement() instanceof AbstractTaskContainer) {
147
		if (((IStructuredSelection) selection).getFirstElement() instanceof AbstractTaskContainer) {
137
			selectedElement = (AbstractTaskContainer) ((IStructuredSelection) selection).getFirstElement();
148
			selectedElement = (AbstractTaskContainer) ((IStructuredSelection) selection).getFirstElement();
138
		}
149
		}
139
		
150
140
		if (TaskTransfer.getInstance().isSupportedType(event.dataType)) {
151
		if (TaskTransfer.getInstance().isSupportedType(event.dataType)) {
141
			List<AbstractTask> tasks = new ArrayList<AbstractTask>();
152
			List<AbstractTask> tasks = new ArrayList<AbstractTask>();
142
			for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
153
			for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
Lines 147-152 Link Here
147
			}
158
			}
148
			event.data = tasks.toArray();
159
			event.data = tasks.toArray();
149
		} else if (FileTransfer.getInstance().isSupportedType(event.dataType)) {
160
		} else if (FileTransfer.getInstance().isSupportedType(event.dataType)) {
161
			createFiles(selection);
162
150
			// detect context paths
163
			// detect context paths
151
			String[] taskPaths = new String[taskTempFiles.length];
164
			String[] taskPaths = new String[taskTempFiles.length];
152
			for (int i = 0; i < taskTempFiles.length; i++) {
165
			for (int i = 0; i < taskTempFiles.length; i++) {
Lines 158-169 Link Here
158
			for (int i = 0; i < queryTempFiles.length; i++) {
171
			for (int i = 0; i < queryTempFiles.length; i++) {
159
				queryPaths[i] = queryTempFiles[i].getAbsolutePath();
172
				queryPaths[i] = queryTempFiles[i].getAbsolutePath();
160
			}
173
			}
161
			
174
162
			// combine paths if needed
175
			// combine paths if needed
163
			String[] paths = new String[taskTempFiles.length + queryTempFiles.length];
176
			String[] paths = new String[taskTempFiles.length + queryTempFiles.length];
164
			System.arraycopy(taskPaths, 0, paths, 0, taskTempFiles.length);
177
			System.arraycopy(taskPaths, 0, paths, 0, taskTempFiles.length);
165
			System.arraycopy(queryPaths, 0, paths, taskTempFiles.length, queryTempFiles.length);
178
			System.arraycopy(queryPaths, 0, paths, taskTempFiles.length, queryTempFiles.length);
166
			
179
167
			if (paths.length > 0) {
180
			if (paths.length > 0) {
168
				event.data = paths;
181
				event.data = paths;
169
			}
182
			}

Return to bug 211080