Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 258853 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/api/tools/ui/internal/actions/ActionMessages.java (-1 / +40 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
2
 * Copyright (c) 2008, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 18-23 Link Here
18
public class ActionMessages extends NLS {
18
public class ActionMessages extends NLS {
19
	private static final String BUNDLE_NAME = "org.eclipse.pde.api.tools.ui.internal.actions.actionmessages"; //$NON-NLS-1$
19
	private static final String BUNDLE_NAME = "org.eclipse.pde.api.tools.ui.internal.actions.actionmessages"; //$NON-NLS-1$
20
	public static String ApiToolingSetupObjectContribution_0;
20
	public static String ApiToolingSetupObjectContribution_0;
21
	public static String SelectABaseline;
22
	public static String SetAsDefault;
23
	public static String EnterFileName;
24
	public static String SelectFileName;
25
	public static String Browse;
26
	public static String ConvertToHtml;
27
	public static String CompareDialogTitle;
28
	public static String CompareDialogCollectingElementTaskName;
29
	public static String CompareDialogComputeDeltasTaskName;
30
	public static String CompareWithAction_comparing_apis;
31
	public static String CompareTaskNoChanges;
32
	public static String RemoveActiveSessionAction_label;
33
	public static String RemoveActiveSessionAction_tooltip;
34
	public static String RemoveAllSessionsAction_label;
35
	public static String RemoveAllSessionsAction_tooltip;
36
	public static String SelectSessionAction_label;
37
	public static String SelectSessionAction_tooltip;
38
	public static String SelectSessionActionEntry_label;
39
	public static String DeltaDetailsDialogTitle;
40
	public static String ExportSessionAction_label;
41
	public static String ExportSessionAction_tooltip;
42
	public static String EnterFileNameForExport;
43
	public static String ExportActionTitle;
44
	public static String PropertyPackageVisibility;
45
46
	public static String PropertyMessageKey;
47
	public static String PropertyComponentKey;
48
	public static String PropertyElementTypeKey;
49
	public static String PropertyFlagsKey;
50
	public static String PropertyKeyKey;
51
	public static String PropertyKindKey;
52
	public static String PropertyNewModifiersKey;
53
	public static String PropertyOldModifiersKey;
54
	public static String PropertyRestrictionsKey;
55
	public static String PropertyTypeNameKey;
56
57
	public static String MessageCategory;
58
	public static String InfoCategory;
59
21
	static {
60
	static {
22
		// initialize resource bundle
61
		// initialize resource bundle
23
		NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class);
62
		NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class);
(-)src/org/eclipse/pde/api/tools/ui/internal/actions/actionmessages.properties (-1 / +41 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2008 IBM Corporation and others.
2
# Copyright (c) 2008, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 9-11 Link Here
9
#     IBM Corporation - initial API and implementation
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
10
###############################################################################
11
ApiToolingSetupObjectContribution_0=Set up API tooling
11
ApiToolingSetupObjectContribution_0=Set up API tooling
12
SelectABaseline=Select a &baseline:
13
SetAsDefault={0} (default)
14
EnterFileName=Report &location:
15
SelectFileName=Select a report location
16
Browse=Bro&wse...
17
ConvertToHtml=Con&vert to html
18
CompareDialogTitle=Compare With Baseline
19
CompareDialogCollectingElementTaskName=Collecting elements to compare
20
CompareDialogComputeDeltasTaskName=Computing deltas...
21
CompareWithAction_comparing_apis=Comparing APIs...
22
CompareTaskNoChanges=No changes have been found
23
RemoveActiveSessionAction_label=Remove Active Session
24
RemoveActiveSessionAction_tooltip=Remove Active Session
25
RemoveAllSessionsAction_label=Remove All Sessions
26
RemoveAllSessionsAction_tooltip=Remove All Sessions
27
SelectSessionAction_label=Select Session
28
SelectSessionAction_tooltip=Select Session
29
# {0} int value
30
# {1} timestamp
31
SelectSessionActionEntry_label=Session {0} ({1})
32
DeltaDetailsDialogTitle=Delta Details
33
ExportSessionAction_label=Export Session
34
ExportSessionAction_tooltip=Export Session
35
EnterFileNameForExport=Enter a file name for export:
36
ExportActionTitle=Export Active Session
37
38
PropertyMessageKey=localized message
39
PropertyComponentKey=component
40
PropertyPackageVisibility=<package visibility>
41
PropertyElementTypeKey=element type
42
PropertyFlagsKey=flags
43
PropertyKeyKey=key
44
PropertyKindKey=kind
45
PropertyNewModifiersKey=new modifiers
46
PropertyOldModifiersKey=old modifiers
47
PropertyRestrictionsKey=restrictions
48
PropertyTypeNameKey=type name
49
50
MessageCategory=Message
51
InfoCategory=Info
(-)src/org/eclipse/pde/api/tools/ui/internal/ApiUIPlugin.java (-5 / +8 lines)
Lines 62-72 Link Here
62
	/**
62
	/**
63
	 * Relative path to object model icons.
63
	 * Relative path to object model icons.
64
	 */
64
	 */
65
	private final static String OBJECT= ICONS_PATH + "obj16/"; //basic colors - size 16x16 //$NON-NLS-1$
65
	private final static String OBJECT = ICONS_PATH + "obj16/"; //basic colors - size 16x16 //$NON-NLS-1$
66
	private final static String OVR= ICONS_PATH + "ovr16/"; //basic colors - size 7x8 //$NON-NLS-1$
66
	private final static String OVR = ICONS_PATH + "ovr16/"; //basic colors - size 7x8 //$NON-NLS-1$
67
	private final static String WIZBAN= ICONS_PATH + "wizban/"; //basic colors - size 16x16 //$NON-NLS-1$
67
	private final static String WIZBAN = ICONS_PATH + "wizban/"; //basic colors - size 16x16 //$NON-NLS-1$
68
	private static final String ELCL= ICONS_PATH + "elcl16/"; 	//basic colors - size 16x16 //$NON-NLS-1$
68
	private static final String ELCL = ICONS_PATH + "elcl16/"; 	//basic colors - size 16x16 //$NON-NLS-1$
69
	
69
	private static final String DLCL = ICONS_PATH + "dlcl16/"; 	//basic colors - size 16x16 disabled//$NON-NLS-1$
70
	/**
70
	/**
71
	 * Maps Image descriptors to images for composite images
71
	 * Maps Image descriptors to images for composite images
72
	 */
72
	 */
Lines 124-129 Link Here
124
		declareRegistryImage(reg, IApiToolsConstants.IMG_OBJ_FRAGMENT, OBJECT + "frgmt_obj.gif"); //$NON-NLS-1$
124
		declareRegistryImage(reg, IApiToolsConstants.IMG_OBJ_FRAGMENT, OBJECT + "frgmt_obj.gif"); //$NON-NLS-1$
125
		declareRegistryImage(reg, IApiToolsConstants.IMG_OBJ_ECLIPSE_PROFILE, OBJECT + "eclipse_profile.gif"); //$NON-NLS-1$
125
		declareRegistryImage(reg, IApiToolsConstants.IMG_OBJ_ECLIPSE_PROFILE, OBJECT + "eclipse_profile.gif"); //$NON-NLS-1$
126
		declareRegistryImage(reg, IApiToolsConstants.IMG_OBJ_BUNDLE_VERSION, OBJECT + "bundleversion.gif"); //$NON-NLS-1$
126
		declareRegistryImage(reg, IApiToolsConstants.IMG_OBJ_BUNDLE_VERSION, OBJECT + "bundleversion.gif"); //$NON-NLS-1$
127
127
		// overlays
128
		// overlays
128
		declareRegistryImage(reg, IApiToolsConstants.IMG_OVR_ERROR, OVR + "error_ovr.gif"); //$NON-NLS-1$
129
		declareRegistryImage(reg, IApiToolsConstants.IMG_OVR_ERROR, OVR + "error_ovr.gif"); //$NON-NLS-1$
129
		declareRegistryImage(reg, IApiToolsConstants.IMG_OVR_WARNING, OVR + "warning_ovr.gif"); //$NON-NLS-1$
130
		declareRegistryImage(reg, IApiToolsConstants.IMG_OVR_WARNING, OVR + "warning_ovr.gif"); //$NON-NLS-1$
Lines 134-139 Link Here
134
		declareRegistryImage(reg, IApiToolsConstants.IMG_ELCL_FILTER, ELCL + "filter_ps.gif"); //$NON-NLS-1$
135
		declareRegistryImage(reg, IApiToolsConstants.IMG_ELCL_FILTER, ELCL + "filter_ps.gif"); //$NON-NLS-1$
135
		declareRegistryImage(reg, IApiToolsConstants.IMG_ELCL_REMOVE, ELCL + "remove_exc.gif"); //$NON-NLS-1$
136
		declareRegistryImage(reg, IApiToolsConstants.IMG_ELCL_REMOVE, ELCL + "remove_exc.gif"); //$NON-NLS-1$
136
		declareRegistryImage(reg, IApiToolsConstants.IMG_ELCL_OPEN_PAGE, ELCL + "open_page.gif"); //$NON-NLS-1$
137
		declareRegistryImage(reg, IApiToolsConstants.IMG_ELCL_OPEN_PAGE, ELCL + "open_page.gif"); //$NON-NLS-1$
138
		declareRegistryImage(reg, IApiToolsConstants.IMG_ELCL_COMPARE_APIS, ELCL + "compare_apis.gif"); //$NON-NLS-1$
139
		declareRegistryImage(reg, IApiToolsConstants.IMG_ELCL_COMPARE_APIS_DISABLED, DLCL + "compare_apis.gif"); //$NON-NLS-1$
137
	}
140
	}
138
141
139
	/**
142
	/**
(-)src/org/eclipse/pde/api/tools/ui/internal/IApiToolsConstants.java (-50 / +56 lines)
Lines 14-118 Link Here
14
 * @since 1.0.0
14
 * @since 1.0.0
15
 */
15
 */
16
public interface IApiToolsConstants {
16
public interface IApiToolsConstants {
17
17
	/**
18
	 * Empty String constant
19
	 */
20
	public static final String EMPTY_STRING = ""; //$NON-NLS-1$
18
	/**
21
	/**
19
	 * Plug-in identifier
22
	 * Plug-in identifier
20
	 */
23
	 */
21
	public static final String ID_API_TOOLS_UI_PLUGIN = "org.eclipse.pde.api.tools.ui"; //$NON-NLS-1$
24
	public static final String ID_API_TOOLS_UI_PLUGIN = "org.eclipse.pde.api.tools.ui"; //$NON-NLS-1$
22
	/**
25
	/**
23
	 * Empty String constant
26
	 * Id for the Api baselines preference page.
27
	 * <br>
28
	 * Value is: <code>org.eclipse.pde.api.tools.ui.apiprofiles.prefpage</code>
24
	 */
29
	 */
25
	public static final String EMPTY_STRING = ""; //$NON-NLS-1$
30
	public static final String ID_BASELINES_PREF_PAGE = "org.eclipse.pde.api.tools.ui.apiprofiles.prefpage"; //$NON-NLS-1$
26
	/**
31
	/**
27
	 * Key for API component image.
32
	 * Id for the API errors / warnings preference page
33
	 * <br>
34
	 * Value is: <code>org.eclipse.pde.api.tools.ui.apitools.errorwarnings.prefpage</code> 
28
	 */
35
	 */
29
	public static final String IMG_OBJ_API_COMPONENT = "IMG_OBJ_API_COMPONENT"; //$NON-NLS-1$
36
	public static final String ID_ERRORS_WARNINGS_PREF_PAGE = "org.eclipse.pde.api.tools.ui.apitools.errorwarnings.prefpage"; //$NON-NLS-1$
37
	
30
	/**
38
	/**
31
	 * Key for API system component image
39
	 * The id for the API errors / warnings property page
40
	 * <br>
41
	 * Value is: <code>org.eclipse.pde.api.tools.ui.apitools.warningspage</code>
32
	 */
42
	 */
33
	public static final String IMG_OBJ_API_SYSTEM_LIBRARY = "IMG_OBJ_API_SYSTEM_LIBRARY"; //$NON-NLS-1$
43
	public static final String ID_ERRORS_WARNINGS_PROP_PAGE = "org.eclipse.pde.api.tools.ui.apitools.warningspage"; //$NON-NLS-1$
34
	
44
	
35
	/**
45
	/**
36
	 * Key for API search image
46
	 * The id for the API problem filters property page
47
	 * <br>
48
	 * Value is: <code>org.eclipse.pde.api.tools.ui.apitools.filterspage</code>
37
	 */
49
	 */
38
	public static final String IMG_OBJ_API_SEARCH = "IMG_OBJ_API_SEARCH"; //$NON-NLS-1$
50
	public static final String ID_FILTERS_PROP_PAGE = "org.eclipse.pde.api.tools.ui.apitools.filterspage"; //$NON-NLS-1$
39
	
51
	
40
	/**
52
	/**
41
	 * Key for bundle image
53
	 * Key for a compare api image
42
	 */
54
	 */
43
	public static final String IMG_OBJ_BUNDLE = "IMG_OBJ_BUNDLE"; //$NON-NLS-1$
55
	public static final String IMG_ELCL_COMPARE_APIS = "IMG_ELCL_COMPARE_APIS"; //$NON-NLS-1$
44
	
45
	/**
56
	/**
46
	 * Key for fragment image
57
	 * Key for a compare api disabled image
47
	 */
58
	 */
48
	public static final String IMG_OBJ_FRAGMENT = "IMG_OBJ_FRAGMENT"; //$NON-NLS-1$		
59
	public static final String IMG_ELCL_COMPARE_APIS_DISABLED = "IMG_ELCL_COMPARE_APIS_DISABLED"; //$NON-NLS-1$
49
	
50
	/**
60
	/**
51
	 * Key for Eclipse SDK/API profile image
61
	 * Key for filter resolution image
52
	 */
62
	 */
53
	public static final String IMG_OBJ_ECLIPSE_PROFILE = "IMG_OBJ_ECLIPSE_PROFILE"; //$NON-NLS-1$
63
	public static final String IMG_ELCL_FILTER = "IMG_ELCL_FILTER"; //$NON-NLS-1$
54
	
64
	
55
	/**
65
	/**
56
	 * Key for a bundle version image
66
	 * Key for the open page image
57
	 */
67
	 */
58
	public static final String IMG_OBJ_BUNDLE_VERSION = "IMG_OBJ_BUNDLE_VERSION"; //$NON-NLS-1$
68
	public static final String IMG_ELCL_OPEN_PAGE = "IMG_ELCL_OPEN_PAGE"; //$NON-NLS-1$
59
	
69
60
	/**
70
	/**
61
	 * Error overlay.
71
	 * Key for enabled remove image
62
	 */
72
	 */
63
	public static final String IMG_OVR_ERROR = "IMG_OVR_ERROR"; //$NON-NLS-1$
73
	public static final String IMG_ELCL_REMOVE = "IMG_ELCL_REMOVE"; //$NON-NLS-1$
64
	
74
	
65
	/**
75
	/**
66
	 * Warning overlay
76
	 * Key for API component image.
67
	 */
77
	 */
68
	public static final String IMG_OVR_WARNING = "IMG_OVR_WARNING"; //$NON-NLS-1$
78
	public static final String IMG_OBJ_API_COMPONENT = "IMG_OBJ_API_COMPONENT"; //$NON-NLS-1$
69
	
79
	
70
	/**
80
	/**
71
	 * Success overlay
81
	 * Key for API search image
72
	 */
82
	 */
73
	public static final String IMG_OVR_SUCCESS = "IMG_OVR_SUCCESS"; //$NON-NLS-1$
83
	public static final String IMG_OBJ_API_SEARCH = "IMG_OBJ_API_SEARCH"; //$NON-NLS-1$
74
	
84
	
75
	/**
85
	/**
76
	 * Wizard banner for editing an API profile
86
	 * Key for API system component image
77
	 */
87
	 */
78
	public static final String IMG_WIZBAN_PROFILE = "IMG_WIZBAN_PROFILE"; //$NON-NLS-1$
88
	public static final String IMG_OBJ_API_SYSTEM_LIBRARY = "IMG_OBJ_API_SYSTEM_LIBRARY"; //$NON-NLS-1$
79
	
89
	
80
	/**
90
	/**
81
	 * Id for the Api baselines preference page.
91
	 * Key for bundle image
82
	 * <br>
83
	 * Value is: <code>org.eclipse.pde.api.tools.ui.apiprofiles.prefpage</code>
84
	 */
92
	 */
85
	public static final String ID_BASELINES_PREF_PAGE = "org.eclipse.pde.api.tools.ui.apiprofiles.prefpage"; //$NON-NLS-1$
93
	public static final String IMG_OBJ_BUNDLE = "IMG_OBJ_BUNDLE"; //$NON-NLS-1$
86
	/**
94
	/**
87
	 * Id for the API errors / warnings preference page
95
	 * Key for a bundle version image
88
	 * <br>
89
	 * Value is: <code>org.eclipse.pde.api.tools.ui.apitools.errorwarnings.prefpage</code> 
90
	 */
96
	 */
91
	public static final String ID_ERRORS_WARNINGS_PREF_PAGE = "org.eclipse.pde.api.tools.ui.apitools.errorwarnings.prefpage"; //$NON-NLS-1$
97
	public static final String IMG_OBJ_BUNDLE_VERSION = "IMG_OBJ_BUNDLE_VERSION"; //$NON-NLS-1$
92
	/**
98
	/**
93
	 * The id for the API problem filters property page
99
	 * Key for Eclipse SDK/API profile image
94
	 * <br>
95
	 * Value is: <code>org.eclipse.pde.api.tools.ui.apitools.filterspage</code>
96
	 */
100
	 */
97
	public static final String ID_FILTERS_PROP_PAGE = "org.eclipse.pde.api.tools.ui.apitools.filterspage"; //$NON-NLS-1$
101
	public static final String IMG_OBJ_ECLIPSE_PROFILE = "IMG_OBJ_ECLIPSE_PROFILE"; //$NON-NLS-1$
98
	/**
102
	/**
99
	 * The id for the API errors / warnings property page
103
	 * Key for fragment image
100
	 * <br>
101
	 * Value is: <code>org.eclipse.pde.api.tools.ui.apitools.warningspage</code>
102
	 */
104
	 */
103
	public static final String ID_ERRORS_WARNINGS_PROP_PAGE = "org.eclipse.pde.api.tools.ui.apitools.warningspage"; //$NON-NLS-1$
105
	public static final String IMG_OBJ_FRAGMENT = "IMG_OBJ_FRAGMENT"; //$NON-NLS-1$		
104
	/**
106
	/**
105
	 * Key for filter resolution image
107
	 * Error overlay.
106
	 */
108
	 */
107
	public static final String IMG_ELCL_FILTER = "IMG_ELCL_FILTER"; //$NON-NLS-1$
109
	public static final String IMG_OVR_ERROR = "IMG_OVR_ERROR"; //$NON-NLS-1$
108
	
110
	
109
	/**
111
	/**
110
	 * Key for enabled remove image
112
	 * Success overlay
111
	 */
113
	 */
112
	public static final String IMG_ELCL_REMOVE = "IMG_ELCL_REMOVE"; //$NON-NLS-1$
114
	public static final String IMG_OVR_SUCCESS = "IMG_OVR_SUCCESS"; //$NON-NLS-1$
113
	
115
	
114
	/**
116
	/**
115
	 * Key for the open page image
117
	 * Warning overlay
116
	 */
118
	 */
117
	public static final String IMG_ELCL_OPEN_PAGE = "IMG_ELCL_OPEN_PAGE"; //$NON-NLS-1$
119
	public static final String IMG_OVR_WARNING = "IMG_OVR_WARNING"; //$NON-NLS-1$
120
	/**
121
	 * Wizard banner for editing an API profile
122
	 */
123
	public static final String IMG_WIZBAN_PROFILE = "IMG_WIZBAN_PROFILE"; //$NON-NLS-1$
118
}
124
}
(-)META-INF/MANIFEST.MF (+1 lines)
Lines 33-37 Link Here
33
 org.eclipse.pde.api.tools.ui.internal.preferences;x-friends:="org.eclipse.pde.api.tools.tests",
33
 org.eclipse.pde.api.tools.ui.internal.preferences;x-friends:="org.eclipse.pde.api.tools.tests",
34
 org.eclipse.pde.api.tools.ui.internal.properties;x-friends:="org.eclipse.pde.api.tools.tests",
34
 org.eclipse.pde.api.tools.ui.internal.properties;x-friends:="org.eclipse.pde.api.tools.tests",
35
 org.eclipse.pde.api.tools.ui.internal.refactoring;x-internal:=true,
35
 org.eclipse.pde.api.tools.ui.internal.refactoring;x-internal:=true,
36
 org.eclipse.pde.api.tools.ui.internal.views;x-internal:=true,
36
 org.eclipse.pde.api.tools.ui.internal.wizards;x-friends:="org.eclipse.pde.api.tools.tests"
37
 org.eclipse.pde.api.tools.ui.internal.wizards;x-friends:="org.eclipse.pde.api.tools.tests"
37
Import-Package: com.ibm.icu.text;version="3.6.1"
38
Import-Package: com.ibm.icu.text;version="3.6.1"
(-)plugin.properties (-1 / +4 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2007, 2008 IBM Corporation and others.
2
# Copyright (c) 2007, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 43-48 Link Here
43
ApiToolsJavadocProposals.name = API Tools Javadoc Proposals
43
ApiToolsJavadocProposals.name = API Tools Javadoc Proposals
44
MarkerGroupingEntryLabel=API Usage and Compatibility
44
MarkerGroupingEntryLabel=API Usage and Compatibility
45
ApiToolsProposalCategory.name = PDE API Tools Proposals
45
ApiToolsProposalCategory.name = PDE API Tools Proposals
46
APICompare.name=Compare With...
47
Apitoolingview.name=API Tooling
48
Apitoolingview.category.name=API Tooling
46
FilterDeleteParticipant.name = API Problem Filter Delete Participant
49
FilterDeleteParticipant.name = API Problem Filter Delete Participant
47
FilterRenameParticipant.name = API Problem Filter Rename Participant
50
FilterRenameParticipant.name = API Problem Filter Rename Participant
48
FilterMoveParticipant.name = API Problem Filter Move Participant
51
FilterMoveParticipant.name = API Problem Filter Move Participant
(-)plugin.xml (+33 lines)
Lines 114-119 Link Here
114
               value="org.eclipse.pde.api.tools.apiAnalysisNature">
114
               value="org.eclipse.pde.api.tools.apiAnalysisNature">
115
         </filter>
115
         </filter>
116
      </objectContribution>
116
      </objectContribution>
117
      <objectContribution
118
            adaptable="false"
119
            id="org.eclipse.pde.api.tools.ui.compare"
120
            objectClass="org.eclipse.jdt.core.IJavaElement">
121
         <action
122
               class="org.eclipse.pde.api.tools.ui.internal.actions.CompareWithAction"
123
               enablesFor="+"
124
               id="org.eclipse.pde.api.tools.ui.action.compare"
125
               label="%APICompare.name"
126
               menubarPath="org.eclipse.pde.ui.project.tools/group1">
127
         </action>
128
         <menu
129
               id="org.eclipse.pde.ui.project.tools"
130
               label="%PdeTools.name">
131
            <separator
132
                  name="group1">
133
            </separator>
134
         </menu>
135
      </objectContribution>
117
   </extension>
136
   </extension>
118
   <extension
137
   <extension
119
         point="org.eclipse.ui.propertyPages">
138
         point="org.eclipse.ui.propertyPages">
Lines 271-276 Link Here
271
      </markerResolutionGenerator>
290
      </markerResolutionGenerator>
272
   </extension>
291
   </extension>
273
   <extension
292
   <extension
293
         point="org.eclipse.ui.views">
294
      <category
295
            id="org.eclipse.pde.api.tools.ui.views.apitooling.view.category"
296
            name="%Apitoolingview.category.name">
297
      </category>
298
      <view
299
            category="org.eclipse.pde.api.tools.ui.views.apitooling.view.category"
300
            class="org.eclipse.pde.api.tools.ui.internal.views.APIToolingView"
301
            icon="icons/full/obj16/api_tools.gif"
302
            id="org.eclipse.pde.api.tools.ui.views.apitooling.views.apitoolingview"
303
            name="%Apitoolingview.name">
304
      </view>
305
   </extension>
306
   <extension
274
         point="org.eclipse.ltk.core.refactoring.renameParticipants">
307
         point="org.eclipse.ltk.core.refactoring.renameParticipants">
275
      <renameParticipant
308
      <renameParticipant
276
            class="org.eclipse.pde.api.tools.ui.internal.refactoring.FilterRenameParticipant"
309
            class="org.eclipse.pde.api.tools.ui.internal.refactoring.FilterRenameParticipant"
(-)src/org/eclipse/pde/api/tools/ui/internal/actions/RemoveAllSessionsAction.java (+37 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.ui.internal.actions;
12
import org.eclipse.jface.action.Action;
13
import org.eclipse.jface.resource.ImageDescriptor;
14
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
15
import org.eclipse.ui.ISharedImages;
16
import org.eclipse.ui.PlatformUI;
17
18
/**
19
 * This action removes the active session.
20
 */
21
public class RemoveAllSessionsAction extends Action {
22
23
	public RemoveAllSessionsAction() {
24
		setText(ActionMessages.RemoveAllSessionsAction_label);
25
		setToolTipText(ActionMessages.RemoveAllSessionsAction_tooltip);
26
		ImageDescriptor enabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_REMOVEALL);
27
		//ImageDescriptor enabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE);
28
		setImageDescriptor(enabledImageDescriptor);
29
		ImageDescriptor disabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_REMOVEALL_DISABLED);
30
		//ImageDescriptor disabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED);
31
		setDisabledImageDescriptor(disabledImageDescriptor);
32
	}
33
34
	public void run() {
35
		ApiPlugin.getDefault().getSessionManager().removeAllSessions();
36
	}
37
}
(-)src/org/eclipse/pde/api/tools/ui/internal/actions/SelectSessionAction.java (+76 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.ui.internal.actions;
12
13
import org.eclipse.jface.action.Action;
14
import org.eclipse.jface.action.IMenuCreator;
15
import org.eclipse.osgi.util.NLS;
16
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
17
import org.eclipse.pde.api.tools.internal.provisional.ISession;
18
import org.eclipse.pde.api.tools.internal.provisional.ISessionManager;
19
import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin;
20
import org.eclipse.pde.api.tools.ui.internal.IApiToolsConstants;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.events.SelectionAdapter;
23
import org.eclipse.swt.events.SelectionEvent;
24
import org.eclipse.swt.widgets.Control;
25
import org.eclipse.swt.widgets.Menu;
26
import org.eclipse.swt.widgets.MenuItem;
27
28
/**
29
 * Drop-down action to select the active session.
30
 */
31
public class SelectSessionAction extends Action implements IMenuCreator {
32
33
	private Menu menu;
34
35
	public SelectSessionAction() {
36
		setText(ActionMessages.SelectSessionAction_label);
37
		setToolTipText(ActionMessages.SelectSessionAction_tooltip);
38
		setImageDescriptor(ApiUIPlugin.getImageDescriptor(IApiToolsConstants.IMG_ELCL_COMPARE_APIS));
39
		setDisabledImageDescriptor(ApiUIPlugin.getImageDescriptor(IApiToolsConstants.IMG_ELCL_COMPARE_APIS_DISABLED));
40
		setMenuCreator(this);
41
		setEnabled(false);
42
	}
43
44
	public Menu getMenu(Control parent) {
45
		if (menu != null) {
46
			menu.dispose();
47
		}
48
		menu = new Menu(parent);
49
50
		final ISessionManager manager = ApiPlugin.getDefault().getSessionManager();
51
		ISession[] sessions = manager.getSessions();
52
		ISession active = manager.getActiveSession();
53
		for (int i = 0; i < sessions.length; i++) {
54
			final ISession session = sessions[i];
55
			MenuItem item = new MenuItem(menu, SWT.RADIO);
56
			Object[] labelparams = new Object[] { new Integer(i + 1), session.getTimestamp()};
57
			item.setText(NLS.bind(ActionMessages.SelectSessionActionEntry_label,
58
					labelparams));
59
			item.setSelection(session == active);
60
			item.addSelectionListener(new SelectionAdapter() {
61
				public void widgetSelected(SelectionEvent e) {
62
					manager.activateSession(session);
63
				}
64
			});
65
		}
66
		return menu;
67
	}
68
69
	public Menu getMenu(Menu parent) {
70
		return null;
71
	}
72
73
	public void dispose() {
74
	}
75
76
}
(-)src/org/eclipse/pde/api/tools/ui/internal/actions/RemoveActiveSessionAction.java (+50 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.ui.internal.actions;
12
import org.eclipse.jface.action.Action;
13
import org.eclipse.jface.resource.ImageDescriptor;
14
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
15
import org.eclipse.pde.api.tools.internal.provisional.ISession;
16
import org.eclipse.pde.api.tools.internal.provisional.ISessionManager;
17
import org.eclipse.ui.ISharedImages;
18
import org.eclipse.ui.PlatformUI;
19
import org.eclipse.ui.actions.ActionFactory;
20
21
/**
22
 * This action removes the active session.
23
 */
24
public class RemoveActiveSessionAction extends Action {
25
26
	public RemoveActiveSessionAction() {
27
		setText(ActionMessages.RemoveActiveSessionAction_label);
28
		setToolTipText(ActionMessages.RemoveActiveSessionAction_tooltip);
29
		ImageDescriptor enabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE);
30
		//ImageDescriptor enabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE);
31
		setImageDescriptor(enabledImageDescriptor);
32
		ImageDescriptor disabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE_DISABLED);
33
		//ImageDescriptor disabledImageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED);
34
		setDisabledImageDescriptor(disabledImageDescriptor);
35
		setActionDefinitionId(ActionFactory.DELETE.getCommandId());
36
	}
37
38
	public void run() {
39
		ISessionManager manager = ApiPlugin.getDefault().getSessionManager();
40
		ISession session = manager.getActiveSession();
41
		if (session != null) {
42
			manager.removeSession(session);
43
		}
44
		ISession[] sessions = manager.getSessions();
45
		int length = sessions.length;
46
		if (length > 0) {
47
			manager.activateSession(sessions[length - 1]);
48
		}
49
	}
50
}
(-)src/org/eclipse/pde/api/tools/ui/internal/actions/CompareDialog.java (+179 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.ui.internal.actions;
12
13
import java.util.Arrays;
14
15
import org.eclipse.jface.dialogs.Dialog;
16
import org.eclipse.jface.dialogs.IDialogSettings;
17
import org.eclipse.jface.window.IShellProvider;
18
import org.eclipse.osgi.util.NLS;
19
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
20
import org.eclipse.pde.api.tools.internal.provisional.IApiBaselineManager;
21
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
22
import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin;
23
import org.eclipse.pde.api.tools.ui.internal.SWTFactory;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.events.SelectionAdapter;
26
import org.eclipse.swt.events.SelectionEvent;
27
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.widgets.Combo;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Control;
31
import org.eclipse.swt.widgets.Shell;
32
33
/**
34
 * Compares {@link org.eclipse.pde.api.tools.internal.provisional.model.IApiElement}s
35
 * to a given {@link IApiBaseline} to get a delta
36
 * 
37
 * @since 1.0.1
38
 */
39
public class CompareDialog extends Dialog {
40
41
	//widget state ids 
42
	static final String SETTINGS_SECTION = ApiUIPlugin.PLUGIN_ID + ".api.compare"; //$NON-NLS-1$
43
	static final String BASELINE_STATE = SETTINGS_SECTION + ".baseline"; //$NON-NLS-1$
44
	
45
	public String baseline = null;
46
	String title = null;;
47
	Combo baselinecombo = null;
48
49
	/**
50
	 * Constructor
51
	 * @param provider
52
	 * @param title
53
	 */
54
	public CompareDialog(IShellProvider provider, String title) {
55
		super(provider);
56
		this.title = title;
57
	}
58
59
	/* (non-Javadoc)
60
	 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
61
	 */
62
	protected void configureShell(Shell newShell) {
63
		super.configureShell(newShell);
64
		newShell.setText(this.title);
65
	}
66
	
67
	/* (non-Javadoc)
68
	 * @see org.eclipse.jface.dialogs.Dialog#isResizable()
69
	 */
70
	protected boolean isResizable() {
71
		return true;
72
	}
73
	
74
	/* (non-Javadoc)
75
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
76
	 */
77
	protected Control createDialogArea(Composite parent) {
78
		Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL);
79
		GridData gd = (GridData) comp.getLayoutData();
80
		gd.widthHint = 310;
81
		
82
		SWTFactory.createWrapLabel(comp, ActionMessages.SelectABaseline, 2);
83
		this.baselinecombo = SWTFactory.createCombo(comp, SWT.BORDER | SWT.FLAT | SWT.READ_ONLY, 2, GridData.FILL_HORIZONTAL, null);
84
		this.baselinecombo.addSelectionListener(new SelectionAdapter(){
85
			public void widgetSelected(SelectionEvent e) {
86
				Combo combo = (Combo) e.widget;
87
				String[] baselineNames = (String[]) combo.getData();
88
				String selectedBaselineName = baselineNames[combo.getSelectionIndex()];
89
				CompareDialog.this.baseline = selectedBaselineName;
90
			}
91
		});
92
		initialize();
93
		return comp;
94
	}
95
	
96
	/**
97
	 * Initializes the controls
98
	 */
99
	void initialize() {
100
		IApiBaselineManager apiBaselineManager = ApiPlugin.getDefault().getApiBaselineManager();
101
		IApiBaseline defaultBaseline = apiBaselineManager.getDefaultApiBaseline();
102
		String defaultBaselineName = defaultBaseline != null ? defaultBaseline.getName() : null;
103
		IApiBaseline[] baselines = apiBaselineManager.getApiBaselines();
104
		int length = baselines.length;
105
		String[] baselinesItems = new String[length];
106
		String[] baselinesNames = new String[length];
107
		// set the names
108
		for (int i = 0; i < length; i++) {
109
			String currentBaselineName = baselines[i].getName();
110
			baselinesNames[i] = currentBaselineName;
111
		}
112
		Arrays.sort(baselinesNames);
113
		// set the labels
114
		int index = 0;
115
		for (int i = 0; i < length; i++) {
116
			String currentBaselineName = baselinesNames[i];
117
			if (defaultBaselineName != null && defaultBaselineName.equals(currentBaselineName)) {
118
				baselinesItems[i] = NLS.bind(ActionMessages.SetAsDefault, currentBaselineName);
119
				this.baseline = currentBaselineName;
120
				index = i;
121
			} else {
122
				baselinesItems[i] = currentBaselineName;
123
			}
124
		}
125
		this.baselinecombo.setItems(baselinesItems);
126
		this.baselinecombo.setData(baselinesNames);
127
		this.baselinecombo.select(index);
128
		
129
		IDialogSettings settings = ApiUIPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
130
		if(settings != null) {
131
			restoreComboSelection(this.baselinecombo, BASELINE_STATE, settings, baselinesNames);
132
		}
133
	}
134
	
135
	/* (non-Javadoc)
136
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
137
	 */
138
	protected void okPressed() {
139
		saveWidgetState();
140
		super.okPressed();
141
	}
142
	/**
143
	 * Restores the selected item for the given combo based on the stored value from the 
144
	 * dialog settings
145
	 * 
146
	 * @param combo
147
	 * @param id
148
	 * @param settings
149
	 */
150
	private void restoreComboSelection(Combo combo, String id, IDialogSettings settings, String[] baselinesNames) {
151
		String value = settings.get(id);
152
		if(value != null) {
153
			CompareDialog.this.baseline = value;
154
			// retrieve the right index in the combo
155
			int index = 0;
156
			int length = baselinesNames.length;
157
			for (int i = 0; i < length; i++) {
158
				String currentBaselineName = baselinesNames[i];
159
				if (value.equals(currentBaselineName)) {
160
					index = i;
161
					break;
162
				}
163
			}
164
			combo.select(index);
165
		}
166
	}
167
	
168
	/**
169
	 * Saves the state of the widgets on the page
170
	 */
171
	void saveWidgetState() {
172
		IDialogSettings rootsettings = ApiUIPlugin.getDefault().getDialogSettings();
173
		IDialogSettings settings = rootsettings.getSection(SETTINGS_SECTION);
174
		if(settings == null) {
175
			settings = rootsettings.addNewSection(SETTINGS_SECTION);
176
		}
177
		settings.put(BASELINE_STATE, this.baseline);
178
	}
179
}
(-)src/org/eclipse/pde/api/tools/ui/internal/views/APIToolingView.java (+406 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.ui.internal.views;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.jdt.core.Flags;
15
import org.eclipse.jdt.ui.JavaUI;
16
import org.eclipse.jface.action.Action;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.action.IMenuManager;
19
import org.eclipse.jface.action.IToolBarManager;
20
import org.eclipse.jface.action.Separator;
21
import org.eclipse.jface.resource.ImageDescriptor;
22
import org.eclipse.jface.viewers.DoubleClickEvent;
23
import org.eclipse.jface.viewers.IDoubleClickListener;
24
import org.eclipse.jface.viewers.ISelection;
25
import org.eclipse.jface.viewers.ISelectionChangedListener;
26
import org.eclipse.jface.viewers.IStructuredContentProvider;
27
import org.eclipse.jface.viewers.IStructuredSelection;
28
import org.eclipse.jface.viewers.ITreeContentProvider;
29
import org.eclipse.jface.viewers.LabelProvider;
30
import org.eclipse.jface.viewers.SelectionChangedEvent;
31
import org.eclipse.jface.viewers.TreeViewer;
32
import org.eclipse.jface.viewers.Viewer;
33
import org.eclipse.pde.api.tools.internal.ApiBaselineManager;
34
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
35
import org.eclipse.pde.api.tools.internal.provisional.ISession;
36
import org.eclipse.pde.api.tools.internal.provisional.ISessionListener;
37
import org.eclipse.pde.api.tools.internal.provisional.ISessionManager;
38
import org.eclipse.pde.api.tools.internal.provisional.ITreeModel;
39
import org.eclipse.pde.api.tools.internal.provisional.ITreeNode;
40
import org.eclipse.pde.api.tools.internal.provisional.comparator.DeltaProcessor;
41
import org.eclipse.pde.api.tools.internal.provisional.comparator.IDelta;
42
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
43
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
44
import org.eclipse.pde.api.tools.ui.internal.ApiImageDescriptor;
45
import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin;
46
import org.eclipse.pde.api.tools.ui.internal.IApiToolsConstants;
47
import org.eclipse.pde.api.tools.ui.internal.actions.ExportSessionAction;
48
import org.eclipse.pde.api.tools.ui.internal.actions.RemoveActiveSessionAction;
49
import org.eclipse.pde.api.tools.ui.internal.actions.RemoveAllSessionsAction;
50
import org.eclipse.pde.api.tools.ui.internal.actions.SelectSessionAction;
51
import org.eclipse.swt.SWT;
52
import org.eclipse.swt.graphics.Image;
53
import org.eclipse.swt.widgets.Composite;
54
import org.eclipse.ui.IActionBars;
55
import org.eclipse.ui.actions.ActionFactory;
56
import org.eclipse.ui.part.ViewPart;
57
import org.eclipse.ui.views.properties.IPropertySheetPage;
58
import org.eclipse.ui.views.properties.PropertySheetPage;
59
60
/**
61
 * The class is used to show api tooling task results in a tree view.
62
 */
63
64
public class APIToolingView extends ViewPart implements ISessionListener {
65
66
	/**
67
	 * The ID of the view as specified by the extension.
68
	 */
69
	public static final String ID = "org.eclipse.pde.api.tools.ui.views.apitooling.views.apitoolingview"; //$NON-NLS-1$
70
71
	public TreeViewer viewer;
72
	private IAction removeActiveSessionAction;
73
	private IAction removeAllSessionsAction;
74
	private IAction selectSessionAction;
75
	private Action doubleClickAction;
76
	private ExportSessionAction exportSessionAction;
77
78
	class ViewContentProvider implements IStructuredContentProvider, ITreeContentProvider {
79
		ITreeModel model;
80
		
81
		public void inputChanged(Viewer v, Object oldInput, Object newInput) {
82
			this.model = null;
83
		}
84
		public void dispose() {
85
		}
86
		public Object[] getElements(Object parent) {
87
			if (parent instanceof ISession) {
88
				ISession session = (ISession) parent;
89
				if (this.model == null) {
90
					this.model = session.getModel();
91
				}
92
				return getChildren(this.model.getRoot());
93
			}
94
			return getChildren(parent);
95
		}
96
		public Object getParent(Object child) {
97
			return null;
98
		}
99
		public Object [] getChildren(Object parent) {
100
			if (parent instanceof ITreeNode) {
101
				return ((ITreeNode) parent).getChildren();
102
			}
103
			return new Object[0];
104
		}
105
		public boolean hasChildren(Object parent) {
106
			if (parent instanceof ITreeNode) {
107
				return ((ITreeNode) parent).hasChildren();
108
			}
109
			return false;
110
		}
111
	}
112
	class ViewLabelProvider extends LabelProvider {
113
		public String getText(Object obj) {
114
			return obj.toString();
115
		}
116
117
		public Image getImage(Object obj) {
118
			if (obj instanceof ITreeNode) {
119
				ITreeNode treeNode = (ITreeNode) obj;
120
				switch(treeNode.getId()) {
121
					case ITreeNode.CLASS :
122
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_CLASS);
123
					case ITreeNode.INTERFACE :
124
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_INTERFACE);
125
					case ITreeNode.ANNOTATION :
126
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_ANNOTATION);
127
					case ITreeNode.ENUM :
128
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_ENUM);
129
					case ITreeNode.PACKAGE :
130
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PACKAGE);
131
				}
132
				Object data = treeNode.getData();
133
				if (data instanceof IDelta) {
134
					IDelta delta = (IDelta) data;
135
					Image image = getDeltaElementImage(delta);
136
					if (image != null) {
137
						int flags = (DeltaProcessor.isCompatible(delta) ? ApiImageDescriptor.SUCCESS : ApiImageDescriptor.ERROR);
138
						ImageDescriptor descriptor = ImageDescriptor.createFromImage(image);
139
						ApiImageDescriptor desc = new ApiImageDescriptor(descriptor, flags);
140
						return ApiUIPlugin.getImage(desc);
141
					}
142
				}
143
			}
144
			return null;
145
		}
