Source Code Cross Referenced for ResetAction.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » ui » wizards » buildpaths » newsourcepage » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jdt » org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage;
011:
012:        import java.lang.reflect.InvocationTargetException;
013:        import java.util.ArrayList;
014:        import java.util.Iterator;
015:        import java.util.List;
016:
017:        import org.eclipse.core.runtime.CoreException;
018:        import org.eclipse.core.runtime.IProgressMonitor;
019:        import org.eclipse.core.runtime.NullProgressMonitor;
020:        import org.eclipse.core.runtime.SubProgressMonitor;
021:
022:        import org.eclipse.jface.operation.IRunnableContext;
023:        import org.eclipse.jface.operation.IRunnableWithProgress;
024:        import org.eclipse.jface.viewers.IStructuredSelection;
025:        import org.eclipse.jface.viewers.StructuredSelection;
026:
027:        import org.eclipse.ui.IWorkbenchSite;
028:        import org.eclipse.ui.PlatformUI;
029:        import org.eclipse.ui.part.ISetSelectionTarget;
030:
031:        import org.eclipse.jdt.core.IClasspathEntry;
032:        import org.eclipse.jdt.core.IJavaElement;
033:        import org.eclipse.jdt.core.IJavaProject;
034:        import org.eclipse.jdt.core.IPackageFragmentRoot;
035:        import org.eclipse.jdt.core.JavaModelException;
036:
037:        import org.eclipse.jdt.internal.corext.buildpath.BuildpathDelta;
038:        import org.eclipse.jdt.internal.corext.buildpath.ClasspathModifier;
039:
040:        import org.eclipse.jdt.internal.ui.JavaPlugin;
041:        import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
042:        import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement;
043:        import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElementAttribute;
044:
045:        //Warning: This is unused and untested code. Images and descriptions are missing too.
046:        //SelectedElements iff enabled: IJavaProject || IPackageFragmentRoot || CPListElementAttribute
047:        public class ResetAction extends BuildpathModifierAction {
048:
049:            private final IRunnableContext fContext;
050:
051:            public ResetAction(IWorkbenchSite site) {
052:                this (site, null, PlatformUI.getWorkbench().getProgressService());
053:            }
054:
055:            public ResetAction(IRunnableContext context,
056:                    ISetSelectionTarget selectionTarget) {
057:                this (null, selectionTarget, context);
058:            }
059:
060:            public ResetAction(IWorkbenchSite site,
061:                    ISetSelectionTarget selectionTarget,
062:                    IRunnableContext context) {
063:                super (site, selectionTarget, BuildpathModifierAction.RESET);
064:
065:                fContext = context;
066:
067:                setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Reset_tooltip);
068:                setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Reset_tooltip);
069:            }
070:
071:            /**
072:             * {@inheritDoc}
073:             */
074:            public String getDetailedDescription() {
075:                if (!isEnabled())
076:                    return null;
077:
078:                Iterator iterator = getSelectedElements().iterator();
079:                Object p = iterator.next();
080:                while (iterator.hasNext()) {
081:                    Object q = iterator.next();
082:                    if ((p instanceof  CPListElementAttribute && !(q instanceof  CPListElementAttribute))
083:                            || (q instanceof  CPListElementAttribute && !(p instanceof  CPListElementAttribute))) {
084:                        return NewWizardMessages.PackageExplorerActionGroup_FormText_Default_Reset;
085:                    }
086:                    p = q;
087:                }
088:                if (p instanceof  CPListElementAttribute) {
089:                    return NewWizardMessages.PackageExplorerActionGroup_FormText_SetOutputToDefault;
090:                } else {
091:                    return NewWizardMessages.PackageExplorerActionGroup_FormText_ResetFilters;
092:                }
093:            }
094:
095:            /**
096:             * {@inheritDoc}
097:             */
098:            public void run() {
099:                final IRunnableWithProgress runnable = new IRunnableWithProgress() {
100:                    public void run(IProgressMonitor monitor)
101:                            throws InvocationTargetException,
102:                            InterruptedException {
103:                        try {
104:                            Object firstElement = getSelectedElements().get(0);
105:                            IJavaProject project = null;
106:                            if (firstElement instanceof  IJavaProject) {
107:                                project = (IJavaProject) firstElement;
108:                            } else if (firstElement instanceof  IPackageFragmentRoot) {
109:                                project = ((IPackageFragmentRoot) firstElement)
110:                                        .getJavaProject();
111:                            } else {
112:                                project = ((CPListElementAttribute) firstElement)
113:                                        .getParent().getJavaProject();
114:                            }
115:
116:                            List result = reset(getSelectedElements(), project,
117:                                    monitor);
118:                            selectAndReveal(new StructuredSelection(result));
119:                        } catch (CoreException e) {
120:                            throw new InvocationTargetException(e);
121:                        }
122:                    }
123:                };
124:                try {
125:                    fContext.run(false, false, runnable);
126:                } catch (InvocationTargetException e) {
127:                    if (e.getCause() instanceof  CoreException) {
128:                        showExceptionDialog((CoreException) e.getCause(), ""); //$NON-NLS-1$
129:                    } else {
130:                        JavaPlugin.log(e);
131:                    }
132:                } catch (InterruptedException e) {
133:                }
134:            }
135:
136:            private List reset(List selection, IJavaProject project,
137:                    IProgressMonitor monitor) throws JavaModelException {
138:                if (monitor == null)
139:                    monitor = new NullProgressMonitor();
140:                try {
141:                    monitor
142:                            .beginTask(
143:                                    NewWizardMessages.ClasspathModifier_Monitor_Resetting,
144:                                    selection.size());
145:                    List entries = ClasspathModifier
146:                            .getExistingEntries(project);
147:                    List result = new ArrayList();
148:                    for (int i = 0; i < selection.size(); i++) {
149:                        Object element = selection.get(i);
150:                        if (element instanceof  IJavaElement) {
151:                            IJavaElement javaElement = (IJavaElement) element;
152:                            IPackageFragmentRoot root;
153:                            if (element instanceof  IJavaProject)
154:                                root = project.getPackageFragmentRoot(project
155:                                        .getResource());
156:                            else
157:                                root = (IPackageFragmentRoot) element;
158:                            CPListElement entry = ClasspathModifier
159:                                    .getClasspathEntry(entries, root);
160:                            ClasspathModifier
161:                                    .resetFilters(javaElement, entry, project,
162:                                            new SubProgressMonitor(monitor, 1));
163:                            result.add(javaElement);
164:                        } else {
165:                            CPListElement selElement = ((CPListElementAttribute) element)
166:                                    .getParent();
167:                            CPListElement entry = ClasspathModifier
168:                                    .getClasspathEntry(entries, selElement);
169:                            CPListElementAttribute outputFolder = ClasspathModifier
170:                                    .resetOutputFolder(entry, project);
171:                            result.add(outputFolder);
172:                        }
173:                    }
174:
175:                    ClasspathModifier.commitClassPath(entries, project, null);
176:
177:                    BuildpathDelta delta = new BuildpathDelta(getToolTipText());
178:                    delta.setNewEntries((CPListElement[]) entries
179:                            .toArray(new CPListElement[entries.size()]));
180:                    informListeners(delta);
181:
182:                    return result;
183:                } finally {
184:                    monitor.done();
185:                }
186:            }
187:
188:            protected boolean canHandle(IStructuredSelection elements) {
189:                try {
190:                    for (Iterator iterator = elements.iterator(); iterator
191:                            .hasNext();) {
192:                        Object element = iterator.next();
193:                        if (element instanceof  IJavaProject) {
194:                            IJavaProject project = (IJavaProject) element;
195:                            if (!project.isOnClasspath(project))
196:                                return false;
197:
198:                            IClasspathEntry entry = ClasspathModifier
199:                                    .getClasspathEntryFor(project.getPath(),
200:                                            project, IClasspathEntry.CPE_SOURCE);
201:                            if (entry.getInclusionPatterns().length == 0
202:                                    && entry.getExclusionPatterns().length == 0)
203:                                return false;
204:
205:                            return true;
206:                        } else if (element instanceof  IPackageFragmentRoot) {
207:                            if (ClasspathModifier
208:                                    .filtersSet((IPackageFragmentRoot) element))
209:                                return true;
210:                        } else if (element instanceof  CPListElementAttribute) {
211:                            if (!ClasspathModifier
212:                                    .isDefaultOutputFolder((CPListElementAttribute) element))
213:                                return true;
214:                        } else {
215:                            return false;
216:                        }
217:                    }
218:                } catch (JavaModelException e) {
219:                    return false;
220:                }
221:                return false;
222:            }
223:        }
w___w___w.__j___a__v__a___2__s_._c__o__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.