List of usage examples for org.eclipse.jface.wizard WizardPage setErrorMessage
@Override public void setErrorMessage(String newMessage)
WizardPage implementation of this method declared on DialogPage updates the container if this is the current page. From source file:com.android.ide.eclipse.adt.internal.assetstudio.ConfigureAssetSetPage.java
License:Open Source License
/** * Generate images using the given wizard state * * @param mValues the state to use// w ww.j av a 2 s . co m * @param previewOnly whether we are only generating previews * @param page if non null, a wizard page to write error messages to * @return a map of image objects */ public static Map<String, Map<String, BufferedImage>> generateImages(@NonNull CreateAssetSetWizardState mValues, boolean previewOnly, @Nullable WizardPage page) { // Map of ids to images: Preserve insertion order (the densities) Map<String, Map<String, BufferedImage>> categoryMap = new LinkedHashMap<String, Map<String, BufferedImage>>(); AssetType type = mValues.type; boolean trim = mValues.trim; BufferedImage sourceImage = null; switch (mValues.sourceType) { case IMAGE: { // Load the image // TODO: Only do this when the source image type is image String path = mValues.imagePath != null ? mValues.imagePath.getPath() : ""; if (path.length() == 0) { if (page != null) { page.setErrorMessage("Enter a filename"); } return Collections.emptyMap(); } if (!path.equals(DEFAULT_LAUNCHER_ICON)) { File file = new File(path); if (!file.isFile()) { if (page != null) { page.setErrorMessage(String.format("%1$s does not exist", file.getPath())); } return Collections.emptyMap(); } } if (page != null) { page.setErrorMessage(null); } try { sourceImage = mValues.getCachedImage(path, false); if (sourceImage != null) { if (trim) { sourceImage = ImageUtils.cropBlank(sourceImage, null, TYPE_INT_ARGB); } if (mValues.padding != 0) { sourceImage = Util.paddedImage(sourceImage, mValues.padding); } } } catch (IOException ioe) { if (page != null) { page.setErrorMessage(ioe.getLocalizedMessage()); } } break; } case CLIPART: { try { sourceImage = GraphicGenerator.getClipartImage(mValues.clipartName); boolean isActionBar = mValues.type == AssetType.ACTIONBAR; if (trim && !isActionBar) { sourceImage = ImageUtils.cropBlank(sourceImage, null, TYPE_INT_ARGB); } if (type.needsColors()) { RGB fg = mValues.foreground; int color = 0xFF000000 | (fg.red << 16) | (fg.green << 8) | fg.blue; Paint paint = new java.awt.Color(color); sourceImage = Util.filledImage(sourceImage, paint); } int padding = mValues.padding; if (padding != 0 && !isActionBar) { sourceImage = Util.paddedImage(sourceImage, padding); } } catch (IOException e) { AdtPlugin.log(e, null); return categoryMap; } break; } case TEXT: { String text = mValues.text; TextRenderUtil.Options options = new TextRenderUtil.Options(); options.font = mValues.getTextFont(); int color; if (type.needsColors()) { RGB fg = mValues.foreground; color = 0xFF000000 | (fg.red << 16) | (fg.green << 8) | fg.blue; } else { color = 0xFFFFFFFF; } options.foregroundColor = color; sourceImage = TextRenderUtil.renderTextImage(text, mValues.padding, options); if (trim) { sourceImage = ImageUtils.cropBlank(sourceImage, null, TYPE_INT_ARGB); } int padding = mValues.padding; if (padding != 0) { sourceImage = Util.paddedImage(sourceImage, padding); } break; } } GraphicGenerator generator = null; GraphicGenerator.Options options = null; switch (type) { case LAUNCHER: { generator = new LauncherIconGenerator(); LauncherIconGenerator.LauncherOptions launcherOptions = new LauncherIconGenerator.LauncherOptions(); launcherOptions.shape = mValues.shape; launcherOptions.crop = mValues.crop; launcherOptions.style = GraphicGenerator.Style.SIMPLE; RGB bg = mValues.background; int color = (bg.red << 16) | (bg.green << 8) | bg.blue; launcherOptions.backgroundColor = color; // Flag which tells the generator iterator to include a web graphic launcherOptions.isWebGraphic = !previewOnly; options = launcherOptions; break; } case MENU: generator = new MenuIconGenerator(); options = new GraphicGenerator.Options(); break; case ACTIONBAR: { generator = new ActionBarIconGenerator(); ActionBarIconGenerator.ActionBarOptions actionBarOptions = new ActionBarIconGenerator.ActionBarOptions(); actionBarOptions.theme = mValues.holoDark ? ActionBarIconGenerator.Theme.HOLO_DARK : ActionBarIconGenerator.Theme.HOLO_LIGHT; actionBarOptions.sourceIsClipart = (mValues.sourceType == SourceType.CLIPART); options = actionBarOptions; break; } case NOTIFICATION: { generator = new NotificationIconGenerator(); options = new NotificationIconGenerator.NotificationOptions(); break; } case TAB: generator = new TabIconGenerator(); options = new TabIconGenerator.TabOptions(); break; default: AdtPlugin.log(IStatus.ERROR, "Unsupported asset type: %1$s", type); return categoryMap; } options.sourceImage = sourceImage; IProject project = mValues.project; if (mValues.minSdk != -1) { options.minSdk = mValues.minSdk; } else { Pair<Integer, Integer> v = ManifestInfo.computeSdkVersions(project); options.minSdk = v.getFirst(); } String baseName = mValues.outputName; generator.generate(null, categoryMap, mValues, options, baseName); return categoryMap; }
From source file:com.bluexml.side.clazz.alfresco.reverse.action.wizard.ReverseFromAlfrescoWizard.java
License:Open Source License
@Override public boolean performFinish() { try {/*from ww w.ja va 2 s . co m*/ AbstractFieldsPage page = (AbstractFieldsPage) getPage(WelcomePage.ID); List<IResource> root = (List<IResource>) page.getFieldValue(WelcomePage.Fields.root.toString()); String output = page.getFieldValueString(WelcomePage.Fields.output.toString()); String libraryId = page.getFieldValueString(WelcomePage.Fields.library.toString()); final List<IFile> sideModels = new ArrayList<IFile>(); if (StringUtils.trimToNull(libraryId) != null) { // reverse may use some SIDE models (reversed) // import library ToolingUtils.importLibrary(libraryId); // models can be acceded in current workspace IConfigurationElement libFromLabel = ToolingUtils.getModelLibraryForId(libraryId); String projectId = libFromLabel.getAttribute(ToolingUtils.MODEL_LIBRARY_PROJECT_ID); IFolder iFolder = IFileHelper.getIFolder("/" + projectId + "/data"); sideModels.addAll(IFileHelper.getAllFiles(iFolder)); } final File sideModelRepo = new File(output); List<IFile> allFiles = new ArrayList<IFile>(); for (IResource entry : root) { IResource value = entry; if (value.getType() == IResource.FOLDER) { try { allFiles.addAll(IFileHelper.getAllFiles((IFolder) value)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (value.getType() == IResource.FILE) { allFiles.add((IFile) value); } } // Convert all Founded IFiles to System.io.File, and avoid duplicate entry Map<String, File> map = new HashMap<String, File>(); for (IFile iFile : allFiles) { map.put(iFile.toString(), IFileHelper.getFile(iFile)); } final Collection<File> files = map.values(); RunnableWithProgress myRunnable = new RunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { current = STATE.started; monitor.beginTask("reversing", -1); try { Reverser.executeReverse(files, sideModelRepo, sideModels, true); } catch (Exception e) { throw new InvocationTargetException(e, "Error while executing reverse"); } monitor.done(); current = STATE.finished; } }; this.getContainer().run(true, true, myRunnable); while (!myRunnable.getState().equals(RunnableWithState.STATE.finished)) { wait(1000); } } catch (Exception e) { e.printStackTrace(); WizardPage currentPage = (WizardPage) getContainer().getCurrentPage(); currentPage.setErrorMessage(e.getLocalizedMessage()); return false; } return true; }
From source file:com.bluexml.side.portal.alfresco.reverse.action.wizard.ReverseFromAlfrescoWizard.java
License:Open Source License
@Override public boolean performFinish() { try {/* w w w . j a v a 2 s .c o m*/ AbstractFieldsPage page = (AbstractFieldsPage) getPage(WelcomePage.ID); String root = page.getFieldValueString(WelcomePage.Fields.root.toString()); String output = page.getFieldValueString(WelcomePage.Fields.output.toString()); String libraryId = page.getFieldValueString(WelcomePage.Fields.library.toString()); final List<IFile> sideModels = new ArrayList<IFile>(); if (StringUtils.trimToNull(libraryId) != null) { // reverse may use some SIDE models (reversed) // import library ToolingUtils.importLibrary(libraryId); // models can be acceded in current workspace IConfigurationElement libFromLabel = ToolingUtils.getModelLibraryForId(libraryId); String projectId = libFromLabel.getAttribute(ToolingUtils.MODEL_LIBRARY_PROJECT_ID); IFolder iFolder = IFileHelper.getIFolder("/" + projectId + "/data"); sideModels.addAll(IFileHelper.getAllFiles(iFolder)); } final File sideModelRepo = new File(output); final File rootFile = new File(root); // Convert all Founded IFiles to System.io.File, and avoid duplicate entry RunnableWithProgress myRunnable = new RunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { current = STATE.started; monitor.beginTask("reversing", -1); try { if (rootFile.isFile()) { Portal createPortal = PortalFactory.eINSTANCE.createPortal(); LayoutReverser lr = new LayoutReverser(rootFile, createPortal, rootFile.getAbsolutePath()); lr.parse(); EResourceUtils.saveModel(new File( "/Users/davidabad/workspaces/runtime-New_configuration/Model-library-Alfresco-4.0.d-CE/portal/alfresco.portal"), createPortal); } else { ReversePortal rp = new ReversePortal(rootFile, sideModelRepo); rp.reverse(); rp.postChanges(); rp.persist(); } } catch (Exception e) { throw new InvocationTargetException(e, "Error while executing reverse"); } monitor.done(); current = STATE.finished; } }; this.getContainer().run(true, true, myRunnable); while (!myRunnable.getState().equals(RunnableWithState.STATE.finished)) { wait(1000); } } catch (Exception e) { e.printStackTrace(); WizardPage currentPage = (WizardPage) getContainer().getCurrentPage(); currentPage.setErrorMessage(e.getLocalizedMessage()); return false; } return true; }
From source file:com.iw.plugins.spindle.ui.wizards.TapestryWizardPage.java
License:Mozilla Public License
public void applyToStatusLine(WizardPage page, IStatus status) { if (status == null) { return;/* w w w . j a v a 2 s .c om*/ } String message = status.getMessage(); switch (status.getSeverity()) { case IStatus.OK: page.setErrorMessage(null); page.setMessage(message, NONE); break; case IStatus.WARNING: page.setErrorMessage(null); page.setMessage(message, WARNING); break; case IStatus.INFO: page.setErrorMessage(null); page.setMessage(message, INFORMATION); break; default: if (message.length() == 0) { message = null; } page.setErrorMessage(message); page.setMessage(null); break; } }
From source file:com.nokia.tools.variant.confml.ui.parts.ConfMLProjectPathsPart.java
License:Open Source License
public boolean validate(WizardPage page) { Map<IPath, String> locations = new HashMap<IPath, String>(); if (!locationGroup.confmlLocation.isValidPath()) { page.setErrorMessage("Confml Location: The specified value must have single path segment"); page.setPageComplete(false);/* w w w . j a v a 2s . c o m*/ return false; } locations.put(locationGroup.confmlLocation.getPath(), "Confml"); if (!locationGroup.implmlLocation.isValidPath()) { page.setErrorMessage("Implml Location: The specified value must have single path segment"); page.setPageComplete(false); return false; } if (locations.containsKey(locationGroup.implmlLocation.getPath())) { page.setErrorMessage("Implml Location: The paths must be different"); page.setPageComplete(false); return false; } locations.put(locationGroup.implmlLocation.getPath(), "Implml"); if (!locationGroup.contentLocation.isValidPath()) { page.setErrorMessage("Content Location: The specified value must have single path segment"); page.setPageComplete(false); return false; } if (locations.containsKey(locationGroup.contentLocation.getPath())) { page.setErrorMessage("Content Location: The paths must be different"); page.setPageComplete(false); return false; } locations.put(locationGroup.contentLocation.getPath(), "Content"); if (!locationGroup.metadataLocation.isValidPath()) { page.setErrorMessage("Metadata Location: The specified value must have single path segment"); page.setPageComplete(false); return false; } if (locations.containsKey(locationGroup.metadataLocation.getPath())) { page.setErrorMessage("Metadata Location: The paths must be different"); page.setPageComplete(false); return false; } return true; }
From source file:com.nokia.tools.variant.confml.ui.parts.ConfMLProjectSettingsPart.java
License:Open Source License
public boolean validate(WizardPage page) { final String layerID = getLayerID(); if (layerID.length() == 0) { page.setErrorMessage("Layer ID: a value must be specified"); page.setPageComplete(false);// w w w. ja va 2 s .c om propertiesGroup.idField.setRequired(true); propertiesGroup.idField.setErrorMessage(null); return false; } if (!VALIDATOR_ID_PATTERN.matcher(layerID).matches()) { page.setErrorMessage("Layer ID: ID must be in reverse DNS form"); page.setPageComplete(false); propertiesGroup.idField.setErrorMessage("Layer ID: ID must be in reverse DNS form"); return false; } propertiesGroup.idField.setRequired(false); propertiesGroup.idField.setErrorMessage(null); final String version = getLayerVersion(); if (version.length() == 0) { page.setErrorMessage("Layer Version: a value must be specified"); page.setPageComplete(false); propertiesGroup.versionField.setRequired(true); propertiesGroup.versionField.setErrorMessage(null); return false; } try { new Version(version); } catch (Exception ex) { page.setErrorMessage( "Layer Version: The specified version does not have the correct format (major.minor.micro.qualifier) or contains invalid characters"); page.setPageComplete(false); propertiesGroup.versionField.setRequired(false); propertiesGroup.versionField.setErrorMessage( "The specified version does not have the correct format (major.minor.micro.qualifier) or contains invalid characters"); return false; } propertiesGroup.versionField.setRequired(false); propertiesGroup.versionField.setErrorMessage(null); return true; }
From source file:com.siteview.mde.ui.templates.OptionTemplateSection.java
License:Open Source License
/** * Locates the page that this option is presented in and flags that the * option is required and is currently not set. The flagging is done by * setting the page incomplete and setting the error message that uses * option's message label./*from w w w . j a v a2s .c o m*/ * * @param option * the option that is required and currently not set */ protected void flagMissingRequiredOption(TemplateOption option) { WizardPage page = null; for (int i = 0; i < pages.size(); i++) { TemplatePage tpage = (TemplatePage) pages.get(i); ArrayList list = tpage.options; if (list.contains(option)) { page = tpage.page; break; } } if (page != null) { page.setPageComplete(false); String message = NLS.bind(MDEUIMessages.OptionTemplateSection_mustBeSet, option.getMessageLabel()); page.setErrorMessage(message); } }
From source file:com.siteview.mde.ui.templates.OptionTemplateSection.java
License:Open Source License
/** * Resets the current page state by clearing the error message and making * the page complete, thereby allowing users to flip to the next page. *//*from ww w . j a va 2 s. com*/ protected void resetPageState() { if (pages.size() == 0) return; WizardPage firstPage = ((TemplatePage) pages.get(0)).page; IWizardContainer container = firstPage.getWizard().getContainer(); WizardPage currentPage = (WizardPage) container.getCurrentPage(); currentPage.setErrorMessage(null); currentPage.setPageComplete(true); }
From source file:edu.buffalo.cse.green.dialogs.NewElementWizard.java
License:Open Source License
/** * Creates the controls for the name section of the page. * //from ww w.java 2 s. c om * @param composite - The parent of the modifier controls group. * @param columns - The number of columns to create. */ private void createNameControls(Composite composite, int columns) { Label nameLabel = new Label(composite, SWT.HORIZONTAL | SWT.LEFT | SWT.SHADOW_NONE); nameLabel.setText("&Name"); GridData data = new GridData(); nameLabel.setLayoutData(data); _name = new Text(composite, SWT.HORIZONTAL | SWT.LEFT | SWT.BORDER | SWT.SINGLE); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); data.horizontalSpan = columns - 1; _name.setLayoutData(data); if (isField()) _name.setText(VariableAffix.getAffixString(FieldPrefix)); else _name.setText(""); _name.setSelection(0, _name.getText().length()); final WizardPage page = this; _name.addKeyListener(new KeyListener() { /** * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent) */ public void keyPressed(KeyEvent e) { } /** * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent) */ public void keyReleased(KeyEvent e) { Pattern p = Pattern.compile("[_abcdefghijklmnopqrstuvwxyz]\\w*"); Matcher m = p.matcher(_name.getText()); if (!m.matches()) { page.setErrorMessage("Invalid name"); } else { page.setErrorMessage(null); } } }); page.setErrorMessage("Invalid name"); }
From source file:eu.geclipse.aws.ui.wizards.AWSAuthTokenWizard.java
License:Open Source License
@Override public boolean performFinish() { WizardPage currentPage = (WizardPage) getContainer().getCurrentPage(); if (currentPage == this.authTokenWizardPage) { if (!this.authTokenWizardPage.isValid()) { this.authTokenWizardPage.registerFormListener(); return false; }/*from ww w. java2s.c o m*/ } AWSAuthTokenDescription tokenDesc = this.authTokenWizardPage.getTokenDescription(); AWSKeyStoreCreationOperation op = new AWSKeyStoreCreationOperation(tokenDesc); try { getContainer().run(false, false, op); } catch (InvocationTargetException itExc) { Throwable cause = itExc.getCause(); ProblemDialog.openProblem(getShell(), Messages.getString("AWSAuthTokenWizard.problem_dialog_title"), //$NON-NLS-1$ Messages.getString("AWSAuthTokenWizard.problem_dialog_description"), //$NON-NLS-1$ cause); currentPage.setErrorMessage(cause.getLocalizedMessage()); } catch (InterruptedException intExc) { currentPage.setErrorMessage(intExc.getLocalizedMessage()); } String errorMessage = currentPage.getErrorMessage(); if (errorMessage == null || errorMessage.length() == 0) { return true; } return false; }