146
147
		private Image getDeltaElementImage(IDelta delta) {
148
			switch(delta.getFlags()) {
149
				case IDelta.API_FIELD :
150
				case IDelta.FIELD : {
151
					int modifiers = delta.getNewModifiers();
152
					switch(delta.getKind()) {
153
						case IDelta.REMOVED : {
154
							modifiers = delta.getOldModifiers();
155
						}
156
					}
157
					if (Flags.isPublic(modifiers)) {
158
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_PUBLIC);
159
					} else if (Flags.isProtected(modifiers)) {
160
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_PROTECTED);
161
					} else if (Flags.isPrivate(modifiers)){
162
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_PRIVATE);
163
					} else {
164
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_DEFAULT);
165
					}
166
				}
167
				case IDelta.METHOD :
168
				case IDelta.METHOD_MOVED_DOWN :
169
				case IDelta.METHOD_MOVED_UP :
170
				case IDelta.METHOD_WITH_DEFAULT_VALUE :
171
				case IDelta.METHOD_WITHOUT_DEFAULT_VALUE :
172
				case IDelta.CONSTRUCTOR :
173
				case IDelta.CLINIT : {
174
					int modifiers = delta.getNewModifiers();
175
					switch(delta.getKind()) {
176
						case IDelta.REMOVED : {
177
							modifiers = delta.getOldModifiers();
178
						}
179
					}
180
					if (Flags.isPublic(modifiers)) {
181
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PUBLIC);
182
					} else if (Flags.isProtected(modifiers)) {
183
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PROTECTED);
184
					} else if (Flags.isPrivate(modifiers)){
185
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PRIVATE);
186
					} else {
187
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_CLASS_DEFAULT);
188
					}
