Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 112805 Details for
Bug 246080
[jar exporter] use current project
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch for org.eclipse.jdt.ui, add project-field in Dialog
fix_246080_20080917.txt (text/plain), 40.46 KB, created by
Ferenc Hechler
on 2008-09-17 14:54:43 EDT
(
hide
)
Description:
patch for org.eclipse.jdt.ui, add project-field in Dialog
Filename:
MIME Type:
Creator:
Ferenc Hechler
Created:
2008-09-17 14:54:43 EDT
Size:
40.46 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/jarpackager/JarPackagerMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarPackagerMessages.java,v >retrieving revision 1.22 >diff -u -r1.22 JarPackagerMessages.java >--- ui/org/eclipse/jdt/internal/ui/jarpackager/JarPackagerMessages.java 12 Sep 2008 12:53:28 -0000 1.22 >+++ ui/org/eclipse/jdt/internal/ui/jarpackager/JarPackagerMessages.java 17 Sep 2008 18:46:04 -0000 >@@ -8,6 +8,7 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar >+ * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 246080 [jar exporter] use current project > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.jarpackager; > >@@ -283,6 +284,8 @@ > > public static String JarPackageWizardPage_error_caption; > >+ public static String JarPackageWizardPage_error_exportDestinationMissing; >+ > public static String JarPackageWizardPage_error_exportDestinationMustNotBeDirectory; > > public static String JarPackageWizardPage_error_jarFileExistsAndNotWritable; >Index: ui/org/eclipse/jdt/internal/ui/jarpackager/AbstractJarDestinationWizardPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/AbstractJarDestinationWizardPage.java,v >retrieving revision 1.7 >diff -u -r1.7 AbstractJarDestinationWizardPage.java >--- ui/org/eclipse/jdt/internal/ui/jarpackager/AbstractJarDestinationWizardPage.java 11 Sep 2008 11:59:44 -0000 1.7 >+++ ui/org/eclipse/jdt/internal/ui/jarpackager/AbstractJarDestinationWizardPage.java 17 Sep 2008 18:46:04 -0000 >@@ -8,6 +8,7 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar >+ * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 246080 [jar exporter] use current project > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.jarpackager; > >@@ -41,6 +42,7 @@ > > import org.eclipse.jdt.ui.jarpackager.JarPackageData; > >+import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; > import org.eclipse.jdt.internal.ui.util.SWTUtil; > import org.eclipse.jdt.internal.ui.wizards.buildpaths.ArchiveFileFilter; > >@@ -54,14 +56,18 @@ > > private final String fStoreDestinationNamesId; > >- private Combo fDestinationNamesCombo; >- private Button fDestinationBrowseButton; >+ protected Combo fDestinationNamesCombo; >+ >+ protected Button fDestinationBrowseButton; >+ >+ protected StatusInfo fDestinationStatus; > private final JarPackageData fJarPackage; > > public AbstractJarDestinationWizardPage(String pageName, IStructuredSelection selection, JarPackageData jarPackage) { > super(pageName, selection); > fStoreDestinationNamesId= pageName + ".DESTINATION_NAMES_ID"; //$NON-NLS-1$ > fJarPackage= jarPackage; >+ fDestinationStatus= new StatusInfo(); > } > > /* >@@ -222,6 +228,25 @@ > return true; > } > >+ /** >+ * update fDestinationStatus indicating whether the passed File handle is is valid and available >+ * for use. >+ * >+ * @param targetFile the target >+ */ >+ protected void updateTargetFileStatus(File targetFile) { >+ if (targetFile.exists() && targetFile.isDirectory() && fDestinationNamesCombo.getText().length() > 0) { >+ fDestinationStatus.setError(JarPackagerMessages.JarPackageWizardPage_error_exportDestinationMustNotBeDirectory); >+ return; >+ } >+ if (targetFile.exists()) { >+ if (!targetFile.canWrite()) { >+ fDestinationStatus.setError(JarPackagerMessages.JarPackageWizardPage_error_jarFileExistsAndNotWritable); >+ return; >+ } >+ } >+ } >+ > /* > * Overrides method from WizardDataTransferPage > */ >@@ -267,6 +292,43 @@ > return ensureTargetFileIsValid(fJarPackage.getAbsoluteJarLocation().toFile()); > } > >+ /* >+ * Overrides method from WizardDataTransferPage >+ */ >+ protected void updateDestinationGroupStatus() { >+ fDestinationStatus.setOK(); >+ if (fDestinationNamesCombo.getText().length() == 0) { >+ fDestinationStatus.setError(JarPackagerMessages.JarPackageWizardPage_error_exportDestinationMissing); >+ return; >+ } >+ if (fJarPackage.getAbsoluteJarLocation().toString().endsWith("/")) { //$NON-NLS-1$ >+ fDestinationStatus.setError(JarPackagerMessages.JarPackageWizardPage_error_exportDestinationMustNotBeDirectory); >+ return; >+ } >+ // Check if the Jar is put into the workspace and conflicts with the containers >+ // exported. If the workspace isn't on the local files system we are fine since >+ // the Jar is always created in the local file system >+ IPath workspaceLocation= ResourcesPlugin.getWorkspace().getRoot().getLocation(); >+ if (workspaceLocation != null && workspaceLocation.isPrefixOf(fJarPackage.getAbsoluteJarLocation())) { >+ int segments= workspaceLocation.matchingFirstSegments(fJarPackage.getAbsoluteJarLocation()); >+ IPath path= fJarPackage.getAbsoluteJarLocation().removeFirstSegments(segments); >+ IResource resource= ResourcesPlugin.getWorkspace().getRoot().findMember(path); >+ if (resource != null && resource.getType() == IResource.FILE) { >+ // test if included >+ if (JarPackagerUtil.contains(JarPackagerUtil.asResources(fJarPackage.getElements()), (IFile)resource)) { >+ fDestinationStatus.setError(JarPackagerMessages.JarPackageWizardPage_error_cantExportJARIntoItself); >+ return; >+ } >+ } >+ } >+ // Inform user about relative directory >+ if (!(new File(fDestinationNamesCombo.getText()).isAbsolute())) { >+ if (fDestinationStatus.isOK()) >+ fDestinationStatus.setInfo(JarPackagerMessages.JarPackageWizardPage_info_relativeExportDestination); >+ } >+ updateTargetFileStatus(fJarPackage.getAbsoluteJarLocation().toFile()); >+ } >+ > /** > * Set the current input focus to self's destination entry field > */ >Index: ui/org/eclipse/jdt/internal/ui/jarpackager/JarPackagerMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarPackagerMessages.properties,v >retrieving revision 1.67 >diff -u -r1.67 JarPackagerMessages.properties >--- ui/org/eclipse/jdt/internal/ui/jarpackager/JarPackagerMessages.properties 12 Sep 2008 12:53:28 -0000 1.67 >+++ ui/org/eclipse/jdt/internal/ui/jarpackager/JarPackagerMessages.properties 17 Sep 2008 18:46:05 -0000 >@@ -8,6 +8,7 @@ > # Contributors: > # IBM Corporation - initial API and implementation > # Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar >+# Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 246080 [jar exporter] use current project > ############################################################################### > > AbstractJarDestinationWizardPage_destinationCombo_AccessibilityText=Select the export destination >@@ -113,6 +114,7 @@ > JarPackageWizardPage_no_refactorings_selected=Select any refactorings to export. > JarPackageWizardPage_exportJavaFiles_text= Export Java &source files and resources > JarPackageWizardPage_info_relativeExportDestination= The export destination will be relative to your workspace. >+JarPackageWizardPage_error_exportDestinationMissing= Export destination missing > JarPackageWizardPage_error_exportDestinationMustNotBeDirectory= Export destination must be a JAR file, not a directory. > JarPackageWizardPage_error_jarFileExistsAndNotWritable= JAR file already exists and cannot be overwritten. > JarPackageWizardPage_error_noExportTypeChecked= No export type checked. >Index: ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackageWizard.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackageWizard.java,v >retrieving revision 1.4 >diff -u -r1.4 FatJarPackageWizard.java >--- ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackageWizard.java 15 Sep 2008 09:35:43 -0000 1.4 >+++ ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackageWizard.java 17 Sep 2008 18:46:06 -0000 >@@ -10,12 +10,11 @@ > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 213638 [jar exporter] create ANT build file for current settings > * Ferenc Hechler <ferenc_hechler@users.sourceforge.net> - [jar exporter] export directory entries in "Runnable JAR File" - https://bugs.eclipse.org/bugs/show_bug.cgi?id=243163 >+ * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 246080 [jar exporter] use current project > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.jarpackagerfat; > > import java.lang.reflect.InvocationTargetException; >-import java.util.HashSet; >-import java.util.Iterator; > > import org.eclipse.swt.widgets.Shell; > >@@ -23,6 +22,8 @@ > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.MultiStatus; > >+import org.eclipse.core.resources.IProject; >+ > import org.eclipse.jface.dialogs.ErrorDialog; > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.dialogs.IDialogSettings; >@@ -37,9 +38,9 @@ > import org.eclipse.ui.IExportWizard; > import org.eclipse.ui.IWorkbench; > >-import org.eclipse.jdt.core.IJavaElement; > import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.core.IPackageFragmentRoot; >+import org.eclipse.jdt.core.JavaCore; > > import org.eclipse.jdt.ui.jarpackager.IJarExportRunnable; > import org.eclipse.jdt.ui.jarpackager.JarPackageData; >@@ -142,25 +143,23 @@ > } > > /** >- * @return all java projects which contain the selected elements in the active workbench window >+ * @return selected java projects if it is the only selected element in the active workbench >+ * window > */ > protected IStructuredSelection getSelectedJavaProjects() { > ISelection currentSelection= JavaPlugin.getActiveWorkbenchWindow().getSelectionService().getSelection(); > if (currentSelection instanceof IStructuredSelection) { > IStructuredSelection structuredSelection= (IStructuredSelection) currentSelection; >- HashSet selectedElements= new HashSet(); >- Iterator iter= structuredSelection.iterator(); >- while (iter.hasNext()) { >- Object selectedElement= iter.next(); >- if (selectedElement instanceof IJavaElement) { >- IJavaProject javaProject= ((IJavaElement) selectedElement).getJavaProject(); >- if (javaProject != null) >- selectedElements.add(javaProject); >+ if (structuredSelection.size() == 1) { >+ Object selectedElement= structuredSelection.getFirstElement(); >+ if (selectedElement instanceof IProject) { >+ IJavaProject result= JavaCore.create((IProject)selectedElement); >+ if ((result != null) && result.exists()) >+ return new StructuredSelection(result); > } > } >- return new StructuredSelection(selectedElements); >- } else >- return StructuredSelection.EMPTY; >+ } >+ return StructuredSelection.EMPTY; > } > > /** >@@ -178,11 +177,9 @@ > > /** > * Initializes this wizard from the given JAR package description. >- * >- * @param workbench >- * the workbench which launched this wizard >- * @param jarPackage >- * the JAR package description used to initialize this wizard >+ * >+ * @param workbench the workbench which launched this wizard >+ * @param jarPackage the JAR package description used to initialize this wizard > */ > public void init(IWorkbench workbench, JarPackageData jarPackage) { > Assert.isNotNull(workbench); >Index: ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackagerMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackagerMessages.properties,v >retrieving revision 1.8 >diff -u -r1.8 FatJarPackagerMessages.properties >--- ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackagerMessages.properties 21 Apr 2008 14:17:40 -0000 1.8 >+++ ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackagerMessages.properties 17 Sep 2008 18:46:08 -0000 >@@ -10,6 +10,7 @@ > # Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar > # Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 211045 [jar application] program arguments are ignored > # Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 213638 [jar exporter] create ANT build file for current settings >+# Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 246080 [jar exporter] use current project > ############################################################################### > > JarPackageWizard_windowTitle= Runnable JAR File Export >@@ -29,6 +30,8 @@ > FatJarPackageWizardPage_antScriptLocation_text=&ANT script location: > FatJarPackageWizardPage_antScriptLocationBrowse_text=Br&owse... > FatJarPackageWizardPage_error_missingClassFile=Fat Jar Export: Could not find classpath entry for ''{0}'' >+FatJarPackageWizardPage_projectBrowse_text=Browse... >+FatJarPackageWizardPage_projectNameLabel_text=Project name: > FatJarPackageWizard_IPIssueDialog_message=This operation repacks referenced libraries.\n\n\ > Please review the licenses associated with libraries you wish to reference to make sure you are able to \ > repack them using this application. Note also that this operation does not copy signature files from \ >@@ -45,10 +48,19 @@ > > FatJarPackageWizardPage_launchConfigGroupTitle=&Launch configuration: > FatJarPackageWizardPage_LaunchConfigurationWithoutMainType_warning=The selected launch configuration has no type with a main method attached. The resulting JAR will not be runnable. >- >+FatJarPackageWizardPage_error_noLaunchConfigSelected= Launch-Configuration has to be selected > FatJarPackageWizard_antScript_error_readingOutputFile=Could not create output file ''{0}''. Reason: {1} > FatJarPackageWizard_antScript_error_writingOutputFile=Could not write output file ''{0}''. Reason: {1} > >+FatJarPackageWizardPage_error_EnterProjectName=Project name must be entered. >+FatJarPackageWizardPage_error_InvalidProjectPath=Invalid project path. >+FatJarPackageWizardPage_error_NotAJavaProject=Project is not a Java project. >+FatJarPackageWizardPage_error_ProjectNotExists=Project does not exist. >+FatJarPackageWizardPage_error_ProjectNotOpen=Project is not open. >+ >+FatJarPackageWizardPage_ChooseProjectDialog_title=Project Selection >+FatJarPackageWizardPage_ChooseProjectDialog_description=&Choose project for the new source folder: >+ > FatJarPackage_confirmCreate_title= Confirm Create > > FatJarPackageAntScript_confirmCreate_message= The location: ''{0}'' for the ANT script file does not exist. Would you like to create it? >Index: ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackageWizardPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackageWizardPage.java,v >retrieving revision 1.13 >diff -u -r1.13 FatJarPackageWizardPage.java >--- ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackageWizardPage.java 11 Sep 2008 11:59:55 -0000 1.13 >+++ ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackageWizardPage.java 17 Sep 2008 18:46:07 -0000 >@@ -10,6 +10,7 @@ > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 211045 [jar application] program arguments are ignored > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 213638 [jar exporter] create ANT build file for current settings >+ * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 246080 [jar exporter] use current project > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.jarpackagerfat; > >@@ -49,9 +50,12 @@ > > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.IDialogSettings; >-import org.eclipse.jface.dialogs.IMessageProvider; > import org.eclipse.jface.operation.IRunnableContext; >+import org.eclipse.jface.viewers.ILabelProvider; > import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.window.Window; >+ >+import org.eclipse.ui.dialogs.ElementListSelectionDialog; > > import org.eclipse.debug.core.DebugPlugin; > import org.eclipse.debug.core.ILaunchConfiguration; >@@ -74,16 +78,24 @@ > import org.eclipse.jdt.launching.IRuntimeClasspathEntry; > import org.eclipse.jdt.launching.JavaRuntime; > >+import org.eclipse.jdt.ui.JavaElementLabelProvider; > import org.eclipse.jdt.ui.JavaUI; > import org.eclipse.jdt.ui.jarpackager.JarPackageData; > > import org.eclipse.jdt.internal.ui.JavaPlugin; >+import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; >+import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; > import org.eclipse.jdt.internal.ui.jarpackager.AbstractJarDestinationWizardPage; > import org.eclipse.jdt.internal.ui.jarpackager.JarPackagerUtil; > import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory; > import org.eclipse.jdt.internal.ui.util.MainMethodSearchEngine; > import org.eclipse.jdt.internal.ui.util.SWTUtil; > import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; >+import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField; >+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener; >+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter; >+import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil; >+import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField; > > > /** >@@ -158,7 +170,25 @@ > > } > >+ private class ProjectFieldAdapter implements IStringButtonAdapter, IDialogFieldListener { >+ // -------- IStringButtonAdapter >+ public void changeControlPressed(DialogField field) { >+ IJavaProject jproject= chooseProject(); >+ if (jproject != null) { >+ IPath path= jproject.getProject().getFullPath().makeRelative(); >+ fProjectField.setText(path.toString()); >+ } >+ update(); >+ } >+ >+ // -------- IDialogFieldListener >+ public void dialogFieldChanged(DialogField field) { >+ update(); >+ } >+ } >+ > private static final String PAGE_NAME= "FatJarPackageWizardPage"; //$NON-NLS-1$ >+ private static final String STORE_PROJECT_NAME= PAGE_NAME + ".PROJECT_NAME"; //$NON-NLS-1$ > private static final String STORE_LAUNCH_CONFIGURATION_SELECTION_NAME= PAGE_NAME + ".LAUNCH_CONFIGURATION_SELECTION_NAME"; //$NON-NLS-1$ > private static final String STORE_DESTINATION_ELEMENT= PAGE_NAME + ".DESTINATION_PATH_SELECTION"; //$NON-NLS-1$ > private static final String STORE_ANTSCRIPT_SAVE= PAGE_NAME + ".ANTSCRIPT_SAVE"; //$NON-NLS-1$ >@@ -183,12 +213,28 @@ > > private IPath fAntScriptLocation; > >+ private IJavaProject fCurrJProject; >+ private IJavaProject fPreselectedJProject; >+ private IJavaProject fFilledJProject; >+ private StringButtonDialogField fProjectField; >+ private StatusInfo fProjectStatus; >+ private StatusInfo fLaunchConfigurationStatus; >+ private StatusInfo fAntScriptStatus; >+ private IStatus fCurrStatus; >+ private boolean fPageVisible; >+ > public FatJarPackageWizardPage(JarPackageData jarPackage, IStructuredSelection selection) { > super(PAGE_NAME, selection, jarPackage); > setTitle(FatJarPackagerMessages.JarPackageWizardPage_title); > setDescription(FatJarPackagerMessages.FatJarPackageWizardPage_description); > fJarPackage= jarPackage; > fLauchConfigurationModel= new ArrayList(); >+ fProjectStatus= new StatusInfo(); >+ fLaunchConfigurationStatus= new StatusInfo(); >+ fAntScriptStatus= new StatusInfo(); >+ fPageVisible= false; >+ if (selection.toList().size() == 1) >+ fPreselectedJProject= (IJavaProject)selection.getFirstElement(); > } > > /** >@@ -202,6 +248,8 @@ > layout.marginWidth= 0; > composite.setLayout(layout); > >+ createProjectGroup(composite); >+ > createContentGroup(composite); > > Label seperator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL); >@@ -213,10 +261,34 @@ > > update(); > >+ // overwrite stored project with preselected project >+ if ((fPreselectedJProject != null) && !fPreselectedJProject.equals(fCurrJProject)) { >+ fProjectField.setText(fPreselectedJProject.getElementName()); >+ update(); >+ } >+ > Dialog.applyDialogFont(composite); > setControl(composite); > } > >+ private void createProjectGroup(Composite parent) { >+ Composite composite= new Composite(parent, SWT.NONE); >+ composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); >+ composite.setLayout(new GridLayout(3, false)); >+ >+ ProjectFieldAdapter adapter= new ProjectFieldAdapter(); >+ fProjectField= new StringButtonDialogField(adapter); >+ fProjectField.setDialogFieldListener(adapter); >+ fProjectField.setLabelText(FatJarPackagerMessages.FatJarPackageWizardPage_projectNameLabel_text); >+ fProjectField.setButtonLabel(FatJarPackagerMessages.FatJarPackageWizardPage_projectBrowse_text); >+ >+ fProjectField.doFillIntoGrid(composite, 3); >+ >+ int maxFieldWidth= convertWidthInCharsToPixels(40); >+ LayoutUtil.setWidthHint(fProjectField.getTextControl(null), maxFieldWidth); >+ LayoutUtil.setHorizontalGrabbing(fProjectField.getTextControl(null)); >+ } >+ > private void createContentGroup(Composite parent) { > Composite composite= new Composite(parent, SWT.NONE); > composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); >@@ -245,16 +317,31 @@ > SWTUtil.setDefaultVisibleItemCount(fLaunchConfigurationCombo); > fLaunchConfigurationCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); > >- fLauchConfigurationModel.addAll(Arrays.asList(getLaunchConfigurations())); >+ fillLaunchConfigs(); >+ >+ fLaunchConfigurationCombo.addListener(SWT.Selection, this); >+ fLaunchConfigurationCombo.addListener(SWT.Modify, this); >+ } >+ >+ private void fillLaunchConfigs() { >+ // leave unchanged if invalid project >+ if (fCurrJProject == null) >+ return; >+ // leave unchanged if already filled for this project >+ if (fCurrJProject.equals(fFilledJProject)) >+ return; >+ fFilledJProject= fCurrJProject; >+ fLauchConfigurationModel.clear(); >+ fLauchConfigurationModel.addAll(Arrays.asList(getProjectLaunchConfigurations(fCurrJProject))); > String[] names= new String[fLauchConfigurationModel.size()]; > for (int i= 0, size= fLauchConfigurationModel.size(); i < size; i++) { > LaunchConfigurationElement element= (LaunchConfigurationElement) fLauchConfigurationModel.get(i); > names[i]= element.getLaunchConfigurationName(); > } > fLaunchConfigurationCombo.setItems(names); >- >- fLaunchConfigurationCombo.addListener(SWT.Selection, this); >- fLaunchConfigurationCombo.addListener(SWT.Modify, this); >+ // select the first entry >+ if (names.length > 0) >+ fLaunchConfigurationCombo.select(0); > } > > private void createAntScriptGroup(Composite parent) { >@@ -343,138 +430,141 @@ > > String comboText= fAntScriptNamesCombo.getText(); > IPath path= Path.fromOSString(comboText); >- if (path.segmentCount() > 0 && ensureAntScriptFileIsValid(path.toFile()) && path.getFileExtension() == null) >+ if (path.segmentCount() > 0 && path.getFileExtension() == null) > path= path.addFileExtension(ANTSCRIPT_EXTENSION); > > fAntScriptLocation= path; > } > > protected void updateWidgetEnablements() { >- boolean antScriptSave= fAntScriptSaveCheckbox.getSelection(); >+ boolean enabled= fCurrJProject != null; >+ boolean antScriptSave= enabled && fAntScriptSaveCheckbox.getSelection(); >+ >+ fAntScriptSaveCheckbox.setEnabled(enabled); >+ fDestinationNamesCombo.setEnabled(enabled); >+ fDestinationBrowseButton.setEnabled(enabled); >+ fLaunchConfigurationCombo.setEnabled(enabled); >+ > fAntScriptLabel.setEnabled(antScriptSave); > fAntScriptNamesCombo.setEnabled(antScriptSave); > fAntScriptBrowseButton.setEnabled(antScriptSave); > } > >- public boolean isPageComplete() { >- clearMessages(); >- boolean complete= validateDestinationGroup(); >- complete= validateLaunchConfigurationGroup() && complete; >- complete= validateAntScriptGroup() && complete; >- return complete; >+ protected void updatePageCompletion() { >+ updateStatus(); > } > >- private boolean validateLaunchConfigurationGroup() { >- int index= fLaunchConfigurationCombo.getSelectionIndex(); >- if (index == -1) >- return false; >+ public void updateStatus() { >+ IJavaProject lastJProject= fCurrJProject; >+ updateProjectGroupStatus(); >+ if (!equalsWithNull(fCurrJProject, lastJProject)) { >+ updateProject(); >+ } >+ updateDestinationGroupStatus(); >+ updateLaunchConfigurationGroupStatus(); >+ updateAntScriptGroupStatus(); >+ fCurrStatus= StatusUtil.getMostSevere(new IStatus[] { fDestinationStatus, fProjectStatus, fLaunchConfigurationStatus, fAntScriptStatus }); >+ updateStatus(fCurrStatus); >+ updateWidgetEnablements(); >+ } > >+ private void updateProject() { >+ if (fCurrJProject != null) { >+ fillLaunchConfigs(); >+ } >+ } >+ >+ private boolean equalsWithNull(Object o1, Object o2) { >+ if (o1 == o2) >+ return true; >+ if ((o1 == null) || (o2 == null)) >+ return false; >+ return o1.equals(o2); >+ } >+ >+ private void updateLaunchConfigurationGroupStatus() { >+ fLaunchConfigurationStatus.setOK(); >+ int index= fLaunchConfigurationCombo.getSelectionIndex(); >+ if (index == -1) { >+ fLaunchConfigurationStatus.setError(FatJarPackagerMessages.FatJarPackageWizardPage_error_noLaunchConfigSelected); >+ return; >+ } >+ > LaunchConfigurationElement element= (LaunchConfigurationElement) fLauchConfigurationModel.get(index); > if (element.hasProgramArguments()) >- setWarningMessage(FatJarPackagerMessages.FatJarPackageWizardPage_warning_launchConfigContainsProgramArgs); >- >+ fLaunchConfigurationStatus.setWarning(FatJarPackagerMessages.FatJarPackageWizardPage_warning_launchConfigContainsProgramArgs); >+ > if (element.hasVMArguments()) >- setWarningMessage(FatJarPackagerMessages.FatJarPackageWizardPage_warning_launchConfigContainsVMArgs); >- >- return true; >+ fLaunchConfigurationStatus.setWarning(FatJarPackagerMessages.FatJarPackageWizardPage_warning_launchConfigContainsVMArgs); > } > >- private boolean validateAntScriptGroup() { >+ private void updateAntScriptGroupStatus() { >+ fAntScriptStatus.setOK(); > if (!fAntScriptSaveCheckbox.getSelection()) > // save as ant not selected >- return true; >+ return; > > if (fAntScriptNamesCombo.getText().length() == 0) { >- setErrorMessage(FatJarPackagerMessages.FatJarPackageWizardPage_error_antScriptLocationMissing); >- return false; >+ fAntScriptStatus.setError(FatJarPackagerMessages.FatJarPackageWizardPage_error_antScriptLocationMissing); >+ return; > } > > if (fAntScriptLocation.toString().endsWith("/")) { //$NON-NLS-1$ >- setErrorMessage(FatJarPackagerMessages.FatJarPackageWizardPage_error_antScriptLocationIsDir); >- fAntScriptNamesCombo.setFocus(); >- return false; >+ fAntScriptStatus.setError(FatJarPackagerMessages.FatJarPackageWizardPage_error_antScriptLocationIsDir); >+ return; > } > > // Inform user about relative directory > if (!(new File(fAntScriptNamesCombo.getText()).isAbsolute())) >- setInfoMessage(FatJarPackagerMessages.FatJarPackageWizardPage_info_antScriptLocationRelative); >+ fAntScriptStatus.setInfo(FatJarPackagerMessages.FatJarPackageWizardPage_info_antScriptLocationRelative); > >- return ensureAntScriptFileIsValid(fAntScriptLocation.toFile()); >+ updateAntScriptFileStatus(fAntScriptLocation.toFile()); > } > > /** >- * Returns a boolean indicating whether the passed File handle is >- * is valid and available for use. >- * >+ * update fAntScriptStatus indicating whether the passed File handle is valid and available for >+ * use. >+ * > * @param antScriptFile the ant script >- * @return boolean > */ >- private boolean ensureAntScriptFileIsValid(File antScriptFile) { >+ private void updateAntScriptFileStatus(File antScriptFile) { > if (antScriptFile.exists() && antScriptFile.isDirectory() && fAntScriptNamesCombo.getText().length() > 0) { >- setErrorMessage(FatJarPackagerMessages.FatJarPackageWizardPage_error_antScriptLocationIsDir); >- fAntScriptNamesCombo.setFocus(); >- return false; >+ fAntScriptStatus.setError(FatJarPackagerMessages.FatJarPackageWizardPage_error_antScriptLocationIsDir); >+ return; > } > if (antScriptFile.exists()) { > if (!antScriptFile.canWrite()) { >- setErrorMessage(FatJarPackagerMessages.FatJarPackageWizardPage_error_antScriptLocationUnwritable); >- fAntScriptNamesCombo.setFocus(); >- return false; >+ fAntScriptStatus.setError(FatJarPackagerMessages.FatJarPackageWizardPage_error_antScriptLocationUnwritable); >+ return; > } > } >- return true; >- } >- >- /** >- * clear all previously set messages and error-messages >- */ >- private void clearMessages() { >- if (getErrorMessage() != null) >- setErrorMessage(null); >- if (getMessage() != null) >- setMessage(null); >- } >- >- /** >- * set message to newMessage with severity WARNING. >- * overwrite existing message only if it is beyond severity WARNING >- * @param newMessage the warning to be set >- */ >- private void setWarningMessage(String newMessage) { >- if (getMessage() == null || getMessageType() < IMessageProvider.WARNING) >- setMessage(newMessage, IMessageProvider.WARNING); >- } >- >- /** >- * set message to newMessage with severity WARNING. >- * overwrite existing message only if it is beyond severity WARNING >- * @param newMessage the warning to be set >- */ >- private void setInfoMessage(String newMessage) { >- if (getMessage() == null || getMessageType() < IMessageProvider.INFORMATION) >- setMessage(newMessage, IMessageProvider.INFORMATION); >+ return; > } > >- private LaunchConfigurationElement[] getLaunchConfigurations() { >+ private LaunchConfigurationElement[] getProjectLaunchConfigurations(IJavaProject jProject) { > ArrayList result= new ArrayList(); > > try { >- ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager(); >- ILaunchConfigurationType type= manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); >- ILaunchConfiguration[] launchconfigs= manager.getLaunchConfigurations(type); >- >- for (int i= 0; i < launchconfigs.length; i++) { >- ILaunchConfiguration launchconfig= launchconfigs[i]; >- if (!launchconfig.getAttribute(IDebugUIConstants.ATTR_PRIVATE, false)) { >- String projectName= launchconfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$ >- result.add(new ExistingLaunchConfigurationElement(launchconfig, projectName)); >+ if (jProject != null) { >+ String selectedProjectName= jProject.getElementName(); >+ ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager(); >+ ILaunchConfigurationType type= manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); >+ ILaunchConfiguration[] launchconfigs= manager.getLaunchConfigurations(type); >+ >+ for (int i= 0; i < launchconfigs.length; i++) { >+ ILaunchConfiguration launchconfig= launchconfigs[i]; >+ if (!launchconfig.getAttribute(IDebugUIConstants.ATTR_PRIVATE, false)) { >+ String projectName= launchconfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$ >+ if (selectedProjectName.equals(projectName)) >+ result.add(new ExistingLaunchConfigurationElement(launchconfig, projectName)); >+ } > } > } > } catch (CoreException e) { > JavaPlugin.log(e); > } > >- return (LaunchConfigurationElement[]) result.toArray(new LaunchConfigurationElement[result.size()]); >+ return (LaunchConfigurationElement[])result.toArray(new LaunchConfigurationElement[result.size()]); > } > > public Object[] getSelectedElementsWithoutContainedChildren(MultiStatus status) { >@@ -725,6 +815,11 @@ > fAntScriptNamesCombo.add(directoryNames[i]); > } > >+ // PROJECT >+ String projectName= settings.get(STORE_PROJECT_NAME); >+ if (projectName != null && projectName.length() > 0) >+ fProjectField.setText(projectName); // this fills the launch-config >+ > // LAUNCH CONFIG > String name= settings.get(STORE_LAUNCH_CONFIGURATION_SELECTION_NAME); > if (name != null) { >@@ -736,10 +831,12 @@ > } > } > >- // DESTINATION >+ // DESTINATION (leave this as last entry before call to super.restoreWidgetValues(), >+ // because any call to update() will clear destination element) > String destinationPath= settings.get(STORE_DESTINATION_ELEMENT); > if (destinationPath != null && destinationPath.length() > 0) { > fJarPackage.setJarLocation(Path.fromOSString(destinationPath)); >+ // super class will set text for fDestinationNamesCombo > } > } > >@@ -773,6 +870,12 @@ > directoryNames= addToHistory(directoryNames, getAntScriptValue()); > settings.put(STORE_ANTSCRIPT_LOCATION_HISTORY, directoryNames); > >+ // PROJECT >+ if (fCurrJProject == null) >+ settings.put(STORE_PROJECT_NAME, ""); //$NON-NLS-1$ >+ else >+ settings.put(STORE_PROJECT_NAME, fCurrJProject.getElementName()); >+ > // LAUNCH CONFIG > int index= fLaunchConfigurationCombo.getSelectionIndex(); > if (index == -1) { >@@ -871,4 +974,88 @@ > return true; > } > >+ private void updateProjectGroupStatus() { >+ fCurrJProject= null; >+ >+ String str= fProjectField.getText(); >+ if (str.length() == 0) { >+ fProjectStatus.setError(FatJarPackagerMessages.FatJarPackageWizardPage_error_EnterProjectName); >+ return; >+ } >+ IPath path= new Path(str); >+ if (path.segmentCount() != 1) { >+ fProjectStatus.setError(FatJarPackagerMessages.FatJarPackageWizardPage_error_InvalidProjectPath); >+ return; >+ } >+ IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(path.toString()); >+ if (!project.exists()) { >+ fProjectStatus.setError(FatJarPackagerMessages.FatJarPackageWizardPage_error_ProjectNotExists); >+ return; >+ } >+ if (!project.isOpen()) { >+ fProjectStatus.setError(FatJarPackagerMessages.FatJarPackageWizardPage_error_ProjectNotOpen); >+ return; >+ } >+ try { >+ if (project.hasNature(JavaCore.NATURE_ID)) { >+ fCurrJProject= JavaCore.create(project); >+ fProjectStatus.setOK(); >+ return; >+ } >+ } catch (CoreException e) { >+ JavaPlugin.log(e); >+ fCurrJProject= null; >+ } >+ fProjectStatus.setError(FatJarPackagerMessages.FatJarPackageWizardPage_error_NotAJavaProject); >+ } >+ >+ /** >+ * Updates the status line and the OK button according to the given status >+ * >+ * @param status status to apply >+ */ >+ protected void updateStatus(IStatus status) { >+ fCurrStatus= status; >+ setPageComplete(!status.matches(IStatus.ERROR)); >+ if (fPageVisible) >+ StatusUtil.applyToStatusLine(this, status); >+ } >+ >+ /* >+ * @see WizardPage#becomesVisible >+ */ >+ public void setVisible(boolean visible) { >+ super.setVisible(visible); >+ fPageVisible= visible; >+ // policy: wizards are not allowed to come up with an error message >+ if (visible && fCurrStatus.matches(IStatus.ERROR)) { >+ StatusInfo status= new StatusInfo(); >+ status.setError(""); //$NON-NLS-1$ >+ fCurrStatus= status; >+ } >+ updateStatus(fCurrStatus); >+ } >+ >+ private IJavaProject chooseProject() { >+ IJavaProject[] projects; >+ try { >+ projects= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects(); >+ } catch (JavaModelException e) { >+ JavaPlugin.log(e); >+ projects= new IJavaProject[0]; >+ } >+ >+ ILabelProvider labelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT); >+ ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider); >+ dialog.setTitle(FatJarPackagerMessages.FatJarPackageWizardPage_ChooseProjectDialog_title); >+ dialog.setMessage(FatJarPackagerMessages.FatJarPackageWizardPage_ChooseProjectDialog_description); >+ dialog.setElements(projects); >+ dialog.setInitialSelections(new Object[] { fCurrJProject }); >+ dialog.setHelpAvailable(false); >+ if (dialog.open() == Window.OK) { >+ return (IJavaProject)dialog.getFirstResult(); >+ } >+ return null; >+ } >+ > } >Index: ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackagerMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackagerMessages.java,v >retrieving revision 1.4 >diff -u -r1.4 FatJarPackagerMessages.java >--- ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackagerMessages.java 11 Sep 2008 11:59:55 -0000 1.4 >+++ ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarPackagerMessages.java 17 Sep 2008 18:46:07 -0000 >@@ -10,6 +10,7 @@ > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 211045 [jar application] program arguments are ignored > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 213638 [jar exporter] create ANT build file for current settings >+ * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 246080 [jar exporter] use current project > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.jarpackagerfat; > >@@ -38,6 +39,8 @@ > public static String FatJarPackageWizardPage_antScriptLocation_text; > public static String FatJarPackageWizardPage_antScriptLocationBrowse_text; > public static String FatJarPackageWizardPage_error_missingClassFile; >+ public static String FatJarPackageWizardPage_projectBrowse_text; >+ public static String FatJarPackageWizardPage_projectNameLabel_text; > public static String FatJarPackageWizard_IPIssueDialog_message; > > public static String FatJarPackageWizard_IPIssueDialog_title; >@@ -47,7 +50,7 @@ > public static String FatJarPackageWizardPage_warning_launchConfigContainsVMArgs; > public static String FatJarPackageWizardPage_error_noMainMethod; > public static String FatJarPackageWizardPage_error_ant_script_generation_failed; >- >+ public static String FatJarPackageWizardPage_error_noLaunchConfigSelected; > public static String FatJarPackageWizardPage_error_antScriptLocationMissing; > public static String FatJarPackageWizardPage_error_antScriptLocationIsDir; > public static String FatJarPackageWizardPage_error_antScriptLocationUnwritable; >@@ -55,6 +58,15 @@ > public static String FatJarPackageWizardPage_LaunchConfigurationWithoutMainType_warning; > public static String FatJarPackageWizardPage_description; > >+ public static String FatJarPackageWizardPage_error_EnterProjectName; >+ public static String FatJarPackageWizardPage_error_InvalidProjectPath; >+ public static String FatJarPackageWizardPage_error_NotAJavaProject; >+ public static String FatJarPackageWizardPage_error_ProjectNotExists; >+ public static String FatJarPackageWizardPage_error_ProjectNotOpen; >+ >+ public static String FatJarPackageWizardPage_ChooseProjectDialog_title; >+ public static String FatJarPackageWizardPage_ChooseProjectDialog_description; >+ > public static String FatJarPackage_confirmCreate_title; > > public static String FatJarPackageAntScript_confirmCreate_message; >Index: ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarAntExporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarAntExporter.java,v >retrieving revision 1.4 >diff -u -r1.4 FatJarAntExporter.java >--- ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarAntExporter.java 11 Sep 2008 11:59:55 -0000 1.4 >+++ ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarAntExporter.java 17 Sep 2008 18:46:05 -0000 >@@ -180,13 +180,13 @@ > > /** > * Create an ANT script to outputStream. >- * >+ * > * @param outputStream to write ANT script to > * @param projectName base project for informational purpose only > * @param absJarfile path to the destination > * @param mainClass the optional main-class > * @param sourceInfos array of sources >- * @throws IOException >+ * @throws IOException if wrong XML is read > */ > private void buildANTScript(OutputStream outputStream, String projectName, IPath absJarfile, String mainClass, SourceInfo[] sourceInfos) throws IOException { >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
daniel_megert
:
review-
Actions:
View
|
Diff
Attachments on
bug 246080
:
112805