/** copied from PropertyAndPreferencePage */ private static void applyToStatusLine(DialogPage page, IStatus status) { String message = status.getMessage(); if (message != null && message.length() == 0) { message = null; } switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null); break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: page.setMessage(null); page.setErrorMessage(message); break; } }
private void update () { final String filterType = this.filterTypeEntry.getText (); final String filterData = this.filterEntry.getText (); boolean warning = false; if ( "".equals ( filterType ) ) { setPageComplete ( false ); setMessage ( "Select a filter type", DialogPage.ERROR ); return; } if ( "".equals ( filterData ) ) { setMessage ( "Empty filter string might be a problem", DialogPage.WARNING ); warning = true; } if ( !warning ) { setMessage ( null ); } setPageComplete ( true ); }
/** * Applies the status to the status line of a dialog page. */ private static void applyToStatusLine(DialogPage page, IStatus status) { String message = Status.OK_STATUS.equals(status) ? null : status.getMessage(); switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null); break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: if (message != null && message.length() == 0) { message = null; } page.setMessage(null); page.setErrorMessage(message); break; } }
/** * Convenience method to set a validation message on {@link DialogPage} from the result of calling * {@link #validateMavenSettings()}. * * @return {@code true} if no validation message was set; {@code false} otherwise * * @see #validateMavenSettings() */ public boolean setValidationMessage(DialogPage page) { IStatus status = validateMavenSettings(); if (status.isOK()) { return true; } if (IStatus.ERROR == status.getSeverity()) { page.setErrorMessage(status.getMessage()); } else if (IStatus.WARNING == status.getSeverity()) { page.setMessage(status.getMessage(), IMessageProvider.WARNING); } else if (IStatus.INFO == status.getSeverity()) { page.setMessage(status.getMessage(), IMessageProvider.INFORMATION); } return false; }
/** * Add a status bar message. * * @param page * @param status */ protected static void applyToStatusLine(DialogPage page, IStatus status) { String errorMessage = null; String warningMessage = null; String statusMessage = status.getMessage(); if (statusMessage.length() > 0) { if (status.matches(IStatus.ERROR)) { errorMessage = statusMessage; } else if (!status.isOK()) { warningMessage = statusMessage; } } page.setErrorMessage(errorMessage); page.setMessage(warningMessage, status.getSeverity()); }
/** * Applies the status to the status line of a dialog page. * * @param page the dialog page * @param status the status */ public static void applyToStatusLine(DialogPage page, IStatus status) { String message = status.getMessage(); switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null); break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: if (message.length() == 0) { message = null; } page.setMessage(null); page.setErrorMessage(message); break; } }
/** * Applies the status to the status line of a dialog page. */ public static void applyToStatusLine(DialogPage page, IStatus status) { String message= Status.OK_STATUS.equals(status) ? null : status.getMessage(); switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null); break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: if (message.length() == 0) { message= null; } page.setMessage(null); page.setErrorMessage(message); break; } }
/** * This should be the ONLY way to notify the wizard page whether the page is * complete or not, as well as display any error or warning messages. * * <p/> * * The wizard page will only be complete if it receives an OK status. * * <p/> * * It is up to the caller to correctly set the OK state of the page in case * it sets a non-OK status, and the non-OK status gets resolved. * * @param updateButtons true if force the wizard button states to be * refreshed. NOTE that if true, it is up to the caller to ensure that the * wizard page has been added to the wizard , and the wizard page is * visible. * @param status if status is OK, the wizard can complete. False otherwise. */ protected void update(boolean updateButtons, IStatus status) { if (status == null) { status = Status.OK_STATUS; } if (status.isOK()) { setErrorMessage(null); } else if (status.getSeverity() == IStatus.ERROR) { setErrorMessage(status.getMessage() != null ? status.getMessage() : Messages.PartsWizardPage_ERROR_UNKNOWN); } else if (status.getSeverity() == IStatus.INFO) { setMessage(status.getMessage(), DialogPage.INFORMATION); } else if (status.getSeverity() == IStatus.WARNING) { setMessage(status.getMessage(), DialogPage.WARNING); } // Container or page may not be available when update request is received if (updateButtons && getWizard() != null && getWizard().getContainer() != null && getWizard().getContainer().getCurrentPage() != null) { getWizard().getContainer().updateButtons(); } }
private static void applyToStatusLine(DialogPage page, IStatus status) { String message = status.getMessage(); if (message != null && message.length() == 0) { message = null; } switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null); break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: page.setMessage(null); page.setErrorMessage(message); break; } }
/** * Add an extra check to validate if the directory inside the project exists or not. We don't want to create a new * directory for the user... * */ @Override public boolean validatePage() { boolean valid = super.validatePage(); if (valid) { // We need to check that the selected directory does exist, otherwise we need to set an error... IResource r = ResourcesPlugin.getWorkspace().getRoot().findMember(getContainerFullPath()); if (r == null || !r.exists() || (r.getType() & IResource.FILE) != 0) { setMessage("The directory specified does not exist or is not a valid folder", DialogPage.ERROR); valid = false; } } return valid; }
/** * Copy from StatusUtil * Applies the status to the status line of a dialog page. */ public static void applyToStatusLine(DialogPage page, IStatus status) { String message = status.getMessage(); switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null); break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: if (message.length() == 0) { message = null; } page.setMessage(null); page.setErrorMessage(message); break; } }
/** * Applies the status to the status line of a dialog page. * @param page the dialog page * @param status the status to apply */ public static void applyToStatusLine(DialogPage page, IStatus status) { String message= status.getMessage(); if (message != null && message.length() == 0) { message= null; } switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null); break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: page.setMessage(null); page.setErrorMessage(message); break; } }
/** * Applies the status to the status line of a dialog page. */ public static void applyToStatusLine(DialogPage page, IStatus status) { String message= status.getMessage(); switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null); break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: if (message.length() == 0) { message= null; } page.setMessage(null); page.setErrorMessage(message); break; } }
/** * Applies the status to the status line of a dialog page. * * @param page the dialog page * @param status the status */ public void applyToStatusLine(DialogPage page, IStatus status) { String message = status.getMessage(); switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null); break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: if (message.length() == 0) { message = null; } page.setMessage(null); page.setErrorMessage(message); break; } }
/** * Applies the status to the status line of a dialog page. * @param page the dialog page * @param status the status to apply */ public static void applyToStatusLine(DialogPage page, IStatus status) { String message = status.getMessage(); if (message != null && message.length() == 0) { message = null; } switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null); break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: page.setMessage(null); page.setErrorMessage(message); break; } }
/** * Sets the error message for the active wizard page. * * Note that this method has no effect if the current page doesn't support error messages. */ private void setErrorMessage(String message) { IWizardContainer container = getContainer(); if (container != null) { IWizardPage currentPage = container.getCurrentPage(); if (currentPage instanceof DialogPage) { ((DialogPage) currentPage).setErrorMessage(message); } } }
private void validateFile() { File file = new File(compilerPathFieldEditor.getStringValue()); if (file.exists() && file.isFile() && file.canExecute() && (file.getName().contains("solc") || file.getName().contains("solcjs"))) { if (file.getName().contains("solcjs")) { setMessage("Use of 'solcjs' is discuraged!", DialogPage.WARNING); } } else { setValid(false); setErrorMessage("Path must point to 'solc' or 'solcjs' executable"); } }
private void showProblem(String errorMessage) { for (IWizardPage page : getPages()) { if (page instanceof DialogPage) { DialogPage dpage = (DialogPage) page; dpage.setErrorMessage(errorMessage); } } }
@Before public void setup() { page = new DialogPage() { @Override public void createControl(Composite parent) { throw new UnsupportedOperationException(); } }; target = new DialogPageMessageTarget(page); }
@Test public void clear() { target.setError("error_msg"); target.clear(); assertNull(page.getMessage()); assertEquals(DialogPage.NONE, page.getMessageType()); }
/** * Applies the status to the status line of a dialog page. */ public static void applyToStatusLine(DialogPage page, IStatus status) { String message = status.getMessage(); switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null); break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: if (message.length() == 0) { message = null; } page.setMessage(null); page.setErrorMessage(message); break; } }
public BaseOrganizationComposite(Composite parent, int style, DialogPage dialogPage, SalesforceEndpoints salesforceEndpoints) { super(parent, style); this.dialogPage = dialogPage; this.salesforceEndpoints = salesforceEndpoints; initialize(); pack(); }
/** * Applies the status to the status line of a dialog page. * * @param page * the dialog page * @param status * the status to apply */ public static void applyToStatusLine( DialogPage page, IStatus status ) { if ( status == null ) { page.setMessage( null, IMessageProvider.NONE ); page.setErrorMessage( null ); return; } String message = status.getMessage( ); if ( message != null && message.length( ) == 0 ) { message = null; } switch ( status.getSeverity( ) ) { case IStatus.OK : page.setMessage( message, IMessageProvider.NONE ); page.setErrorMessage( null ); break; case IStatus.WARNING : page.setMessage( message, IMessageProvider.WARNING ); page.setErrorMessage( null ); break; case IStatus.INFO : page.setMessage( message, IMessageProvider.INFORMATION ); page.setErrorMessage( null ); break; default : page.setMessage( null ); page.setErrorMessage( message ); break; } }
public static void applyStatusToPage(DialogPage page, IStatus status) { String message = StringUtil.emptyAsNull(status.getMessage()); if(status.getSeverity() == IStatus.ERROR) { page.setErrorMessage(message); page.setMessage(null); } else { page.setErrorMessage(null); page.setMessage(message, severityToMessageType(status)); } }
@Test public void setInfo() { target.setInfo("info_msg"); assertEquals("info_msg", page.getMessage()); assertEquals(DialogPage.INFORMATION, page.getMessageType()); }
@Test public void setError() { target.setError("error_msg"); assertEquals("error_msg", page.getMessage()); assertEquals(DialogPage.ERROR, page.getMessageType()); }
public static SetMessageRunnable create(DialogPage page, String message, int level) { return new SetMessageRunnable(page, message, level); }
private SetMessageRunnable(DialogPage page, String message, int level) { this.page = page; this.message = message; this.level = level; }
public DialogPageMessageTarget(DialogPage target) { this.target = target; }
@Override public void setInfo(String message) { target.setMessage(message, DialogPage.INFORMATION); }
@Override public void setError(String message) { target.setMessage(message, DialogPage.ERROR); }
@Override public void init(IWorkbench workbench, IStructuredSelection selection) { this.workbench = workbench; final WizardNewFileCreationPage page = new WizardNewFileCreationPage("filenameSelection", selection) { @Override protected boolean validatePage() { if (!super.validatePage()) { return false; } final IPath path = this.getContainerFullPath(); final IResource member = ResourcesPlugin.getWorkspace().getRoot().findMember(path); if (member instanceof IProject) { setMessage("The architecture can't be created directly " + "in a project. Please select a folder.", DialogPage.ERROR); return false; } return true; } // We don't want "Advanced" section to be displayed. @Override protected void createAdvancedControls(Composite parent) { // Does nothing, DO NOT REMOVE. Overwrites link related stuff } @Override protected IStatus validateLinkedResource() { // Does nothing, DO NOT REMOVE. Overwrites link related stuff return Status.OK_STATUS; } @Override protected void createLinkTarget() { // Does nothing, DO NOT REMOVE. Overwrites link related stuff } }; page.setFileExtension(TurnusExtensions.ARCHITECTURE); page.setDescription("Select a parent folder and a name for the new architecture."); page.setAllowExistingResources(false); // Fill the page with a filename, if user selected one if (!selection.isEmpty()) { final Object firstSel = selection.getFirstElement(); if (firstSel instanceof IFile) { final IFile selectedFile = (IFile) firstSel; final String fileName = selectedFile.getName(); final String ext = selectedFile.getFileExtension(); if (ext == null || ext.isEmpty()) { page.setFileName(fileName); } else { int idx = fileName.indexOf(ext); if (idx > 0) { page.setFileName(fileName.substring(0, idx - 1)); } } } } addPage(page); }
/** * Reports an error to the user * * @param message */ private void reportError(String message) { this.setPageComplete(false); this.setMessage(message, DialogPage.ERROR); }
/** * Reports a warning to the user * * @param message */ private void reportWarning(String message) { this.setPageComplete(true); this.setMessage(message, DialogPage.WARNING); }
/** * Creates the encoding field editor. * * @param composite the parent composite * @param string list with all controls */ private void encodingControl(Composite composite, String text) { Label label = new Label(composite, SWT.NONE); label.setText(text); label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); fEncodingEditorParent = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginWidth = 0; layout.marginHeight = 0; fEncodingEditorParent.setLayout(layout); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 3; gd.horizontalIndent += SwtUtil.getIndent(); fEncodingEditorParent.setLayoutData(gd); encEditor = new EncodingFieldEditor(SPELLING_USER_DICTIONARY_ENCODING, "", null, fEncodingEditorParent); //$NON-NLS-1$ PreferenceStore store = new PreferenceStore(); String defaultEncoding = ResourcesPlugin.getEncoding(); store.setDefault(SPELLING_USER_DICTIONARY_ENCODING, defaultEncoding); String encoding = store.getString(SPELLING_USER_DICTIONARY_ENCODING); if (encoding != null && encoding.length() > 0) store.setValue(SPELLING_USER_DICTIONARY_ENCODING, encoding); encEditor.setPreferenceStore(store); // Redirect status messages from the field editor to the status change listener DialogPage fakePage = new DialogPage() { public void createControl(Composite c) {} @Override public void setErrorMessage(String newMessage) { StatusInfo status = new StatusInfo(); if (newMessage != null) status.setError(newMessage); fEncodingFieldEditorStatus = status; fContext.statusChanged(StatusUtil .getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus })); } }; encEditor.setPage(fakePage); encEditor.load(); if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0) { encEditor.loadDefault(); } }
protected void setWizardInformation(String message) { wizardPage.setMessage(message, DialogPage.INFORMATION); }