189
				}
190
			}
191
			switch(delta.getElementType()) {
192
				case IDelta.ANNOTATION_ELEMENT_TYPE : return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_ANNOTATION);
193
				case IDelta.ENUM_ELEMENT_TYPE : return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_ENUM);
194
				case IDelta.CLASS_ELEMENT_TYPE : return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_CLASS);
195
				case IDelta.INTERFACE_ELEMENT_TYPE : return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_INTERFACE);
196
				case IDelta.FIELD_ELEMENT_TYPE : {
197
					int modifiers = delta.getNewModifiers();
198
					switch(delta.getKind()) {
199
						case IDelta.REMOVED : {
200
							modifiers = delta.getOldModifiers();
201
						}
202
					}
203
					if (Flags.isPublic(modifiers)) {
204
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_PUBLIC);
205
					} else if (Flags.isProtected(modifiers)) {
206
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_PROTECTED);
207
					} else if (Flags.isPrivate(modifiers)){
208
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_PRIVATE);
209
					} else {
210
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_FIELD_DEFAULT);
211
					}
212
				}
213
				case IDelta.METHOD_ELEMENT_TYPE :
214
				case IDelta.CONSTRUCTOR_ELEMENT_TYPE : {
215
					int modifiers = delta.getNewModifiers();
216
					switch(delta.getKind()) {
217
						case IDelta.REMOVED : {
218
							modifiers = delta.getOldModifiers();
219
						}
220
					}
221
					if (Flags.isPublic(modifiers)) {
222
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PUBLIC);
223
					} else if (Flags.isProtected(modifiers)) {
224
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PROTECTED);
225
					} else if (Flags.isPrivate(modifiers)){
226
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PRIVATE);
227
					} else {
228
						return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_CLASS_DEFAULT);
229
					}
230
				}
