/** 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; } }
protected void modelDestroyed(GenericDataModelEvent event) { if (getContainer().isDisposed()) { return; } updateTitle(); editorDirtyStateChanged(); String modelDestroyedMessage = getModelDestroyedMessage(); if (modelDestroyedMessage != null) { IManagedForm headerForm = getHeaderForm(); ScrolledForm scrolledForm = headerForm.getForm(); Form form = scrolledForm.getForm(); form.setMessage(modelDestroyedMessage, IMessageProvider.ERROR); } for (DataModelFormPage<M> page : _Pages) { page.modelDestroyed(event); } }
protected void update () { try { validate (); setMessage ( null, IMessageProvider.NONE ); setPageComplete ( this.mergeController.getLocalData () != null ); } catch ( final Exception e ) { setMessage ( e.getLocalizedMessage (), IMessageProvider.ERROR ); setPageComplete ( false ); } final Map<String, Map<String, Map<String, String>>> localData = this.mergeController.getLocalData (); if ( localData != null ) { this.dataLabel.setText ( String.format ( Messages.LocalDataPage_StatusLabelFormat, localData.size () ) ); } else { this.dataLabel.setText ( Messages.LocalDataPage_EmptyStatusLabelText ); } }
private void update () { final Button button = getButton ( OK ); try { setMessage ( Messages.LoginDialog_DefaultMessage, IMessageProvider.INFORMATION ); validate (); button.setEnabled ( true ); } catch ( final Exception e ) { button.setEnabled ( false ); setMessage ( e.getMessage (), IMessageProvider.ERROR ); } }
private void validatePipeline() { EPipeline pipeline = pipelineValue.getValue(); if(pipelineValue.getValue() == null) { this.pipelineValidValue.setValue(false); this.pipelineStatusValue.setValue("No pipeline value"); form.setMessage("No pipeline value", IMessageProvider.ERROR); } else { String msg = context.get(NLPService.class).validatePipeline(pipeline); this.pipelineStatusValue.setValue(msg); this.pipelineValidValue.setValue(msg == null); if(this.pipelineStatusValue.getValue() == null) form.setMessage("Ok", IMessageProvider.NONE); else form.setMessage(this.pipelineStatusValue.getValue(), IMessageProvider.ERROR); } }
public void validate(Object value) { if (value != null && startsWithChar.matcher(value.toString()).matches()) { if(resourceService.canCreatePipeline(value.toString())) { setMessage("Ok", IMessageProvider.NONE); getButton(IDialogConstants.OK_ID).setEnabled(true); } else { setMessage("Pipeline " + value + " already exists", IMessageProvider.ERROR); getButton(IDialogConstants.OK_ID).setEnabled(false); } } else { getButton(IDialogConstants.OK_ID).setEnabled(false); setMessage(value + " is not a valid file name. Valid chars : letters, digits, - and _", IMessageProvider.ERROR); } getShell().redraw(); }
/** * 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; } }
@Override public void create() { super.create(); String title; String message; int type; if (anomalyCausingConstraints == null) { title = getTitleNoAnomaly(); message = getMessageNoAnomaly(); type = IMessageProvider.INFORMATION; } else { title = getTitleAnomalyExplanation(); message = getMessageAnomalyExplanation(); type = IMessageProvider.ERROR; } setTitle(title); setMessage(message, type); }
@Override public void create() { super.create(); String title; String message; int type; if (invalidContextValues == null && invalidDate == null) { title = TITLE_NO_INVALID_CONTEXT; message = MESSAGE_NO_INVALID_CONTEXT; type = IMessageProvider.INFORMATION; } else { title = TITLE_INVALID_CONTEXT; message = MESSAGE_INVALID_CONTEXT; type = IMessageProvider.ERROR; } setTitle(title); setMessage(message, type); }
public boolean isValid() { final ImportEclipseProject[] selectedProjects = getSelectedProjects(); if (selectedProjects.length == 0) { setMessage( Messages.getString("GitImportWizardSelectProjectsPage.NoEclipseProjectImportedWarningMessage"), //$NON-NLS-1$ IMessageProvider.WARNING); return true; } if (workspaceProjectNameCollision(selectedProjects)) { return false; } if (duplicateProjectNamesSelected(selectedProjects)) { return false; } setErrorMessage(null); setMessage(null); return true; }
@Override public IStatus getStatus() { // DialogPage has an unfortunately complex set of message possibilities String message = messages.getErrorMessage(); if (message != null) { return new Status(IStatus.ERROR, PLUGIN_ID, message); } int messageType = messages.getMessageType(); switch (messageType) { case IMessageProvider.INFORMATION: return new Status(IStatus.INFO, PLUGIN_ID, messages.getMessage()); case IMessageProvider.WARNING: return new Status(IStatus.WARNING, PLUGIN_ID, messages.getMessage()); case IMessageProvider.ERROR: return new Status(IStatus.ERROR, PLUGIN_ID, messages.getMessage()); default: return Status.OK_STATUS; } }
@Override protected Control createDialogArea(final Composite parent) { Composite dialogArea = (Composite) super.createDialogArea(parent); Composite container = new Composite(dialogArea, SWT.NONE); content = createDeployPreferencesPanel(container, project, loginService, getLayoutChangedHandler(), new ProjectRepository(googleApiFactory)); GridDataFactory.fillDefaults().grab(true, false).applyTo(content); // we pull in Dialog's content margins which are zeroed out by TitleAreaDialog GridDataFactory.fillDefaults().grab(true, true).applyTo(container); GridLayoutFactory.fillDefaults() .margins(LayoutConstants.getMargins().x, LayoutConstants.getMargins().y) .generateLayout(container); TitleAreaDialogSupport.create(this, content.getDataBindingContext()) .setValidationMessageProvider(new ValidationMessageProvider() { @Override public int getMessageType(ValidationStatusProvider statusProvider) { int type = super.getMessageType(statusProvider); setValid(type != IMessageProvider.ERROR); return type; } }); return dialogArea; }
/** * 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; }
@Test public void testErrorStatusResults() { page = new AreaBasedPreferencePage("test"); area1 = new TestPrefArea("pref1", "value", preferences); page.addArea(area1); show(page); assertTrue(page.isValid()); assertEquals(IMessageProvider.NONE, page.getMessageType()); area1.status = new Status(IStatus.ERROR, "foo", "message"); area1.fireValueChanged(TestPrefArea.IS_VALID, true, false); assertFalse(page.isValid()); assertEquals(IMessageProvider.ERROR, page.getMessageType()); assertEquals("message", page.getMessage()); }
@Test public void testStatusSeverityWarn() { // add three areas, status = OK, WARN, INFO; verify showing WARN setupAreas(); area3.status = new Status(IStatus.INFO, "foo", "info3"); area3.fireValueChanged(TestPrefArea.IS_VALID, true, false); assertTrue("should still be valid", page.isValid()); assertEquals(IMessageProvider.INFORMATION, page.getMessageType()); assertEquals("info3", page.getMessage()); area2.status = new Status(IStatus.WARNING, "foo", "warn2"); area2.fireValueChanged(TestPrefArea.IS_VALID, true, false); assertTrue("should still be valid", page.isValid()); assertEquals(IMessageProvider.WARNING, page.getMessageType()); assertEquals("warn2", page.getMessage()); }
private void setupAreas() { page = new AreaBasedPreferencePage("test"); area1 = new TestPrefArea("pref1", "value", preferences); area2 = new TestPrefArea("pref2", "value", preferences); area3 = new TestPrefArea("pref3", "value", preferences); page.addArea(area1); page.addArea(area2); page.addArea(area3); area1.status = Status.OK_STATUS; area2.status = Status.OK_STATUS; area3.status = Status.OK_STATUS; show(page); assertTrue(page.isValid()); assertEquals(IMessageProvider.NONE, page.getMessageType()); }
protected boolean checkPathname(String pathname, String target) { if (pathname.trim().isEmpty()) { page.setMessage("Missing pathname of " + target + " executable", IMessageProvider.ERROR); return false; } File file = new File(pathname); if (target != null) { if (!isValidExecutable(file.getPath(), target)) { page.setMessage("Invalid name of " + target + " executable", IMessageProvider.ERROR); return false; } } if (!file.isFile()) { page.setMessage("Invalid pathname of " + target + " executable", IMessageProvider.ERROR); return false; } return true; }
/** * 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; } }
@Override public void create() { super.create(); setTitle("Event Details"); String titleMessage = ""; titleMessage += "\tGeneration Time:\t" + TimeEncoding.toString(event.getGenerationTime()) + "\n"; titleMessage += "\tReception Time:\t" + TimeEncoding.toString(event.getReceptionTime()); int icon = IMessageProvider.NONE; if (event.getSeverity() == EventSeverity.ERROR) icon = IMessageProvider.ERROR; else if (event.getSeverity() == EventSeverity.WARNING) icon = IMessageProvider.WARNING; else if (event.getSeverity() == EventSeverity.INFO) icon = IMessageProvider.INFORMATION; setMessage(titleMessage, icon); }
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; } }
@Override public void create() { // TODO Auto-generated method stub super.create(); dialogArea.addListener(SWT.Traverse, new Listener() { @Override public void handleEvent(final Event e) { if (e.detail == SWT.TRAVERSE_ESCAPE) { e.doit = false; } } }); setTitle("Database Manager"); if (message != null) { setMessage(message, IMessageProvider.WARNING); } }
private boolean isValidLogin() { if (!authenticatedUserIsAdmin) { String passWord = oldPasswordText.getText().trim(); try { if (!userController.isValidAuthentication(user.getUserName(), passWord)) { setMessage("Old password not valid!", IMessageProvider.ERROR); return false; } } catch (Exception e) { logger.info(e); //FIXME abfangen wenn datenbank korrumpiert/nicht installiert/nicht gestartet wurde return false; } } String newPassword = newPasswordText.getText().trim(); if (!newPassword.equals(newPasswordTextRepeat.getText().trim())) { setMessage("New password not correctly repeated!", IMessageProvider.ERROR); return false; } return true; }
private boolean validateLogin() { try { final String salt = ServiceLocator.getInstance().getLoginService() .requestSaltForUserName(txtName.getText()); final String hashPassword = CryptoUtil.hashPassword(txtPassword.getText(), salt); final boolean loggedIn = ServiceLocator.getInstance().getLoginService().loginWithHash(txtName.getText(), hashPassword); if (!loggedIn) { setMessage("Name und Passwort stimmen nicht überein!", IMessageProvider.ERROR); return false; } setMessage("", IMessageProvider.NONE); //$NON-NLS-1$ return true; } catch (final ConnectException e) { if (e instanceof BadGatewayException) { setMessage("Proxy-Konfiguration fehlerhaft", IMessageProvider.ERROR); } else { setMessage(Messages.MESSAGE_ERROR_CONNECTION, IMessageProvider.WARNING); } } return false; }
@SuppressWarnings("incomplete-switch") private void updateStatusMessage( ValidationStatus validationStatus ) { if( visible ) { int messageType = IMessageProvider.NONE; String message = null; switch( validationStatus.getSeverity() ) { case ERROR: messageType = IMessageProvider.ERROR; message = validationStatus.getMessage(); break; case WARNING: messageType = IMessageProvider.WARNING; message = validationStatus.getMessage(); break; } setMessage( message, messageType ); setPageComplete( validationStatus.getSeverity() != Severity.ERROR ); } }
/** * Update the status of the page and save the fields. To have a valid status the two expression * must be not empty */ protected void updateStatus() { labelValue = label.getText(); lowExpressionValue = lowExpression.getExpression(); highExpressionValue = highExpression.getExpression(); backgroundValue = backgroundColor.getColor(); if (highExpression.getExpression() == null || highExpression.getExpression().getText().isEmpty()) { setMessage(Messages.NewMeterIntervalPage_9, IMessageProvider.ERROR); setPageComplete(false); } else if (lowExpression.getExpression() == null || lowExpression.getExpression().getText().isEmpty()) { setMessage(Messages.NewMeterIntervalPage_10, IMessageProvider.ERROR); setPageComplete(false); } else { setMessage(Messages.NewMeterIntervalPage_11, IMessageProvider.INFORMATION); setPageComplete(true); } }
/** * 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; } }
public void update() { if (controlMessages.isEmpty()) { decoration.setDescriptionText(null); decoration.hide(); } else { final ArrayList peers = createPeers(controlMessages); final int type = ((IMessage) peers.get(0)).getMessageType(); final String description = createDetails(createPeers(peers), true); if (type == IMessageProvider.ERROR) decoration.setImage(standardError.getImage()); else if (type == IMessageProvider.WARNING) decoration.setImage(standardWarning.getImage()); else if (type == IMessageProvider.INFORMATION) decoration.setImage(standardInformation.getImage()); decoration.setDescriptionText(description); decoration.show(); } }
/** * @return Returns the number of error messages */ @SuppressWarnings("unchecked") public int getErrorMessageCount() { int errors = 0; for (final Enumeration<ControlDecorator> enm = decorators.elements(); enm.hasMoreElements();) { final ControlDecorator dec = enm.nextElement(); final ArrayList<?> allMessages = dec.controlMessages; for (final Object object : allMessages) { if (object instanceof Message) { final Message message = (Message) object; if (message.getMessageType() == IMessageProvider.ERROR) { errors++; } } } } return errors; }
private void update(final ArrayList mergedList) { pruneControlDecorators(); if (scrolledForm.getHead().getBounds().height == 0 || mergedList.isEmpty() || mergedList == null) { scrolledForm.setMessage(null, IMessageProvider.NONE); return; } final ArrayList peers = createPeers(mergedList); final int maxType = ((IMessage) peers.get(0)).getMessageType(); String messageText; final IMessage[] array = (IMessage[]) peers.toArray(new IMessage[peers.size()]); if (peers.size() == 1 && ((Message) peers.get(0)).prefix == null) { // a single message final IMessage message = (IMessage) peers.get(0); messageText = message.getMessage(); scrolledForm.setMessage(messageText, maxType, array); } else { // show a summary message for the message // and list of errors for the details if (peers.size() > 1) messageText = Messages.bind(MULTIPLE_MESSAGE_SUMMARY_KEYS[maxType], new String[] { peers.size() + "" }); //$NON-NLS-1$ else messageText = SINGLE_MESSAGE_SUMMARY_KEYS[maxType]; scrolledForm.setMessage(messageText, maxType, array); } }
/** * 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; } }
public void updateMessage() { if (currentPage == null) { return; } pageMessage = currentPage.getMessage(); if (pageMessage != null && currentPage instanceof IMessageProvider) { pageMessageType = ((IMessageProvider) currentPage).getMessageType(); } else { pageMessageType = IMessageProvider.NONE; } if (pageMessage == null) { setMessage(pageDescription); } else { setMessage(pageMessage, pageMessageType); } setErrorMessage(currentPage.getErrorMessage()); }
public void updateMessage( ) { PropertyPage propertyPage = getCurrentPropertyPage( ); if ( propertyPage != null ) { String message = propertyPage.getMessage( ); int messageType = propertyPage.getMessageType( ); // if error message exists, it takes precedence over page's non-error message if ( messageType < IMessageProvider.ERROR ) { String errMessage = propertyPage.getErrorMessage(); if ( errMessage != null ) { message = errMessage; messageType = IMessageProvider.ERROR; } } setMessage( message, messageType ); } }
/** * This method should be called in the following occations: 1. The value of * selected driver is changed 2. The value of inputed URL is changed 3. When * the control is created 4. */ private void updateTestButton( ) { // Jdbc Url cannot be blank if ( isDriverClassBlank( ) || isURLBlank( ) ) { if( isJNDIBlank( ) ) { setMessage( EMPTY_DRIVER_CLASS_OR_URL, IMessageProvider.ERROR ); testButton.setEnabled( false ); } else { setMessage( DEFAULT_MESSAGE ); if ( !testButton.isEnabled( ) ) testButton.setEnabled( true ); } } else { setMessage( DEFAULT_MESSAGE ); if ( !testButton.isEnabled( ) ) testButton.setEnabled( true ); } }
@Override protected void addUserInputPages() { String message= null; int messageType= IMessageProvider.NONE; if(!getExtractConstantRefactoring().selectionAllStaticFinal()) { message= RefactoringMessages.ExtractConstantInputPage_selection_refers_to_nonfinal_fields; messageType= IMessageProvider.INFORMATION; } else { message= MESSAGE; messageType= IMessageProvider.NONE; } String[] guessedNames= getExtractConstantRefactoring().guessConstantNames(); String initialValue= guessedNames.length == 0 ? "" : guessedNames[0]; //$NON-NLS-1$ addPage(new ExtractConstantInputPage(message, messageType, initialValue, guessedNames)); }
/** * Create contents of the dialog. * @param parent */ @Override protected Control createDialogArea(Composite parent) { setTitle(title); setMessage("Select a class.", IMessageProvider.INFORMATION); Composite container = (Composite) super.createDialogArea(parent); container.setLayout(new GridLayout(1, false)); listViewer = new ListViewer(container, SWT.BORDER | SWT.V_SCROLL); list = listViewer.getList(); list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); initValues(); return container; }
/** * 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; } }
/** * Validate the state of the wizard based on the results of the listeners on * the various controls. */ protected void validateWizardState() { if (karafRuntimeWC == null) { wizard.setMessage("", IMessageProvider.ERROR); return; } final IStatus status = karafRuntimeWC.validate(null); if (status == null || status.isOK()) { wizard.setMessage(null, IMessageProvider.NONE); } else if (status.getSeverity() == IStatus.WARNING) { wizard.setMessage(status.getMessage(), IMessageProvider.WARNING); } else { wizard.setMessage(status.getMessage(), IMessageProvider.ERROR); } wizard.update(); }