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 132099 Details for
Bug 258853
Provide a compare ant task
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Work in progress
patch_258853.txt (text/plain), 108.19 KB, created by
Olivier Thomann
on 2009-04-16 11:42:58 EDT
(
hide
)
Description:
Work in progress
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2009-04-16 11:42:58 EDT
Size:
108.19 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.api.tools >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/META-INF/MANIFEST.MF,v >retrieving revision 1.26 >diff -u -r1.26 MANIFEST.MF >--- META-INF/MANIFEST.MF 1 Apr 2009 18:54:05 -0000 1.26 >+++ META-INF/MANIFEST.MF 16 Apr 2009 15:42:15 -0000 >@@ -19,7 +19,7 @@ > org.eclipse.core.filesystem;bundle-version="1.2.0" > Export-Package: org.eclipse.pde.api.tools.internal;x-friends:="org.eclipse.pde.api.tools.tests,org.eclipse.pde.api.tools.ui", > org.eclipse.pde.api.tools.internal.builder;x-friends:="org.eclipse.pde.api.tools.ui", >- org.eclipse.pde.api.tools.internal.comparator;x-internal:=true, >+ org.eclipse.pde.api.tools.internal.comparator;x-friends:="org.eclipse.pde.api.tools.ui", > org.eclipse.pde.api.tools.internal.descriptors;x-friends:="org.eclipse.pde.api.tools.tests,org.eclipse.pde.api.tools.ui", > org.eclipse.pde.api.tools.internal.model;x-friends:="org.eclipse.pde.api.tools.tests,org.eclipse.pde.api.tools.ui", > org.eclipse.pde.api.tools.internal.natures;x-internal:=true, >Index: src/org/eclipse/pde/api/tools/internal/provisional/ApiPlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/ApiPlugin.java,v >retrieving revision 1.54 >diff -u -r1.54 ApiPlugin.java >--- src/org/eclipse/pde/api/tools/internal/provisional/ApiPlugin.java 11 Feb 2009 14:11:38 -0000 1.54 >+++ src/org/eclipse/pde/api/tools/internal/provisional/ApiPlugin.java 16 Apr 2009 15:42:15 -0000 >@@ -34,6 +34,7 @@ > import org.eclipse.pde.api.tools.internal.ApiDescriptionManager; > import org.eclipse.pde.api.tools.internal.ApiFilterStore; > import org.eclipse.pde.api.tools.internal.JavadocTagManager; >+import org.eclipse.pde.api.tools.internal.SessionManager; > import org.eclipse.pde.api.tools.internal.builder.AbstractProblemDetector; > import org.eclipse.pde.api.tools.internal.builder.ApiAnalysisBuilder; > import org.eclipse.pde.api.tools.internal.builder.ReferenceAnalyzer; >@@ -146,7 +147,10 @@ > * Singleton instance of the {@link JavadocTagManager} > */ > private static JavadocTagManager fgTagManager = null; >- >+ /** >+ * Singleton instance of the {@link ISessionManager} >+ */ >+ private static ISessionManager fgSessionManager = null; > /** > * Private debug options > */ >@@ -518,6 +522,13 @@ > } > return SEVERITY_IGNORE; > } >+ >+ public ISessionManager getSessionManager() { >+ if(fgSessionManager == null) { >+ fgSessionManager = new SessionManager(); >+ } >+ return fgSessionManager; >+ } > > /** > * Returns the enable state for the specific key from the given {@link IProject}. >Index: src/org/eclipse/pde/api/tools/internal/util/Util.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java,v >retrieving revision 1.126 >diff -u -r1.126 Util.java >--- src/org/eclipse/pde/api/tools/internal/util/Util.java 9 Apr 2009 15:56:43 -0000 1.126 >+++ src/org/eclipse/pde/api/tools/internal/util/Util.java 16 Apr 2009 15:42:15 -0000 >@@ -2244,4 +2244,9 @@ > return 0; > } > }; >+ >+ public static void checkCanceled(IProgressMonitor monitor) { >+ if (monitor.isCanceled()) >+ throw new OperationCanceledException(); >+ } > } >Index: src/org/eclipse/pde/api/tools/internal/provisional/comparator/ApiComparator.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/ApiComparator.java,v >retrieving revision 1.47 >diff -u -r1.47 ApiComparator.java >--- src/org/eclipse/pde/api/tools/internal/provisional/comparator/ApiComparator.java 27 Mar 2009 16:05:53 -0000 1.47 >+++ src/org/eclipse/pde/api/tools/internal/provisional/comparator/ApiComparator.java 16 Apr 2009 15:42:15 -0000 >@@ -15,7 +15,9 @@ > import java.util.Set; > > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.jdt.core.Flags; > import org.eclipse.pde.api.tools.internal.comparator.ClassFileComparator; > import org.eclipse.pde.api.tools.internal.comparator.Delta; >@@ -665,6 +667,7 @@ > * @param baseline the given API baseline to compare with > * @param visibilityModifiers the given visibility that triggers what visibility should be used for the comparison > * @param force a flag to force the comparison of nested API components with the same versions >+ * @param monitor the given progress monitor to report progress > * > * @return a delta, an empty delta if no difference is found or null if the delta detection failed > * @throws IllegalArgumentException if one of the two baselines is null >@@ -674,12 +677,19 @@ > final IApiScope scope, > final IApiBaseline baseline, > final int visibilityModifiers, >- final boolean force) throws CoreException { >+ final boolean force, >+ final IProgressMonitor monitor) throws CoreException { > if (scope == null || baseline == null) { > throw new IllegalArgumentException("None of the scope or the baseline must be null"); //$NON-NLS-1$ > } >+ IProgressMonitor localMonitor = null; >+ if (monitor == null) { >+ localMonitor = new NullProgressMonitor(); >+ } else { >+ localMonitor = monitor; >+ } > final Set deltas = new HashSet(); >- final CompareApiScopeVisitor visitor = new CompareApiScopeVisitor(deltas, baseline, force, visibilityModifiers); >+ final CompareApiScopeVisitor visitor = new CompareApiScopeVisitor(deltas, baseline, force, visibilityModifiers, localMonitor); > scope.accept(visitor); > if (visitor.containsError()) { > return null; >@@ -711,6 +721,28 @@ > } > return globalDelta.isEmpty() ? NO_DELTA : globalDelta; > } >+ >+ /** >+ * Returns a delta that corresponds to the comparison of the two given API baselines. >+ * Nested API components with the same versions are not compared. >+ * <p>Equivalent to: compare(baseline, baseline2, visibilityModifiers, force, null);</p> >+ * >+ * @param scope the given scope for the comparison >+ * @param baseline the given API baseline to compare with >+ * @param visibilityModifiers the given visibility that triggers what visibility should be used for the comparison >+ * @param force a flag to force the comparison of nested API components with the same versions >+ * >+ * @return a delta, an empty delta if no difference is found or null if the delta detection failed >+ * @throws IllegalArgumentException if one of the two baselines is null >+ * CoreException if one of the element in the scope cannot be visited >+ */ >+ public static IDelta compare( >+ final IApiScope scope, >+ final IApiBaseline baseline, >+ final int visibilityModifiers, >+ final boolean force) throws CoreException { >+ return compare(scope, baseline, visibilityModifiers, force, null); >+ } > /** > * Returns a delta that corresponds to the comparison of the two given API baselines. > * Nested API components with the same versions are not compared. >Index: src/org/eclipse/pde/api/tools/internal/provisional/comparator/CompareApiScopeVisitor.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/comparator/CompareApiScopeVisitor.java,v >retrieving revision 1.4 >diff -u -r1.4 CompareApiScopeVisitor.java >--- src/org/eclipse/pde/api/tools/internal/provisional/comparator/CompareApiScopeVisitor.java 17 Mar 2009 15:51:44 -0000 1.4 >+++ src/org/eclipse/pde/api/tools/internal/provisional/comparator/CompareApiScopeVisitor.java 16 Apr 2009 15:42:15 -0000 >@@ -13,6 +13,7 @@ > import java.util.Set; > > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; > import org.eclipse.pde.api.tools.internal.provisional.model.ApiScopeVisitor; > import org.eclipse.pde.api.tools.internal.provisional.model.ApiTypeContainerVisitor; >@@ -20,6 +21,7 @@ > import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent; > import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer; > import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot; >+import org.eclipse.pde.api.tools.internal.util.Util; > > /** > * ApiScope visitor implementation to run the comparison on all elements of the scope. >@@ -31,72 +33,105 @@ > int visibilityModifiers; > boolean force; > boolean containsErrors = false; >+ IProgressMonitor monitor; > >- public CompareApiScopeVisitor(final Set deltas, final IApiBaseline baseline, final boolean force, final int visibilityModifiers) { >+ public CompareApiScopeVisitor( >+ final Set deltas, >+ final IApiBaseline baseline, >+ final boolean force, >+ final int visibilityModifiers, >+ final IProgressMonitor monitor) { > this.deltas = deltas; > this.referenceBaseline = baseline; > this.visibilityModifiers = visibilityModifiers; > this.force = force; >+ this.monitor = monitor; > } > > public boolean visit(IApiBaseline baseline) throws CoreException { >- IDelta delta = ApiComparator.compare(this.referenceBaseline, baseline, this.visibilityModifiers, this.force); >- if (delta != null) { >- delta.accept(new DeltaVisitor() { >- public void endVisit(IDelta localDelta) { >- if (localDelta.getChildren().length == 0) { >- CompareApiScopeVisitor.this.deltas.add(localDelta); >+ try { >+ Util.checkCanceled(this.monitor); >+ IDelta delta = ApiComparator.compare(this.referenceBaseline, baseline, this.visibilityModifiers, this.force); >+ if (delta != null) { >+ delta.accept(new DeltaVisitor() { >+ public void endVisit(IDelta localDelta) { >+ if (localDelta.getChildren().length == 0) { >+ CompareApiScopeVisitor.this.deltas.add(localDelta); >+ } > } >- } >- }); >- } else { >- this.containsErrors = true; >+ }); >+ } else { >+ this.containsErrors = true; >+ } >+ return false; >+ } finally { >+ this.monitor.worked(1); > } >- return false; > } > > public boolean visit(IApiTypeContainer container) throws CoreException { >- container.accept(new ApiTypeContainerVisitor() { >- public void visit(String packageName, IApiTypeRoot typeroot) { >- try { >- CompareApiScopeVisitor.this.visit(typeroot); >- } catch (CoreException e) { >- ApiPlugin.log(e); >+ try { >+ Util.checkCanceled(this.monitor); >+ container.accept(new ApiTypeContainerVisitor() { >+ public void visit(String packageName, IApiTypeRoot typeroot) { >+ try { >+ Util.checkCanceled(CompareApiScopeVisitor.this.monitor); >+ compareApiTypeRoot(typeroot); >+ } catch (CoreException e) { >+ ApiPlugin.log(e); >+ } > } >- } >- }); >- return false; >+ }); >+ return false; >+ } finally { >+ this.monitor.worked(1); >+ } > } > > public boolean visit(IApiComponent component) throws CoreException { >- if (component.getErrors() != null) { >- this.containsErrors = true; >- return false; >- } >- IApiComponent referenceComponent = this.referenceBaseline.getApiComponent(component.getId()); >- if (referenceComponent.getErrors() != null) { >- this.containsErrors = true; >- return false; >- } >- if (component.isSourceComponent() || component.isSystemComponent()) { >- return false; >- } >- IDelta delta = ApiComparator.compare(referenceComponent, component, this.visibilityModifiers); >- if (delta != null) { >- delta.accept(new DeltaVisitor() { >- public void endVisit(IDelta localDelta) { >- if (localDelta.getChildren().length == 0) { >- CompareApiScopeVisitor.this.deltas.add(localDelta); >+ try { >+ Util.checkCanceled(this.monitor); >+ if (component.getErrors() != null) { >+ this.containsErrors = true; >+ return false; >+ } >+ IApiComponent referenceComponent = this.referenceBaseline.getApiComponent(component.getId()); >+ if (referenceComponent.getErrors() != null) { >+ this.containsErrors = true; >+ return false; >+ } >+ if (component.isSourceComponent() || component.isSystemComponent()) { >+ return false; >+ } >+ Util.checkCanceled(this.monitor); >+ IDelta delta = ApiComparator.compare(referenceComponent, component, this.visibilityModifiers); >+ if (delta != null) { >+ delta.accept(new DeltaVisitor() { >+ public void endVisit(IDelta localDelta) { >+ if (localDelta.getChildren().length == 0) { >+ CompareApiScopeVisitor.this.deltas.add(localDelta); >+ } > } >- } >- }); >- } else { >- this.containsErrors = true; >+ }); >+ } else { >+ this.containsErrors = true; >+ } >+ return false; >+ } finally { >+ this.monitor.worked(1); > } >- return false; > } > > public void visit(IApiTypeRoot root) throws CoreException { >+ try { >+ Util.checkCanceled(this.monitor); >+ compareApiTypeRoot(root); >+ } finally { >+ this.monitor.worked(1); >+ } >+ } >+ >+ void compareApiTypeRoot(IApiTypeRoot root) throws CoreException { > IApiComponent apiComponent = root.getApiComponent(); > if (apiComponent == null || apiComponent.isSystemComponent() || apiComponent.isSourceComponent()) { > return; >Index: src/org/eclipse/pde/api/tools/internal/SessionManager.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/internal/SessionManager.java >diff -N src/org/eclipse/pde/api/tools/internal/SessionManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/internal/SessionManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,113 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.internal; >+ >+import java.util.ArrayList; >+import java.util.HashSet; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Set; >+ >+import org.eclipse.pde.api.tools.internal.provisional.ISession; >+import org.eclipse.pde.api.tools.internal.provisional.ISessionListener; >+import org.eclipse.pde.api.tools.internal.provisional.ISessionManager; >+ >+/** >+ * Implementation of the ISessionManager. >+ * Synchronize all accesses to prevent concurrent modifications. >+ */ >+public class SessionManager implements ISessionManager { >+ >+ // use a list so that we can preserve the order >+ private List sessions = new ArrayList(); >+ private Set listeners = new HashSet(); >+ private ISession activeSession; >+ >+ public synchronized void addSession(ISession session, boolean activate) { >+ if (session == null) { >+ throw new IllegalArgumentException("The given session cannot be null"); //$NON-NLS-1$ >+ } >+ if (!this.sessions.contains(session)) { >+ this.sessions.add(session); >+ fireSessionAdded(session); >+ } >+ if (activate) { >+ this.activeSession = session; >+ fireSessionActivated(session); >+ } >+ } >+ >+ public synchronized void removeSession(ISession session) { >+ if (sessions.remove(session)) { >+ if (session.equals(this.activeSession)) { >+ this.activeSession = null; >+ fireSessionActivated(null); >+ } >+ fireSessionRemoved(session); >+ } >+ } >+ >+ public synchronized void removeAllSessions() { >+ ISession[] allSessions = (ISession[]) this.sessions.toArray(new ISession[this.sessions.size()]); >+ this.sessions.clear(); >+ this.activeSession = null; >+ fireSessionActivated(null); >+ for (int i = 0; i < allSessions.length; i++) { >+ ISession session = allSessions[i]; >+ fireSessionRemoved(session); >+ } >+ } >+ >+ public synchronized ISession[] getSessions() { >+ return (ISession[]) sessions.toArray(new ISession[sessions.size()]); >+ } >+ >+ public synchronized void addSessionListener(ISessionListener listener) { >+ if (listener == null) throw new IllegalArgumentException("The given listener cannot be null"); //$NON-NLS-1$ >+ listeners.add(listener); >+ } >+ >+ public synchronized void removeSessionListener(ISessionListener listener) { >+ listeners.remove(listener); >+ } >+ >+ protected synchronized void fireSessionAdded(ISession session) { >+ Iterator i = listeners.iterator(); >+ while (i.hasNext()) { >+ ((ISessionListener) i.next()).sessionAdded(session); >+ } >+ } >+ >+ protected synchronized void fireSessionRemoved(ISession session) { >+ Iterator i = listeners.iterator(); >+ while (i.hasNext()) { >+ ((ISessionListener) i.next()).sessionRemoved(session); >+ } >+ } >+ >+ public ISession getActiveSession() { >+ return this.activeSession; >+ } >+ >+ protected synchronized void fireSessionActivated(ISession session) { >+ Iterator i = listeners.iterator(); >+ while (i.hasNext()) { >+ ((ISessionListener) i.next()).sessionActivated(session); >+ } >+ } >+ >+ public void activateSession(ISession session) { >+ if (this.sessions.contains(session) && !session.equals(this.activeSession)) { >+ this.activeSession = session; >+ fireSessionActivated(session); >+ } >+ } >+} >Index: src/org/eclipse/pde/api/tools/internal/provisional/ITreeNode.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/internal/provisional/ITreeNode.java >diff -N src/org/eclipse/pde/api/tools/internal/provisional/ITreeNode.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/internal/provisional/ITreeNode.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.internal.provisional; >+ >+public interface ITreeNode { >+ public static final int CLASS = 1; >+ public static final int INTERFACE = 2; >+ public static final int ANNOTATION = 3; >+ public static final int ENUM = 4; >+ public static final int PACKAGE = 5; >+ >+ Object[] getChildren(); >+ boolean hasChildren(); >+ int getId(); >+ Object getData(); >+} >Index: src/org/eclipse/pde/api/tools/internal/provisional/ITreeModel.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/internal/provisional/ITreeModel.java >diff -N src/org/eclipse/pde/api/tools/internal/provisional/ITreeModel.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/internal/provisional/ITreeModel.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,15 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.internal.provisional; >+ >+public interface ITreeModel { >+ public ITreeNode getRoot(); >+} >Index: src/org/eclipse/pde/api/tools/internal/provisional/ISession.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/internal/provisional/ISession.java >diff -N src/org/eclipse/pde/api/tools/internal/provisional/ISession.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/internal/provisional/ISession.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.internal.provisional; >+ >+/** >+ * Provide information about the API Tooling session. >+ */ >+public interface ISession { >+ >+ public ITreeModel getModel(); >+ >+ public String getTimestamp(); >+} >Index: src/org/eclipse/pde/api/tools/internal/provisional/ISessionListener.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/internal/provisional/ISessionListener.java >diff -N src/org/eclipse/pde/api/tools/internal/provisional/ISessionListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/internal/provisional/ISessionListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.internal.provisional; >+ >+ >+ >+/** >+ * Listener interface for changes of the session manager. >+ * >+ * @see ISessionManager#addSessionListener(ISessionListener) >+ * @see ISessionManager#removeSessionListener(ISessionListener) >+ */ >+public interface ISessionListener { >+ >+ /** >+ * Called when a session has been added. >+ * >+ * @param addedSession the given added session >+ */ >+ public void sessionAdded(ISession addedSession); >+ >+ /** >+ * Called when a session has been removed. >+ * >+ * @param removedSession the given removed session >+ */ >+ public void sessionRemoved(ISession removedSession); >+ >+ /** >+ * Called when a new session has been activated or the last session has been >+ * removed. In this case <code>null</code> is passed as a parameter. >+ * >+ * @param session the given activated session or <code>null</code> >+ */ >+ public void sessionActivated(ISession session); >+} >Index: src/org/eclipse/pde/api/tools/internal/provisional/ISessionManager.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/internal/provisional/ISessionManager.java >diff -N src/org/eclipse/pde/api/tools/internal/provisional/ISessionManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/internal/provisional/ISessionManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,80 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.internal.provisional; >+ >+/** >+ * The session manager holds a list of currently available sessions. >+ * >+ * @noimplement This interface is not intended to be implemented by clients. >+ * @noextend This interface is not intended to be extended by clients. >+ */ >+public interface ISessionManager { >+ >+ /** >+ * Adds the given session to this session manager. If the session is already >+ * part of this session manager, the method has no effect. >+ * >+ * @param session the new session >+ * @param activate if <code>true</code> the session will also be activated, <code>false</code> otherwise >+ * @throws IllegalArgumentException if the given session is null >+ */ >+ public void addSession(ISession session, boolean activate); >+ >+ /** >+ * Removes the given session. If the session is not in included in this >+ * session manager, this method has no effect. >+ * >+ * @param session the given session to remove >+ */ >+ public void removeSession(ISession session); >+ >+ /** >+ * Removes all available sessions. >+ */ >+ public void removeAllSessions(); >+ >+ /** >+ * Returns all available sessions registered with this session manager. >+ * >+ * @return list of available sessions >+ */ >+ public ISession[] getSessions(); >+ >+ /** >+ * Adds the given session listener unless it has been added before. >+ * >+ * @param listener the given session listener to add >+ * @throws IllegalArgumentException if the given listener is null >+ */ >+ public void addSessionListener(ISessionListener listener); >+ >+ /** >+ * Removes the given session listener. If the listener has not been added >+ * before this method has no effect. >+ * >+ * @param listener the given session listener to remove >+ */ >+ public void removeSessionListener(ISessionListener listener); >+ >+ /** >+ * Returns the active session or <code>null</code> if there is no session. >+ * >+ * @return active session or <code>null</null> >+ */ >+ public ISession getActiveSession(); >+ /** >+ * Activates the given session. If the session is not in included in this >+ * session manager this method has no effect. >+ * >+ * @param session the given session or <code>null</code> to remove the active session. >+ */ >+ public void activateSession(ISession session); >+} >#P org.eclipse.pde.api.tools.ui >Index: src/org/eclipse/pde/api/tools/ui/internal/actions/ActionMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/ActionMessages.java,v >retrieving revision 1.1 >diff -u -r1.1 ActionMessages.java >--- src/org/eclipse/pde/api/tools/ui/internal/actions/ActionMessages.java 13 Feb 2008 19:59:11 -0000 1.1 >+++ src/org/eclipse/pde/api/tools/ui/internal/actions/ActionMessages.java 16 Apr 2009 15:42:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008 IBM Corporation and others. >+ * Copyright (c) 2008, 2009 IBM Corporation and others. > * 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 >@@ -18,6 +18,31 @@ > public class ActionMessages extends NLS { > private static final String BUNDLE_NAME = "org.eclipse.pde.api.tools.ui.internal.actions.actionmessages"; //$NON-NLS-1$ > public static String ApiToolingSetupObjectContribution_0; >+ public static String SelectABaseline; >+ public static String SetAsDefault; >+ public static String EnterFileName; >+ public static String SelectFileName; >+ public static String Browse; >+ public static String ConvertToHtml; >+ public static String CompareDialogTitle; >+ public static String CompareDialogCollectingElementTaskName; >+ public static String CompareDialogComputeDeltasTaskName; >+ public static String CompareWithAction_comparing_apis; >+ public static String CompareTaskNoChanges; >+ public static String RemoveActiveSessionAction_label; >+ public static String RemoveActiveSessionAction_tooltip; >+ public static String RemoveAllSessionsAction_label; >+ public static String RemoveAllSessionsAction_tooltip; >+ public static String SelectSessionAction_label; >+ public static String SelectSessionAction_tooltip; >+ public static String SelectSessionActionEntry_label; >+ public static String DeltaDetailsDialogTitle; >+ public static String ExportSessionAction_label; >+ public static String ExportSessionAction_tooltip; >+ public static String EnterFileNameForExport; >+ public static String ExportActionTitle; >+ public static String DeltaDetails; >+ > static { > // initialize resource bundle > NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class); >Index: src/org/eclipse/pde/api/tools/ui/internal/actions/actionmessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/actionmessages.properties,v >retrieving revision 1.2 >diff -u -r1.2 actionmessages.properties >--- src/org/eclipse/pde/api/tools/ui/internal/actions/actionmessages.properties 21 Feb 2008 20:30:43 -0000 1.2 >+++ src/org/eclipse/pde/api/tools/ui/internal/actions/actionmessages.properties 16 Apr 2009 15:42:16 -0000 >@@ -1,5 +1,5 @@ > ############################################################################### >-# Copyright (c) 2008 IBM Corporation and others. >+# Copyright (c) 2008, 2009 IBM Corporation and others. > # 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 >@@ -9,3 +9,29 @@ > # IBM Corporation - initial API and implementation > ############################################################################### > ApiToolingSetupObjectContribution_0=Set up API tooling >+SelectABaseline=Select a &baseline: >+SetAsDefault={0} (default) >+EnterFileName=Report &location: >+SelectFileName=Select a report location >+Browse=Bro&wse... >+ConvertToHtml=Con&vert to html >+CompareDialogTitle=Compare With Baseline >+CompareDialogCollectingElementTaskName=Collecting elements to compare >+CompareDialogComputeDeltasTaskName=Computing deltas... >+CompareWithAction_comparing_apis=Comparing APIs... >+CompareTaskNoChanges=No changes have been found >+RemoveActiveSessionAction_label=Remove Active Session >+RemoveActiveSessionAction_tooltip=Remove Active Session >+RemoveAllSessionsAction_label=Remove All Sessions >+RemoveAllSessionsAction_tooltip=Remove All Sessions >+SelectSessionAction_label=Select Session >+SelectSessionAction_tooltip=Select Session >+# {0} int value >+# {1} timestamp >+SelectSessionActionEntry_label=Session {0} ({1}) >+DeltaDetailsDialogTitle=Delta Details >+ExportSessionAction_label=Export Session >+ExportSessionAction_tooltip=Export Session >+EnterFileNameForExport=Enter a file name for export: >+ExportActionTitle=Export Active Session >+DeltaDetails=Delta Information >\ No newline at end of file >Index: src/org/eclipse/pde/api/tools/ui/internal/ApiUIPlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/ApiUIPlugin.java,v >retrieving revision 1.13 >diff -u -r1.13 ApiUIPlugin.java >--- src/org/eclipse/pde/api/tools/ui/internal/ApiUIPlugin.java 23 Feb 2009 18:02:00 -0000 1.13 >+++ src/org/eclipse/pde/api/tools/ui/internal/ApiUIPlugin.java 16 Apr 2009 15:42:16 -0000 >@@ -62,11 +62,11 @@ > /** > * Relative path to object model icons. > */ >- private final static String OBJECT= ICONS_PATH + "obj16/"; //basic colors - size 16x16 //$NON-NLS-1$ >- private final static String OVR= ICONS_PATH + "ovr16/"; //basic colors - size 7x8 //$NON-NLS-1$ >- private final static String WIZBAN= ICONS_PATH + "wizban/"; //basic colors - size 16x16 //$NON-NLS-1$ >- private static final String ELCL= ICONS_PATH + "elcl16/"; //basic colors - size 16x16 //$NON-NLS-1$ >- >+ private final static String OBJECT = ICONS_PATH + "obj16/"; //basic colors - size 16x16 //$NON-NLS-1$ >+ private final static String OVR = ICONS_PATH + "ovr16/"; //basic colors - size 7x8 //$NON-NLS-1$ >+ private final static String WIZBAN = ICONS_PATH + "wizban/"; //basic colors - size 16x16 //$NON-NLS-1$ >+ private static final String ELCL = ICONS_PATH + "elcl16/"; //basic colors - size 16x16 //$NON-NLS-1$ >+ private static final String DLCL = ICONS_PATH + "dlcl16/"; //basic colors - size 16x16 disabled//$NON-NLS-1$ > /** > * Maps Image descriptors to images for composite images > */ >@@ -124,6 +124,7 @@ > declareRegistryImage(reg, IApiToolsConstants.IMG_OBJ_FRAGMENT, OBJECT + "frgmt_obj.gif"); //$NON-NLS-1$ > declareRegistryImage(reg, IApiToolsConstants.IMG_OBJ_ECLIPSE_PROFILE, OBJECT + "eclipse_profile.gif"); //$NON-NLS-1$ > declareRegistryImage(reg, IApiToolsConstants.IMG_OBJ_BUNDLE_VERSION, OBJECT + "bundleversion.gif"); //$NON-NLS-1$ >+ > // overlays > declareRegistryImage(reg, IApiToolsConstants.IMG_OVR_ERROR, OVR + "error_ovr.gif"); //$NON-NLS-1$ > declareRegistryImage(reg, IApiToolsConstants.IMG_OVR_WARNING, OVR + "warning_ovr.gif"); //$NON-NLS-1$ >@@ -134,6 +135,8 @@ > declareRegistryImage(reg, IApiToolsConstants.IMG_ELCL_FILTER, ELCL + "filter_ps.gif"); //$NON-NLS-1$ > declareRegistryImage(reg, IApiToolsConstants.IMG_ELCL_REMOVE, ELCL + "remove_exc.gif"); //$NON-NLS-1$ > declareRegistryImage(reg, IApiToolsConstants.IMG_ELCL_OPEN_PAGE, ELCL + "open_page.gif"); //$NON-NLS-1$ >+ declareRegistryImage(reg, IApiToolsConstants.IMG_ELCL_COMPARE_APIS, ELCL + "compare_apis.gif"); //$NON-NLS-1$ >+ declareRegistryImage(reg, IApiToolsConstants.IMG_ELCL_COMPARE_APIS_DISABLED, DLCL + "compare_apis.gif"); //$NON-NLS-1$ > } > > /** >Index: src/org/eclipse/pde/api/tools/ui/internal/IApiToolsConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/IApiToolsConstants.java,v >retrieving revision 1.12 >diff -u -r1.12 IApiToolsConstants.java >--- src/org/eclipse/pde/api/tools/ui/internal/IApiToolsConstants.java 19 Jan 2009 23:20:38 -0000 1.12 >+++ src/org/eclipse/pde/api/tools/ui/internal/IApiToolsConstants.java 16 Apr 2009 15:42:16 -0000 >@@ -14,105 +14,111 @@ > * @since 1.0.0 > */ > public interface IApiToolsConstants { >- >+ /** >+ * Empty String constant >+ */ >+ public static final String EMPTY_STRING = ""; //$NON-NLS-1$ > /** > * Plug-in identifier > */ > public static final String ID_API_TOOLS_UI_PLUGIN = "org.eclipse.pde.api.tools.ui"; //$NON-NLS-1$ > /** >- * Empty String constant >+ * Id for the Api baselines preference page. >+ * <br> >+ * Value is: <code>org.eclipse.pde.api.tools.ui.apiprofiles.prefpage</code> > */ >- public static final String EMPTY_STRING = ""; //$NON-NLS-1$ >+ public static final String ID_BASELINES_PREF_PAGE = "org.eclipse.pde.api.tools.ui.apiprofiles.prefpage"; //$NON-NLS-1$ > /** >- * Key for API component image. >+ * Id for the API errors / warnings preference page >+ * <br> >+ * Value is: <code>org.eclipse.pde.api.tools.ui.apitools.errorwarnings.prefpage</code> > */ >- public static final String IMG_OBJ_API_COMPONENT = "IMG_OBJ_API_COMPONENT"; //$NON-NLS-1$ >+ public static final String ID_ERRORS_WARNINGS_PREF_PAGE = "org.eclipse.pde.api.tools.ui.apitools.errorwarnings.prefpage"; //$NON-NLS-1$ >+ > /** >- * Key for API system component image >+ * The id for the API errors / warnings property page >+ * <br> >+ * Value is: <code>org.eclipse.pde.api.tools.ui.apitools.warningspage</code> > */ >- public static final String IMG_OBJ_API_SYSTEM_LIBRARY = "IMG_OBJ_API_SYSTEM_LIBRARY"; //$NON-NLS-1$ >+ public static final String ID_ERRORS_WARNINGS_PROP_PAGE = "org.eclipse.pde.api.tools.ui.apitools.warningspage"; //$NON-NLS-1$ > > /** >- * Key for API search image >+ * The id for the API problem filters property page >+ * <br> >+ * Value is: <code>org.eclipse.pde.api.tools.ui.apitools.filterspage</code> > */ >- public static final String IMG_OBJ_API_SEARCH = "IMG_OBJ_API_SEARCH"; //$NON-NLS-1$ >+ public static final String ID_FILTERS_PROP_PAGE = "org.eclipse.pde.api.tools.ui.apitools.filterspage"; //$NON-NLS-1$ > > /** >- * Key for bundle image >+ * Key for a compare api image > */ >- public static final String IMG_OBJ_BUNDLE = "IMG_OBJ_BUNDLE"; //$NON-NLS-1$ >- >+ public static final String IMG_ELCL_COMPARE_APIS = "IMG_ELCL_COMPARE_APIS"; //$NON-NLS-1$ > /** >- * Key for fragment image >+ * Key for a compare api disabled image > */ >- public static final String IMG_OBJ_FRAGMENT = "IMG_OBJ_FRAGMENT"; //$NON-NLS-1$ >- >+ public static final String IMG_ELCL_COMPARE_APIS_DISABLED = "IMG_ELCL_COMPARE_APIS_DISABLED"; //$NON-NLS-1$ > /** >- * Key for Eclipse SDK/API profile image >+ * Key for filter resolution image > */ >- public static final String IMG_OBJ_ECLIPSE_PROFILE = "IMG_OBJ_ECLIPSE_PROFILE"; //$NON-NLS-1$ >+ public static final String IMG_ELCL_FILTER = "IMG_ELCL_FILTER"; //$NON-NLS-1$ > > /** >- * Key for a bundle version image >+ * Key for the open page image > */ >- public static final String IMG_OBJ_BUNDLE_VERSION = "IMG_OBJ_BUNDLE_VERSION"; //$NON-NLS-1$ >- >+ public static final String IMG_ELCL_OPEN_PAGE = "IMG_ELCL_OPEN_PAGE"; //$NON-NLS-1$ >+ > /** >- * Error overlay. >+ * Key for enabled remove image > */ >- public static final String IMG_OVR_ERROR = "IMG_OVR_ERROR"; //$NON-NLS-1$ >+ public static final String IMG_ELCL_REMOVE = "IMG_ELCL_REMOVE"; //$NON-NLS-1$ > > /** >- * Warning overlay >+ * Key for API component image. > */ >- public static final String IMG_OVR_WARNING = "IMG_OVR_WARNING"; //$NON-NLS-1$ >+ public static final String IMG_OBJ_API_COMPONENT = "IMG_OBJ_API_COMPONENT"; //$NON-NLS-1$ > > /** >- * Success overlay >+ * Key for API search image > */ >- public static final String IMG_OVR_SUCCESS = "IMG_OVR_SUCCESS"; //$NON-NLS-1$ >+ public static final String IMG_OBJ_API_SEARCH = "IMG_OBJ_API_SEARCH"; //$NON-NLS-1$ > > /** >- * Wizard banner for editing an API profile >+ * Key for API system component image > */ >- public static final String IMG_WIZBAN_PROFILE = "IMG_WIZBAN_PROFILE"; //$NON-NLS-1$ >+ public static final String IMG_OBJ_API_SYSTEM_LIBRARY = "IMG_OBJ_API_SYSTEM_LIBRARY"; //$NON-NLS-1$ > > /** >- * Id for the Api baselines preference page. >- * <br> >- * Value is: <code>org.eclipse.pde.api.tools.ui.apiprofiles.prefpage</code> >+ * Key for bundle image > */ >- public static final String ID_BASELINES_PREF_PAGE = "org.eclipse.pde.api.tools.ui.apiprofiles.prefpage"; //$NON-NLS-1$ >+ public static final String IMG_OBJ_BUNDLE = "IMG_OBJ_BUNDLE"; //$NON-NLS-1$ > /** >- * Id for the API errors / warnings preference page >- * <br> >- * Value is: <code>org.eclipse.pde.api.tools.ui.apitools.errorwarnings.prefpage</code> >+ * Key for a bundle version image > */ >- public static final String ID_ERRORS_WARNINGS_PREF_PAGE = "org.eclipse.pde.api.tools.ui.apitools.errorwarnings.prefpage"; //$NON-NLS-1$ >+ public static final String IMG_OBJ_BUNDLE_VERSION = "IMG_OBJ_BUNDLE_VERSION"; //$NON-NLS-1$ > /** >- * The id for the API problem filters property page >- * <br> >- * Value is: <code>org.eclipse.pde.api.tools.ui.apitools.filterspage</code> >+ * Key for Eclipse SDK/API profile image > */ >- public static final String ID_FILTERS_PROP_PAGE = "org.eclipse.pde.api.tools.ui.apitools.filterspage"; //$NON-NLS-1$ >+ public static final String IMG_OBJ_ECLIPSE_PROFILE = "IMG_OBJ_ECLIPSE_PROFILE"; //$NON-NLS-1$ > /** >- * The id for the API errors / warnings property page >- * <br> >- * Value is: <code>org.eclipse.pde.api.tools.ui.apitools.warningspage</code> >+ * Key for fragment image > */ >- public static final String ID_ERRORS_WARNINGS_PROP_PAGE = "org.eclipse.pde.api.tools.ui.apitools.warningspage"; //$NON-NLS-1$ >+ public static final String IMG_OBJ_FRAGMENT = "IMG_OBJ_FRAGMENT"; //$NON-NLS-1$ > /** >- * Key for filter resolution image >+ * Error overlay. > */ >- public static final String IMG_ELCL_FILTER = "IMG_ELCL_FILTER"; //$NON-NLS-1$ >+ public static final String IMG_OVR_ERROR = "IMG_OVR_ERROR"; //$NON-NLS-1$ > > /** >- * Key for enabled remove image >+ * Success overlay > */ >- public static final String IMG_ELCL_REMOVE = "IMG_ELCL_REMOVE"; //$NON-NLS-1$ >+ public static final String IMG_OVR_SUCCESS = "IMG_OVR_SUCCESS"; //$NON-NLS-1$ > > /** >- * Key for the open page image >+ * Warning overlay > */ >- public static final String IMG_ELCL_OPEN_PAGE = "IMG_ELCL_OPEN_PAGE"; //$NON-NLS-1$ >+ public static final String IMG_OVR_WARNING = "IMG_OVR_WARNING"; //$NON-NLS-1$ >+ /** >+ * Wizard banner for editing an API profile >+ */ >+ public static final String IMG_WIZBAN_PROFILE = "IMG_WIZBAN_PROFILE"; //$NON-NLS-1$ > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.17 >diff -u -r1.17 MANIFEST.MF >--- META-INF/MANIFEST.MF 14 Apr 2009 17:06:46 -0000 1.17 >+++ META-INF/MANIFEST.MF 16 Apr 2009 15:42:16 -0000 >@@ -33,5 +33,6 @@ > org.eclipse.pde.api.tools.ui.internal.preferences;x-friends:="org.eclipse.pde.api.tools.tests", > org.eclipse.pde.api.tools.ui.internal.properties;x-friends:="org.eclipse.pde.api.tools.tests", > org.eclipse.pde.api.tools.ui.internal.refactoring;x-internal:=true, >+ org.eclipse.pde.api.tools.ui.internal.views;x-internal:=true, > org.eclipse.pde.api.tools.ui.internal.wizards;x-friends:="org.eclipse.pde.api.tools.tests" > Import-Package: com.ibm.icu.text;version="3.6.1" >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools.ui/plugin.properties,v >retrieving revision 1.17 >diff -u -r1.17 plugin.properties >--- plugin.properties 14 Apr 2009 17:06:46 -0000 1.17 >+++ plugin.properties 16 Apr 2009 15:42:16 -0000 >@@ -1,5 +1,5 @@ > ############################################################################### >-# Copyright (c) 2007, 2008 IBM Corporation and others. >+# Copyright (c) 2007, 2009 IBM Corporation and others. > # 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 >@@ -43,6 +43,9 @@ > ApiToolsJavadocProposals.name = API Tools Javadoc Proposals > MarkerGroupingEntryLabel=API Usage and Compatibility > ApiToolsProposalCategory.name = PDE API Tools Proposals >+APICompare.name=Compare With... >+Apitoolingview.name=API Tooling >+Apitoolingview.category.name=API Tooling > FilterDeleteParticipant.name = API Problem Filter Delete Participant > FilterRenameParticipant.name = API Problem Filter Rename Participant > FilterMoveParticipant.name = API Problem Filter Move Participant >\ No newline at end of file >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/pde/apitools/org.eclipse.pde.api.tools.ui/plugin.xml,v >retrieving revision 1.21 >diff -u -r1.21 plugin.xml >--- plugin.xml 14 Apr 2009 17:06:46 -0000 1.21 >+++ plugin.xml 16 Apr 2009 15:42:16 -0000 >@@ -114,6 +114,25 @@ > value="org.eclipse.pde.api.tools.apiAnalysisNature"> > </filter> > </objectContribution> >+ <objectContribution >+ adaptable="false" >+ id="org.eclipse.pde.api.tools.ui.compare" >+ objectClass="org.eclipse.jdt.core.IJavaElement"> >+ <action >+ class="org.eclipse.pde.api.tools.ui.internal.actions.CompareWithAction" >+ enablesFor="+" >+ id="org.eclipse.pde.api.tools.ui.action.compare" >+ label="%APICompare.name" >+ menubarPath="org.eclipse.pde.ui.project.tools/group1"> >+ </action> >+ <menu >+ id="org.eclipse.pde.ui.project.tools" >+ label="%PdeTools.name"> >+ <separator >+ name="group1"> >+ </separator> >+ </menu> >+ </objectContribution> > </extension> > <extension > point="org.eclipse.ui.propertyPages"> >@@ -271,6 +290,26 @@ > </markerResolutionGenerator> > </extension> > <extension >+ point="org.eclipse.ui.views"> >+ <category >+ id="org.eclipse.pde.api.tools.ui.views.apitooling.view.category" >+ name="%Apitoolingview.category.name"> >+ </category> >+ <view >+ category="org.eclipse.pde.api.tools.ui.views.apitooling.view.category" >+ class="org.eclipse.pde.api.tools.ui.internal.views.APIToolingView" >+ icon="icons/full/obj16/api_tools.gif" >+ id="org.eclipse.pde.api.tools.ui.views.apitooling.views.apitoolingview" >+ name="%Apitoolingview.name"> >+ </view> >+ </extension> >+ <extension >+ point="org.eclipse.help.contexts"> >+ <contexts >+ file="contexts.xml"> >+ </contexts> >+ </extension> >+ <extension > point="org.eclipse.ltk.core.refactoring.renameParticipants"> > <renameParticipant > class="org.eclipse.pde.api.tools.ui.internal.refactoring.FilterRenameParticipant" >Index: src/org/eclipse/pde/api/tools/ui/internal/actions/RemoveAllSessionsAction.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/ui/internal/actions/RemoveAllSessionsAction.java >diff -N src/org/eclipse/pde/api/tools/ui/internal/actions/RemoveAllSessionsAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/ui/internal/actions/RemoveAllSessionsAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,27 @@ >+package org.eclipse.pde.api.tools.ui.internal.actions; >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; >+import org.eclipse.ui.ISharedImages; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * This action removes the active session. >+ */ >+public class RemoveAllSessionsAction extends Action { >+ >+ public RemoveAllSessionsAction() { >+ setText(ActionMessages.RemoveAllSessionsAction_label); >+ setToolTipText(ActionMessages.RemoveAllSessionsAction_tooltip); >+ ImageDescriptor enabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_REMOVEALL); >+ //ImageDescriptor enabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE); >+ setImageDescriptor(enabledImageDescriptor); >+ ImageDescriptor disabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_REMOVEALL_DISABLED); >+ //ImageDescriptor disabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED); >+ setDisabledImageDescriptor(disabledImageDescriptor); >+ } >+ >+ public void run() { >+ ApiPlugin.getDefault().getSessionManager().removeAllSessions(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/pde/api/tools/ui/internal/actions/SelectSessionAction.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/ui/internal/actions/SelectSessionAction.java >diff -N src/org/eclipse/pde/api/tools/ui/internal/actions/SelectSessionAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/ui/internal/actions/SelectSessionAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,66 @@ >+package org.eclipse.pde.api.tools.ui.internal.actions; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.IMenuCreator; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; >+import org.eclipse.pde.api.tools.internal.provisional.ISession; >+import org.eclipse.pde.api.tools.internal.provisional.ISessionManager; >+import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin; >+import org.eclipse.pde.api.tools.ui.internal.IApiToolsConstants; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.MenuItem; >+ >+/** >+ * Drop-down action to select the active session. >+ */ >+public class SelectSessionAction extends Action implements IMenuCreator { >+ >+ private Menu menu; >+ >+ public SelectSessionAction() { >+ setText(ActionMessages.SelectSessionAction_label); >+ setToolTipText(ActionMessages.SelectSessionAction_tooltip); >+ setImageDescriptor(ApiUIPlugin.getImageDescriptor(IApiToolsConstants.IMG_ELCL_COMPARE_APIS)); >+ setDisabledImageDescriptor(ApiUIPlugin.getImageDescriptor(IApiToolsConstants.IMG_ELCL_COMPARE_APIS_DISABLED)); >+ setMenuCreator(this); >+ setEnabled(false); >+ } >+ >+ public Menu getMenu(Control parent) { >+ if (menu != null) { >+ menu.dispose(); >+ } >+ menu = new Menu(parent); >+ >+ final ISessionManager manager = ApiPlugin.getDefault().getSessionManager(); >+ ISession[] sessions = manager.getSessions(); >+ ISession active = manager.getActiveSession(); >+ for (int i = 0; i < sessions.length; i++) { >+ final ISession session = sessions[i]; >+ MenuItem item = new MenuItem(menu, SWT.RADIO); >+ Object[] labelparams = new Object[] { new Integer(i + 1), session.getTimestamp()}; >+ item.setText(NLS.bind(ActionMessages.SelectSessionActionEntry_label, >+ labelparams)); >+ item.setSelection(session == active); >+ item.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ manager.activateSession(session); >+ } >+ }); >+ } >+ return menu; >+ } >+ >+ public Menu getMenu(Menu parent) { >+ return null; >+ } >+ >+ public void dispose() { >+ } >+ >+} >\ No newline at end of file >Index: src/org/eclipse/pde/api/tools/ui/internal/actions/RemoveActiveSessionAction.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/ui/internal/actions/RemoveActiveSessionAction.java >diff -N src/org/eclipse/pde/api/tools/ui/internal/actions/RemoveActiveSessionAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/ui/internal/actions/RemoveActiveSessionAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+package org.eclipse.pde.api.tools.ui.internal.actions; >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; >+import org.eclipse.pde.api.tools.internal.provisional.ISession; >+import org.eclipse.pde.api.tools.internal.provisional.ISessionManager; >+import org.eclipse.ui.ISharedImages; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.actions.ActionFactory; >+ >+/** >+ * This action removes the active session. >+ */ >+public class RemoveActiveSessionAction extends Action { >+ >+ public RemoveActiveSessionAction() { >+ setText(ActionMessages.RemoveActiveSessionAction_label); >+ setToolTipText(ActionMessages.RemoveActiveSessionAction_tooltip); >+ ImageDescriptor enabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE); >+ //ImageDescriptor enabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE); >+ setImageDescriptor(enabledImageDescriptor); >+ ImageDescriptor disabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE_DISABLED); >+ //ImageDescriptor disabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED); >+ setDisabledImageDescriptor(disabledImageDescriptor); >+ setActionDefinitionId(ActionFactory.DELETE.getCommandId()); >+ } >+ >+ public void run() { >+ ISessionManager manager = ApiPlugin.getDefault().getSessionManager(); >+ ISession session = manager.getActiveSession(); >+ if (session != null) { >+ manager.removeSession(session); >+ } >+ ISession[] sessions = manager.getSessions(); >+ int length = sessions.length; >+ if (length > 0) { >+ manager.activateSession(sessions[length - 1]); >+ } >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/pde/api/tools/ui/internal/actions/CompareDialog.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/ui/internal/actions/CompareDialog.java >diff -N src/org/eclipse/pde/api/tools/ui/internal/actions/CompareDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/ui/internal/actions/CompareDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,179 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.ui.internal.actions; >+ >+import java.util.Arrays; >+ >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.dialogs.IDialogSettings; >+import org.eclipse.jface.window.IShellProvider; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; >+import org.eclipse.pde.api.tools.internal.provisional.IApiBaselineManager; >+import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline; >+import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin; >+import org.eclipse.pde.api.tools.ui.internal.SWTFactory; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Combo; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Shell; >+ >+/** >+ * Compares {@link org.eclipse.pde.api.tools.internal.provisional.model.IApiElement}s >+ * to a given {@link IApiBaseline} to get a delta >+ * >+ * @since 1.0.1 >+ */ >+public class CompareDialog extends Dialog { >+ >+ //widget state ids >+ static final String SETTINGS_SECTION = ApiUIPlugin.PLUGIN_ID + ".api.compare"; //$NON-NLS-1$ >+ static final String BASELINE_STATE = SETTINGS_SECTION + ".baseline"; //$NON-NLS-1$ >+ >+ public String baseline = null; >+ String title = null;; >+ Combo baselinecombo = null; >+ >+ /** >+ * Constructor >+ * @param provider >+ * @param title >+ */ >+ public CompareDialog(IShellProvider provider, String title) { >+ super(provider); >+ this.title = title; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) >+ */ >+ protected void configureShell(Shell newShell) { >+ super.configureShell(newShell); >+ newShell.setText(this.title); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#isResizable() >+ */ >+ protected boolean isResizable() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createDialogArea(Composite parent) { >+ Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL); >+ GridData gd = (GridData) comp.getLayoutData(); >+ gd.widthHint = 310; >+ >+ SWTFactory.createWrapLabel(comp, ActionMessages.SelectABaseline, 2); >+ this.baselinecombo = SWTFactory.createCombo(comp, SWT.BORDER | SWT.FLAT | SWT.READ_ONLY, 2, GridData.FILL_HORIZONTAL, null); >+ this.baselinecombo.addSelectionListener(new SelectionAdapter(){ >+ public void widgetSelected(SelectionEvent e) { >+ Combo combo = (Combo) e.widget; >+ String[] baselineNames = (String[]) combo.getData(); >+ String selectedBaselineName = baselineNames[combo.getSelectionIndex()]; >+ CompareDialog.this.baseline = selectedBaselineName; >+ } >+ }); >+ initialize(); >+ return comp; >+ } >+ >+ /** >+ * Initializes the controls >+ */ >+ void initialize() { >+ IApiBaselineManager apiBaselineManager = ApiPlugin.getDefault().getApiBaselineManager(); >+ IApiBaseline defaultBaseline = apiBaselineManager.getDefaultApiBaseline(); >+ String defaultBaselineName = defaultBaseline != null ? defaultBaseline.getName() : null; >+ IApiBaseline[] baselines = apiBaselineManager.getApiBaselines(); >+ int length = baselines.length; >+ String[] baselinesItems = new String[length]; >+ String[] baselinesNames = new String[length]; >+ // set the names >+ for (int i = 0; i < length; i++) { >+ String currentBaselineName = baselines[i].getName(); >+ baselinesNames[i] = currentBaselineName; >+ } >+ Arrays.sort(baselinesNames); >+ // set the labels >+ int index = 0; >+ for (int i = 0; i < length; i++) { >+ String currentBaselineName = baselinesNames[i]; >+ if (defaultBaselineName != null && defaultBaselineName.equals(currentBaselineName)) { >+ baselinesItems[i] = NLS.bind(ActionMessages.SetAsDefault, currentBaselineName); >+ this.baseline = currentBaselineName; >+ index = i; >+ } else { >+ baselinesItems[i] = currentBaselineName; >+ } >+ } >+ this.baselinecombo.setItems(baselinesItems); >+ this.baselinecombo.setData(baselinesNames); >+ this.baselinecombo.select(index); >+ >+ IDialogSettings settings = ApiUIPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION); >+ if(settings != null) { >+ restoreComboSelection(this.baselinecombo, BASELINE_STATE, settings, baselinesNames); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#okPressed() >+ */ >+ protected void okPressed() { >+ saveWidgetState(); >+ super.okPressed(); >+ } >+ /** >+ * Restores the selected item for the given combo based on the stored value from the >+ * dialog settings >+ * >+ * @param combo >+ * @param id >+ * @param settings >+ */ >+ private void restoreComboSelection(Combo combo, String id, IDialogSettings settings, String[] baselinesNames) { >+ String value = settings.get(id); >+ if(value != null) { >+ CompareDialog.this.baseline = value; >+ // retrieve the right index in the combo >+ int index = 0; >+ int length = baselinesNames.length; >+ for (int i = 0; i < length; i++) { >+ String currentBaselineName = baselinesNames[i]; >+ if (value.equals(currentBaselineName)) { >+ index = i; >+ break; >+ } >+ } >+ combo.select(index); >+ } >+ } >+ >+ /** >+ * Saves the state of the widgets on the page >+ */ >+ void saveWidgetState() { >+ IDialogSettings rootsettings = ApiUIPlugin.getDefault().getDialogSettings(); >+ IDialogSettings settings = rootsettings.getSection(SETTINGS_SECTION); >+ if(settings == null) { >+ settings = rootsettings.addNewSection(SETTINGS_SECTION); >+ } >+ settings.put(BASELINE_STATE, this.baseline); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/pde/api/tools/ui/internal/views/APIToolingView.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/ui/internal/views/APIToolingView.java >diff -N src/org/eclipse/pde/api/tools/ui/internal/views/APIToolingView.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/ui/internal/views/APIToolingView.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,385 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.ui.internal.views; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jdt.core.Flags; >+import org.eclipse.jdt.ui.JavaUI; >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.action.IMenuManager; >+import org.eclipse.jface.action.IToolBarManager; >+import org.eclipse.jface.action.Separator; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.viewers.DoubleClickEvent; >+import org.eclipse.jface.viewers.IDoubleClickListener; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.pde.api.tools.internal.ApiBaselineManager; >+import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; >+import org.eclipse.pde.api.tools.internal.provisional.ISession; >+import org.eclipse.pde.api.tools.internal.provisional.ISessionListener; >+import org.eclipse.pde.api.tools.internal.provisional.ISessionManager; >+import org.eclipse.pde.api.tools.internal.provisional.ITreeModel; >+import org.eclipse.pde.api.tools.internal.provisional.ITreeNode; >+import org.eclipse.pde.api.tools.internal.provisional.comparator.DeltaProcessor; >+import org.eclipse.pde.api.tools.internal.provisional.comparator.IDelta; >+import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline; >+import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent; >+import org.eclipse.pde.api.tools.ui.internal.ApiImageDescriptor; >+import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin; >+import org.eclipse.pde.api.tools.ui.internal.IApiToolsConstants; >+import org.eclipse.pde.api.tools.ui.internal.actions.ActionMessages; >+import org.eclipse.pde.api.tools.ui.internal.actions.DeltaPropertyDialog; >+import org.eclipse.pde.api.tools.ui.internal.actions.ExportSessionAction; >+import org.eclipse.pde.api.tools.ui.internal.actions.RemoveActiveSessionAction; >+import org.eclipse.pde.api.tools.ui.internal.actions.RemoveAllSessionsAction; >+import org.eclipse.pde.api.tools.ui.internal.actions.SelectSessionAction; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.IActionBars; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.actions.ActionFactory; >+import org.eclipse.ui.part.ViewPart; >+ >+/** >+ * The class is used to show api tooling task results in a tree view. >+ */ >+ >+public class APIToolingView extends ViewPart implements ISessionListener { >+ >+ /** >+ * The ID of the view as specified by the extension. >+ */ >+ public static final String ID = "org.eclipse.pde.api.tools.ui.views.apitooling.views.apitoolingview"; //$NON-NLS-1$ >+ >+ public TreeViewer viewer; >+ private IAction removeActiveSessionAction; >+ private IAction removeAllSessionsAction; >+ private IAction selectSessionAction; >+ private Action doubleClickAction; >+ private ExportSessionAction exportSessionAction; >+ >+ class ViewContentProvider implements IStructuredContentProvider, ITreeContentProvider { >+ ITreeModel model; >+ >+ public void inputChanged(Viewer v, Object oldInput, Object newInput) { >+ this.model = null; >+ } >+ public void dispose() { >+ } >+ public Object[] getElements(Object parent) { >+ if (parent instanceof ISession) { >+ ISession session = (ISession) parent; >+ if (this.model == null) { >+ this.model = session.getModel(); >+ } >+ return getChildren(this.model.getRoot()); >+ } >+ return getChildren(parent); >+ } >+ public Object getParent(Object child) { >+ return null; >+ } >+ public Object [] getChildren(Object parent) { >+ if (parent instanceof ITreeNode) { >+ return ((ITreeNode) parent).getChildren(); >+ } >+ return new Object[0]; >+ } >+ public boolean hasChildren(Object parent) { >+ if (parent instanceof ITreeNode) { >+ return ((ITreeNode) parent).hasChildren(); >+ } >+ return false; >+ } >+ } >+ class ViewLabelProvider extends LabelProvider { >+ public String getText(Object obj) { >+ return obj.toString(); >+ } >+ >+ public Image getImage(Object obj) { >+ if (obj instanceof ITreeNode) { >+ ITreeNode treeNode = (ITreeNode) obj; >+ switch(treeNode.getId()) { >+ case ITreeNode.CLASS : >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_CLASS); >+ case ITreeNode.INTERFACE : >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_INTERFACE); >+ case ITreeNode.ANNOTATION : >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_ANNOTATION); >+ case ITreeNode.ENUM : >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_ENUM); >+ case ITreeNode.PACKAGE : >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PACKAGE); >+ } >+ Object data = treeNode.getData(); >+ if (data instanceof IDelta) { >+ IDelta delta = (IDelta) data; >+ Image image = getDeltaElementImage(delta); >+ if (image != null) { >+ int flags = (DeltaProcessor.isCompatible(delta) ? ApiImageDescriptor.SUCCESS : ApiImageDescriptor.ERROR); >+ ImageDescriptor descriptor = ImageDescriptor.createFromImage(image); >+ ApiImageDescriptor desc = new ApiImageDescriptor(descriptor, flags); >+ return ApiUIPlugin.getImage(desc); >+ } >+ } >+ } >+ return null; >+ } >+ >+ private Image getDeltaElementImage(IDelta delta) { >+ switch(delta.getFlags()) { >+ case IDelta.API_FIELD : >+ case IDelta.FIELD : { >+ int modifiers = delta.getNewModifiers(); >+ switch(delta.getKind()) { >+ case IDelta.REMOVED : { >+ modifiers = delta.getOldModifiers(); >+ } >+ } >+ if (Flags.isPublic(modifiers)) { >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_PUBLIC); >+ } else if (Flags.isProtected(modifiers)) { >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_PROTECTED); >+ } else if (Flags.isPrivate(modifiers)){ >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_PRIVATE); >+ } else { >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_DEFAULT); >+ } >+ } >+ case IDelta.METHOD : >+ case IDelta.METHOD_MOVED_DOWN : >+ case IDelta.METHOD_MOVED_UP : >+ case IDelta.METHOD_WITH_DEFAULT_VALUE : >+ case IDelta.METHOD_WITHOUT_DEFAULT_VALUE : >+ case IDelta.CONSTRUCTOR : >+ case IDelta.CLINIT : { >+ int modifiers = delta.getNewModifiers(); >+ switch(delta.getKind()) { >+ case IDelta.REMOVED : { >+ modifiers = delta.getOldModifiers(); >+ } >+ } >+ if (Flags.isPublic(modifiers)) { >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PUBLIC); >+ } else if (Flags.isProtected(modifiers)) { >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PROTECTED); >+ } else if (Flags.isPrivate(modifiers)){ >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PRIVATE); >+ } else { >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_CLASS_DEFAULT); >+ } >+ } >+ } >+ switch(delta.getElementType()) { >+ case IDelta.ANNOTATION_ELEMENT_TYPE : return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_ANNOTATION); >+ case IDelta.ENUM_ELEMENT_TYPE : return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_ENUM); >+ case IDelta.CLASS_ELEMENT_TYPE : return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_CLASS); >+ case IDelta.INTERFACE_ELEMENT_TYPE : return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_INTERFACE); >+ case IDelta.FIELD_ELEMENT_TYPE : { >+ int modifiers = delta.getNewModifiers(); >+ switch(delta.getKind()) { >+ case IDelta.REMOVED : { >+ modifiers = delta.getOldModifiers(); >+ } >+ } >+ if (Flags.isPublic(modifiers)) { >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_PUBLIC); >+ } else if (Flags.isProtected(modifiers)) { >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_PROTECTED); >+ } else if (Flags.isPrivate(modifiers)){ >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_PRIVATE); >+ } else { >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_DEFAULT); >+ } >+ } >+ case IDelta.METHOD_ELEMENT_TYPE : >+ case IDelta.CONSTRUCTOR_ELEMENT_TYPE : { >+ int modifiers = delta.getNewModifiers(); >+ switch(delta.getKind()) { >+ case IDelta.REMOVED : { >+ modifiers = delta.getOldModifiers(); >+ } >+ } >+ if (Flags.isPublic(modifiers)) { >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PUBLIC); >+ } else if (Flags.isProtected(modifiers)) { >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PROTECTED); >+ } else if (Flags.isPrivate(modifiers)){ >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PRIVATE); >+ } else { >+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_CLASS_DEFAULT); >+ } >+ } >+ case IDelta.TYPE_PARAMETER_ELEMENT_TYPE : return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PUBLIC); >+ case IDelta.API_PROFILE_ELEMENT_TYPE : return ApiUIPlugin.getSharedImage(IApiToolsConstants.IMG_OBJ_ECLIPSE_PROFILE); >+ case IDelta.API_COMPONENT_ELEMENT_TYPE : { >+ String componentVersionId = delta.getComponentVersionId(); >+ IApiComponent component = null; >+ if (componentVersionId != null) { >+ int indexOfOpen = componentVersionId.lastIndexOf('('); >+ String componentID = componentVersionId.substring(0, indexOfOpen); >+ IApiBaseline baseline = ApiBaselineManager.getManager().getWorkspaceBaseline(); >+ if (baseline != null) { >+ IApiComponent apiComponent = baseline.getApiComponent(componentID); >+ if (apiComponent != null) { >+ component = apiComponent; >+ } >+ } >+ } >+ if (component != null) { >+ if(component.isSystemComponent()) { >+ return ApiUIPlugin.getSharedImage(IApiToolsConstants.IMG_OBJ_API_SYSTEM_LIBRARY); >+ } >+ try { >+ if (component.isFragment()) { >+ return ApiUIPlugin.getSharedImage(IApiToolsConstants.IMG_OBJ_FRAGMENT); >+ } >+ } catch (CoreException e) { >+ ApiPlugin.log(e); >+ } >+ return ApiUIPlugin.getSharedImage(IApiToolsConstants.IMG_OBJ_BUNDLE); >+ } >+ } >+ } >+ return null; >+ } >+ } >+ >+ /** >+ * The constructor. >+ */ >+ public APIToolingView() { >+ } >+ /** >+ * This is a callback that will allow us >+ * to create the viewer and initialize it. >+ */ >+ public void createPartControl(Composite parent) { >+ this.viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); >+ this.viewer.setContentProvider(new ViewContentProvider()); >+ this.viewer.setLabelProvider(new ViewLabelProvider()); >+ ISession[] sessions = ApiPlugin.getDefault().getSessionManager().getSessions(); >+ if (sessions.length > 0) { >+ this.viewer.setInput(sessions[0]); >+ } >+ // Create the help context id for the viewer's control >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this.viewer.getControl(), APIToolingView.ID); >+ createActions(); >+ updateActions(); >+ configureToolbar(); >+ hookDoubleClickAction(); >+ >+ ApiPlugin.getDefault().getSessionManager().addSessionListener(this); >+ } >+ private void hookDoubleClickAction() { >+ this.viewer.addDoubleClickListener(new IDoubleClickListener() { >+ public void doubleClick(DoubleClickEvent event) { >+ APIToolingView.this.doubleClickAction.run(); >+ } >+ }); >+ } >+ public void dispose() { >+ ApiPlugin.getDefault().getSessionManager().removeSessionListener(this); >+ } >+ protected void configureToolbar() { >+ IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager(); >+ tbm.add(new Separator()); >+ tbm.add(this.removeActiveSessionAction); >+ tbm.add(this.removeAllSessionsAction); >+ tbm.add(this.selectSessionAction); >+ tbm.add(new Separator()); >+// tbm.add(new CollapseAllAction(this.viewer)); >+ >+ IMenuManager mm = getViewSite().getActionBars().getMenuManager(); >+ mm.add(this.exportSessionAction); >+ } >+ private void createActions() { >+ final IActionBars actionBars = getViewSite().getActionBars(); >+ >+ this.removeActiveSessionAction = new RemoveActiveSessionAction(); >+ actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), removeActiveSessionAction); >+ >+ this.removeAllSessionsAction = new RemoveAllSessionsAction(); >+ this.selectSessionAction = new SelectSessionAction(); >+ this.doubleClickAction = new Action() { >+ public void run() { >+ ISelection selection = viewer.getSelection(); >+ if (selection instanceof IStructuredSelection) { >+ Object item = ((IStructuredSelection) selection).getFirstElement(); >+ if (APIToolingView.this.viewer.getExpandedState(item)) { >+ APIToolingView.this.viewer.collapseToLevel(item, 1); >+ } else { >+ APIToolingView.this.viewer.expandToLevel(item, 1); >+ } >+ if (item instanceof ITreeNode) { >+ ITreeNode node = (ITreeNode) item; >+ if (node.getData() != null) { >+ DeltaPropertyDialog dialog = new DeltaPropertyDialog(APIToolingView.this.getSite(), ActionMessages.DeltaDetails, (IDelta) node.getData()); >+ dialog.open(); >+ } >+ } >+ } >+ } >+ }; >+ this.exportSessionAction = new ExportSessionAction(this); >+ } >+ private void updateActions() { >+ this.viewer.getControl().getDisplay().asyncExec(new Runnable() { >+ public void run() { >+ ISessionManager sessionManager = ApiPlugin.getDefault().getSessionManager(); >+ ISession active = sessionManager.getActiveSession(); >+ setContentDescription(active == null ? "" : active.getTimestamp()); //$NON-NLS-1$ >+ ISession[] sessions = sessionManager.getSessions(); >+ boolean atLeastOne = sessions.length >= 1; >+ APIToolingView.this.removeActiveSessionAction.setEnabled(atLeastOne); >+ APIToolingView.this.removeAllSessionsAction.setEnabled(atLeastOne); >+ APIToolingView.this.selectSessionAction.setEnabled(atLeastOne); >+ APIToolingView.this.exportSessionAction.setEnabled(active != null); >+ } >+ }); >+ } >+ /** >+ * Passing the focus request to the viewer's control. >+ */ >+ public void setFocus() { >+ this.viewer.getControl().setFocus(); >+ } >+ public void sessionAdded(final ISession session) { >+ this.viewer.getControl().getDisplay().asyncExec(new Runnable() { >+ public void run() { >+ APIToolingView.this.viewer.setInput(session); >+ } >+ }); >+ updateActions(); >+ } >+ public void sessionRemoved(ISession session) { >+ this.viewer.setInput(null); >+ updateActions(); >+ } >+ >+ public void sessionActivated(final ISession session) { >+ this.viewer.getControl().getDisplay().asyncExec(new Runnable() { >+ public void run() { >+ APIToolingView.this.viewer.setInput(session); >+ } >+ }); >+ updateActions(); >+ } >+} >\ No newline at end of file >Index: contexts.xml >=================================================================== >RCS file: contexts.xml >diff -N contexts.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ contexts.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,12 @@ >+<contexts> >+ <context id="viewer" title="Sample View"> >+ <description>This is the context help for the sample view with a tree viewer. It was generated by a PDE template.</description> >+ <topic href="/PLUGINS_ROOT/org.eclipse.platform.doc.isv/guide/ua_help_context.htm" label="Context-sensitive help"> >+ <enablement> >+ <with variable="platform"> >+ <test property="org.eclipse.core.runtime.isBundleInstalled" args="org.eclipse.platform.doc.isv"/> >+ </with> >+ </enablement> >+ </topic> >+ </context> >+</contexts> >Index: src/org/eclipse/pde/api/tools/ui/internal/actions/ExportSessionAction.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/ui/internal/actions/ExportSessionAction.java >diff -N src/org/eclipse/pde/api/tools/ui/internal/actions/ExportSessionAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/ui/internal/actions/ExportSessionAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,160 @@ >+package org.eclipse.pde.api.tools.ui.internal.actions; >+ >+import java.io.BufferedWriter; >+import java.io.File; >+import java.io.FileWriter; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.Writer; >+ >+import javax.xml.transform.Result; >+import javax.xml.transform.Source; >+import javax.xml.transform.Transformer; >+import javax.xml.transform.TransformerConfigurationException; >+import javax.xml.transform.TransformerException; >+import javax.xml.transform.TransformerFactory; >+import javax.xml.transform.stream.StreamResult; >+import javax.xml.transform.stream.StreamSource; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.SubMonitor; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.window.Window; >+import org.eclipse.pde.api.tools.internal.comparator.DeltaXmlVisitor; >+import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; >+import org.eclipse.pde.api.tools.internal.provisional.ISession; >+import org.eclipse.pde.api.tools.internal.provisional.comparator.IDelta; >+import org.eclipse.pde.api.tools.internal.util.Util; >+import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin; >+import org.eclipse.pde.api.tools.ui.internal.views.APIToolingView; >+ >+/** >+ * Drop-down action to select the active session. >+ */ >+public class ExportSessionAction extends Action { >+ private static final String DELTAS_XSLT_TRANSFORM_PATH = "/xslt/deltas.xsl"; //$NON-NLS-1$ >+ private static final String XML_FILE_EXTENSION = ".xml"; //$NON-NLS-1$ >+ private static final String HTML_FILE_EXTENSION = ".html"; //$NON-NLS-1$ >+ APIToolingView view; >+ public ExportSessionAction(APIToolingView view) { >+ setText(ActionMessages.ExportSessionAction_label); >+ setToolTipText(ActionMessages.ExportSessionAction_tooltip); >+ setEnabled(false); >+ this.view = view; >+ } >+ >+ public void run() { >+ final ISession activeSession = ApiPlugin.getDefault().getSessionManager().getActiveSession(); >+ if (activeSession == null) { >+ return; >+ } >+ ExportDialog dialog = new ExportDialog(view.getSite(), ActionMessages.ExportActionTitle); >+ int returnCode = dialog.open(); >+ if (returnCode == Window.CANCEL) { >+ return; >+ } >+ final String reportFileName = dialog.reportPath; >+ if (reportFileName == null) { >+ return; >+ } >+ final String lowerCase = reportFileName.toLowerCase(); >+ if (!lowerCase.endsWith(HTML_FILE_EXTENSION) && !lowerCase.endsWith(XML_FILE_EXTENSION)) { >+ return; >+ } >+ >+ Job job = new Job(ActionMessages.CompareWithAction_comparing_apis){ >+ protected IStatus run(IProgressMonitor monitor) { >+ SubMonitor progress = SubMonitor.convert(monitor, 100); >+ progress.subTask(ActionMessages.CompareDialogCollectingElementTaskName); >+ boolean isHtmlFile = lowerCase.endsWith(HTML_FILE_EXTENSION); >+ File xmlOutputFile = null; >+ try { >+ progress.subTask(ActionMessages.CompareDialogComputeDeltasTaskName); >+ BufferedWriter writer = null; >+ try { >+ progress.worked(50); >+ Util.checkCanceled(progress); >+ if (isHtmlFile) { >+ xmlOutputFile = File.createTempFile(String.valueOf(System.currentTimeMillis()), XML_FILE_EXTENSION); >+ } else { >+ xmlOutputFile = new File(reportFileName); >+ } >+ if (xmlOutputFile.exists()) { >+ xmlOutputFile.delete(); >+ } >+ writer = new BufferedWriter(new FileWriter(xmlOutputFile)); >+ DeltaXmlVisitor visitor = new DeltaXmlVisitor(); >+ Object data = activeSession.getModel().getRoot().getData(); >+ if (data instanceof IDelta) { >+ IDelta delta = (IDelta) data; >+ progress.worked(25); >+ delta.accept(visitor); >+ writer.write(visitor.getXML()); >+ writer.flush(); >+ progress.worked(25); >+ } >+ return Status.OK_STATUS; >+ } catch (IOException e) { >+ ApiPlugin.log(e); >+ } catch (CoreException e) { >+ ApiPlugin.log(e); >+ } catch(OperationCanceledException e) { >+ // ignore >+ } finally { >+ try { >+ if (writer != null) { >+ writer.close(); >+ } >+ } catch(IOException e) {} >+ } >+ progress.worked(1); >+ } finally { >+ monitor.done(); >+ } >+ if(isHtmlFile) { >+ // remaining part is to convert the xml file to html using XSLT >+ Source xmlSource = new StreamSource(xmlOutputFile); >+ InputStream stream = ApiPlugin.class.getResourceAsStream(DELTAS_XSLT_TRANSFORM_PATH); >+ Source xsltSource = new StreamSource(stream); >+ Writer writer = null; >+ try { >+ writer = new BufferedWriter(new FileWriter(reportFileName)); >+ Result result = new StreamResult(writer); >+ >+ // create an instance of TransformerFactory >+ TransformerFactory transFact = TransformerFactory.newInstance(); >+ >+ Transformer trans = transFact.newTransformer(xsltSource); >+ trans.transform(xmlSource, result); >+ } catch (TransformerConfigurationException e) { >+ ApiUIPlugin.log(e); >+ } catch (TransformerException e) { >+ ApiUIPlugin.log(e); >+ } catch(IOException e) { >+ ApiUIPlugin.log(e); >+ } finally { >+ if (writer != null) { >+ try { >+ writer.close(); >+ } catch(IOException e) { >+ // ignore >+ } >+ } >+ } >+ } >+ return Status.CANCEL_STATUS; >+ } >+ }; >+ job.setSystem(false); >+ job.setPriority(Job.LONG); >+ job.schedule(); >+ } >+ public void dispose() { >+ } >+ >+} >\ No newline at end of file >Index: src/org/eclipse/pde/api/tools/ui/internal/actions/ExportDialog.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/ui/internal/actions/ExportDialog.java >diff -N src/org/eclipse/pde/api/tools/ui/internal/actions/ExportDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/ui/internal/actions/ExportDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,154 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.ui.internal.actions; >+ >+import java.io.File; >+ >+import org.eclipse.core.runtime.Path; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.dialogs.IDialogSettings; >+import org.eclipse.jface.window.IShellProvider; >+import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin; >+import org.eclipse.pde.api.tools.ui.internal.SWTFactory; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.FileDialog; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Text; >+ >+/** >+ * Compares {@link org.eclipse.pde.api.tools.internal.provisional.model.IApiElement}s >+ * to a given {@link IApiBaseline} to get a delta >+ * >+ * @since 1.0.1 >+ */ >+public class ExportDialog extends Dialog { >+ >+ //widget state ids >+ static final String SETTINGS_SECTION = ApiUIPlugin.PLUGIN_ID + ".api.exportsession"; //$NON-NLS-1$ >+ static final String REPORT_PATH_STATE = SETTINGS_SECTION + ".reportpath"; //$NON-NLS-1$ >+ >+ private String title = null;; >+ private Text reportPathText; >+ public String reportPath; >+ >+ /** >+ * Constructor >+ * @param provider >+ * @param title >+ */ >+ public ExportDialog(IShellProvider provider, String title) { >+ super(provider); >+ this.title = title; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) >+ */ >+ protected void configureShell(Shell newShell) { >+ super.configureShell(newShell); >+ newShell.setText(this.title); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#isResizable() >+ */ >+ protected boolean isResizable() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createDialogArea(Composite parent) { >+ Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL); >+ GridData gd = (GridData) comp.getLayoutData(); >+ gd.widthHint = 310; >+ >+ SWTFactory.createWrapLabel(comp, ActionMessages.EnterFileNameForExport, 2); >+ this.reportPathText = SWTFactory.createText(comp, SWT.SINGLE | SWT.BORDER | SWT.FLAT, 1, GridData.BEGINNING | GridData.FILL_HORIZONTAL); >+ gd = (GridData) this.reportPathText.getLayoutData(); >+ gd.grabExcessHorizontalSpace = true; >+ >+ Button browseButton = SWTFactory.createPushButton(comp, ActionMessages.Browse, null); >+ browseButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ FileDialog dialog = new FileDialog(getShell()); >+ dialog.setText(ActionMessages.SelectFileName); >+ String loctext = ExportDialog.this.reportPathText.getText().trim(); >+ if (loctext.length() > 0) { >+ File file = new File(loctext).getParentFile(); >+ if (file != null && file.exists()) { >+ dialog.setFilterPath(file.getAbsolutePath()); >+ } >+ } >+ String newPath = dialog.open(); >+ if (newPath != null && !new Path(loctext).equals(new Path(newPath))) { >+ ExportDialog.this.reportPathText.setText(newPath); >+ ExportDialog.this.reportPath = newPath; >+ } >+ } >+ }); >+ >+ initialize(); >+ return comp; >+ } >+ >+ /** >+ * Initializes the controls >+ */ >+ void initialize() { >+ IDialogSettings settings = ApiUIPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION); >+ if(settings != null) { >+ restoreTextSelection(this.reportPathText, REPORT_PATH_STATE, settings); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#okPressed() >+ */ >+ protected void okPressed() { >+ saveWidgetState(); >+ super.okPressed(); >+ } >+ /** >+ * Restores the selected item for the given combo based on the stored value from the >+ * dialog settings >+ * >+ * @param combo >+ * @param id >+ * @param settings >+ */ >+ private void restoreTextSelection(Text text, String id, IDialogSettings settings) { >+ String value = settings.get(id); >+ if(value != null) { >+ ExportDialog.this.reportPath = value; >+ text.setText(value); >+ } >+ } >+ >+ /** >+ * Saves the state of the widgets on the page >+ */ >+ void saveWidgetState() { >+ IDialogSettings rootsettings = ApiUIPlugin.getDefault().getDialogSettings(); >+ IDialogSettings settings = rootsettings.getSection(SETTINGS_SECTION); >+ if(settings == null) { >+ settings = rootsettings.addNewSection(SETTINGS_SECTION); >+ } >+ settings.put(REPORT_PATH_STATE, this.reportPath); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/pde/api/tools/ui/internal/actions/DeltaPropertyDialog.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/ui/internal/actions/DeltaPropertyDialog.java >diff -N src/org/eclipse/pde/api/tools/ui/internal/actions/DeltaPropertyDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/ui/internal/actions/DeltaPropertyDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,79 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.ui.internal.actions; >+ >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.window.IShellProvider; >+import org.eclipse.pde.api.tools.internal.provisional.comparator.IDelta; >+import org.eclipse.pde.api.tools.ui.internal.SWTFactory; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Shell; >+ >+/** >+ * Compares {@link org.eclipse.pde.api.tools.internal.provisional.model.IApiElement}s >+ * to a given {@link IApiBaseline} to get a delta >+ * >+ * @since 1.0.1 >+ */ >+public class DeltaPropertyDialog extends Dialog { >+ private String title = null;; >+ private IDelta delta; >+ >+ /** >+ * Constructor >+ * @param provider >+ * @param title >+ */ >+ public DeltaPropertyDialog(IShellProvider provider, String title, IDelta delta) { >+ super(provider); >+ this.title = title; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) >+ */ >+ protected void configureShell(Shell newShell) { >+ super.configureShell(newShell); >+ newShell.setText(this.title); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#isResizable() >+ */ >+ protected boolean isResizable() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createDialogArea(Composite parent) { >+ Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL); >+ GridData gd = (GridData) comp.getLayoutData(); >+ gd.widthHint = 310; >+ return comp; >+ } >+ >+ /** >+ * Initializes the controls >+ */ >+ void initialize() { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#okPressed() >+ */ >+ protected void okPressed() { >+ super.okPressed(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/pde/api/tools/ui/internal/actions/CompareWithAction.java >=================================================================== >RCS file: src/org/eclipse/pde/api/tools/ui/internal/actions/CompareWithAction.java >diff -N src/org/eclipse/pde/api/tools/ui/internal/actions/CompareWithAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/api/tools/ui/internal/actions/CompareWithAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,442 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.api.tools.ui.internal.actions; >+ >+import java.util.Date; >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.SubMonitor; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.jdt.core.Flags; >+import org.eclipse.jdt.core.IClassFile; >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.IPackageFragment; >+import org.eclipse.jdt.core.IPackageFragmentRoot; >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.window.Window; >+import org.eclipse.pde.api.tools.internal.ApiBaselineManager; >+import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; >+import org.eclipse.pde.api.tools.internal.provisional.Factory; >+import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations; >+import org.eclipse.pde.api.tools.internal.provisional.IApiDescription; >+import org.eclipse.pde.api.tools.internal.provisional.ISession; >+import org.eclipse.pde.api.tools.internal.provisional.ITreeModel; >+import org.eclipse.pde.api.tools.internal.provisional.ITreeNode; >+import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers; >+import org.eclipse.pde.api.tools.internal.provisional.comparator.ApiComparator; >+import org.eclipse.pde.api.tools.internal.provisional.comparator.ApiScope; >+import org.eclipse.pde.api.tools.internal.provisional.comparator.DeltaVisitor; >+import org.eclipse.pde.api.tools.internal.provisional.comparator.IDelta; >+import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline; >+import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent; >+import org.eclipse.pde.api.tools.internal.provisional.model.IApiScope; >+import org.eclipse.pde.api.tools.internal.provisional.model.IApiType; >+import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot; >+import org.eclipse.ui.IObjectActionDelegate; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchPartSite; >+ >+import com.ibm.icu.text.DateFormat; >+ >+public class CompareWithAction implements IObjectActionDelegate { >+ >+ public static class DeltaSession implements ISession { >+ static Object[] NO_CHILDREN = new Object[0]; >+ >+ static class TreeNode implements ITreeNode { >+ Map children; >+ String name; >+ TreeNode parent; >+ Object data; >+ int id; >+ >+ public TreeNode(int id, String name, Object data) { >+ this.name = name; >+ this.id = id; >+ this.data = data; >+ } >+ public Object[] getChildren() { >+ if (this.children == null) { >+ return NO_CHILDREN; >+ } >+ return this.children.values().toArray(new Object[this.children.size()]); >+ } >+ public TreeNode getNode(String name) { >+ if (this.children == null) { >+ return null; >+ } >+ return (TreeNode) this.children.get(name); >+ } >+ public int getId() { >+ return this.id; >+ } >+ public void add(TreeNode node) { >+ if (this.children == null) { >+ this.children = new HashMap(); >+ } >+ this.children.put(node.name, node); >+ } >+ public boolean hasChildren() { >+ return this.children != null && !this.children.isEmpty(); >+ } >+ public String toString() { >+ return String.valueOf(this.name); >+ } >+ public Object getData() { >+ return this.data; >+ } >+ } >+ >+ static class TreeModel implements ITreeModel { >+ TreeNode root; >+ >+ TreeModel(TreeNode root) { >+ this.root = root; >+ } >+ public ITreeNode getRoot() { >+ return this.root; >+ } >+ } >+ >+ IDelta delta; >+ String baselineName; >+ String timestamp; >+ >+ public DeltaSession(IDelta delta, String baselineName) { >+ this.delta = delta; >+ this.baselineName = baselineName; >+ this.timestamp = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(System.currentTimeMillis())); >+ } >+ public ITreeModel getModel() { >+ TreeNode root = new TreeNode(0, null, this.delta); >+ TreeModel model = new TreeModel(root); >+ class TreeBuilder extends DeltaVisitor { >+ TreeNode node; >+ >+ public TreeBuilder(TreeNode node) { >+ this.node = node; >+ } >+ public void endVisit(IDelta delta) { >+ if (delta.getChildren().length == 0) { >+ String typeName = delta.getTypeName(); >+ if (typeName == null) { >+ this.node.add(new TreeNode(0, delta.getKey(), delta)); >+ } else { >+ // split the type name (package - type) >+ int index = typeName.lastIndexOf('.'); >+ String packageName = "<default package>"; //$NON-NLS-1$ >+ String actualTypeName = null; >+ if (index != -1) { >+ packageName = typeName.substring(0, index); >+ actualTypeName = typeName.substring(index + 1); >+ } else { >+ actualTypeName = typeName; >+ } >+ TreeNode node2 = this.node.getNode(packageName); >+ if (node2 == null) { >+ node2 = new TreeNode(ITreeNode.PACKAGE, packageName, null); >+ this.node.add(node2); >+ } >+ TreeNode node3 = node2.getNode(actualTypeName); >+ if (node3 == null) { >+ int id = 0; >+ switch(delta.getElementType()) { >+ case IDelta.ANNOTATION_ELEMENT_TYPE : >+ id = ITreeNode.ANNOTATION; >+ break; >+ case IDelta.INTERFACE_ELEMENT_TYPE : >+ id = ITreeNode.INTERFACE; >+ break; >+ case IDelta.CLASS_ELEMENT_TYPE : >+ id = ITreeNode.CLASS; >+ break; >+ case IDelta.ENUM_ELEMENT_TYPE : >+ id = ITreeNode.ENUM; >+ default : >+ // we need to retrieve the type kind >+ try { >+ String componentVersionId = delta.getComponentVersionId(); >+ if (componentVersionId != null) { >+ int indexOfOpen = componentVersionId.lastIndexOf('('); >+ String componentID = componentVersionId.substring(0, indexOfOpen); >+ String version = componentVersionId.substring(indexOfOpen + 1, componentVersionId.length() - 1); >+ IApiBaseline baseline = ApiBaselineManager.getManager().getApiBaseline(DeltaSession.this.baselineName); >+ int modifiers = 0; >+ if (baseline != null) { >+ IApiComponent apiComponent = baseline.getApiComponent(componentID); >+ if (apiComponent != null && version.equals(apiComponent.getVersion())) { >+ IApiTypeRoot typeRoot = apiComponent.findTypeRoot(typeName); >+ if (typeRoot != null) { >+ IApiType structure = typeRoot.getStructure(); >+ modifiers = structure.getModifiers(); >+ } >+ } >+ } >+ if (modifiers == 0) { >+ // try the workspace baseline >+ baseline = ApiBaselineManager.getManager().getWorkspaceBaseline(); >+ if (baseline != null) { >+ IApiComponent apiComponent = baseline.getApiComponent(componentID); >+ if (apiComponent != null && version.equals(apiComponent.getVersion())) { >+ IApiTypeRoot typeRoot = apiComponent.findTypeRoot(typeName); >+ if (typeRoot != null) { >+ IApiType structure = typeRoot.getStructure(); >+ modifiers = structure.getModifiers(); >+ } >+ } >+ } >+ } >+ if (Flags.isEnum(modifiers)) { >+ id = ITreeNode.ENUM; >+ } else if (Flags.isAnnotation(modifiers)) { >+ id = ITreeNode.ANNOTATION; >+ } else if (Flags.isInterface(modifiers)) { >+ id = ITreeNode.INTERFACE; >+ } else { >+ id = ITreeNode.CLASS; >+ } >+ } >+ } catch (CoreException e) { >+ // ignore >+ } >+ } >+ node3 = new TreeNode(id, actualTypeName, null); >+ node2.add(node3); >+ } >+ node3.add(new TreeNode(0, delta.getMessage(), delta)); >+ } >+ } >+ } >+ } >+ if (this.delta == ApiComparator.NO_DELTA) { >+ root.add(new TreeNode(0, ActionMessages.CompareTaskNoChanges, null)); >+ } else { >+ this.delta.accept(new TreeBuilder(root)); >+ } >+ return model; >+ } >+ >+ public String getTimestamp() { >+ return this.timestamp; >+ } >+ } >+ >+ private IWorkbenchPartSite workbenchPartSite; >+ private ISelection selection = null; >+ >+ /** >+ * Constructor for Action1. >+ */ >+ public CompareWithAction() { >+ super(); >+ } >+ >+ /** >+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) >+ */ >+ public void setActivePart(IAction action, IWorkbenchPart targetPart) { >+ workbenchPartSite = targetPart.getSite(); >+ } >+ /** >+ * @see IActionDelegate#run(IAction) >+ */ >+ public void run(IAction action) { >+ if (this.selection instanceof IStructuredSelection) { >+ final IStructuredSelection structuredSelection=(IStructuredSelection) this.selection; >+ CompareDialog dialog = new CompareDialog(workbenchPartSite, ActionMessages.CompareDialogTitle); >+ int returnCode = dialog.open(); >+ if (returnCode == Window.CANCEL) return; >+ final String baselineName = dialog.baseline; >+ if (baselineName == null) return; >+ final IApiBaseline baseline = ApiBaselineManager.getManager().getApiBaseline(baselineName); >+ if (baseline == null) { >+ return; >+ } >+ Job job = new Job(ActionMessages.CompareWithAction_comparing_apis){ >+ protected IStatus run(IProgressMonitor monitor) { >+ SubMonitor progress = SubMonitor.convert(monitor, 100); >+ progress.subTask(ActionMessages.CompareDialogCollectingElementTaskName); >+ SubMonitor loopProgress = progress.newChild(10).setWorkRemaining(structuredSelection.size()); >+ final IApiScope scope = walkStructureSelection(structuredSelection, loopProgress); >+ try { >+ progress.subTask(ActionMessages.CompareDialogComputeDeltasTaskName); >+ SubMonitor compareProgress = progress.newChild(98).setWorkRemaining(scope.getApiElements().length); >+ try { >+ IDelta delta = ApiComparator.compare(scope, baseline, VisibilityModifiers.API, false, compareProgress); >+ ApiPlugin.getDefault().getSessionManager().addSession(new DeltaSession(delta, baselineName), true); >+ progress.worked(1); >+ return Status.OK_STATUS; >+ } catch (CoreException e) { >+ ApiPlugin.log(e); >+ } catch(OperationCanceledException e) { >+ // ignore >+ } >+ } finally { >+ monitor.done(); >+ } >+ return Status.CANCEL_STATUS; >+ } >+ }; >+ job.setSystem(false); >+ job.setPriority(Job.LONG); >+ job.schedule(); >+ return; >+ } >+ } >+ >+ public static ApiScope walkStructureSelection( >+ IStructuredSelection structuredSelection, >+ IProgressMonitor monitor) { >+ Object[] selected=structuredSelection.toArray(); >+ ApiScope scope = new ApiScope(); >+ IApiBaseline workspaceBaseline = ApiBaselineManager.getManager().getWorkspaceBaseline(); >+ if (workspaceBaseline == null) { >+ return scope; >+ } >+ for (int i=0, max = selected.length; i < max; i++) { >+ Object currentSelection = selected[i]; >+ if (currentSelection instanceof IJavaElement) { >+ monitor.worked(1); >+ IJavaElement element =(IJavaElement) currentSelection; >+ IJavaProject javaProject = element.getJavaProject(); >+ try { >+ switch (element.getElementType()) { >+ case IJavaElement.COMPILATION_UNIT: { >+ ICompilationUnit compilationUnit = (ICompilationUnit) element; >+ IApiComponent apiComponent = workspaceBaseline.getApiComponent(javaProject.getElementName()); >+ if (apiComponent != null) { >+ addElementFor(compilationUnit, apiComponent, scope); >+ } >+ break; >+ } >+ case IJavaElement.PACKAGE_FRAGMENT: { >+ IPackageFragment fragment = (IPackageFragment) element; >+ IApiComponent apiComponent = workspaceBaseline.getApiComponent(javaProject.getElementName()); >+ IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) fragment.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); >+ boolean isArchive = false; >+ if (packageFragmentRoot != null) { >+ isArchive = packageFragmentRoot.isArchive(); >+ } >+ if (apiComponent != null) { >+ addElementFor(fragment, isArchive, apiComponent, scope); >+ } >+ break; >+ } >+ case IJavaElement.PACKAGE_FRAGMENT_ROOT: { >+ IPackageFragmentRoot fragmentRoot = (IPackageFragmentRoot) element; >+ IApiComponent apiComponent = workspaceBaseline.getApiComponent(javaProject.getElementName()); >+ if (apiComponent != null) { >+ addElementFor(fragmentRoot, apiComponent, scope); >+ } >+ break; >+ } >+ case IJavaElement.JAVA_PROJECT: >+ IApiComponent apiComponent = workspaceBaseline.getApiComponent(javaProject.getElementName()); >+ IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots(); >+ for (int j = 0, max2 = roots.length; j < max2; j++) { >+ addElementFor(roots[j], apiComponent, scope); >+ } >+ break; >+ } >+ } catch (JavaModelException e) { >+ ApiPlugin.log(e); >+ } catch (CoreException e) { >+ ApiPlugin.log(e); >+ } >+ } >+ } >+ return scope; >+ } >+ >+ private static void addElementFor( >+ IPackageFragmentRoot fragmentRoot, IApiComponent apiComponent, >+ ApiScope scope) throws JavaModelException, CoreException { >+ boolean isArchive = fragmentRoot.isArchive(); >+ IJavaElement[] packageFragments = fragmentRoot.getChildren(); >+ for (int j = 0, max2 = packageFragments.length; j < max2; j++) { >+ IPackageFragment packageFragment = (IPackageFragment) packageFragments[j]; >+ addElementFor(packageFragment, isArchive, apiComponent, scope); >+ } >+ } >+ >+ private static void addElementFor( >+ IPackageFragment packageFragment, >+ boolean isArchive, >+ IApiComponent apiComponent, >+ ApiScope scope) >+ throws JavaModelException, CoreException { >+ >+ // add package fragment elements only if this is an API package >+ IApiDescription apiDescription = apiComponent.getApiDescription(); >+ IApiAnnotations annotations = apiDescription.resolveAnnotations(Factory.packageDescriptor(packageFragment.getElementName())); >+ if (annotations == null || !VisibilityModifiers.isAPI(annotations.getVisibility())) { >+ return; >+ } >+ if (isArchive) { >+ IClassFile[] classFiles = packageFragment.getClassFiles(); >+ for (int i = 0, max= classFiles.length; i < max; i++) { >+ addElementFor(classFiles[i], apiComponent, scope); >+ } >+ } else { >+ ICompilationUnit[] units = packageFragment.getCompilationUnits(); >+ for (int i = 0, max= units.length; i < max; i++) { >+ addElementFor(units[i], apiComponent, scope); >+ } >+ } >+ } >+ >+ private static void addElementFor(IClassFile classFile, >+ IApiComponent apiComponent, ApiScope scope) { >+ try { >+ IApiTypeRoot typeRoot = apiComponent.findTypeRoot(classFile.getType().getFullyQualifiedName()); >+ if (typeRoot != null) { >+ scope.add(typeRoot); >+ } >+ } catch (CoreException e) { >+ ApiPlugin.log(e); >+ } >+ } >+ >+ private static void addElementFor(ICompilationUnit compilationUnit, IApiComponent component, ApiScope scope) throws JavaModelException { >+ IType[] types = compilationUnit.getTypes(); >+ for (int i = 0, max = types.length; i < max; i++) { >+ try { >+ IApiTypeRoot typeRoot = component.findTypeRoot(types[i].getFullyQualifiedName()); >+ if (typeRoot != null) { >+ scope.add(typeRoot); >+ } >+ } catch (CoreException e) { >+ ApiPlugin.log(e); >+ } >+ } >+ } >+ >+ /** >+ * @see IActionDelegate#selectionChanged(IAction, ISelection) >+ */ >+ public void selectionChanged(IAction action, ISelection selection) { >+ this.selection = selection; >+ } >+ >+ >+}
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
Actions:
View
|
Diff
Attachments on
bug 258853
:
127736
|
127838
|
132099
|
132259
|
132475