231
				case IDelta.TYPE_PARAMETER_ELEMENT_TYPE : return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PUBLIC);
232
				case IDelta.API_PROFILE_ELEMENT_TYPE : return ApiUIPlugin.getSharedImage(IApiToolsConstants.IMG_OBJ_ECLIPSE_PROFILE);
233
				case IDelta.API_COMPONENT_ELEMENT_TYPE : {
234
					String componentVersionId = delta.getComponentVersionId();
235
					IApiComponent component = null;
236
					if (componentVersionId != null) {
237
						int indexOfOpen = componentVersionId.lastIndexOf('(');
238
						String componentID = componentVersionId.substring(0, indexOfOpen);
239
						IApiBaseline baseline = ApiBaselineManager.getManager().getWorkspaceBaseline();
240
						if (baseline != null) {
241
							IApiComponent apiComponent = baseline.getApiComponent(componentID);
242
							if (apiComponent != null) {
243
								component = apiComponent;
244
							}
245
						}
246
					}
247
					if (component != null) {
248
						if(component.isSystemComponent()) {
249
							return ApiUIPlugin.getSharedImage(IApiToolsConstants.IMG_OBJ_API_SYSTEM_LIBRARY);
250
						}
251
						try {
252
							if (component.isFragment()) {
253
								return ApiUIPlugin.getSharedImage(IApiToolsConstants.IMG_OBJ_FRAGMENT);
254
							}
255
						} catch (CoreException e) {
256
							ApiPlugin.log(e);
257
						}
258
						return ApiUIPlugin.getSharedImage(IApiToolsConstants.IMG_OBJ_BUNDLE);
259
					}
260
				}
261
			}
262
			return null;
263
		}
264
	}
265
266
	/**
267
	 * The constructor.
268
	 */
269
	public APIToolingView() {
270
	}
271
	/**
272
	 * This is a callback that will allow us
273
	 * to create the viewer and initialize it.
274
	 */
275
	public void createPartControl(Composite parent) {
276
		this.viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
277
		this.viewer.setContentProvider(new ViewContentProvider());
278
		this.viewer.setLabelProvider(new ViewLabelProvider());
279
		this.viewer.addSelectionChangedListener(new ISelectionChangedListener() {
280
			public void selectionChanged(SelectionChangedEvent event) {
281
				// TODO Auto-generated method stub
282
				
283
			}
284
		});
285
		ISession[] sessions = ApiPlugin.getDefault().getSessionManager().getSessions();
286
		if (sessions.length > 0) {
287
			this.viewer.setInput(sessions[0]);
288
		}
289
		createActions();
290
		updateActions();
291
		configureToolbar();
292
		hookDoubleClickAction();
293
294
		ApiPlugin.getDefault().getSessionManager().addSessionListener(this);
295
		
296
		getSite().setSelectionProvider(this.viewer);
297
	}
298
	private void hookDoubleClickAction() {
299
		this.viewer.addDoubleClickListener(new IDoubleClickListener() {
300
			public void doubleClick(DoubleClickEvent event) {
301
				APIToolingView.this.doubleClickAction.run();
302
			}
303
		});
304
	}
305
	public void dispose() {
306
		ApiPlugin.getDefault().getSessionManager().removeSessionListener(this);
307
	}
308
	protected void configureToolbar() {
309
		IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager();
310
		tbm.add(new Separator());
311
		tbm.add(this.removeActiveSessionAction);
312
		tbm.add(this.removeAllSessionsAction);
313
		tbm.add(this.selectSessionAction);
314
		tbm.add(new Separator());
315
//		tbm.add(new CollapseAllAction(this.viewer));
316
317
		IMenuManager mm = getViewSite().getActionBars().getMenuManager();
318
		mm.add(this.exportSessionAction);
319
	}
320
	private void createActions() {
321
		final IActionBars actionBars = getViewSite().getActionBars();
322
323
		this.removeActiveSessionAction = new RemoveActiveSessionAction();
324
		actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), removeActiveSessionAction);
325
326
		this.removeAllSessionsAction = new RemoveAllSessionsAction();
327
		this.selectSessionAction = new SelectSessionAction();
328
		this.doubleClickAction = new Action() {
329
			public void run() {
330
				ISelection selection = viewer.getSelection();
331
				if (selection instanceof IStructuredSelection) {
332
					Object item = ((IStructuredSelection) selection).getFirstElement();
333
					if (APIToolingView.this.viewer.getExpandedState(item)) {
334
						APIToolingView.this.viewer.collapseToLevel(item, 1);
335
					} else {
336
						APIToolingView.this.viewer.expandToLevel(item, 1);
337
					}
338
					if (item instanceof ITreeNode) {
339
						ITreeNode node = (ITreeNode) item;
340
						if (node.getData() != null) {
341
							// show in Properties view
342
						}
343
					}
344
				}
345
			}
346
		};
347
		this.exportSessionAction = new ExportSessionAction(this);
348
	}
349
	private void updateActions() {
350
		this.viewer.getControl().getDisplay().asyncExec(new Runnable() {
351
			public void run() {
352
				ISessionManager sessionManager = ApiPlugin.getDefault().getSessionManager();
353
				ISession active = sessionManager.getActiveSession();
354
				setContentDescription(active == null ? "" : active.getTimestamp()); //$NON-NLS-1$
355
				ISession[] sessions =  sessionManager.getSessions();
356
				boolean atLeastOne = sessions.length >= 1;
357
				APIToolingView.this.removeActiveSessionAction.setEnabled(atLeastOne);
358
				APIToolingView.this.removeAllSessionsAction.setEnabled(atLeastOne);
359
				APIToolingView.this.selectSessionAction.setEnabled(atLeastOne);
360
				APIToolingView.this.exportSessionAction.setEnabled(active != null);
361
			}
362
		});
363
	}
364
	/**
365
	 * Passing the focus request to the viewer's control.
366
	 */
367
	public void setFocus() {
368
		this.viewer.getControl().setFocus();
369
	}
370
	public void sessionAdded(final ISession session) {
371
		this.viewer.getControl().getDisplay().asyncExec(new Runnable() {
372
			public void run() {
373
				APIToolingView.this.viewer.setInput(session);
374
			}
375
		});
376
		updateActions();
377
	}
378
	public void sessionRemoved(ISession session) {
379
		this.viewer.setInput(null);
380
		updateActions();
381
	}
382
	
383
	public void sessionActivated(final ISession session) {
384
		this.viewer.getControl().getDisplay().asyncExec(new Runnable() {
385
			public void run() {
386
				APIToolingView.this.viewer.setInput(session);
387
			}
388
		});
389
		updateActions();
390
	}
391
	/**
392
	 * Returns the property sheet.
393
	 */
394
	protected IPropertySheetPage getPropertySheet() {
395
		return new PropertySheetPage();
396
	}
397
	/* (non-Javadoc)
398
	 * Method declared on IAdaptable
399
	 */
400
	public Object getAdapter(Class adapter) {
401
		if (adapter.equals(IPropertySheetPage.class)) {
402
			return getPropertySheet();
403
		}
404
		return super.getAdapter(adapter);
405
	}
