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

Collapse All | Expand All

(-)a/org.eclipse.jdt.ui/plugin.xml (+5 lines)
Lines 12-17 Link Here
12
<!--     Francis Upton IV, Oakland Software <francisu@ieee.org> - Add support for Go Into with the ProjectExplorer - https://bugs.eclipse.org/bugs/show_bug.cgi?id=262091 -->
12
<!--     Francis Upton IV, Oakland Software <francisu@ieee.org> - Add support for Go Into with the ProjectExplorer - https://bugs.eclipse.org/bugs/show_bug.cgi?id=262091 -->
13
<!--     Troy Bishop <tjbishop@ca.ibm.com> - Add support for importing/exporting Java Code Style preferences - https://bugs.eclipse.org/bugs/show_bug.cgi?id=304395 -->
13
<!--     Troy Bishop <tjbishop@ca.ibm.com> - Add support for importing/exporting Java Code Style preferences - https://bugs.eclipse.org/bugs/show_bug.cgi?id=304395 -->
14
<!--     Eugene Lucash <e.lucash@gmail.com> - [quick assist] Add key binding for Extract method Quick Assist - https://bugs.eclipse.org/424166 -->
14
<!--     Eugene Lucash <e.lucash@gmail.com> - [quick assist] Add key binding for Extract method Quick Assist - https://bugs.eclipse.org/424166 -->
15
<!--     Frits Jalvingh <jal@etc.to> - Contribution for Bug 459831 - [launching] Support attaching external annotations to a JRE container -->
15
<!-- ====================================================================== -->
16
<!-- ====================================================================== -->
16
<plugin>
17
<plugin>
17
18
Lines 170-175 Link Here
170
      <classpathAttributeConfiguration
171
      <classpathAttributeConfiguration
171
      		attributeName="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY"
172
      		attributeName="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY"
172
            class="org.eclipse.jdt.internal.ui.wizards.buildpaths.NativeLibAttributeConfiguration">
173
            class="org.eclipse.jdt.internal.ui.wizards.buildpaths.NativeLibAttributeConfiguration">
174
      </classpathAttributeConfiguration>
175
      <classpathAttributeConfiguration
176
            attributeName="annotationpath"
177
            class="org.eclipse.jdt.internal.ui.wizards.buildpaths.ExternalAnnotationsAttributeConfiguration">
173
      </classpathAttributeConfiguration>      
178
      </classpathAttributeConfiguration>      
174
   </extension>
179
   </extension>
175
180
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/IJavaHelpContextIds.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2012 IBM Corporation and others.
2
 * Copyright (c) 2000, 2015 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-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Sebastian Davids <sdavids@gmx.de> bug 38692
10
 *     Sebastian Davids <sdavids@gmx.de> bug 38692
11
 *     Mateusz Matela <mateusz.matela@gmail.com> - [code manipulation] [dcr] toString() builder wizard - https://bugs.eclipse.org/bugs/show_bug.cgi?id=26070
11
 *     Mateusz Matela <mateusz.matela@gmail.com> - [code manipulation] [dcr] toString() builder wizard - https://bugs.eclipse.org/bugs/show_bug.cgi?id=26070
