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

Collapse All | Expand All

(-)a/Eclipse (+46 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Mykola Nikishov <mn@mn.com.ua>
3
 *
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 ******************************************************************************/
9
10
package org.eclipse.ui.internal.commands;
11
12
import java.util.HashMap;
13
import java.util.Map;
14
15
import org.eclipse.core.commands.IParameterValues;
16
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.runtime.IAdaptable;
18
import org.eclipse.ui.IWorkingSet;
19
import org.eclipse.ui.PlatformUI;
20
21
public abstract class WorkingSetValues implements IParameterValues {
22
23
	protected abstract boolean isActionable(IProject project);
24
25
	final public Map getParameterValues() {
26
		IWorkingSet[] allWorkingSets = PlatformUI.getWorkbench()
27
				.getWorkingSetManager().getAllWorkingSets();
28
		final HashMap result = new HashMap();
29
		for (int i = 0; i < allWorkingSets.length; i++) {
30
			IWorkingSet workingSet = allWorkingSets[i];
31
			if (!workingSet.isAggregateWorkingSet()) {
32
				IAdaptable[] elements = workingSet.getElements();
33
				for (int j = 0; j < elements.length; j++) {
34
					IProject project = (IProject) elements[j]
35
							.getAdapter(IProject.class);
36
					if (project != null && isActionable(project)) {
37
						result.put(workingSet.getLabel(), workingSet.getName());
38
						break;
39
					}
40
				}
41
			}
42
		}
43
		return result;
44
	}
45
46
}
(-)a/Eclipse (+32 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Mykola Nikishov <mn@mn.com.ua>
3
 *
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 ******************************************************************************/
9
10
package org.eclipse.ui.internal.handlers;
11
12
13
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.runtime.CoreException;
15
16
public class CloseWorkingSetHandler extends WorkingSetHandler {
17
18
	private static final String PARAMETER_ID = "org.eclipse.ui.workingSet.commandParameter1"; //$NON-NLS-1$
19
20
	protected void executeOperation(IProject project) throws CoreException {
21
		project.close(null);
22
	}
23
24
	protected boolean isAplicable(IProject project) {
25
		return project.isOpen();
26
	}
27
28
	protected String getParameterId() {
29
		return PARAMETER_ID;
30
	}
31
32
}
(-)a/Eclipse (+22 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Mykola Nikishov <mn@mn.com.ua>
3
 *
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 ******************************************************************************/
9
10
package org.eclipse.ui.internal.handlers;
11
12
import org.eclipse.ui.internal.commands.WorkingSetValues;
13
14
import org.eclipse.core.resources.IProject;
15
16
public class CloseWorkingSetValues extends WorkingSetValues {
17
18
	protected boolean isActionable(IProject project) {
19
		return !project.isOpen();
20
	}
21
22
}
(-)a/Eclipse (+32 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Mykola Nikishov <mn@mn.com.ua>
3
 *
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 ******************************************************************************/
9
10
package org.eclipse.ui.internal.handlers;
11
12
13
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.runtime.CoreException;
15
16
public class OpenWorkingSetHandler extends WorkingSetHandler {
17
18
	private static final String PARAMETER_ID = "org.eclipse.ui.workingSet.commandParameter2"; //$NON-NLS-1$
19
20
	protected void executeOperation(IProject project) throws CoreException {
21
		project.open(null);
22
	}
23
24
	protected String getParameterId() {
25
		return PARAMETER_ID;
26
	}
27
28
	protected boolean isAplicable(IProject project) {
29
		return !project.isOpen();
30
	}
31
32
}
(-)a/Eclipse (+22 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Mykola Nikishov <mn@mn.com.ua>
3
 *
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 ******************************************************************************/
9
10
package org.eclipse.ui.internal.handlers;
11
12
import org.eclipse.ui.internal.commands.WorkingSetValues;
13
14
import org.eclipse.core.resources.IProject;
15
16
public class OpenWorkingSetValues extends WorkingSetValues {
17
18
	protected boolean isActionable(IProject project) {
19
		return project.isOpen();
20
	}
21
22
}
(-)a/Eclipse (+50 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Mykola Nikishov <mn@mn.com.ua>
3
 *
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 ******************************************************************************/
9
10
package org.eclipse.ui.internal.handlers;
11
12
import org.eclipse.core.commands.AbstractHandler;
13
import org.eclipse.core.commands.ExecutionEvent;
14
import org.eclipse.core.commands.ExecutionException;
15
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IAdaptable;
18
import org.eclipse.ui.IWorkingSet;
19
import org.eclipse.ui.PlatformUI;
20
21
public abstract class WorkingSetHandler extends AbstractHandler {
22
23
	protected abstract boolean isAplicable(IProject project);
24
25
	protected abstract void executeOperation(IProject project)
26
			throws CoreException;
27
28
	public final Object execute(ExecutionEvent event) throws ExecutionException {
29
		String parameter = event.getParameter(getParameterId());
30
		IWorkingSet workingSetToClose = PlatformUI.getWorkbench()
31
				.getWorkingSetManager().getWorkingSet(parameter);
32
		IAdaptable[] elements = workingSetToClose.getElements();
33
		for (int j = 0; j < elements.length; j++) {
34
			IProject project = (IProject) elements[j]
35
					.getAdapter(IProject.class);
36
			if (project != null && isAplicable(project)) {
37
				try {
38
					executeOperation(project);
39
				} catch (CoreException e) {
40
					// TODO Auto-generated catch block
41
					e.printStackTrace();
42
				}
43
			}
44
		}
45
		return null;
46
	}
47
48
	protected abstract String getParameterId();
49
50
}
(-)a/META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 98-104 Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)", Link Here
98
 org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)",
98
 org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)",
99
 org.eclipse.jface.databinding;bundle-version="[1.3.0,2.0.0)",
99
 org.eclipse.jface.databinding;bundle-version="[1.3.0,2.0.0)",
100
 org.eclipse.core.databinding.property;bundle-version="[1.2.0,2.0.0)",
100
 org.eclipse.core.databinding.property;bundle-version="[1.2.0,2.0.0)",
101
 org.eclipse.core.databinding.observable;bundle-version="[1.2.0,2.0.0)"
101
 org.eclipse.core.databinding.observable;bundle-version="[1.2.0,2.0.0)",
102
 org.eclipse.core.resources;bundle-version="[3.6.0,4.0.0)"
102
Import-Package: com.ibm.icu.text,
103
Import-Package: com.ibm.icu.text,
103
 com.ibm.icu.util,
104
 com.ibm.icu.util,
104
 javax.xml.parsers,
105
 javax.xml.parsers,

Return to bug 58085