406
}
(-)src/org/eclipse/pde/api/tools/ui/internal/actions/ExportSessionAction.java (+179 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.ui.internal.actions;
12
13
import java.io.BufferedWriter;
14
import java.io.File;
15
import java.io.FileWriter;
16
import java.io.IOException;
17
import java.io.InputStream;
18
19
import javax.xml.transform.Result;
20
import javax.xml.transform.Source;
21
import javax.xml.transform.Transformer;
22
import javax.xml.transform.TransformerConfigurationException;
23
import javax.xml.transform.TransformerException;
24
import javax.xml.transform.TransformerFactory;
25
import javax.xml.transform.stream.StreamResult;
26
import javax.xml.transform.stream.StreamSource;
27
28
import org.eclipse.core.runtime.CoreException;
29
import org.eclipse.core.runtime.IProgressMonitor;
30
import org.eclipse.core.runtime.IStatus;
31
import org.eclipse.core.runtime.OperationCanceledException;
32
import org.eclipse.core.runtime.Status;
33
import org.eclipse.core.runtime.SubMonitor;
34
import org.eclipse.core.runtime.jobs.Job;
35
import org.eclipse.jface.action.Action;
36
import org.eclipse.jface.window.Window;
37
import org.eclipse.pde.api.tools.internal.comparator.DeltaXmlVisitor;
38
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
39
import org.eclipse.pde.api.tools.internal.provisional.ISession;
40
import org.eclipse.pde.api.tools.internal.provisional.comparator.IDelta;
41
import org.eclipse.pde.api.tools.internal.util.Util;
42
import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin;
43
import org.eclipse.pde.api.tools.ui.internal.views.APIToolingView;
44
45
/**
46
 * Drop-down action to select the active session.
47
 */
48
public class ExportSessionAction extends Action {
49
	private static final String DELTAS_XSLT_TRANSFORM_PATH = "/xslt/compare.xsl"; //$NON-NLS-1$
50
	private static final String XML_FILE_EXTENSION = ".xml"; //$NON-NLS-1$
51
	private static final String HTML_FILE_EXTENSION = ".html"; //$NON-NLS-1$
52
	APIToolingView view;
53
	public ExportSessionAction(APIToolingView view) {
54
		setText(ActionMessages.ExportSessionAction_label);
55
		setToolTipText(ActionMessages.ExportSessionAction_tooltip);
56
		setEnabled(false);
57
		this.view = view;
58
	}
59
60
	public void run() {
61
		final ISession activeSession = ApiPlugin.getDefault().getSessionManager().getActiveSession();
62
		if (activeSession == null) {
63
			return;
64
		}
65
		ExportDialog dialog = new ExportDialog(view.getSite(), ActionMessages.ExportActionTitle);
66
		int returnCode = dialog.open();
67
		if (returnCode == Window.CANCEL) {
68
			return;
69
		}
70
		final String reportFileName = dialog.reportPath;
71
		if (reportFileName == null) {
72
			return;
73
		}
74
		final String lowerCase = reportFileName.toLowerCase();
75
		if (!lowerCase.endsWith(HTML_FILE_EXTENSION) && !lowerCase.endsWith(XML_FILE_EXTENSION)) {
76
			return;
77
		}
78
		
79
		Job job = new Job(ActionMessages.CompareWithAction_comparing_apis){
80
			protected IStatus run(IProgressMonitor monitor) {
81
				SubMonitor progress = SubMonitor.convert(monitor, 100);
82
				progress.subTask(ActionMessages.CompareDialogCollectingElementTaskName);
83
				boolean isHtmlFile = lowerCase.endsWith(HTML_FILE_EXTENSION);
84
				File xmlOutputFile = null;
85
				try {
86
					progress.subTask(ActionMessages.CompareDialogComputeDeltasTaskName);
87
					File reportFile = new File(reportFileName);
88
					try {
89
						progress.worked(25);
90
						Util.checkCanceled(progress);
91
						BufferedWriter writer = null;
92
						try {
93
							if (isHtmlFile) {
94
								xmlOutputFile = File.createTempFile(String.valueOf(System.currentTimeMillis()), XML_FILE_EXTENSION);
95
							} else {
96
								xmlOutputFile = reportFile;
97
							}
98
							if (xmlOutputFile.exists()) {
99
								xmlOutputFile.delete();
100
							}
101
							writer = new BufferedWriter(new FileWriter(xmlOutputFile));
102
							DeltaXmlVisitor visitor = new DeltaXmlVisitor();
103
							Object data = activeSession.getModel().getRoot().getData();
104
							if (data instanceof IDelta) {
105
								IDelta delta = (IDelta) data;
106
								progress.worked(25);
107
								Util.checkCanceled(progress);
108
								delta.accept(visitor);
109
								writer.write(visitor.getXML());
110
								writer.flush();
111
								progress.worked(25);
112
							}
113
						} catch (IOException e) {
114
							ApiPlugin.log(e);
115
						} catch (CoreException e) {
116
							ApiPlugin.log(e);
117
						} finally {
118
							if (writer != null) {
119
								try {
120
									writer.close();
121
								} catch(IOException e) {
122
									// ignore
123
								}
124
							}
125
						}
126
						if(isHtmlFile) {
127
							// remaining part is to convert the xml file to html using XSLT
128
							Util.checkCanceled(progress);
129
							Source xmlSource = new StreamSource(xmlOutputFile);
130
							InputStream stream = ApiPlugin.class.getResourceAsStream(DELTAS_XSLT_TRANSFORM_PATH);
131
							Source xsltSource = new StreamSource(stream);
132
							try {
133
								writer = new BufferedWriter(new FileWriter(reportFile));
134
								Result result = new StreamResult(writer);
135
								// create an instance of TransformerFactory
136
								TransformerFactory transFact = TransformerFactory.newInstance();
137
								Transformer trans = transFact.newTransformer(xsltSource);
138
								trans.transform(xmlSource, result);
139
							} catch (TransformerConfigurationException e) {
140
								ApiUIPlugin.log(e);
141
							} catch (TransformerException e) {
142
								ApiUIPlugin.log(e);
143
							} catch(IOException e) {
144
								ApiUIPlugin.log(e);
145
							} finally {
146
								if (writer != null) {
147
									try {
148
										writer.close();
149
									} catch(IOException e) {
150
										// ignore
151
									}
152
								}
153
							}
154
						}
155
						progress.worked(25);
156
						return Status.OK_STATUS;
157
					} catch(OperationCanceledException e) {
158
						// ignore
159
						if (xmlOutputFile != null && xmlOutputFile.exists()) {
160
							xmlOutputFile.delete();
161
						}
162
						if (reportFile.exists()) {
163
							reportFile.delete();
164
						}
165
					}
166
				} finally {
167
					monitor.done();
168
				}
169
				return Status.CANCEL_STATUS;
170
			}
171
		};
172
		job.setSystem(false);
173
		job.setPriority(Job.LONG);
174
		job.schedule();
175
	}
176
	public void dispose() {
177
	}
178
179
}
(-)src/org/eclipse/pde/api/tools/ui/internal/actions/ExportDialog.java (+160 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.ui.internal.actions;
12
13
import java.io.File;
14
15
import org.eclipse.core.runtime.Path;
16
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.jface.dialogs.IDialogSettings;
18
import org.eclipse.jface.window.IShellProvider;
19
import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin;
20
import org.eclipse.pde.api.tools.ui.internal.SWTFactory;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.events.SelectionAdapter;
23
import org.eclipse.swt.events.SelectionEvent;
24
import org.eclipse.swt.layout.GridData;
25
import org.eclipse.swt.widgets.Button;
26
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.swt.widgets.FileDialog;
29
import org.eclipse.swt.widgets.Shell;
30
import org.eclipse.swt.widgets.Text;
31
32
/**
33
 * Compares {@link org.eclipse.pde.api.tools.internal.provisional.model.IApiElement}s
34
 * to a given {@link IApiBaseline} to get a delta
35
 * 
36
 * @since 1.0.1
37
 */
38
public class ExportDialog extends Dialog {
39
40
	//widget state ids 
41
	static final String SETTINGS_SECTION = ApiUIPlugin.PLUGIN_ID + ".api.exportsession"; //$NON-NLS-1$
42
	static final String REPORT_PATH_STATE = SETTINGS_SECTION + ".reportpath"; //$NON-NLS-1$
43
	
44
	private String title = null;;
45
	private Text reportPathText;
46
	public String reportPath;
47
48
	/**
49
	 * Constructor
50
	 * @param provider
51
	 * @param title
52
	 */
53
	public ExportDialog(IShellProvider provider, String title) {
54
		super(provider);
55
		this.title = title;
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
60
	 */
61
	protected void configureShell(Shell newShell) {
62
		super.configureShell(newShell);
63
		newShell.setText(this.title);
64
	}
65
	
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.jface.dialogs.Dialog#isResizable()
68
	 */
69
	protected boolean isResizable() {
70
		return true;
71
	}
72
	
73
	/* (non-Javadoc)
74
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
75
	 */
76
	protected Control createDialogArea(Composite parent) {
77
		Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL);
78
		GridData gd = (GridData) comp.getLayoutData();
79
		gd.widthHint = 310;
80
81
		SWTFactory.createWrapLabel(comp, ActionMessages.EnterFileNameForExport, 2);
82
		this.reportPathText = SWTFactory.createText(comp, SWT.SINGLE | SWT.BORDER | SWT.FLAT, 1, GridData.BEGINNING | GridData.FILL_HORIZONTAL);
83
		gd = (GridData) this.reportPathText.getLayoutData();
84
		gd.grabExcessHorizontalSpace = true;
85
86
		Button browseButton = SWTFactory.createPushButton(comp, ActionMessages.Browse, null);
87
		browseButton.addSelectionListener(new SelectionAdapter() {
88
			public void widgetSelected(SelectionEvent e) {
89
				FileDialog dialog = new FileDialog(getShell());
90
				dialog.setText(ActionMessages.SelectFileName);
91
				String loctext = ExportDialog.this.reportPathText.getText().trim();
92
				if (loctext.length() > 0) {
93
					File file = new File(loctext).getParentFile();
94
					if (file != null && file.exists()) {
95
						dialog.setFilterPath(file.getAbsolutePath());
96
					}
97
				}
98
				String newPath = dialog.open();
99
				if (newPath != null && !new Path(loctext).equals(new Path(newPath))) {
100
					ExportDialog.this.reportPathText.setText(newPath);
101
					ExportDialog.this.reportPath = newPath;
102
				}
103
			}
104
		});
105
106
		initialize();
107
		return comp;
108
	}
109
	
110
	/**
111
	 * Initializes the controls
112
	 */
113
	void initialize() {
114
		IDialogSettings settings = ApiUIPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
115
		if(settings != null) {
116
			restoreTextSelection(this.reportPathText, REPORT_PATH_STATE, settings);
117
		}
118
	}
119
120
	/* (non-Javadoc)
121
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
122
	 */
123
	protected void okPressed() {
124
		String oldPath = this.reportPath;
125
		String newPath = this.reportPathText.getText().trim();
126
		if (newPath != null && !new Path(oldPath).equals(new Path(newPath))) {
127
			this.reportPathText.setText(newPath);
128
			this.reportPath = newPath;
129
		}
130
		saveWidgetState();
131
		super.okPressed();
132
	}
133
	/**
134
	 * Restores the selected item for the given combo based on the stored value from the 
135
	 * dialog settings
136
	 * 
137
	 * @param combo
138
	 * @param id
139
	 * @param settings
140
	 */
141
	private void restoreTextSelection(Text text, String id, IDialogSettings settings) {
142
		String value = settings.get(id);
143
		if(value != null) {
144
			ExportDialog.this.reportPath = value;
145
			text.setText(value);
146
		}
147
	}
148
	
149
	/**
150
	 * Saves the state of the widgets on the page
151
	 */
152
	void saveWidgetState() {
153
		IDialogSettings rootsettings = ApiUIPlugin.getDefault().getDialogSettings();
154
		IDialogSettings settings = rootsettings.getSection(SETTINGS_SECTION);
155
		if(settings == null) {
156
			settings = rootsettings.addNewSection(SETTINGS_SECTION);
157
		}
158
		settings.put(REPORT_PATH_STATE, this.reportPath);
159
	}
160
}
(-)src/org/eclipse/pde/api/tools/ui/internal/actions/CompareWithAction.java (+687 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.ui.internal.actions;
12
13
import java.util.ArrayList;
14
import java.util.Date;
15
import java.util.HashMap;
16
import java.util.List;
17
import java.util.Map;
18
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IAdaptable;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.OperationCanceledException;
24
import org.eclipse.core.runtime.Status;
25
import org.eclipse.core.runtime.SubMonitor;
26
import org.eclipse.core.runtime.jobs.Job;
27
import org.eclipse.jdt.core.Flags;
28
import org.eclipse.jdt.core.IClassFile;
29
import org.eclipse.jdt.core.ICompilationUnit;
30
import org.eclipse.jdt.core.IJavaElement;
31
import org.eclipse.jdt.core.IJavaProject;
32
import org.eclipse.jdt.core.IPackageFragment;
33
import org.eclipse.jdt.core.IPackageFragmentRoot;
34
import org.eclipse.jdt.core.IType;
35
import org.eclipse.jdt.core.JavaModelException;
36
import org.eclipse.jface.action.IAction;
37
import org.eclipse.jface.viewers.ISelection;
38
import org.eclipse.jface.viewers.IStructuredSelection;
39
import org.eclipse.jface.window.Window;
40
import org.eclipse.pde.api.tools.internal.ApiBaselineManager;
41
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
42
import org.eclipse.pde.api.tools.internal.provisional.Factory;
43
import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;
44
import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
45
import org.eclipse.pde.api.tools.internal.provisional.ISession;
46
import org.eclipse.pde.api.tools.internal.provisional.ITreeModel;
47
import org.eclipse.pde.api.tools.internal.provisional.ITreeNode;
48
import org.eclipse.pde.api.tools.internal.provisional.RestrictionModifiers;
49
import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
50
import org.eclipse.pde.api.tools.internal.provisional.comparator.ApiComparator;
51
import org.eclipse.pde.api.tools.internal.provisional.comparator.ApiScope;
52
import org.eclipse.pde.api.tools.internal.provisional.comparator.DeltaVisitor;
53
import org.eclipse.pde.api.tools.internal.provisional.comparator.IDelta;
54
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
55
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
56
import org.eclipse.pde.api.tools.internal.provisional.model.IApiScope;
57
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
58
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;
59
import org.eclipse.pde.api.tools.internal.util.Util;
60
import org.eclipse.ui.IObjectActionDelegate;
61
import org.eclipse.ui.IWorkbenchPart;
62
import org.eclipse.ui.IWorkbenchPartSite;
63
import org.eclipse.ui.views.properties.IPropertyDescriptor;
64
import org.eclipse.ui.views.properties.IPropertySheetEntry;
65
import org.eclipse.ui.views.properties.IPropertySource;
66
import org.eclipse.ui.views.properties.PropertyDescriptor;
67
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
68
69
import com.ibm.icu.text.DateFormat;
70
71
public class CompareWithAction implements IObjectActionDelegate {
72
73
	public static class DeltaSession implements ISession {
74
		static Object[] NO_CHILDREN = new Object[0];
75
76
		static class TreeNode implements ITreeNode, IPropertySource, IAdaptable {
77
			private static final IPropertyDescriptor[] NO_PROPERTY_DESCRIPTORS = new IPropertyDescriptor[0];
78
			// Property id keys
79
			public static final String ID_MESSAGE = "IDelta.Message"; //$NON-NLS-1$
80
			public static final String ID_COMPONENT = "IDelta.Component"; //$NON-NLS-1$
81
			public static final String ID_ELEMENT_TYPE = "IDelta.ElementType"; //$NON-NLS-1$
82
			public static final String ID_FLAGS = "IDelta.Flags"; //$NON-NLS-1$
83
			private static final Object ID_KEY = "IDelta.Key"; //$NON-NLS-1$
84
			private static final Object ID_KIND = "IDelta.Kind"; //$NON-NLS-1$
85
			private static final Object ID_NEW_MODIFIERS = "IDelta.NewModifiers"; //$NON-NLS-1$
86
			private static final Object ID_OLD_MODIFIERS = "IDelta.OldModifiers"; //$NON-NLS-1$
87
			private static final Object ID_RESTRICTIONS = "IDelta.Restrictions"; //$NON-NLS-1$
88
			private static final Object ID_TYPENAME = "IDelta.TypeName"; //$NON-NLS-1$
89
90
			// categories
91
			public static final String P_MESSAGE_CATEGORY = ActionMessages.MessageCategory;
92
			public static final String P_INFO_CATEGORY = ActionMessages.InfoCategory;
93
94
			public static final String P_MESSAGE = ActionMessages.PropertyMessageKey;
95
			public static final String P_COMPONENT = ActionMessages.PropertyComponentKey;
96
			public static final String P_ELEMENT_TYPE = ActionMessages.PropertyElementTypeKey;
97
			public static final String P_FLAGS = ActionMessages.PropertyFlagsKey;
98
			public static final String P_KEY = ActionMessages.PropertyKeyKey;
99
			public static final String P_KIND = ActionMessages.PropertyKindKey;
100
			public static final String P_NEW_MODIFIERS = ActionMessages.PropertyNewModifiersKey;
101
			public static final String P_OLD_MODIFIERS = ActionMessages.PropertyOldModifiersKey;
102
			public static final String P_RESTRICTIONS = ActionMessages.PropertyRestrictionsKey;
103
			public static final String P_TYPENAME = ActionMessages.PropertyTypeNameKey;
104
105
			private static List Descriptors;
106
			static {
107
				Descriptors = new ArrayList();
108
109
				PropertyDescriptor propertyDescriptor = new TextPropertyDescriptor(ID_MESSAGE, P_MESSAGE);
110
				propertyDescriptor.setCategory(P_MESSAGE_CATEGORY);
111
				Descriptors.add(propertyDescriptor);
112
113
				propertyDescriptor = new TextPropertyDescriptor(ID_COMPONENT, P_COMPONENT);
114
				propertyDescriptor.setCategory(P_INFO_CATEGORY);
115
				Descriptors.add(propertyDescriptor);
116
117
				propertyDescriptor = new TextPropertyDescriptor(ID_KEY, P_KEY);
118
				propertyDescriptor.setCategory(P_INFO_CATEGORY);
119
				propertyDescriptor.setFilterFlags(new String[] { IPropertySheetEntry.FILTER_ID_EXPERT });
120
				Descriptors.add(propertyDescriptor);
121
122
				propertyDescriptor = new TextPropertyDescriptor(ID_KIND, P_KIND);
123
				propertyDescriptor.setCategory(P_INFO_CATEGORY);
124
				Descriptors.add(propertyDescriptor);
125
126
				propertyDescriptor = new TextPropertyDescriptor(ID_NEW_MODIFIERS, P_NEW_MODIFIERS);
127
				propertyDescriptor.setCategory(P_INFO_CATEGORY);
128
				Descriptors.add(propertyDescriptor);
129
130
				propertyDescriptor = new TextPropertyDescriptor(ID_OLD_MODIFIERS, P_OLD_MODIFIERS);
131
				propertyDescriptor.setCategory(P_INFO_CATEGORY);
132
				Descriptors.add(propertyDescriptor);
133
134
				propertyDescriptor = new TextPropertyDescriptor(ID_RESTRICTIONS, P_RESTRICTIONS);
135
				propertyDescriptor.setCategory(P_INFO_CATEGORY);
136
				Descriptors.add(propertyDescriptor);
137
138
				propertyDescriptor = new TextPropertyDescriptor(ID_TYPENAME, P_TYPENAME);
139
				propertyDescriptor.setCategory(P_INFO_CATEGORY);
140
				Descriptors.add(propertyDescriptor);
141
142
				propertyDescriptor = new TextPropertyDescriptor(ID_FLAGS, P_FLAGS);
143
				propertyDescriptor.setCategory(P_INFO_CATEGORY);
144
				Descriptors.add(propertyDescriptor);
145
				
146
				propertyDescriptor = new TextPropertyDescriptor(ID_ELEMENT_TYPE, P_ELEMENT_TYPE);
147
				propertyDescriptor.setCategory(P_INFO_CATEGORY);
148
				Descriptors.add(propertyDescriptor);
149
			}
150
			/**
151
			 * Returns the descriptors
152
			 */
153
			static List getDescriptors() {
154
				return Descriptors;
155
			}
156
			Map children;
157
			String name;
158
			TreeNode parent;
159
			Object data;
160
			int id;
161
162
			public TreeNode(int id, String name, Object data) {
163
				this.name = name;
164
				this.id = id;
165
				this.data = data;
166
			}
167
			public Object[] getChildren() {
168
				if (this.children == null) {
169
					return NO_CHILDREN;
170
				}
171
				return this.children.values().toArray(new Object[this.children.size()]);
172
			}
173
			public TreeNode getNode(String name) {
174
				if (this.children == null) {
175
					return null;
176
				}
177
				return (TreeNode) this.children.get(name);
178
			}
179
			public int getId() {
180
				return this.id;
181
			}
182
			public void add(TreeNode node) {
183
				if (this.children == null) {
184
					this.children = new HashMap();
185
				}
186
				this.children.put(node.name, node);
187
			}
188
			public boolean hasChildren() {
189
				return this.children != null && !this.children.isEmpty();
190
			}
191
			public String toString() {
192
				return String.valueOf(this.name);
193
			}
194
			public Object getData() {
195
				return this.data;
196
			}
197
			public Object getEditableValue() {
198
				return null;
199
			}
200
			public IPropertyDescriptor[] getPropertyDescriptors() {
201
				if (this.data != null) {
202
					return (IPropertyDescriptor[]) getDescriptors().toArray(
203
							new IPropertyDescriptor[getDescriptors().size()]);
204
				}
205
				return NO_PROPERTY_DESCRIPTORS;
206
			}
207
			public Object getPropertyValue(Object propKey) {
208
				if (this.data == null) return null;
209
				IDelta delta = (IDelta) this.data;
210
				if (ID_MESSAGE.equals(propKey)) {
211
					return delta.getMessage();
212
				}
213
				if (ID_COMPONENT.equals(propKey)) {
214
					return delta.getComponentVersionId();
215
				}
216
				if (ID_ELEMENT_TYPE.equals(propKey)) {
217
					int elementType = delta.getElementType();
218
					StringBuffer buffer = new StringBuffer(Util.getDeltaElementType(elementType));
219
					buffer.append(" (").append(elementType).append(')'); //$NON-NLS-1$
220
					return String.valueOf(buffer);
221
				}
222
				if (ID_FLAGS.equals(propKey)) {
223
					int flags = delta.getFlags();
224
					StringBuffer buffer = new StringBuffer(Util.getDeltaFlagsName(flags));
225
					buffer.append(" (").append(flags).append(')'); //$NON-NLS-1$
226
					return String.valueOf(buffer);
227
				}
228
				if (ID_KEY.equals(propKey)) {
229
					return delta.getKey();
230
				}
231
				if (ID_KIND.equals(propKey)) {
232
					int kind = delta.getKind();
233
					StringBuffer buffer = new StringBuffer(Util.getDeltaKindName(kind));
234
					buffer.append(" (").append(kind).append(')'); //$NON-NLS-1$
235
					return String.valueOf(buffer);
236
				}
237
				if (ID_NEW_MODIFIERS.equals(propKey)) {
238
					return getDisplayedModifiers(delta.getNewModifiers());
239
				}
240
				if (ID_OLD_MODIFIERS.equals(propKey)) {
241
					return getDisplayedModifiers(delta.getOldModifiers());
242
					}
243
				if (ID_RESTRICTIONS.equals(propKey)) {
244
					int restrictions = delta.getRestrictions();
245
					StringBuffer buffer = new StringBuffer(RestrictionModifiers.getRestrictionText(restrictions));
246
					buffer.append(" (0x").append(Integer.toHexString(restrictions)).append(')'); //$NON-NLS-1$
247
					return String.valueOf(buffer);
248
				}
249
				if (ID_TYPENAME.equals(propKey)) {
250
					return delta.getTypeName();
251
				}
252
				return null;
253
			}
254
			public boolean isPropertySet(Object id) {
255
				return false;
256
			}
257
			public void resetPropertyValue(Object id) {
258
				// nothing to do
259
			}
260
			public void setPropertyValue(Object id, Object value) {
261
				// nothing to do
262
			}
263
			/* (non-Javadoc)
264
			 * Method declared on IAdaptable
265
			 */
266
			public Object getAdapter(Class adapter) {
267
				if (adapter == IPropertySource.class) {
268
					return this;
269
				}
270
				return null;
271
			}
272
			private static String getDisplayedModifiers(int newModifiers) {
273
				StringBuffer buffer = new StringBuffer();
274
				if(newModifiers == 0) {
275
					buffer.append(ActionMessages.PropertyPackageVisibility);
276
				} else {
277
					if (Flags.isAbstract(newModifiers)) {
278
						buffer.append("abstract"); //$NON-NLS-1$
279
					}
280
					String separator = " | "; //$NON-NLS-1$
281
					if(Flags.isFinal(newModifiers)) {
282
						if(buffer.length() > 0) {
283
							buffer.append(separator);
284
						}
285
						buffer.append("final"); //$NON-NLS-1$
286
					}
287
					if(Flags.isNative(newModifiers)) {
288
						if(buffer.length() > 0) {
289
							buffer.append(separator);
290
						}
291
						buffer.append("native"); //$NON-NLS-1$
292
					}
293
					if(Flags.isPrivate(newModifiers)) {
294
						if(buffer.length() > 0) {
295
							buffer.append(separator);
296
						}
297
						buffer.append("private"); //$NON-NLS-1$
298
					}
299
					if(Flags.isProtected(newModifiers)) {
300
						if(buffer.length() > 0) {
301
							buffer.append(separator);
302
						}
303
						buffer.append("protected"); //$NON-NLS-1$
304
					}
305
					if(Flags.isPublic(newModifiers)) {
306
						if(buffer.length() > 0) {
307
							buffer.append(separator);
308
						}
309
						buffer.append("public"); //$NON-NLS-1$
310
					}
311
					if(Flags.isStatic(newModifiers)) {
312
						if(buffer.length() > 0) {
313
							buffer.append(separator);
314
						}
315
						buffer.append("static"); //$NON-NLS-1$
316
					}
317
					if(Flags.isStrictfp(newModifiers)) {
318
						if(buffer.length() > 0) {
319
							buffer.append(separator);
320
						}
321
						buffer.append("strictfp"); //$NON-NLS-1$
322
					}
323
					if(Flags.isSynchronized(newModifiers)) {
324
						if(buffer.length() > 0) {
325
							buffer.append(separator);
326
						}
327
						buffer.append("synchronized"); //$NON-NLS-1$
328
					}
329
					if(Flags.isTransient(newModifiers)) {
330
						if(buffer.length() > 0) {
331
							buffer.append(separator);
332
						}
333
						buffer.append("transient"); //$NON-NLS-1$
334
					}
335
					if(Flags.isVolatile(newModifiers)) {
336
						if(buffer.length() > 0) {
337
							buffer.append(separator);
338
						}
339
						buffer.append("volatile"); //$NON-NLS-1$
340
					}
341
					if(Flags.isVarargs(newModifiers)) {
342
						if(buffer.length() > 0) {
343
							buffer.append(separator);
344
						}
345
						buffer.append("vargars"); //$NON-NLS-1$
346
					}
347
				}
348
				buffer.append(" (0x").append(Integer.toHexString(newModifiers)).append(')'); //$NON-NLS-1$
349
				return buffer.toString();
350
			}
351
		}
352
353
		static class TreeModel implements ITreeModel, IAdaptable {
354
			TreeNode root;
355
356
			TreeModel(TreeNode root) {
357
				this.root = root;
358
			}
359
			public ITreeNode getRoot() {
360
				return this.root;
361
			}
362
			public Object getAdapter(Class adapter) {
363
				// TODO Auto-generated method stub
364
				return null;
365
			}
366
		}
367
368
		IDelta delta;
369
		String baselineName;
370
		String timestamp;
371
		
372
		public DeltaSession(IDelta delta, String baselineName) {
373
			this.delta = delta;
374
			this.baselineName = baselineName;
375
			this.timestamp = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(System.currentTimeMillis()));
376
		}
377
		public ITreeModel getModel() {
378
			TreeNode root = new TreeNode(0, null, this.delta);
379
			TreeModel model = new TreeModel(root);
380
			class TreeBuilder extends DeltaVisitor {
381
				TreeNode node;
382
				
383
				public TreeBuilder(TreeNode node) {
384
					this.node = node;
385
				}
386
				public void endVisit(IDelta delta) {
387
					if (delta.getChildren().length == 0) {
388
						String typeName = delta.getTypeName();
389
						if (typeName == null) {
390
							this.node.add(new TreeNode(0, delta.getKey(), delta));
391
						} else {
392
							// split the type name (package - type)
393
							int index = typeName.lastIndexOf('.');
394
							String packageName = "<default package>"; //$NON-NLS-1$
395
							String actualTypeName = null;
396
							if (index != -1) {
397
								packageName = typeName.substring(0, index);
398
								actualTypeName = typeName.substring(index + 1);
399
							} else {
400
								actualTypeName = typeName;
401
							}
402
							TreeNode node2 = this.node.getNode(packageName);
403
							if (node2 == null) {
404
								node2 = new TreeNode(ITreeNode.PACKAGE, packageName, null);
405
								this.node.add(node2);
406
							}
407
							TreeNode node3 = node2.getNode(actualTypeName);
408
							if (node3 == null) {
409
								int id = 0;
410
								switch(delta.getElementType()) {
411
									case IDelta.ANNOTATION_ELEMENT_TYPE :
412
										id = ITreeNode.ANNOTATION;
413
										break;
414
									case IDelta.INTERFACE_ELEMENT_TYPE :
415
										id = ITreeNode.INTERFACE;
416
										break;
417
									case IDelta.CLASS_ELEMENT_TYPE :
418
										id = ITreeNode.CLASS;
419
										break;
420
									case IDelta.ENUM_ELEMENT_TYPE :
421
										id = ITreeNode.ENUM;
422
									default :
423
										// we need to retrieve the type kind
424
										try {
425
											String componentVersionId = delta.getComponentVersionId();
426
											if (componentVersionId != null) {
427
												int indexOfOpen = componentVersionId.lastIndexOf('(');
428
												String componentID = componentVersionId.substring(0, indexOfOpen);
429
												String version = componentVersionId.substring(indexOfOpen + 1, componentVersionId.length() - 1);
430
												IApiBaseline baseline = ApiBaselineManager.getManager().getApiBaseline(DeltaSession.this.baselineName);
431
												int modifiers = 0;
432
												if (baseline != null) {
433
													IApiComponent apiComponent = baseline.getApiComponent(componentID);
434
													if (apiComponent != null && version.equals(apiComponent.getVersion())) {
435
														IApiTypeRoot typeRoot = apiComponent.findTypeRoot(typeName);
436
														if (typeRoot != null) {
437
															IApiType structure = typeRoot.getStructure();
438
															modifiers = structure.getModifiers();
439
														}
440
													}
441
												}
442
												if (modifiers == 0) {
443
													// try the workspace baseline
444
													baseline = ApiBaselineManager.getManager().getWorkspaceBaseline();
445
													if (baseline != null) {
446
														IApiComponent apiComponent = baseline.getApiComponent(componentID);
447
														if (apiComponent != null && version.equals(apiComponent.getVersion())) {
448
															IApiTypeRoot typeRoot = apiComponent.findTypeRoot(typeName);
449
															if (typeRoot != null) {
450
																IApiType structure = typeRoot.getStructure();
451
																modifiers = structure.getModifiers();
452
															}
453
														}
454
													}
455
												}
456
												if (Flags.isEnum(modifiers)) {
457
													id = ITreeNode.ENUM;
458
												} else if (Flags.isAnnotation(modifiers)) {
459
													id = ITreeNode.ANNOTATION;
460
												} else if (Flags.isInterface(modifiers)) {
461
													id = ITreeNode.INTERFACE;
462
												} else {
463
													id = ITreeNode.CLASS;
464
												}
465
											}
466
										} catch (CoreException e) {
467
											// ignore
468
										}
469
								}
470
								node3 = new TreeNode(id, actualTypeName, null);
471
								node2.add(node3);
472
							}
473
							node3.add(new TreeNode(0, delta.getMessage(), delta));
474
						}
475
					}
476
				}
477
			}
478
			if (this.delta == ApiComparator.NO_DELTA) {
479
				root.add(new TreeNode(0, ActionMessages.CompareTaskNoChanges, null));
480
			} else {
481
				this.delta.accept(new TreeBuilder(root));
482
			}
483
			return model;
484
		}
485
		
486
		public String getTimestamp() {
487
			return this.timestamp;
488
		}
489
	}
490
491
	private IWorkbenchPartSite workbenchPartSite;
492
	private ISelection selection = null;
493
	
494
	/**
495
	 * Constructor for Action1.
496
	 */
497
	public CompareWithAction() {
498
		super();
499
	}
500
501
	/**
502
	 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
503
	 */
504
	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
505
		workbenchPartSite = targetPart.getSite();
506
	}
507
	/**
508
	 * @see IActionDelegate#run(IAction)
509
	 */
510
	public void run(IAction action) {
511
		if (this.selection instanceof IStructuredSelection) {
512
			final IStructuredSelection structuredSelection=(IStructuredSelection) this.selection;
513
			CompareDialog dialog = new CompareDialog(workbenchPartSite, ActionMessages.CompareDialogTitle);
514
			int returnCode = dialog.open();
515
			if (returnCode == Window.CANCEL) return;
516
			final String baselineName = dialog.baseline;
517
			if (baselineName == null) return;
518
			final IApiBaseline baseline = ApiBaselineManager.getManager().getApiBaseline(baselineName);
519
			if (baseline == null) {
520
				return;
521
			}
522
			Job job = new Job(ActionMessages.CompareWithAction_comparing_apis){
523
				protected IStatus run(IProgressMonitor monitor) {
524
					SubMonitor progress = SubMonitor.convert(monitor, 100);
525
					progress.subTask(ActionMessages.CompareDialogCollectingElementTaskName);
526
					SubMonitor loopProgress = progress.newChild(10).setWorkRemaining(structuredSelection.size());
527
					final IApiScope scope = walkStructureSelection(structuredSelection, loopProgress);
528
					try {
529
						progress.subTask(ActionMessages.CompareDialogComputeDeltasTaskName);
530
						SubMonitor compareProgress = progress.newChild(98).setWorkRemaining(scope.getApiElements().length);
531
						try {
532
							IDelta delta = ApiComparator.compare(scope, baseline, VisibilityModifiers.API, false, compareProgress);
533
							ApiPlugin.getDefault().getSessionManager().addSession(new DeltaSession(delta, baselineName), true);
534
							progress.worked(1);
535
							return Status.OK_STATUS;
536
						} catch (CoreException e) {
537
							ApiPlugin.log(e);
538
						} catch(OperationCanceledException e) {
539
							// ignore
540
						}
541
					} finally {
542
						monitor.done();
543
					}
544
					return Status.CANCEL_STATUS;
545
				}
546
			};
547
			job.setSystem(false);
548
			job.setPriority(Job.LONG);
549
			job.schedule();
550
			return;
551
		}
552
	}
553
554
	public static ApiScope walkStructureSelection(
555
			IStructuredSelection structuredSelection,
556
			IProgressMonitor monitor) {
557
		Object[] selected=structuredSelection.toArray();
558
		ApiScope scope = new ApiScope();
559
		IApiBaseline workspaceBaseline = ApiBaselineManager.getManager().getWorkspaceBaseline();
560
		if (workspaceBaseline == null) {
561
			return scope;
562
		}
563
		for (int i=0, max = selected.length; i < max; i++) {
564
			Object currentSelection = selected[i];
565
			if (currentSelection instanceof IJavaElement) {
566
				monitor.worked(1);
567
				IJavaElement element =(IJavaElement) currentSelection;
568
				IJavaProject javaProject = element.getJavaProject();
569
				try {
570
					switch (element.getElementType()) {
571
						case IJavaElement.COMPILATION_UNIT: {
572
							ICompilationUnit compilationUnit = (ICompilationUnit) element;
573
							IApiComponent apiComponent = workspaceBaseline.getApiComponent(javaProject.getElementName());
574
							if (apiComponent != null) {
575
								addElementFor(compilationUnit, apiComponent, scope);
576
							}
577
							break;
578
						}
579
						case IJavaElement.PACKAGE_FRAGMENT: {
580
							IPackageFragment fragment = (IPackageFragment) element;
581
							IApiComponent apiComponent = workspaceBaseline.getApiComponent(javaProject.getElementName());
582
							IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) fragment.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
583
							boolean isArchive = false;
584
							if (packageFragmentRoot != null) {
585
								isArchive = packageFragmentRoot.isArchive();
586
							}
587
							if (apiComponent != null) {
588
								addElementFor(fragment, isArchive, apiComponent, scope);
589
							}
590
							break;
591
						}
592
						case IJavaElement.PACKAGE_FRAGMENT_ROOT: {
593
							IPackageFragmentRoot fragmentRoot = (IPackageFragmentRoot) element;
594
							IApiComponent apiComponent = workspaceBaseline.getApiComponent(javaProject.getElementName());
595
							if (apiComponent != null) {
596
								addElementFor(fragmentRoot, apiComponent, scope);
597
							}
598
							break;
599
						}
600
						case IJavaElement.JAVA_PROJECT:
601
							IApiComponent apiComponent = workspaceBaseline.getApiComponent(javaProject.getElementName());
602
							IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
603
							for (int j = 0, max2 = roots.length; j < max2; j++) {
604
								addElementFor(roots[j], apiComponent, scope);
605
							}
606
							break;
607
					}
608
				} catch (JavaModelException e) {
609
					ApiPlugin.log(e);
610
				} catch (CoreException e) {
611
					ApiPlugin.log(e);
612
				}
613
			}
614
		}
615
		return scope;
616
	}
617
618
	private static void addElementFor(
619
			IPackageFragmentRoot fragmentRoot, IApiComponent apiComponent,
620
			ApiScope scope) throws JavaModelException, CoreException {
621
		boolean isArchive = fragmentRoot.isArchive();
622
		IJavaElement[] packageFragments = fragmentRoot.getChildren();
623
		for (int j = 0, max2 = packageFragments.length; j < max2; j++) {
624
			IPackageFragment packageFragment = (IPackageFragment) packageFragments[j];
625
			addElementFor(packageFragment, isArchive, apiComponent, scope);
626
		}
627
	}
628
629
	private static void addElementFor(
630
			IPackageFragment packageFragment,
631
			boolean isArchive,
632
			IApiComponent apiComponent,
633
			ApiScope scope)
634
		throws JavaModelException, CoreException {
635
636
		// add package fragment elements only if this is an API package
637
		IApiDescription apiDescription = apiComponent.getApiDescription();
638
		IApiAnnotations annotations = apiDescription.resolveAnnotations(Factory.packageDescriptor(packageFragment.getElementName()));
639
		if (annotations == null || !VisibilityModifiers.isAPI(annotations.getVisibility())) {
640
			return;
641
		}
642
		if (isArchive) {
643
			IClassFile[] classFiles = packageFragment.getClassFiles();
644
			for (int i = 0, max= classFiles.length; i < max; i++) {
645
				addElementFor(classFiles[i], apiComponent, scope);
646
			}
647
		} else {
648
			ICompilationUnit[] units = packageFragment.getCompilationUnits();
649
			for (int i = 0, max= units.length; i < max; i++) {
650
				addElementFor(units[i], apiComponent, scope);
651
			}
652
		}
653
	}
654
655
	private static void addElementFor(IClassFile classFile,
656
			IApiComponent apiComponent, ApiScope scope) {
657
		try {
658
			IApiTypeRoot typeRoot = apiComponent.findTypeRoot(classFile.getType().getFullyQualifiedName());
659
			if (typeRoot != null) {
660
				scope.add(typeRoot);
661
			}
662
		} catch (CoreException e) {
663
			ApiPlugin.log(e);
664
		}
665
	}
666
667
	private static void addElementFor(ICompilationUnit compilationUnit, IApiComponent component, ApiScope scope) throws JavaModelException {
668
		IType[] types = compilationUnit.getTypes();
669
		for (int i = 0, max = types.length; i < max; i++) {
670
			try {
671
				IApiTypeRoot typeRoot = component.findTypeRoot(types[i].getFullyQualifiedName());
672
				if (typeRoot != null) {
673
					scope.add(typeRoot);
674
				}
675
			} catch (CoreException e) {
676
				ApiPlugin.log(e);
677
			}
678
		}
679
	}
680
681
	/**
682
	 * @see IActionDelegate#selectionChanged(IAction, ISelection)
683
	 */
684
	public void selectionChanged(IAction action, ISelection selection) {
685
		this.selection = selection;
686
	}
687
}
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 19-25 Link Here
19
 org.eclipse.core.filesystem;bundle-version="1.2.0"
