/** * @deprecated Use {@link #getRunnable(Shell, IClasspathEntry, IJavaProject, IPath)} */ public IRunnableWithProgress getRunnable(final Shell shell) { return getRunnable(shell, getNewEntry(), fProject, fContainerPath); }
/** * Creates an instance of the SourceAttachmentDialog. After * <code>open</code>, the edited paths can be accessed from * the classpath entry returned by <code>getResult</code> * @param parent Parent shell for the dialog * @param entry The entry to edit. * @param canEditEncoding whether the source attachment encoding can be edited */ public SourceAttachmentDialog(Shell parent, IClasspathEntry entry, boolean canEditEncoding) { super(parent); IStatusChangeListener listener= new IStatusChangeListener() { @Override public void statusChanged(IStatus status) { updateStatus(status); } }; fSourceAttachmentBlock= new SourceAttachmentBlock(listener, entry, canEditEncoding); setTitle(NewWizardMessages.SourceAttachmentDialog_title); }
private void doStatusLineUpdate() { IStatus status; if (isVariableEntry()) { // set the resolved path for variable jars if (fFullPathResolvedLabel != null) { fFullPathResolvedLabel.setText(getResolvedLabelString()); } fVariableFileNameField.enableButton(canBrowseFileName()); status= fVariableNameStatus; } else { boolean isWorkSpace= fWorkspaceRadio.isSelected(); if (isWorkSpace) { fWorkspaceFileNameField.enableButton(canBrowseFileName()); status= fWorkspaceNameStatus; } else { fExternalFileNameField.enableButton(canBrowseFileName()); status= fExternalNameStatus; } } fContext.statusChanged(status); }
private void attachmentChangeControlPressed(DialogField field) { if (field == fFileNameField) { IPath jarFilePath= isVariableEntry() ? chooseExtension() : chooseExtJarFile(); if (jarFilePath != null) { fFileNameField.setText(jarFilePath.toString()); } } }
private void attachmentDialogFieldChanged(DialogField field) { if (field == fVariableFileNameField) { fVariableNameStatus= updateFileNameStatus(fVariableFileNameField); } else if (field == fWorkspaceFileNameField) { fWorkspaceNameStatus= updateFileNameStatus(fWorkspaceFileNameField); } else if (field == fExternalFileNameField) { fExternalNameStatus= updateFileNameStatus(fExternalFileNameField); } else if (field == fExternalFolderButton) { IPath folderPath= chooseExtFolder(); if (folderPath != null) { fExternalFileNameField.setText(folderPath.toString()); } return; } doStatusLineUpdate(); }
private IPath chooseExtension() { IPath currPath= getFilePath(); if (currPath.segmentCount() == 0) { currPath= fEntry.getPath(); } IPath resolvedPath= getResolvedPath(currPath); File initialSelection= resolvedPath != null ? resolvedPath.toFile() : null; String currVariable= currPath.segment(0); JARFileSelectionDialog dialog= new JARFileSelectionDialog(getShell(), false, true, false); dialog.setTitle(NewWizardMessages.SourceAttachmentBlock_extvardialog_title); dialog.setMessage(NewWizardMessages.SourceAttachmentBlock_extvardialog_description); dialog.setInput(fFileVariablePath.toFile()); dialog.setInitialSelection(initialSelection); if (dialog.open() == Window.OK) { File result= (File) dialog.getResult()[0]; IPath returnPath= Path.fromOSString(result.getPath()).makeAbsolute(); return modifyPath(returnPath, currVariable); } return null; }
private void attachmentDialogFieldChanged(DialogField field) { if (field == fFileNameField) { fNameStatus= updateFileNameStatus(); } else if (field == fWorkspaceButton) { IPath jarFilePath= chooseInternal(); if (jarFilePath != null) { fFileNameField.setText(jarFilePath.toString()); } return; } else if (field == fExternalFolderButton) { IPath folderPath= chooseExtFolder(); if (folderPath != null) { fFileNameField.setText(folderPath.toString()); } return; } doStatusLineUpdate(); }
private IPath chooseExtFolder() { IPath currPath= getFilePath(); if (currPath.segmentCount() == 0) { currPath= fEntry.getPath(); } if (ArchiveFileFilter.isArchivePath(currPath, true)) { currPath= currPath.removeLastSegments(1); } DirectoryDialog dialog= new DirectoryDialog(getShell()); dialog.setMessage(NewWizardMessages.SourceAttachmentBlock_extfolderdialog_message); dialog.setText(NewWizardMessages.SourceAttachmentBlock_extfolderdialog_text); dialog.setFilterPath(currPath.toOSString()); String res= dialog.open(); if (res != null) { return Path.fromOSString(res).makeAbsolute(); } return null; }
private void attachmentChangeControlPressed(DialogField field) { if (field == fWorkspaceFileNameField) { IPath jarFilePath= chooseInternal(); if (jarFilePath != null) { fWorkspaceFileNameField.setText(jarFilePath.toString()); } } else if (field == fExternalFileNameField) { IPath jarFilePath= chooseExtJarFile(); if (jarFilePath != null) { fExternalFileNameField.setText(jarFilePath.toString()); } } else if (field == fVariableFileNameField) { IPath jarFilePath= chooseExtension(); if (jarFilePath != null) { fVariableFileNameField.setText(jarFilePath.toString()); } } }
private String getResolvedLabelString() { IPath resolvedPath= getResolvedPath(getFilePath()); if (resolvedPath != null) { return BasicElementLabels.getPathLabel(resolvedPath, true); } return ""; //$NON-NLS-1$ }
fEntry= entry; fSourceAttachmentBlock= new SourceAttachmentBlock(this, entry); return fSourceAttachmentBlock.createControl(composite); } catch (CoreException e) { JavaPlugin.log(e);
protected void applySourceAttachment(Shell shell, IClasspathEntry newEntry, IJavaProject project, IPath containerPath, boolean isReferencedEntry) { try { IRunnableWithProgress runnable= SourceAttachmentBlock.getRunnable(shell, newEntry, project, containerPath, isReferencedEntry); PlatformUI.getWorkbench().getProgressService().run(true, true, runnable); } catch (InvocationTargetException e) { String title= JavaEditorMessages.SourceAttachmentForm_attach_error_title; String message= JavaEditorMessages.SourceAttachmentForm_attach_error_message; ExceptionHandler.handle(e, shell, title, message); } catch (InterruptedException e) { // cancelled } }
private void doStatusLineUpdate() { fFileNameField.enableButton(canBrowseFileName()); // set the resolved path for variable jars if (fFullPathResolvedLabel != null) { fFullPathResolvedLabel.setText(getResolvedLabelString()); } IStatus status= StatusUtil.getMostSevere(new IStatus[] { fNameStatus }); fContext.statusChanged(status); }
/** * Gets the source attachment path chosen by the user * @return the source attachment path */ public IPath getSourceAttachmentPath() { return (getFilePath().segmentCount() == 0) ? null : getFilePath(); }
/** * Creates the controls for the source attachment configuration. * * @param composite the parent composite * @return the control */ protected Control createSourceAttachmentControls(Composite composite) { return fSourceAttachmentBlock.createControl(composite); }
private IPath chooseExtension() { IPath currPath= getFilePath(); if (currPath.segmentCount() == 0) { currPath= fEntry.getPath(); } IPath resolvedPath= getResolvedPath(currPath); File initialSelection= resolvedPath != null ? resolvedPath.toFile() : null; String currVariable= currPath.segment(0); JARFileSelectionDialog dialog= new JARFileSelectionDialog(getShell(), false, true, false); dialog.setTitle(NewWizardMessages.SourceAttachmentBlock_extvardialog_title); dialog.setMessage(NewWizardMessages.SourceAttachmentBlock_extvardialog_description); dialog.setInput(fFileVariablePath.toFile()); dialog.setInitialSelection(initialSelection); if (dialog.open() == Window.OK) { File result= (File) dialog.getResult()[0]; IPath returnPath= Path.fromOSString(result.getPath()).makeAbsolute(); return modifyPath(returnPath, currVariable); } return null; }
private IPath chooseExtFolder() { IPath currPath= getFilePath(); if (currPath.segmentCount() == 0) { currPath= fEntry.getPath(); } if (ArchiveFileFilter.isArchivePath(currPath)) { currPath= currPath.removeLastSegments(1); } DirectoryDialog dialog= new DirectoryDialog(getShell()); dialog.setMessage(NewWizardMessages.SourceAttachmentBlock_extfolderdialog_message); dialog.setText(NewWizardMessages.SourceAttachmentBlock_extfolderdialog_text); dialog.setFilterPath(currPath.toOSString()); String res= dialog.open(); if (res != null) { return Path.fromOSString(res).makeAbsolute(); } return null; }
private void attachmentDialogFieldChanged(DialogField field) { if (field == fVariableFileNameField) { fVariableNameStatus= updateFileNameStatus(fVariableFileNameField); } else if (field == fWorkspaceFileNameField) { fWorkspaceNameStatus= updateFileNameStatus(fWorkspaceFileNameField); } else if (field == fExternalFileNameField) { fExternalNameStatus= updateFileNameStatus(fExternalFileNameField); } else if (field == fExternalFolderButton) { IPath folderPath= chooseExtFolder(); if (folderPath != null) { fExternalFileNameField.setText(folderPath.toString()); } return; } doStatusLineUpdate(); }
private void attachmentChangeControlPressed(DialogField field) { if (field == fWorkspaceFileNameField) { IPath jarFilePath= chooseInternal(); if (jarFilePath != null) { fWorkspaceFileNameField.setText(jarFilePath.toString()); } } else if (field == fExternalFileNameField) { IPath jarFilePath= chooseExtJarFile(); if (jarFilePath != null) { fExternalFileNameField.setText(jarFilePath.toString()); } } else if (field == fVariableFileNameField) { IPath jarFilePath= chooseExtension(); if (jarFilePath != null) { fVariableFileNameField.setText(jarFilePath.toString()); } } }
private String getResolvedLabelString() { IPath resolvedPath= getResolvedPath(getFilePath()); if (resolvedPath != null) { return resolvedPath.toOSString(); } return ""; //$NON-NLS-1$ }