12
 *     Frits Jalvingh <jal@etc.to> - Contribution for Bug 459831 - [launching] Support attaching external annotations to a JRE container
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.jdt.internal.ui;
14
package org.eclipse.jdt.internal.ui;
14
15
Lines 246-251 public interface IJavaHelpContextIds { Link Here
246
	public static final String TYPE_SELECTION_DIALOG2= PREFIX + "type_selection_dialog2_context"; //$NON-NLS-1$
247
	public static final String TYPE_SELECTION_DIALOG2= PREFIX + "type_selection_dialog2_context"; //$NON-NLS-1$
247
	public static final String OPEN_PACKAGE_DIALOG= PREFIX + "open_package_dialog_context"; //$NON-NLS-1$
248
	public static final String OPEN_PACKAGE_DIALOG= PREFIX + "open_package_dialog_context"; //$NON-NLS-1$
248
	public static final String SOURCE_ATTACHMENT_DIALOG= PREFIX + "source_attachment_dialog_context"; //$NON-NLS-1$
249
	public static final String SOURCE_ATTACHMENT_DIALOG= PREFIX + "source_attachment_dialog_context"; //$NON-NLS-1$
250
	public static final String EXTERNAL_ANNOTATIONS_ATTACHMENT_DIALOG= PREFIX + "annotations_attachment_dialog_context"; //$NON-NLS-1$
249
	public static final String LIBRARIES_WORKBOOK_PAGE_ADVANCED_DIALOG= PREFIX + "advanced_dialog_context"; //$NON-NLS-1$
251
	public static final String LIBRARIES_WORKBOOK_PAGE_ADVANCED_DIALOG= PREFIX + "advanced_dialog_context"; //$NON-NLS-1$
250
	public static final String CONFIRM_SAVE_MODIFIED_RESOURCES_DIALOG= PREFIX + "confirm_save_modified_resources_dialog_context"; //$NON-NLS-1$
252
	public static final String CONFIRM_SAVE_MODIFIED_RESOURCES_DIALOG= PREFIX + "confirm_save_modified_resources_dialog_context"; //$NON-NLS-1$
251
	public static final String NEW_VARIABLE_ENTRY_DIALOG= PREFIX + "new_variable_dialog_context"; //$NON-NLS-1$
253
	public static final String NEW_VARIABLE_ENTRY_DIALOG= PREFIX + "new_variable_dialog_context"; //$NON-NLS-1$
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java (-1 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
2
 * Copyright (c) 2000, 2015 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 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar
10
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar
11
 *     Frits Jalvingh <jal@etc.to> - Contribution for Bug 459831 - [launching] Support attaching external annotations to a JRE container
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.jdt.internal.ui;
13
package org.eclipse.jdt.internal.ui;
13
14
Lines 135-140 public class JavaPluginImages { Link Here
135
	public static final String IMG_OBJS_LIBRARY= NAME_PREFIX + "library_obj.gif"; 		//$NON-NLS-1$
136
	public static final String IMG_OBJS_LIBRARY= NAME_PREFIX + "library_obj.gif"; 		//$NON-NLS-1$
136
137
137
	public static final String IMG_OBJS_JAVADOCTAG= NAME_PREFIX + "jdoc_tag_obj.gif"; 	//$NON-NLS-1$
138
	public static final String IMG_OBJS_JAVADOCTAG= NAME_PREFIX + "jdoc_tag_obj.gif"; 	//$NON-NLS-1$
139
	public static final String IMG_OBJS_EXTERNAL_ANNOTATIONS = NAME_PREFIX + "external_annotation_location_attrib.gif"; 	//$NON-NLS-1$
138
	public static final String IMG_OBJS_HTMLTAG= NAME_PREFIX + "html_tag_obj.gif"; 		//$NON-NLS-1$
140
	public static final String IMG_OBJS_HTMLTAG= NAME_PREFIX + "html_tag_obj.gif"; 		//$NON-NLS-1$
139
141
140
	public static final String IMG_OBJS_TEMPLATE= NAME_PREFIX + "template_obj.gif"; 		//$NON-NLS-1$
142
	public static final String IMG_OBJS_TEMPLATE= NAME_PREFIX + "template_obj.gif"; 		//$NON-NLS-1$
Lines 291-296 public class JavaPluginImages { Link Here
291
	public static final ImageDescriptor DESC_OBJS_SOURCE_ATTACH_ATTRIB= createUnManaged(T_OBJ, "source_attach_attrib.gif"); //$NON-NLS-1$
293
	public static final ImageDescriptor DESC_OBJS_SOURCE_ATTACH_ATTRIB= createUnManaged(T_OBJ, "source_attach_attrib.gif"); //$NON-NLS-1$
292
	public static final ImageDescriptor DESC_OBJS_JAVADOC_LOCATION_ATTRIB= createUnManaged(T_OBJ, "javadoc_location_attrib.gif"); //$NON-NLS-1$
294
	public static final ImageDescriptor DESC_OBJS_JAVADOC_LOCATION_ATTRIB= createUnManaged(T_OBJ, "javadoc_location_attrib.gif"); //$NON-NLS-1$
293
295
296
	public static final ImageDescriptor DESC_OBJS_EXTERNAL_ANNOTATION_LOCATION_ATTRIB= createManagedFromKey(T_OBJ, IMG_OBJS_EXTERNAL_ANNOTATIONS);
297
294
	public static final ImageDescriptor DESC_OBJS_ACCESSRULES_ATTRIB= createManagedFromKey(T_OBJ, IMG_OBJS_ACCESSRULES_ATTRIB);
298
	public static final ImageDescriptor DESC_OBJS_ACCESSRULES_ATTRIB= createManagedFromKey(T_OBJ, IMG_OBJS_ACCESSRULES_ATTRIB);
295
	public static final ImageDescriptor DESC_OBJS_NATIVE_LIB_PATH_ATTRIB= createUnManaged(T_OBJ, "native_lib_path_attrib.gif"); //$NON-NLS-1$
299
	public static final ImageDescriptor DESC_OBJS_NATIVE_LIB_PATH_ATTRIB= createUnManaged(T_OBJ, "native_lib_path_attrib.gif"); //$NON-NLS-1$
296
300
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java (-1 / +26 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2012 IBM Corporation and others.
2
 * Copyright (c) 2000, 2015 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-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Philippe Marschall <philippe.marschall@netcetera.ch> - [type wizards] Allow the creation of a compilation unit called package-info.java - https://bugs.eclipse.org/86168
10
 *     Philippe Marschall <philippe.marschall@netcetera.ch> - [type wizards] Allow the creation of a compilation unit called package-info.java - https://bugs.eclipse.org/86168
11
 *     Michael Pellaton <michael.pellaton@netcetera.ch> - [type wizards] Allow the creation of a compilation unit called package-info.java - https://bugs.eclipse.org/86168
11
 *     Michael Pellaton <michael.pellaton@netcetera.ch> - [type wizards] Allow the creation of a compilation unit called package-info.java - https://bugs.eclipse.org/86168
12
 *     Frits Jalvingh <jal@etc.to> - Contribution for Bug 459831 - [launching] Support attaching external annotations to a JRE container
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.jdt.internal.ui.wizards;
14
package org.eclipse.jdt.internal.ui.wizards;
14
15
Lines 402-407 public final class NewWizardMessages extends NLS { Link Here
402
	public static String BuildPathSupport_putoncpdialog_message;
403
	public static String BuildPathSupport_putoncpdialog_message;
403
404
404
	public static String SourceAttachmentDialog_title;
405
	public static String SourceAttachmentDialog_title;
406
407
	public static String ExternalAnnotationsDialog_title;
408
409
	public static String AnnotationsAttachmentBlock_message;
410
	public static String AnnotationsAttachmentBlock_filename_externalfile_button;
411
	public static String AnnotationsAttachmentBlock_filename_externalfolder_button;
412
	public static String AnnotationsAttachmentBlock_filename_external_label;
413
	public static String AnnotationsAttachmentBlock_filename_error_notvalid;
414
	public static String AnnotationsAttachmentBlock_filename_error_notabsolute;
415
	public static String AnnotationsAttachmentBlock_filename_error_filenotexists;
416
	public static String AnnotationsAttachmentBlock_filename_workspace_browse;
417
	public static String AnnotationsAttachmentBlock_filename_workspace_label;
418
	public static String AnnotationsAttachmentBlock_intjardialog_title;
419
	public static String AnnotationsAttachmentBlock_intjardialog_message;
420
	public static String AnnotationsAttachmentBlock_external_radiolabel;
421
	public static String AnnotationsAttachmentBlock_extjardialog_text;
422
	public static String AnnotationsAttachmentBlock_extfolderdialog_text;
423
	public static String AnnotationsAttachmentBlock_extfolderdialog_message;
424
	public static String AnnotationsAttachmentBlock_workspace_radiolabel;
425
426
405
	public static String EditVariableEntryDialog_title;
427
	public static String EditVariableEntryDialog_title;
406
	public static String EditVariableEntryDialog_filename_varlabel;
428
	public static String EditVariableEntryDialog_filename_varlabel;
407
	public static String EditVariableEntryDialog_filename_variable_button;
429
	public static String EditVariableEntryDialog_filename_variable_button;
Lines 725-730 public final class NewWizardMessages extends NLS { Link Here
725
	public static String ClasspathModifierQueries_delete_linked_folder;
747
	public static String ClasspathModifierQueries_delete_linked_folder;
726
	public static String ClasspathModifierQueries_do_not_delete_linked_folder;
748
	public static String ClasspathModifierQueries_do_not_delete_linked_folder;
727
	public static String EditVariableEntryDialog_filename_empty;
749
	public static String EditVariableEntryDialog_filename_empty;
750
751
	public static String CPListLabelProvider_external_annotations_location_label;
752
728
	static {
753
	static {
729
		NLS.initializeMessages(BUNDLE_NAME, NewWizardMessages.class);
754
		NLS.initializeMessages(BUNDLE_NAME, NewWizardMessages.class);
730
	}
755
	}
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties (-2 / +30 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2014 IBM Corporation and others.
2
# Copyright (c) 2000, 2015 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-14 Link Here
9
#     IBM Corporation - initial API and implementation
9
#     IBM Corporation - initial API and implementation
10
#     Philippe Marschall <philippe.marschall@netcetera.ch> - [type wizards] Allow the creation of a compilation unit called package-info.java - https://bugs.eclipse.org/86168
10
#     Philippe Marschall <philippe.marschall@netcetera.ch> - [type wizards] Allow the creation of a compilation unit called package-info.java - https://bugs.eclipse.org/86168
11
#     Michael Pellaton <michael.pellaton@netcetera.ch> - [type wizards] Allow the creation of a compilation unit called package-info.java - https://bugs.eclipse.org/86168
11
#     Michael Pellaton <michael.pellaton@netcetera.ch> - [type wizards] Allow the creation of a compilation unit called package-info.java - https://bugs.eclipse.org/86168
12
#     Frits Jalvingh <jal@etc.to> - Contribution for Bug 459831 - [launching] Support attaching external annotations to a JRE container
12
###############################################################################
13
###############################################################################
13
14
14
# ------- AbstractOpenWizardAction -------
15
# ------- AbstractOpenWizardAction -------
Lines 303-309 CPListLabelProvider_unbound_library={0} (unbound) Link Here
303
CPListLabelProvider_attribute_label={0}: {1}
304
CPListLabelProvider_attribute_label={0}: {1}
304
CPListLabelProvider_systemlibrary={0} [system library]
305
CPListLabelProvider_systemlibrary={0} [system library]
305
306
306
307
# ------- SourceContainerWorkbookPage-------
307
# ------- SourceContainerWorkbookPage-------
308
308
309
SourceContainerWorkbookPage_folders_label=Source folders on build pat&h:
309
SourceContainerWorkbookPage_folders_label=Source folders on build pat&h:
Lines 436-441 BuildPathSupport_deprecated={0} is deprecated: {1}. Link Here
436
BuildPathSupport_putoncpdialog_message=Source can only be attached to libraries on the build path.\nDo you want to add the library to the build path?
436
BuildPathSupport_putoncpdialog_message=Source can only be attached to libraries on the build path.\nDo you want to add the library to the build path?
437
SourceAttachmentDialog_title=Source Attachment Configuration
437
SourceAttachmentDialog_title=Source Attachment Configuration
438
438
439
# ------- ExternalAnnotationsAttachmentBlock -------
440
AnnotationsAttachmentBlock_message=Select the location (folder, JAR or zip) containing the external annotations
441
442
AnnotationsAttachmentBlock_filename_external_label=Pa&th:
443
AnnotationsAttachmentBlock_filename_externalfile_button=External &File...
444
AnnotationsAttachmentBlock_filename_externalfolder_button=External F&older...
445
446
AnnotationsAttachmentBlock_external_radiolabel=E&xternal location
447
448
AnnotationsAttachmentBlock_filename_error_notvalid= The archive path is not a valid path.
449
AnnotationsAttachmentBlock_filename_error_notabsolute=The path must be absolute.
450
AnnotationsAttachmentBlock_filename_error_filenotexists= The path ''{0}'' does not exist.
451
AnnotationsAttachmentBlock_filename_workspace_browse=&Browse...
452
AnnotationsAttachmentBlock_filename_workspace_label=&Path:
453
454
AnnotationsAttachmentBlock_intjardialog_title=External Annotations Location Selection
455
AnnotationsAttachmentBlock_intjardialog_message=&Select folder or JAR/zip archive containing the external annotations:
456
457
AnnotationsAttachmentBlock_extjardialog_text=JAR/ZIP File Selection
458
AnnotationsAttachmentBlock_extfolderdialog_text=Folder Selection
459
AnnotationsAttachmentBlock_extfolderdialog_message=Choose a directory containing external annotations:
460
AnnotationsAttachmentBlock_workspace_radiolabel=Wor&kspace location
461
ExternalAnnotationsDialog_title=External Annotations Attachment Configuration
462
463
439
# ------- EditVariableEntryDialog -------
464
# ------- EditVariableEntryDialog -------
440
465
441
EditVariableEntryDialog_title=Edit Variable Entry
466
EditVariableEntryDialog_title=Edit Variable Entry
Lines 664-669 MultipleFolderSelectionDialog_button=Create &New Folder... Link Here
664
CPListLabelProvider_javadoc_location_label=Javadoc location
689
CPListLabelProvider_javadoc_location_label=Javadoc location
665
CPListLabelProvider_native_library_path=Native library location
690
CPListLabelProvider_native_library_path=Native library location
666
691
692
CPListLabelProvider_external_annotations_location_label=External annotations
693
694
667
CPListLabelProvider_ignore_optional_problems_label=Ignore optional compile problems: {0}
695
CPListLabelProvider_ignore_optional_problems_label=Ignore optional compile problems: {0}
668
CPListLabelProvider_ignore_optional_problems_yes=Yes
696
CPListLabelProvider_ignore_optional_problems_yes=Yes
669
CPListLabelProvider_ignore_optional_problems_no=No
697
CPListLabelProvider_ignore_optional_problems_no=No
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2012 IBM Corporation and others.
2
 * Copyright (c) 2000, 2015 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Frits Jalvingh <jal@etc.to> - Contribution for Bug 459831 - [launching] Support attaching external annotations to a JRE container
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.ui.wizards.buildpaths;
12
package org.eclipse.jdt.internal.ui.wizards.buildpaths;
12
13
Lines 121-126 public class CPListElement { Link Here
121
			case IClasspathEntry.CPE_VARIABLE:
122
			case IClasspathEntry.CPE_VARIABLE:
122
				createAttributeElement(SOURCEATTACHMENT, null, true);
123
				createAttributeElement(SOURCEATTACHMENT, null, true);
123
				createAttributeElement(JAVADOC, null, false);
124
				createAttributeElement(JAVADOC, null, false);
125
				createAttributeElement(IClasspathAttribute.EXTERNAL_ANNOTATION_PATH, null, false);
124
				createAttributeElement(SOURCE_ATTACHMENT_ENCODING, null, false);
126
				createAttributeElement(SOURCE_ATTACHMENT_ENCODING, null, false);
125
				createAttributeElement(NATIVE_LIB_PATH, null, false);
127
				createAttributeElement(NATIVE_LIB_PATH, null, false);
126
				createAttributeElement(ACCESSRULES, new IAccessRule[0], true);
128
				createAttributeElement(ACCESSRULES, new IAccessRule[0], true);
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ExternalAnnotationsAttachmentBlock.java (+466 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2015 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
 *     Frits Jalvingh <jal@etc.to> - Contribution for Bug 459831 - [launching] Support attaching external annotations to a JRE container
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.ui.wizards.buildpaths;
12
13
import java.io.File;
14
import java.lang.reflect.InvocationTargetException;
15
import java.util.List;
16
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.layout.GridData;
19
import org.eclipse.swt.layout.GridLayout;
20
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Control;
22
import org.eclipse.swt.widgets.DirectoryDialog;
23
import org.eclipse.swt.widgets.FileDialog;
24
import org.eclipse.swt.widgets.Label;
25
import org.eclipse.swt.widgets.Shell;
26
27
import org.eclipse.core.runtime.CoreException;
28
import org.eclipse.core.runtime.IPath;
29
import org.eclipse.core.runtime.IProgressMonitor;
30
import org.eclipse.core.runtime.IStatus;
31
import org.eclipse.core.runtime.Path;
32
33
import org.eclipse.core.resources.IResource;
34
import org.eclipse.core.resources.IWorkspace;
35
import org.eclipse.core.resources.IWorkspaceRoot;
36
import org.eclipse.core.resources.ResourcesPlugin;
37
38
import org.eclipse.jface.dialogs.Dialog;
39
import org.eclipse.jface.layout.PixelConverter;
40
import org.eclipse.jface.operation.IRunnableWithProgress;
41
import org.eclipse.jface.viewers.ILabelProvider;
42
import org.eclipse.jface.viewers.ITreeContentProvider;
43
import org.eclipse.jface.viewers.ViewerFilter;
44
import org.eclipse.jface.window.Window;
45
46
import org.eclipse.ui.PlatformUI;
47
import org.eclipse.ui.model.WorkbenchContentProvider;
48
import org.eclipse.ui.model.WorkbenchLabelProvider;
49
50
import org.eclipse.jdt.core.IClasspathAttribute;
51
import org.eclipse.jdt.core.IClasspathEntry;
52
import org.eclipse.jdt.core.IJavaProject;
53
import org.eclipse.jdt.core.JavaCore;
54
55
import org.eclipse.jdt.internal.corext.util.Messages;
56
57
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
58
import org.eclipse.jdt.internal.ui.JavaPlugin;
59
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
60
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
61
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
62
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
63
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
64
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
65
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
66
import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
67
import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
68
import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
69
70
71
/**
72
 * UI to set the External Annotations path. Same implementation for both setting attachments for
73
 * libraries from variable entries and for normal (internal or external) jar.
74
 */
75
public class ExternalAnnotationsAttachmentBlock {
76
77
	private final IStatusChangeListener fContext;
78
79
	private StringButtonDialogField fWorkspaceFileNameField;
80
	private StringButtonDialogField fExternalFileNameField;
81
	private SelectionButtonDialogField fExternalFolderButton;
82
	private SelectionButtonDialogField fExternalRadio, fWorkspaceRadio;
83
84
	private IStatus fWorkspaceNameStatus;
85
	private IStatus fExternalNameStatus;
86
87
	private final IWorkspaceRoot fWorkspaceRoot;
88
89
	private Control fSWTWidget;
90
91
	private final IPath fEntry;
92
93
	/**
94
	 * @param context listeners for status updates
95
	 * @param entry The entry to edit
96
	 */
97
	public ExternalAnnotationsAttachmentBlock(IStatusChangeListener context, IPath entry) {
98
		fContext= context;
99
		fEntry= entry == null ? Path.EMPTY : entry;
100
101
		fWorkspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
102
103
		fWorkspaceNameStatus= new StatusInfo();
104
		fExternalNameStatus= new StatusInfo();
105
106
		AnnotationsAttachmentAdapter adapter= new AnnotationsAttachmentAdapter();
107
108
		// create the dialog fields (no widgets yet)
109
		fWorkspaceRadio= new SelectionButtonDialogField(SWT.RADIO);
110
		fWorkspaceRadio.setDialogFieldListener(adapter);
111
		fWorkspaceRadio.setLabelText(NewWizardMessages.AnnotationsAttachmentBlock_workspace_radiolabel);
112
113
		fWorkspaceFileNameField= new StringButtonDialogField(adapter);
114
		fWorkspaceFileNameField.setDialogFieldListener(adapter);
115
		fWorkspaceFileNameField.setLabelText(NewWizardMessages.AnnotationsAttachmentBlock_filename_workspace_label);
116
		fWorkspaceFileNameField.setButtonLabel(NewWizardMessages.AnnotationsAttachmentBlock_filename_workspace_browse);
117
118
		fExternalRadio= new SelectionButtonDialogField(SWT.RADIO);
119
		fExternalRadio.setDialogFieldListener(adapter);
120
		fExternalRadio.setLabelText(NewWizardMessages.AnnotationsAttachmentBlock_external_radiolabel);
121
122
		fExternalFileNameField= new StringButtonDialogField(adapter);
123
		fExternalFileNameField.setDialogFieldListener(adapter);
124
		fExternalFileNameField.setLabelText(NewWizardMessages.AnnotationsAttachmentBlock_filename_external_label);
125
		fExternalFileNameField.setButtonLabel(NewWizardMessages.AnnotationsAttachmentBlock_filename_externalfile_button);
126
127
		fExternalFolderButton= new SelectionButtonDialogField(SWT.PUSH);
128
		fExternalFolderButton.setDialogFieldListener(adapter);
129
		fExternalFolderButton.setLabelText(NewWizardMessages.AnnotationsAttachmentBlock_filename_externalfolder_button);
130
131
		setDefaults();
132
	}
133
134
	public void setDefaults() {
135
		IPath annotationsAttachmentPath= fEntry;
136
		String path= annotationsAttachmentPath == null ? null : annotationsAttachmentPath.toPortableString();
137
138
		if (isWorkspacePath(annotationsAttachmentPath)) {
139
			fWorkspaceRadio.setSelection(true);
140
			fWorkspaceFileNameField.setText(path);
141
		} else if (path != null && path.length() != 0) {
142
			fExternalRadio.setSelection(true);
143
			fExternalFileNameField.setText(path);
144
		} else {
145
			fWorkspaceRadio.setSelection(true);
146
			fExternalRadio.setSelection(false);
147
		}
148
	}
149
150
	private boolean isWorkspacePath(IPath path) {
151
		if (path == null || path.getDevice() != null)
152
			return false;
153
		IWorkspace workspace= ResourcesPlugin.getWorkspace();
154
		if (workspace == null)
155
			return false;
156
		return workspace.getRoot().findMember(path) != null;
157
	}
158
159
	/**
160
	 * Gets the source attachment path chosen by the user
161
	 * @return the source attachment path
162
	 */
163
	public IPath getAnnotationsPath() {
164
		return (getFilePath().segmentCount() == 0) ? null : getFilePath();
165
	}
166
167
	/**
168
	 * Creates the control
169
	 * @param parent the parent
170
	 * @return the created control
171
	 */
172
	public Control createControl(Composite parent) {
173
		PixelConverter converter= new PixelConverter(parent);
174
175
		fSWTWidget= parent;
176
177
		Composite composite= new Composite(parent, SWT.NONE);
178
179
		GridLayout layout= new GridLayout();
180
		layout.marginHeight= 0;
181
		layout.marginWidth= 0;
182
		layout.numColumns= 4;
183
		composite.setLayout(layout);
184
185
186
		int widthHint= converter.convertWidthInCharsToPixels(60);
187
188
		GridData gd= new GridData(GridData.FILL, GridData.BEGINNING, false, false, 3, 1);
189
		gd.widthHint= converter.convertWidthInCharsToPixels(50);
190
191
		Label message= new Label(composite, SWT.LEFT + SWT.WRAP);
192
		message.setLayoutData(gd);
193
		message.setText(NewWizardMessages.AnnotationsAttachmentBlock_message);
194
195
		fWorkspaceRadio.doFillIntoGrid(composite, 4);
196
197
		fWorkspaceFileNameField.doFillIntoGrid(composite, 4);
198
		LayoutUtil.setWidthHint(fWorkspaceFileNameField.getTextControl(null), widthHint);
199
		LayoutUtil.setHorizontalGrabbing(fWorkspaceFileNameField.getTextControl(null));
200
201
		DialogField.createEmptySpace(composite, 4);
202
203
		fExternalRadio.doFillIntoGrid(composite, 4);
204
		fExternalFileNameField.doFillIntoGrid(composite, 4);
205
		LayoutUtil.setWidthHint(fExternalFileNameField.getTextControl(null), widthHint);
206
		LayoutUtil.setHorizontalGrabbing(fExternalFileNameField.getTextControl(null));
207
208
		DialogField.createEmptySpace(composite, 1);
209
210
		fExternalFolderButton.doFillIntoGrid(composite, 1);
211
212
		LayoutUtil.setHorizontalIndent(fWorkspaceFileNameField.getLabelControl(null));
213
		LayoutUtil.setHorizontalIndent(fExternalFileNameField.getLabelControl(null));
214
215
		fWorkspaceRadio.attachDialogField(fWorkspaceFileNameField);
216
		fExternalRadio.attachDialogFields(new DialogField[] { fExternalFileNameField, fExternalFolderButton });
217
218
		Dialog.applyDialogFont(composite);
219
220
		PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.EXTERNAL_ANNOTATIONS_ATTACHMENT_DIALOG);
221
		return composite;
222
	}
223
224
225
	private class AnnotationsAttachmentAdapter implements IStringButtonAdapter, IDialogFieldListener {
226
227
		// -------- IStringButtonAdapter --------
228
		public void changeControlPressed(DialogField field) {
229
			attachmentChangeControlPressed(field);
230
		}
231
232
		// ---------- IDialogFieldListener --------
233
		public void dialogFieldChanged(DialogField field) {
234
			attachmentDialogFieldChanged(field);
235
		}
236
	}
237
238
	private void attachmentChangeControlPressed(DialogField field) {
239
		if (field == fWorkspaceFileNameField) {
240
			IPath jarFilePath= chooseInternal();
241
			if (jarFilePath != null) {
242
				fWorkspaceFileNameField.setText(jarFilePath.toString());
243
			}
244
		} else if (field == fExternalFileNameField) {
245
			IPath jarFilePath= chooseExtJarFile();
246
			if (jarFilePath != null) {
247
				fExternalFileNameField.setText(jarFilePath.toString());
248
			}
249
		}
250
	}
251
252
	// ---------- IDialogFieldListener --------
253
254
	private void attachmentDialogFieldChanged(DialogField field) {
255
		if (field == fWorkspaceFileNameField) {
256
			fWorkspaceNameStatus= updateFileNameStatus(fWorkspaceFileNameField);
257
		} else if (field == fExternalFileNameField) {
258
			fExternalNameStatus= updateFileNameStatus(fExternalFileNameField);
259
		} else if (field == fExternalFolderButton) {
260
			IPath folderPath= chooseExtFolder();
261
			if (folderPath != null) {
262
				fExternalFileNameField.setText(folderPath.toString());
263
			}
264
			return;
265
		}
266
		doStatusLineUpdate();
267
	}
268
269
	private void doStatusLineUpdate() {
270
		IStatus status;
271
		boolean isWorkSpace= fWorkspaceRadio.isSelected();
272
		if (isWorkSpace) {
273
			fWorkspaceFileNameField.enableButton(canBrowseFileName());
274
			status= fWorkspaceNameStatus;
275
		} else {
276
			fExternalFileNameField.enableButton(canBrowseFileName());
277
			status= fExternalNameStatus;
278
		}
279
		fContext.statusChanged(status);
280
	}
281
282
	private boolean canBrowseFileName() { // FIXME remove
283
		return true;
284
	}
285
286
	private IStatus updateFileNameStatus(StringButtonDialogField field) {
287
		StatusInfo status= new StatusInfo();
288
289
		String fileName= field.getText();
290
		if (fileName.length() == 0) {
291
			// no external annotations file defined
292
			return status;
293
		} else {
294
			if (!Path.EMPTY.isValidPath(fileName)) {
295
				status.setError(NewWizardMessages.AnnotationsAttachmentBlock_filename_error_notvalid);
296
				return status;
297
			}
298
			IPath filePath= Path.fromOSString(fileName);
299
			IPath resolvedPath;
300
			File file= filePath.toFile();
301
			IResource res= fWorkspaceRoot.findMember(filePath);
302
			boolean exists;
303
			if (res != null) {
304
				IPath location= res.getLocation();
305
				if (location != null) {
306
					exists= location.toFile().exists();
307
				} else {
308
					exists= res.exists();
309
				}
310
			} else {
311
				exists= file.exists();
312
			}
313
			if (!exists) {
314
				String message= Messages.format(NewWizardMessages.AnnotationsAttachmentBlock_filename_error_filenotexists, BasicElementLabels.getPathLabel(filePath, false));
315
				status.setError(message);
316
				return status;
317
			}
318
			if (!filePath.isAbsolute()) {
319
				String message= Messages.format(NewWizardMessages.AnnotationsAttachmentBlock_filename_error_notabsolute, BasicElementLabels.getPathLabel(filePath, false));
320
				status.setError(message);
321
				return status;
322
			}
323
		}
324
		return status;
325
	}
326
327
	private IPath getFilePath() {
328
		String filePath= fWorkspaceRadio.isSelected() ? fWorkspaceFileNameField.getText() : fExternalFileNameField.getText();
329
		return Path.fromOSString(filePath).makeAbsolute();
330
	}
331
332
	/*
333
	 * Opens a dialog to choose a jar from the file system.
334
	 */
335
	private IPath chooseExtJarFile() {
336
		IPath currPath= getFilePath();
337
		if (currPath.segmentCount() == 0) {
338
			currPath= fEntry;
339
		}
340
341
		if (ArchiveFileFilter.isArchivePath(currPath, true)) {
342
			currPath= currPath.removeLastSegments(1);
343
		}
344
345
		FileDialog dialog= new FileDialog(getShell());
346
		dialog.setText(NewWizardMessages.AnnotationsAttachmentBlock_extjardialog_text);
347
		dialog.setFilterExtensions(ArchiveFileFilter.JAR_ZIP_FILTER_EXTENSIONS);
348
		dialog.setFilterPath(currPath.toOSString());
349
		String res= dialog.open();
350
		if (res != null) {
351
			return Path.fromOSString(res).makeAbsolute();
352
		}
353
		return null;
354
	}
355
356
	private IPath chooseExtFolder() {
357
		IPath currPath= getFilePath();
358
		if (currPath.segmentCount() == 0) {
359
			currPath= fEntry;
360
		}
361
		if (ArchiveFileFilter.isArchivePath(currPath, true)) {
362
			currPath= currPath.removeLastSegments(1);
363
		}
364
365
		DirectoryDialog dialog= new DirectoryDialog(getShell());
366
		dialog.setMessage(NewWizardMessages.AnnotationsAttachmentBlock_extfolderdialog_message);
367
		dialog.setText(NewWizardMessages.AnnotationsAttachmentBlock_extfolderdialog_text);
368
		dialog.setFilterPath(currPath.toOSString());
369
		String res= dialog.open();
370
		if (res != null) {
371
			return Path.fromOSString(res).makeAbsolute();
372
		}
373
		return null;
374
	}
375
376
	/*
377
	 * Opens a dialog to choose an internal jar.
378
	 */
379
	private IPath chooseInternal() {
380
		String initSelection= fWorkspaceFileNameField.getText();
381
382
		ViewerFilter filter= new ArchiveFileFilter((List<IResource>) null, false, false);
383
384
		ILabelProvider lp= new WorkbenchLabelProvider();
385
		ITreeContentProvider cp= new WorkbenchContentProvider();
386
387
		IResource initSel= null;
388
		if (initSelection.length() > 0) {
389
			initSel= fWorkspaceRoot.findMember(new Path(initSelection));
390
		}
391
		if (initSel == null) {
392
			initSel= fWorkspaceRoot.findMember(fEntry);
393
		}
394
395
		FolderSelectionDialog dialog= new FolderSelectionDialog(getShell(), lp, cp);
396
		dialog.setAllowMultiple(false);
397
		dialog.addFilter(filter);
398
		dialog.setTitle(NewWizardMessages.AnnotationsAttachmentBlock_intjardialog_title);
399
		dialog.setMessage(NewWizardMessages.AnnotationsAttachmentBlock_intjardialog_message);
400
		dialog.setInput(fWorkspaceRoot);
401
		dialog.setInitialSelection(initSel);
402
		if (dialog.open() == Window.OK) {
403
			IResource res= (IResource) dialog.getFirstResult();
404
			return res.getFullPath();
405
		}
406
		return null;
407
	}
408
409
	private Shell getShell() {
410
		if (fSWTWidget != null) {
411
			return fSWTWidget.getShell();
412
		}
413
		return JavaPlugin.getActiveWorkbenchShell();
414
	}
415
416
	/**
417
	 * Takes a path and replaces the beginning with a variable name
418
	 * (if the beginning matches with the variables value)
419
	 * @param path the path
420
	 * @param varName the variable
421
	 * @return the modified path
422
	 */
423
	private IPath modifyPath(IPath path, String varName) {
424
		if (varName == null || path == null) {
425
			return null;
426
		}
427
		if (path.isEmpty()) {
428
			return new Path(varName);
429
		}
430
431
		IPath varPath= JavaCore.getClasspathVariable(varName);
432
		if (varPath != null) {
433
			if (varPath.isPrefixOf(path)) {
434
				path= path.removeFirstSegments(varPath.segmentCount());
435
			} else {
436
				path= new Path(path.lastSegment());
437
			}
438
		} else {
439
			path= new Path(path.lastSegment());
440
		}
441
		return new Path(varName).append(path);
442
	}
443
444
445
	/**
446
	 * Creates a runnable that sets the annotations attachment by modifying the project's classpath.
447
	 * @param shell the shell
448
	 * @param newEntry the new entry
449
	 * @param jproject the Java project
450
	 * @param containerPath the path of the parent container or <code>null</code> if the element is not in a container
451
	 * @param isReferencedEntry <code>true</code> iff the entry has a {@link IClasspathEntry#getReferencingEntry() referencing entry}
452
	 * @return return the runnable
453
	 */
454
	public static IRunnableWithProgress getRunnable(final Shell shell, final IClasspathEntry newEntry, final IJavaProject jproject, final IPath containerPath, final boolean isReferencedEntry) {
455
		return new IRunnableWithProgress() {
456
			public void run(IProgressMonitor monitor) throws InvocationTargetException {
457
				try {
458
					String[] changedAttributes= { IClasspathAttribute.EXTERNAL_ANNOTATION_PATH };
459
					BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, jproject, containerPath, isReferencedEntry, monitor);
460
				} catch (CoreException e) {
461
					throw new InvocationTargetException(e);
462
				}
463
			}
464
		};
465
	}
466
}
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ExternalAnnotationsAttachmentDialog.java (+106 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2015 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
 *     Frits Jalvingh <jal@etc.to> - Contribution for Bug 459831 - [launching] Support attaching external annotations to a JRE container
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.ui.wizards.buildpaths;
12
13
import org.eclipse.swt.layout.GridData;
14
import org.eclipse.swt.widgets.Composite;
15
import org.eclipse.swt.widgets.Control;
16
import org.eclipse.swt.widgets.Shell;
17
18
import org.eclipse.core.runtime.IPath;
19
import org.eclipse.core.runtime.IStatus;
20
21
import org.eclipse.jface.dialogs.StatusDialog;
22
23
import org.eclipse.ui.PlatformUI;
24
25
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
26
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
27
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
28
29
/**
30
 * A dialog to configure the external annotations attachment of a library (class folder, archives
31
 * and variable entries).
32
 *
33
 */
34
public class ExternalAnnotationsAttachmentDialog extends StatusDialog {
35
36
	private ExternalAnnotationsAttachmentBlock fAnnotationsAttachmentBlock;
37
38
	/**
39
	 * Creates an instance. After <code>open</code>, the edited path can be accessed from the
40
	 * classpath entry returned by <code>getResult</code>
41
	 *
42
	 * @param parent Parent shell for the dialog
43
	 * @param entry The entry to edit.
44
	 */
45
	public ExternalAnnotationsAttachmentDialog(Shell parent, IPath entry) {
46
		super(parent);
47
48
		IStatusChangeListener listener= new IStatusChangeListener() {
49
			public void statusChanged(IStatus status) {
50
				updateStatus(status);
51
			}
52
		};
53
		fAnnotationsAttachmentBlock= new ExternalAnnotationsAttachmentBlock(listener, entry);
54
55
		setTitle(NewWizardMessages.ExternalAnnotationsDialog_title);
56
	}
57
58
	/*
59
	 * @see org.eclipse.jface.dialogs.Dialog#isResizable()
60
	 */
61
	@Override
62
	protected boolean isResizable() {
63
		return true;
64
	}
65
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
68
	 */
69
	@Override
70
	protected void configureShell(Shell newShell) {
71
		super.configureShell(newShell);
72
		PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.EXTERNAL_ANNOTATIONS_ATTACHMENT_DIALOG);
73
	}
74
75
	/* (non-Javadoc)
76
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
77
	 */
78
	@Override
79
	protected Control createDialogArea(Composite parent) {
80
		Composite composite= (Composite) super.createDialogArea(parent);
81
82
		Control inner= createAnnotationAttachmentControls(composite);
83
		inner.setLayoutData(new GridData(GridData.FILL_BOTH));
84
		applyDialogFont(composite);
85
		return composite;
86
	}
87
88
	/**
89
	 * Creates the controls for the annotations attachment configuration.
90
	 *
91
	 * @param composite the parent composite
92
	 * @return the control
93
	 */
94
	protected Control createAnnotationAttachmentControls(Composite composite) {
95
		return fAnnotationsAttachmentBlock.createControl(composite);
96
	}
97
98
	/**
99
	 * Returns the configured class path entry.
100
	 *
101
	 * @return the configured class path entry
102
	 */
103
	public IPath getResult() {
104
		return fAnnotationsAttachmentBlock.getAnnotationsPath();
105
	}
106
}
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ExternalAnnotationsAttributeConfiguration.java (+98 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2015 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
 *     Frits Jalvingh <jal@etc.to> - Contribution for Bug 459831 - [launching] Support attaching external annotations to a JRE container
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.ui.wizards.buildpaths;
12
13
import org.eclipse.swt.widgets.Shell;
14
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.Path;
17
18
import org.eclipse.jface.resource.ImageDescriptor;
19
20
import org.eclipse.jdt.core.IClasspathAttribute;
21
import org.eclipse.jdt.core.JavaCore;
22
23
import org.eclipse.jdt.internal.corext.javadoc.JavaDocLocations;
24
import org.eclipse.jdt.internal.corext.util.Messages;
25
26
import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
27
import org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration;
28
29
import org.eclipse.jdt.internal.ui.JavaPluginImages;
30
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
31
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
32
33
public class ExternalAnnotationsAttributeConfiguration extends ClasspathAttributeConfiguration {
34
35
	public ExternalAnnotationsAttributeConfiguration() {
36
	}
37
38
	@Override
39
	public ImageDescriptor getImageDescriptor(ClasspathAttributeAccess attribute) {
40
		return JavaPluginImages.DESC_OBJS_EXTERNAL_ANNOTATION_LOCATION_ATTRIB; // FIXME Need image
41
	}
42
43
	@Override
44
	public String getNameLabel(ClasspathAttributeAccess attribute) {
45
		return NewWizardMessages.CPListLabelProvider_external_annotations_location_label;
46
	}
47
48
	@Override
49
	public String getValueLabel(ClasspathAttributeAccess access) {
50
		String arg= null;
51
		String str= access.getClasspathAttribute().getValue();
52
		if (str != null) {
53
			String prefix= JavaDocLocations.ARCHIVE_PREFIX;
54
			if (str.startsWith(prefix)) {
55
				int sepIndex= str.lastIndexOf("!/"); //$NON-NLS-1$
56
				if (sepIndex == -1) {
57
					arg= str.substring(prefix.length());
58
				} else {
59
					String archive= str.substring(prefix.length(), sepIndex);
60
					String root= str.substring(sepIndex + 2);
61
					if (root.length() > 0) {
62
						arg= Messages.format(NewWizardMessages.CPListLabelProvider_twopart, new String[] { BasicElementLabels.getURLPart(archive), BasicElementLabels.getURLPart(root) });
63
					} else {
64
						arg= BasicElementLabels.getURLPart(archive);
65
					}
66
				}
67
			} else {
68
				arg= BasicElementLabels.getURLPart(str);
69
			}
70
		} else {
71
			arg= NewWizardMessages.CPListLabelProvider_none;
72
		}
73
		return arg;
74
	}
75
76
	@Override
77
	public boolean canEdit(ClasspathAttributeAccess attribute) {
78
		return true;
79
	}
80
81
	@Override
82
	public boolean canRemove(ClasspathAttributeAccess attribute) {
83
		return attribute.getClasspathAttribute().getValue() != null;
84
	}
85
86
	@Override
87
	public IClasspathAttribute performEdit(Shell shell, ClasspathAttributeAccess attribute) {
88
		String initialLocation= attribute.getClasspathAttribute().getValue();
89
		IPath locationPath= initialLocation == null ? null : new Path(initialLocation);
90
		IPath newPath= BuildPathDialogAccess.configureExternalAnnotationsAttachment(shell, locationPath);
91
		return JavaCore.newClasspathAttribute(IClasspathAttribute.EXTERNAL_ANNOTATION_PATH, newPath == null ? null : newPath.toPortableString());
92
	}
93
94
	@Override
95
	public IClasspathAttribute performRemove(ClasspathAttributeAccess attribute) {
96
		return JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, null);
97
	}
98
}
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/ISharedImages.java (-1 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2015 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Frits Jalvingh - Contribution for Bug 459831 - [launching] Support attaching external annotations to a JRE container
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.ui;
12
package org.eclipse.jdt.ui;
12
13
Lines 294-299 public interface ISharedImages { Link Here
294
	public static final String IMG_OBJS_JAVADOCTAG= JavaPluginImages.IMG_OBJS_JAVADOCTAG;
295
	public static final String IMG_OBJS_JAVADOCTAG= JavaPluginImages.IMG_OBJS_JAVADOCTAG;
295
296
296
	/**
297
	/**
298
	 * Key to access the shared image or image descriptor for external annotations.
299
	 * @since 3.11
300
	 */
301
	public static final String IMG_OBJS_EXTERNAL_ANNOTATIONS = JavaPluginImages.IMG_OBJS_EXTERNAL_ANNOTATIONS;
302
303
	/**
297
	 * Returns the shared image managed under the given key.
304
	 * Returns the shared image managed under the given key.
298
	 * <p>
305
	 * <p>
299
	 * Note that clients <b>must not</b> dispose the image returned by this method.
306
	 * Note that clients <b>must not</b> dispose the image returned by this method.
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/BuildPathDialogAccess.java (-1 / +20 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2012 IBM Corporation and others.
2
 * Copyright (c) 2000, 2015 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Frits Jalvingh <jal@etc.to> - Contribution for Bug 459831 - [launching] Support attaching external annotations to a JRE container
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.ui.wizards;
12
package org.eclipse.jdt.ui.wizards;
12
13
Lines 55-60 import org.eclipse.jdt.internal.ui.wizards.buildpaths.ArchiveFileFilter; Link Here
55
import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement;
56
import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement;
56
import org.eclipse.jdt.internal.ui.wizards.buildpaths.ClasspathContainerWizard;
57
import org.eclipse.jdt.internal.ui.wizards.buildpaths.ClasspathContainerWizard;
57
import org.eclipse.jdt.internal.ui.wizards.buildpaths.EditVariableEntryDialog;
58
import org.eclipse.jdt.internal.ui.wizards.buildpaths.EditVariableEntryDialog;
59
import org.eclipse.jdt.internal.ui.wizards.buildpaths.ExternalAnnotationsAttachmentDialog;
58
import org.eclipse.jdt.internal.ui.wizards.buildpaths.JavadocLocationDialog;
60
import org.eclipse.jdt.internal.ui.wizards.buildpaths.JavadocLocationDialog;
59
import org.eclipse.jdt.internal.ui.wizards.buildpaths.MultipleFolderSelectionDialog;
61
import org.eclipse.jdt.internal.ui.wizards.buildpaths.MultipleFolderSelectionDialog;
60
import org.eclipse.jdt.internal.ui.wizards.buildpaths.NewVariableEntryDialog;
62
import org.eclipse.jdt.internal.ui.wizards.buildpaths.NewVariableEntryDialog;
Lines 138-143 public final class BuildPathDialogAccess { Link Here
138
	}
140
	}
139
	
141
	
140
	/**
142
	/**
143
	 * Shows the UI for configuring an external annotations attachment. <code>null</code> is
144
	 * returned when the user cancels the dialog. The dialog does not apply any changes.
145
	 *
146
	 * @since 3.11
147
	 * @param shell The parent shell for the dialog
148
	 * @param initialEntry The entry to edit.
149
	 * @return Returns the selected path, possibly different from the initialEntry.
150
	 */
151
	public static IPath configureExternalAnnotationsAttachment(Shell shell, IPath initialEntry) {
152
		ExternalAnnotationsAttachmentDialog dialog= new ExternalAnnotationsAttachmentDialog(shell, initialEntry);
153
		if (dialog.open() == Window.OK) {
154
			return dialog.getResult();
155
		}
156
		return null;
157
	}
158
159
	/**
141
	 * Shows the UI for configuring a javadoc location. <code>null</code> is returned
160
	 * Shows the UI for configuring a javadoc location. <code>null</code> is returned
142
	 * if the user cancels the dialog. If OK is pressed, an array of length 1 containing the configured URL is
161
	 * if the user cancels the dialog. If OK is pressed, an array of length 1 containing the configured URL is
143
	 * returned. Note that the configured URL can be <code>null</code> when the user
162
	 * returned. Note that the configured URL can be <code>null</code> when the user

Return to bug 440815