19
 org.eclipse.core.filesystem;bundle-version="1.2.0"
20
Export-Package: org.eclipse.pde.api.tools.internal;x-friends:="org.eclipse.pde.api.tools.tests,org.eclipse.pde.api.tools.ui",
20
Export-Package: org.eclipse.pde.api.tools.internal;x-friends:="org.eclipse.pde.api.tools.tests,org.eclipse.pde.api.tools.ui",
21
 org.eclipse.pde.api.tools.internal.builder;x-friends:="org.eclipse.pde.api.tools.ui",
21
 org.eclipse.pde.api.tools.internal.builder;x-friends:="org.eclipse.pde.api.tools.ui",
22
 org.eclipse.pde.api.tools.internal.comparator;x-internal:=true,
22
 org.eclipse.pde.api.tools.internal.comparator;x-friends:="org.eclipse.pde.api.tools.ui",
23
 org.eclipse.pde.api.tools.internal.descriptors;x-friends:="org.eclipse.pde.api.tools.tests,org.eclipse.pde.api.tools.ui",
23
 org.eclipse.pde.api.tools.internal.descriptors;x-friends:="org.eclipse.pde.api.tools.tests,org.eclipse.pde.api.tools.ui",
24
 org.eclipse.pde.api.tools.internal.model;x-friends:="org.eclipse.pde.api.tools.tests,org.eclipse.pde.api.tools.ui",
