@Override public void createControl(Composite parent) { initializeDialogUnits(parent); getNewFileLabel(), IDEWorkbenchMessages.WizardNewFileCreationPage_file, false, SIZING_CONTAINER_GROUP_HEIGHT); resourceGroup.setAllowExistingResources(initialAllowExistingResources); initialPopulateContainerNameField(); createAdvancedControls(topLevel); if (initialFileName != null) { resourceGroup.setResource(initialFileName); resourceGroup.setResourceExtension(initialFileExtension); validatePage(); setErrorMessage(null); setMessage(null); setControl(topLevel);
public void createControl(Composite parent) { super.createControl(parent); setPageComplete(true); }
@Override public boolean performFinish() { final IFile file = page.createNewFile(); if (file == null || !file.exists()) { return false; } getShell().getDisplay().asyncExec(new Runnable() { public void run() { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { IDE.openEditor(page, file, editorId); } catch (PartInitException e) { } } }); return true; }
/** * The <code>WizardNewFileCreationPage</code> implementation of this * <code>Listener</code> method handles all events and enablements for * controls on this page. Subclasses may extend. */ @Override public void handleEvent(Event event) { setPageComplete(validatePage()); }
@Override public void addPages() { super.addPages(); mainPage = new WizardNewFileCreationPage("newFilePage1", getSelection());//$NON-NLS-1$ mainPage.setTitle(ResourceMessages.FileResource_pageTitle); mainPage.setDescription(ResourceMessages.FileResource_description); addPage(mainPage); }
/** * Checks whether the linked resource target is valid. Sets the error * message accordingly and returns the status. * * @return IStatus validation result from the CreateLinkedResourceGroup */ protected IStatus validateLinkedResource() { IPath containerPath = resourceGroup.getContainerFullPath(); IPath newFilePath = containerPath.append(resourceGroup.getResource()); IFile newFileHandle = createFileHandle(newFilePath); IStatus status = linkedResourceGroup .validateLinkLocation(newFileHandle); if (status.getSeverity() == IStatus.ERROR) { if (firstLinkCheck) { setMessage(status.getMessage()); setErrorMessage(null); } else { setErrorMessage(status.getMessage()); } } else if (status.getSeverity() == IStatus.WARNING) { setMessage(status.getMessage(), WARNING); setErrorMessage(null); } return status; }
@Override protected boolean validatePage() { String filename = getFileName().trim(); // Verify the filename is non-empty if (filename.length() == 0) { // Reset previous error message set if any setErrorMessage(null); return false; } // Verify the file name does not begin with a dot if (filename.charAt(0) == '.') { setErrorMessage(PDEUIMessages.PDEWizardNewFileCreationPage_errorMsgStartsWithDot); return false; } // Perform default validation return super.validatePage(); }
advancedButton.setFont(linkedResourceParent.getFont()); advancedButton.setText(IDEWorkbenchMessages.showAdvanced); GridData data = setButtonLayoutData(advancedButton); data.horizontalAlignment = GridData.BEGINNING; advancedButton.setLayoutData(data); setPageComplete(validatePage()); firstLinkCheck = false; }, new CreateLinkedResourceGroup.IStringValue() {
final IFile newFileHandle = createFileHandle(newFilePath); final InputStream initialContents = getInitialContents(); createLinkTarget(); IFileStore store = EFS.getStore(resolvedPath); if (!store.fetchInfo().exists()) { MessageDialog dlg = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.WizardNewFileCreationPage_createLinkLocationTitle, null, MessageDialog .open(MessageDialog.ERROR, getContainer().getShell(), IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle, NLS MessageDialog .open(MessageDialog.ERROR, getContainer().getShell(), IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle, NLS .getUIInfoAdapter(getShell())); } catch (final ExecutionException e) { getContainer().getShell().getDisplay().syncExec( () -> { if (e.getCause() instanceof CoreException) { ErrorDialog
setupLinkedResourceTargetRecursiveFlag = true; try { if (isFilteredByParent()) { URI existingLink = linkedResourceGroup.getLinkTargetURI(); boolean setDefaultLinkValue = false; IPath containerPath = resourceGroup.getContainerFullPath(); IPath newFilePath = containerPath.append(resourceGroup.getResource()); IFile newFileHandle = createFileHandle(newFilePath); try { URI uri= newFileHandle.getPathVariableManager().convertToRelative(newFileHandle.getLocationURI(), false, null);
private boolean isFilteredByParent() { if ((linkedResourceGroup == null) || linkedResourceGroup.isEnabled()) return false; IPath containerPath = resourceGroup.getContainerFullPath(); if (containerPath == null) return false; String resourceName = resourceGroup.getResource(); if (resourceName == null) return false; if (resourceName.length() > 0) { IPath newFolderPath = containerPath.append(resourceName); IFile newFileHandle = createFileHandle(newFolderPath); IWorkspace workspace = newFileHandle.getWorkspace(); return !workspace.validateFiltered(newFileHandle).isOK(); } return false; }
/** * The framework calls this to see if the file is correct. */ @Override protected boolean validatePage() { if (super.validatePage()) { String extension = new Path(getFileName()).getFileExtension(); if (extension == null || !extension.equals("genmodel")) { setErrorMessage(ImporterPlugin.INSTANCE.getString("_UI_GeneratorModelFileNameMustEndWithGenModel_message")); return false; } else { genModelContainerPath = getContainerFullPath(); genModelFileName = getFileName(); return true; } } else { return false; } }
protected boolean validatePage() { String fullFileName = getFileName(); if (!extensionValidForContentType(fullFileName)) { setErrorMessage(NLS.bind(XMLWizardsMessages._ERROR_BAD_FILENAME_EXTENSION, getValidExtensions().toString())); return false; } // no fileExtension, let's check for this file with default file // extension fullFileName += defaultFileExtension; if ((getContainerFullPath() != null) && (getContainerFullPath().isEmpty() == false) && (getFileName().compareTo("") != 0)) //$NON-NLS-1$ { Path fullPath = new Path(getContainerFullPath().toString() + '/' + fullFileName); IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(fullPath); if (resource != null) { setErrorMessage(XMLWizardsMessages._ERROR_FILE_ALREADY_EXISTS); return false; } } // check for file should be case insensitive String sameName = existsFileAnyCase(fullFileName); if (sameName != null) { // ISSUE: is qualitifedFileName not needed, or is it supposed // to be used in error message? // String qualifiedFileName = // getContainerFullPath().toString() + '/' + fullFileName; setErrorMessage(XMLWizardsMessages._ERROR_FILE_ALREADY_EXISTS + " " + sameName); //$NON-NLS-1$ return false; } return super.validatePage(); }
public void createControl(Composite parent) { super.createControl(parent); PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaDebugHelpContextIds.NEW_SNIPPET_WIZARD_PAGE); } }
@Override public boolean performFinish() { IFile file = mainPage.createNewFile(); if (file == null) { return false; } selectAndReveal(file); // Open editor on new file. IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow(); try { if (dw != null) { IWorkbenchPage page = dw.getActivePage(); if (page != null) { IDE.openEditor(page, file, true); } } } catch (PartInitException e) { DialogUtil.openError(dw.getShell(), ResourceMessages.FileResource_errorMessage, e.getMessage(), e); } return true; } }
boolean retValue= super.validatePage();
public void createControl(Composite parent) { // inherit default container and name specification widgets super.createControl(parent); this.setFileName(computeDefaultFileName()); setPageComplete(validatePage()); }
protected boolean validatePage() { Path newName = new Path(getFileName()); String fullFileName = getFileName(); String extension = newName.getFileExtension(); if (extension == null || !extension.equalsIgnoreCase("xsd")) { setErrorMessage(XSDEditorPlugin.getXSDString("_ERROR_FILENAME_MUST_END_XSD")); return false; } else { setErrorMessage(null); } // check for file should be case insensitive String sameName = existsFileAnyCase(fullFileName); if (sameName != null) { setErrorMessage(XSDEditorPlugin.getPlugin().getString("_ERROR_FILE_ALREADY_EXISTS", sameName)); //$NON-NLS-1$ return false; } return super.validatePage(); }
public void createControl(Composite parent) { // inherit default container and name specification widgets super.createControl(parent); this.setFileName(computeDefaultFileName()); setPageComplete(validatePage()); }
protected boolean validatePage() { boolean valid= super.validatePage(); if (!valid) return false;