Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 152491 Details for
Bug 58085
[WorkingSets] Option: Keep open only projects of current working set (close other projects automatically)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed implementation
implementation.patch (text/plain), 9.46 KB, created by
Mykola Nikishov
on 2009-11-18 12:47:37 EST
(
hide
)
Description:
Proposed implementation
Filename:
MIME Type:
Creator:
Mykola Nikishov
Created:
2009-11-18 12:47:37 EST
Size:
9.46 KB
patch
obsolete
>diff --git a/Eclipse UI/org/eclipse/ui/internal/commands/WorkingSetValues.java b/Eclipse UI/org/eclipse/ui/internal/commands/WorkingSetValues.java >new file mode 100644 >index 0000000..fd801b0 >--- /dev/null >+++ b/Eclipse UI/org/eclipse/ui/internal/commands/WorkingSetValues.java >@@ -0,0 +1,46 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Mykola Nikishov <mn@mn.com.ua> >+ * >+ * 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 >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.commands; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.commands.IParameterValues; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.ui.IWorkingSet; >+import org.eclipse.ui.PlatformUI; >+ >+public abstract class WorkingSetValues implements IParameterValues { >+ >+ protected abstract boolean isActionable(IProject project); >+ >+ final public Map getParameterValues() { >+ IWorkingSet[] allWorkingSets = PlatformUI.getWorkbench() >+ .getWorkingSetManager().getAllWorkingSets(); >+ final HashMap result = new HashMap(); >+ for (int i = 0; i < allWorkingSets.length; i++) { >+ IWorkingSet workingSet = allWorkingSets[i]; >+ if (!workingSet.isAggregateWorkingSet()) { >+ IAdaptable[] elements = workingSet.getElements(); >+ for (int j = 0; j < elements.length; j++) { >+ IProject project = (IProject) elements[j] >+ .getAdapter(IProject.class); >+ if (project != null && isActionable(project)) { >+ result.put(workingSet.getLabel(), workingSet.getName()); >+ break; >+ } >+ } >+ } >+ } >+ return result; >+ } >+ >+} >diff --git a/Eclipse UI/org/eclipse/ui/internal/handlers/CloseWorkingSetHandler.java b/Eclipse UI/org/eclipse/ui/internal/handlers/CloseWorkingSetHandler.java >new file mode 100644 >index 0000000..73e95e6 >--- /dev/null >+++ b/Eclipse UI/org/eclipse/ui/internal/handlers/CloseWorkingSetHandler.java >@@ -0,0 +1,32 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Mykola Nikishov <mn@mn.com.ua> >+ * >+ * 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 >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.handlers; >+ >+ >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; >+ >+public class CloseWorkingSetHandler extends WorkingSetHandler { >+ >+ private static final String PARAMETER_ID = "org.eclipse.ui.workingSet.commandParameter1"; //$NON-NLS-1$ >+ >+ protected void executeOperation(IProject project) throws CoreException { >+ project.close(null); >+ } >+ >+ protected boolean isAplicable(IProject project) { >+ return project.isOpen(); >+ } >+ >+ protected String getParameterId() { >+ return PARAMETER_ID; >+ } >+ >+} >diff --git a/Eclipse UI/org/eclipse/ui/internal/handlers/CloseWorkingSetValues.java b/Eclipse UI/org/eclipse/ui/internal/handlers/CloseWorkingSetValues.java >new file mode 100644 >index 0000000..e87df99 >--- /dev/null >+++ b/Eclipse UI/org/eclipse/ui/internal/handlers/CloseWorkingSetValues.java >@@ -0,0 +1,22 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Mykola Nikishov <mn@mn.com.ua> >+ * >+ * 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 >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.handlers; >+ >+import org.eclipse.ui.internal.commands.WorkingSetValues; >+ >+import org.eclipse.core.resources.IProject; >+ >+public class CloseWorkingSetValues extends WorkingSetValues { >+ >+ protected boolean isActionable(IProject project) { >+ return !project.isOpen(); >+ } >+ >+} >diff --git a/Eclipse UI/org/eclipse/ui/internal/handlers/OpenWorkingSetHandler.java b/Eclipse UI/org/eclipse/ui/internal/handlers/OpenWorkingSetHandler.java >new file mode 100644 >index 0000000..ad30d2a >--- /dev/null >+++ b/Eclipse UI/org/eclipse/ui/internal/handlers/OpenWorkingSetHandler.java >@@ -0,0 +1,32 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Mykola Nikishov <mn@mn.com.ua> >+ * >+ * 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 >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.handlers; >+ >+ >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; >+ >+public class OpenWorkingSetHandler extends WorkingSetHandler { >+ >+ private static final String PARAMETER_ID = "org.eclipse.ui.workingSet.commandParameter2"; //$NON-NLS-1$ >+ >+ protected void executeOperation(IProject project) throws CoreException { >+ project.open(null); >+ } >+ >+ protected String getParameterId() { >+ return PARAMETER_ID; >+ } >+ >+ protected boolean isAplicable(IProject project) { >+ return !project.isOpen(); >+ } >+ >+} >diff --git a/Eclipse UI/org/eclipse/ui/internal/handlers/OpenWorkingSetValues.java b/Eclipse UI/org/eclipse/ui/internal/handlers/OpenWorkingSetValues.java >new file mode 100644 >index 0000000..483322e >--- /dev/null >+++ b/Eclipse UI/org/eclipse/ui/internal/handlers/OpenWorkingSetValues.java >@@ -0,0 +1,22 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Mykola Nikishov <mn@mn.com.ua> >+ * >+ * 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 >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.handlers; >+ >+import org.eclipse.ui.internal.commands.WorkingSetValues; >+ >+import org.eclipse.core.resources.IProject; >+ >+public class OpenWorkingSetValues extends WorkingSetValues { >+ >+ protected boolean isActionable(IProject project) { >+ return project.isOpen(); >+ } >+ >+} >diff --git a/Eclipse UI/org/eclipse/ui/internal/handlers/WorkingSetHandler.java b/Eclipse UI/org/eclipse/ui/internal/handlers/WorkingSetHandler.java >new file mode 100644 >index 0000000..d5e663d >--- /dev/null >+++ b/Eclipse UI/org/eclipse/ui/internal/handlers/WorkingSetHandler.java >@@ -0,0 +1,50 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Mykola Nikishov <mn@mn.com.ua> >+ * >+ * 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 >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.handlers; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.ui.IWorkingSet; >+import org.eclipse.ui.PlatformUI; >+ >+public abstract class WorkingSetHandler extends AbstractHandler { >+ >+ protected abstract boolean isAplicable(IProject project); >+ >+ protected abstract void executeOperation(IProject project) >+ throws CoreException; >+ >+ public final Object execute(ExecutionEvent event) throws ExecutionException { >+ String parameter = event.getParameter(getParameterId()); >+ IWorkingSet workingSetToClose = PlatformUI.getWorkbench() >+ .getWorkingSetManager().getWorkingSet(parameter); >+ IAdaptable[] elements = workingSetToClose.getElements(); >+ for (int j = 0; j < elements.length; j++) { >+ IProject project = (IProject) elements[j] >+ .getAdapter(IProject.class); >+ if (project != null && isAplicable(project)) { >+ try { >+ executeOperation(project); >+ } catch (CoreException e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ } >+ } >+ return null; >+ } >+ >+ protected abstract String getParameterId(); >+ >+} >diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF >index 67c85f0..42be2d8 100644 >--- a/META-INF/MANIFEST.MF >+++ b/META-INF/MANIFEST.MF >@@ -98,7 +98,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)", > org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)", > org.eclipse.jface.databinding;bundle-version="[1.3.0,2.0.0)", > org.eclipse.core.databinding.property;bundle-version="[1.2.0,2.0.0)", >- org.eclipse.core.databinding.observable;bundle-version="[1.2.0,2.0.0)" >+ org.eclipse.core.databinding.observable;bundle-version="[1.2.0,2.0.0)", >+ org.eclipse.core.resources;bundle-version="[3.6.0,4.0.0)" > Import-Package: com.ibm.icu.text, > com.ibm.icu.util, > javax.xml.parsers,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mn
:
review?
Actions:
View
|
Diff
Attachments on
bug 58085
: 152491 |
152492