24
 org.eclipse.pde.api.tools.internal.model;x-friends:="org.eclipse.pde.api.tools.tests,org.eclipse.pde.api.tools.ui",
25
 org.eclipse.pde.api.tools.internal.natures;x-internal:=true,
25
 org.eclipse.pde.api.tools.internal.natures;x-internal:=true,
(-)src/org/eclipse/pde/api/tools/internal/provisional/ApiPlugin.java (-1 / +12 lines)
Lines 34-39 Link Here
34
import org.eclipse.pde.api.tools.internal.ApiDescriptionManager;
34
import org.eclipse.pde.api.tools.internal.ApiDescriptionManager;
35
import org.eclipse.pde.api.tools.internal.ApiFilterStore;
35
import org.eclipse.pde.api.tools.internal.ApiFilterStore;
36
import org.eclipse.pde.api.tools.internal.JavadocTagManager;
36
import org.eclipse.pde.api.tools.internal.JavadocTagManager;
37
import org.eclipse.pde.api.tools.internal.SessionManager;
37
import org.eclipse.pde.api.tools.internal.builder.AbstractProblemDetector;
38
import org.eclipse.pde.api.tools.internal.builder.AbstractProblemDetector;
38
import org.eclipse.pde.api.tools.internal.builder.ApiAnalysisBuilder;
39
import org.eclipse.pde.api.tools.internal.builder.ApiAnalysisBuilder;
39
import org.eclipse.pde.api.tools.internal.builder.ReferenceAnalyzer;
40
import org.eclipse.pde.api.tools.internal.builder.ReferenceAnalyzer;
Lines 146-152 Link Here
146
	 * Singleton instance of the {@link JavadocTagManager}
147
	 * Singleton instance of the {@link JavadocTagManager}
147
	 */
148
	 */
148
	private static JavadocTagManager fgTagManager = null;
149
	private static JavadocTagManager fgTagManager = null;
149
150
	/**
151
	 * Singleton instance of the {@link ISessionManager}
152
	 */
153
	private static ISessionManager fgSessionManager = null;
150
	/**
154
	/**
151
	 * Private debug options
155
	 * Private debug options
152
	 */
156
	 */
Lines 518-523 Link Here
518
		}
522
		}
519
		return SEVERITY_IGNORE;
523
		return SEVERITY_IGNORE;
520
	}
524
	}
525
	
526
	public ISessionManager getSessionManager() {
527
		if(fgSessionManager == null) {
528
			fgSessionManager = new SessionManager();
529
		}
530
		return fgSessionManager;
531
	}
521
532
522
	/**
533
	/**
523
	 * Returns the enable state for the specific key from the given {@link IProject}.
534
	 * Returns the enable state for the specific key from the given {@link IProject}.
(-)src/org/eclipse/pde/api/tools/internal/util/Util.java (+5 lines)
Lines 2244-2247 Link Here
2244
			return 0;
2244
			return 0;
2245
		}
2245
		}
2246
	};
2246
	};
2247
2248
	public static void checkCanceled(IProgressMonitor monitor) {
2249
		if (monitor.isCanceled())
2250
			throw new OperationCanceledException();
2251
	}
2247
}
2252
}
(-)src/org/eclipse/pde/api/tools/internal/provisional/comparator/ApiComparator.java (-2 / +34 lines)
Lines 15-21 Link Here
15
import java.util.Set;
15
import java.util.Set;
16
16
17
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.NullProgressMonitor;
19
import org.eclipse.jdt.core.Flags;
21
import org.eclipse.jdt.core.Flags;
20
import org.eclipse.pde.api.tools.internal.comparator.ClassFileComparator;
22
import org.eclipse.pde.api.tools.internal.comparator.ClassFileComparator;
21
import org.eclipse.pde.api.tools.internal.comparator.Delta;
23
import org.eclipse.pde.api.tools.internal.comparator.Delta;
Lines 665-670 Link Here
665
	 * @param baseline the given API baseline to compare with
667
	 * @param baseline the given API baseline to compare with
666
	 * @param visibilityModifiers the given visibility that triggers what visibility should be used for the comparison
668
	 * @param visibilityModifiers the given visibility that triggers what visibility should be used for the comparison
667
	 * @param force a flag to force the comparison of nested API components with the same versions 
669
	 * @param force a flag to force the comparison of nested API components with the same versions 
670
	 * @param monitor the given progress monitor to report progress
668
	 *
671
	 *
669
	 * @return a delta, an empty delta if no difference is found or null if the delta detection failed
672
	 * @return a delta, an empty delta if no difference is found or null if the delta detection failed
670
	 * @throws IllegalArgumentException if one of the two baselines is null
673
	 * @throws IllegalArgumentException if one of the two baselines is null
Lines 674-685 Link Here
674
			final IApiScope scope,
677
			final IApiScope scope,
675
			final IApiBaseline baseline,
678
			final IApiBaseline baseline,
676
			final int visibilityModifiers,
679
			final int visibilityModifiers,
677
			final boolean force) throws CoreException {
680
			final boolean force,
681
			final IProgressMonitor monitor) throws CoreException {
678
		if (scope == null || baseline == null) {
682
		if (scope == null || baseline == null) {
679
			throw new IllegalArgumentException("None of the scope or the baseline must be null"); //$NON-NLS-1$
683
			throw new IllegalArgumentException("None of the scope or the baseline must be null"); //$NON-NLS-1$
680
		}
684
		}
685
		IProgressMonitor localMonitor = null;
686
		if (monitor == null) {
687
			localMonitor = new NullProgressMonitor();
688
		} else {
689
			localMonitor = monitor;
690
		}
681
		final Set deltas = new HashSet();
691
		final Set deltas = new HashSet();
682
		final CompareApiScopeVisitor visitor = new CompareApiScopeVisitor(deltas, baseline, force, visibilityModifiers);
692
		final CompareApiScopeVisitor visitor = new CompareApiScopeVisitor(deltas, baseline, force, visibilityModifiers, localMonitor);
683
		scope.accept(visitor);
693
		scope.accept(visitor);
684
		if (visitor.containsError()) {
694
		if (visitor.containsError()) {
685
			return null;
695
			return null;
Lines 711-716 Link Here
711
		}
721
		}
712
		return globalDelta.isEmpty() ? NO_DELTA : globalDelta;
722
		return globalDelta.isEmpty() ? NO_DELTA : globalDelta;
713
	}
723
	}
724
725
	/**
726
	 * Returns a delta that corresponds to the comparison of the two given API baselines. 
727
	 * Nested API components with the same versions are not compared.
728
	 * <p>Equivalent to: compare(baseline, baseline2, visibilityModifiers, force, null);</p>
729
	 * 
730
	 * @param scope the given scope for the comparison
731
	 * @param baseline the given API baseline to compare with
732
	 * @param visibilityModifiers the given visibility that triggers what visibility should be used for the comparison
733
	 * @param force a flag to force the comparison of nested API components with the same versions 
734
	 *
735
	 * @return a delta, an empty delta if no difference is found or null if the delta detection failed
736
	 * @throws IllegalArgumentException if one of the two baselines is null
737
	 *         CoreException if one of the element in the scope cannot be visited
738
	 */
739
	public static IDelta compare(
740
			final IApiScope scope,
741
			final IApiBaseline baseline,
742
			final int visibilityModifiers,
743
			final boolean force) throws CoreException {
744
		return compare(scope, baseline, visibilityModifiers, force, null);
745
	}
714
	/**
746
	/**
715
	 * Returns a delta that corresponds to the comparison of the two given API baselines. 
747
	 * Returns a delta that corresponds to the comparison of the two given API baselines. 
716
	 * Nested API components with the same versions are not compared.
748
	 * Nested API components with the same versions are not compared.
(-)src/org/eclipse/pde/api/tools/internal/provisional/comparator/CompareApiScopeVisitor.java (-44 / +79 lines)
Lines 13-18 Link Here
13
import java.util.Set;
13
import java.util.Set;
14
14
15
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
17
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
17
import org.eclipse.pde.api.tools.internal.provisional.model.ApiScopeVisitor;
18
import org.eclipse.pde.api.tools.internal.provisional.model.ApiScopeVisitor;
18
import org.eclipse.pde.api.tools.internal.provisional.model.ApiTypeContainerVisitor;
19
import org.eclipse.pde.api.tools.internal.provisional.model.ApiTypeContainerVisitor;
Lines 20-25 Link Here
20
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
21
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
21
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
22
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
22
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;
23
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;
24
import org.eclipse.pde.api.tools.internal.util.Util;
23
25
24
/**
26
/**
25
 * ApiScope visitor implementation to run the comparison on all elements of the scope.
27
 * ApiScope visitor implementation to run the comparison on all elements of the scope.
Lines 31-102 Link Here
31
	int visibilityModifiers;
33
	int visibilityModifiers;
32
	boolean force;
34
	boolean force;
33
	boolean containsErrors = false;
35
	boolean containsErrors = false;
36
	IProgressMonitor monitor;
34
37
35
	public CompareApiScopeVisitor(final Set deltas, final IApiBaseline baseline, final boolean force, final int visibilityModifiers) {
38
	public CompareApiScopeVisitor(
39
			final Set deltas,
40
			final IApiBaseline baseline,
41
			final boolean force,
42
			final int visibilityModifiers,
43
			final IProgressMonitor monitor) {
36
		this.deltas = deltas;
44
		this.deltas = deltas;
37
		this.referenceBaseline = baseline;
45
		this.referenceBaseline = baseline;
38
		this.visibilityModifiers = visibilityModifiers;
46
		this.visibilityModifiers = visibilityModifiers;
39
		this.force = force;
47
		this.force = force;
48
		this.monitor = monitor;
40
	}
49
	}
41
	
50
	
42
	public boolean visit(IApiBaseline baseline) throws CoreException {
51
	public boolean visit(IApiBaseline baseline) throws CoreException {
43
		IDelta delta = ApiComparator.compare(this.referenceBaseline, baseline, this.visibilityModifiers, this.force);
52
		try {
44
		if (delta != null) {
53
			Util.checkCanceled(this.monitor);
45
			delta.accept(new DeltaVisitor() {
54
			IDelta delta = ApiComparator.compare(this.referenceBaseline, baseline, this.visibilityModifiers, this.force);
46
				public void endVisit(IDelta localDelta) {
55
			if (delta != null) {
47
					if (localDelta.getChildren().length == 0) {
56
				delta.accept(new DeltaVisitor() {
48
						CompareApiScopeVisitor.this.deltas.add(localDelta);
57
					public void endVisit(IDelta localDelta) {
58
						if (localDelta.getChildren().length == 0) {
59
							CompareApiScopeVisitor.this.deltas.add(localDelta);
60
						}
49
					}
61
					}
50
				}
62
				});
51
			});
63
			} else {
52
		} else {
64
				this.containsErrors = true;
53
			this.containsErrors = true;
65
			}
66
			return false;
67
		} finally {
68
			this.monitor.worked(1);
54
		}
69
		}
55
		return false;
56
	}
70
	}
57
71
58
	public boolean visit(IApiTypeContainer container) throws CoreException {
72
	public boolean visit(IApiTypeContainer container) throws CoreException {
59
		container.accept(new ApiTypeContainerVisitor() {
73
		try {
60
			public void visit(String packageName, IApiTypeRoot typeroot) {
74
			Util.checkCanceled(this.monitor);
61
				try {
75
			container.accept(new ApiTypeContainerVisitor() {
62
					CompareApiScopeVisitor.this.visit(typeroot);
76
				public void visit(String packageName, IApiTypeRoot typeroot) {
63
				} catch (CoreException e) {
77
					try {
64
					ApiPlugin.log(e);
78
						Util.checkCanceled(CompareApiScopeVisitor.this.monitor);
79
						compareApiTypeRoot(typeroot);
80
					} catch (CoreException e) {
81
						ApiPlugin.log(e);
82
					}
65
				}
83
				}
66
			}
84
			});
67
		});
85
			return false;
68
		return false;
86
		} finally {
87
			this.monitor.worked(1);
88
		}
69
	}
89
	}
70
90
71
	public boolean visit(IApiComponent component) throws CoreException {
91
	public boolean visit(IApiComponent component) throws CoreException {
72
		if (component.getErrors() != null) {
92
		try {
73
			this.containsErrors = true;
93
			Util.checkCanceled(this.monitor);
74
			return false;
94
			if (component.getErrors() != null) {
75
		}
95
				this.containsErrors = true;
76
		IApiComponent referenceComponent = this.referenceBaseline.getApiComponent(component.getId());
96
				return false;
77
		if (referenceComponent.getErrors() != null) {
97
			}
78
			this.containsErrors = true;
98
			IApiComponent referenceComponent = this.referenceBaseline.getApiComponent(component.getId());
79
			return false;
99
			if (referenceComponent.getErrors() != null) {
80
		}
100
				this.containsErrors = true;
81
		if (component.isSourceComponent() || component.isSystemComponent()) {
101
				return false;
82
			return false;
102
			}
83
		}
103
			if (component.isSourceComponent() || component.isSystemComponent()) {
84
		IDelta delta = ApiComparator.compare(referenceComponent, component, this.visibilityModifiers);
104
				return false;
85
		if (delta != null) {
105
			}
86
			delta.accept(new DeltaVisitor() {
106
			Util.checkCanceled(this.monitor);
87
				public void endVisit(IDelta localDelta) {
107
			IDelta delta = ApiComparator.compare(referenceComponent, component, this.visibilityModifiers);
88
					if (localDelta.getChildren().length == 0) {
108
			if (delta != null) {
89
						CompareApiScopeVisitor.this.deltas.add(localDelta);
109
				delta.accept(new DeltaVisitor() {
110
					public void endVisit(IDelta localDelta) {
111
						if (localDelta.getChildren().length == 0) {
112
							CompareApiScopeVisitor.this.deltas.add(localDelta);
113
						}
90
					}
114
					}
91
				}
115
				});
92
			});
116
			} else {
93
		} else {
117
				this.containsErrors = true;
94
			this.containsErrors = true;
118
			}
119
			return false;
120
		} finally {
121
			this.monitor.worked(1);
95
		}
122
		}
96
		return false;
97
	}
123
	}
98
	
124
	
99
	public void visit(IApiTypeRoot root) throws CoreException {
125
	public void visit(IApiTypeRoot root) throws CoreException {
126
		try {
127
			Util.checkCanceled(this.monitor);
128
			compareApiTypeRoot(root);
129
		} finally {
130
			this.monitor.worked(1);
131
		}
132
	}
133
134
	void compareApiTypeRoot(IApiTypeRoot root) throws CoreException {
100
		IApiComponent apiComponent = root.getApiComponent();
135
		IApiComponent apiComponent = root.getApiComponent();
101
		if (apiComponent == null || apiComponent.isSystemComponent() || apiComponent.isSourceComponent()) {
136
		if (apiComponent == null || apiComponent.isSystemComponent() || apiComponent.isSourceComponent()) {
102
			return;
137
			return;
(-)src/org/eclipse/pde/api/tools/internal/SessionManager.java (+113 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.internal;
12
13
import java.util.ArrayList;
14
import java.util.HashSet;
15
import java.util.Iterator;
16
import java.util.List;
17
import java.util.Set;
18
19
import org.eclipse.pde.api.tools.internal.provisional.ISession;
20
import org.eclipse.pde.api.tools.internal.provisional.ISessionListener;
21
import org.eclipse.pde.api.tools.internal.provisional.ISessionManager;
22
23
/**
24
 * Implementation of the ISessionManager.
25
 * Synchronize all accesses to prevent concurrent modifications.
26
 */
27
public class SessionManager implements ISessionManager {
28
29
	// use a list so that we can preserve the order
30
	private List sessions = new ArrayList();
31
	private Set listeners = new HashSet();
32
	private ISession activeSession;
33
34
	public synchronized void addSession(ISession session, boolean activate) {
35
		if (session == null) {
36
			throw new IllegalArgumentException("The given session cannot be null"); //$NON-NLS-1$
37
		}
38
		if (!this.sessions.contains(session)) {
39
			this.sessions.add(session);
40
			fireSessionAdded(session);
41
		}
42
		if (activate) {
43
			this.activeSession = session;
44
			fireSessionActivated(session);
45
		}
46
	}
47
48
	public synchronized void removeSession(ISession session) {
49
		if (sessions.remove(session)) {
50
			if (session.equals(this.activeSession)) {
51
				this.activeSession = null;
52
				fireSessionActivated(null);
53
			}
54
			fireSessionRemoved(session);
55
		}
56
	}
57
58
	public synchronized void removeAllSessions() {
59
		ISession[] allSessions = (ISession[]) this.sessions.toArray(new ISession[this.sessions.size()]);
60
		this.sessions.clear();
61
		this.activeSession = null;
62
		fireSessionActivated(null);
63
		for (int i = 0; i < allSessions.length; i++) {
64
			ISession session = allSessions[i];
65
			fireSessionRemoved(session);
66
		}
67
	}
68
69
	public synchronized ISession[] getSessions() {
70
		return (ISession[]) sessions.toArray(new ISession[sessions.size()]);
71
	}
72
73
	public synchronized void addSessionListener(ISessionListener listener) {
74
		if (listener == null) throw new IllegalArgumentException("The given listener cannot be null"); //$NON-NLS-1$
75
		listeners.add(listener);
76
	}
77
78
	public synchronized void removeSessionListener(ISessionListener listener) {
79
		listeners.remove(listener);
80
	}
81
82
	protected synchronized void fireSessionAdded(ISession session) {
83
		Iterator i = listeners.iterator();
84
		while (i.hasNext()) {
85
			((ISessionListener) i.next()).sessionAdded(session);
86
		}
87
	}
88
89
	protected synchronized void fireSessionRemoved(ISession session) {
90
		Iterator i = listeners.iterator();
91
		while (i.hasNext()) {
92
			((ISessionListener) i.next()).sessionRemoved(session);
93
		}
94
	}
95
96
	public ISession getActiveSession() {
97
		return this.activeSession;
98
	}
99
100
	protected synchronized void fireSessionActivated(ISession session) {
101
		Iterator i = listeners.iterator();
102
		while (i.hasNext()) {
103
			((ISessionListener) i.next()).sessionActivated(session);
104
		}
105
	}
106
107
	public void activateSession(ISession session) {
108
		if (this.sessions.contains(session) && !session.equals(this.activeSession)) {
109
			this.activeSession = session;
110
			fireSessionActivated(session);
111
		}
112
	}
113
}
(-)src/org/eclipse/pde/api/tools/internal/provisional/ITreeNode.java (+24 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.internal.provisional;
12
13
public interface ITreeNode {
14
	public static final int CLASS = 1;
15
	public static final int INTERFACE = 2;
16
	public static final int ANNOTATION = 3;
17
	public static final int ENUM = 4;
18
	public static final int PACKAGE = 5;
19
20
	Object[] getChildren();
21
	boolean hasChildren();
22
	int getId();
23
	Object getData();
24
}
(-)src/org/eclipse/pde/api/tools/internal/provisional/ITreeModel.java (+15 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.internal.provisional;
12
13
public interface ITreeModel {
14
	public ITreeNode getRoot();
15
}
(-)src/org/eclipse/pde/api/tools/internal/provisional/ISession.java (+21 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.internal.provisional;
12
13
/**
14
 * Provide information about the API Tooling session.
15
 */
16
public interface ISession {
17
	
18
	public ITreeModel getModel();
19
	
20
	public String getTimestamp();
21
}
(-)xslt/compare.xsl (+114 lines)
Added Link Here
1
<?xml version="1.0" encoding="iso-8859-1"?>
2
<!--
3
	Copyright (c) IBM Corporation and others 2009. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page.
4
	
5
	All Platform Debug contexts, those for org.eclipse.debug.ui, are located in this file
6
	All contexts are grouped by their relation, with all relations grouped alphabetically.
7
-->
8
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
9
<xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
10
<xsl:template match="/">
11
<html xmlns="http://www.w3.org/1999/xhtml">
12
	<head>
13
	<title>Reference Details</title>
14
		<style type="text/css">
15
			.main{		font-family:Arial, Helvetica, sans-serif;}
16
			.main h3 {	font-family:Arial, Helvetica, sans-serif;
17
						background-color:#FFFFFF;
18
						font-size:14px;
19
						margin:0.1em;}
20
			.main h4 { 	background-color:#CCCCCC;
21
						margin:0.15em;}
22
			a.typeslnk{	font-family:Arial, Helvetica, sans-serif;
23
					   	text-decoration:none;
24
					   	margin-left:0.25em;}
25
			a.typeslnk:hover{text-decoration:underline;}
26
			a.kindslnk{	font-family:Arial, Helvetica, sans-serif;
27
					  	text-decoration:none;
28
					   	margin-left:0.25em;}
29
			.types{	display:none;
30
					margin-bottom:0.25em;
31
					margin-top:0.25em;
32
					margin-right:0.25em;
33
				   	margin-left:0.75em;} 
34
		</style>
35
		<script type="text/javascript">
36
			function expand(loc){
37
			   if(document.getElementById){
38
				  var foc = loc.firstChild;
39
				  foc = loc.firstChild.innerHTML ? loc.firstChild : loc.firstChild.nextSibling;
40
				  foc = loc.parentNode.nextSibling.style ? loc.parentNode.nextSibling : loc.parentNode.nextSibling.nextSibling;
41
				  foc.style.display = foc.style.display == 'block' ? 'none' : 'block';
42
				}
43
			}  
44
		</script>
45
		<noscript>
46
			<style type="text/css">
47
				.types{display:block;}
48
				.kinds{display:block;}
49
			</style>
50
		</noscript>
51
	</head>
52
	<body>
53
		<xsl:variable name="originbundle" select="references/@origin"/>
54
		<h3>
55
			<xsl:value-of select="references/@name"/> from <xsl:value-of select="references/@referee"/> used by <xsl:value-of  select="$originbundle"/>
56
		</h3>
57
		<p>
58
			Click an entry in the table below to reveal the details of the references made to that element.
59
		</p>
60
		<div align="left" class="main">
61
			<table border="1" width="90%">
62
				<tr bgcolor="#CC9933">
63
					<td><b>Reference Details</b></td>
64
				</tr>
65
				<xsl:for-each select="references/type_name">
66
				<xsl:sort select="@name"/>
67
					<tr>
68
						<td>
69
							<h3>
70
								<a href="javascript:void(0)" class="typeslnk" onclick="expand(this)">
71
									<b><xsl:value-of disable-output-escaping="yes" select="@name"/></b>
72
								</a>
73
							</h3>
74
							<div class="types">
75
								<table border="0" width="100%">
76
									<xsl:for-each select="reference_kind">
77
										<xsl:sort select="@reference_kind_name"/>
78
										<tr>
79
											<td colspan="2" bgcolor="#CCCCCC"><b><xsl:value-of select="@reference_kind_name"/></b></td>
80
										</tr>	
81
										<tr bgcolor="#CC9933">
82
											<td align="left" width="92%"><b>Reference Location</b></td>
83
											<td align="center" width="8%"><b>Line Number</b></td>
84
										</tr>
85
										<xsl:for-each select="reference">
86
											<xsl:sort select="@origin"/>
87
											<tr align="left">
88
												<td><xsl:value-of disable-output-escaping="yes" select="@origin"/></td>
89
												<td align="center"><xsl:value-of select="@linenumber"/></td>
90
											</tr>
91
										</xsl:for-each>
92
									</xsl:for-each>
93
								</table>
94
							</div>
95
						</td>
96
					</tr>
97
				</xsl:for-each>
98
			</table>
99
			<p>
100
				Back to reference summary for <a href="../{$originbundle}.html"><xsl:value-of select="$originbundle"/></a>
101
			</p>
102
		</div>
103
		<p>
104
			<a href="http://validator.w3.org/check?uri=referer">
105
				<img src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01 Transitional" height="31" width="88" />
106
			</a>
107
			<a href="http://validator.w3.org/check?uri=referer">
108
				<img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" height="31" width="88" />
109
			</a>
110
		</p>
111
	</body>
112
</html>
113
</xsl:template>
114
</xsl:stylesheet>
(-)src/org/eclipse/pde/api/tools/internal/provisional/ISessionListener.java (+44 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.internal.provisional;
12
13
14
15
/**
16
 * Listener interface for changes of the session manager.
17
 * 
18
 * @see ISessionManager#addSessionListener(ISessionListener)
19
 * @see ISessionManager#removeSessionListener(ISessionListener)
20
 */
21
public interface ISessionListener {
22
23
	/**
24
	 * Called when a session has been added.
25
	 * 
26
	 * @param addedSession the given added session
27
	 */  
28
	public void sessionAdded(ISession addedSession);
29
30
	/**
31
	 * Called when a session has been removed.
32
	 * 
33
	 * @param removedSession the given removed session
34
	 */
35
	public void sessionRemoved(ISession removedSession);
36
	
37
	/**
38
	 * Called when a new session has been activated or the last session has been
39
	 * removed. In this case <code>null</code> is passed as a parameter.
40
	 * 
41
	 * @param session the given activated session or <code>null</code>
42
	 */
43
	public void sessionActivated(ISession session);
44
}
(-)src/org/eclipse/pde/api/tools/internal/provisional/ISessionManager.java (+80 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.api.tools.internal.provisional;
12
13
/**
14
 * The session manager holds a list of currently available sessions.
15
 *
16
 * @noimplement This interface is not intended to be implemented by clients.
17
 * @noextend This interface is not intended to be extended by clients.
18
 */
19
public interface ISessionManager {
20
21
	/**
22
	 * Adds the given session to this session manager. If the session is already
23
	 * part of this session manager, the method has no effect.
24
	 * 
25
	 * @param session the new session
26
	 * @param activate if <code>true</code> the session will also be activated, <code>false</code> otherwise
27
	 * @throws IllegalArgumentException if the given session is null
28
	 */
29
	public void addSession(ISession session, boolean activate);
30
31
	/**
32
	 * Removes the given session. If the session is not in included in this
33
	 * session manager, this method has no effect.
34
	 * 
35
	 * @param session the given session to remove
36
	 */
37
	public void removeSession(ISession session);
38
39
	/**
40
	 * Removes all available sessions.
41
	 */
42
	public void removeAllSessions();
43
44
	/**
45
	 * Returns all available sessions registered with this session manager.
46
	 * 
47
	 * @return list of available sessions
48
	 */
49
	public ISession[] getSessions();
50
51
	/**
52
	 * Adds the given session listener unless it has been added before.
53
	 * 
54
	 * @param listener the given session listener to add
55
	 * @throws IllegalArgumentException if the given listener is null
56
	 */
57
	public void addSessionListener(ISessionListener listener);
58
59
	/**
60
	 * Removes the given session listener. If the listener has not been added
61
	 * before this method has no effect.
62
	 * 
63
	 * @param listener the given session listener to remove
64
	 */
65
	public void removeSessionListener(ISessionListener listener);
66
67
	/**
68
	 * Returns the active session or <code>null</code> if there is no session.
69
	 * 
70
	 * @return active session or <code>null</null>
71
	 */
72
	public ISession getActiveSession();
73
	/**
74
	 * Activates the given session. If the session is not in included in this
75
	 * session manager this method has no effect.
76
	 * 
77
	 * @param session the given session or <code>null</code> to remove the active session.
78
	 */
79
	public void activateSession(ISession session);
80
}

Return to bug 258853