List of usage examples for org.eclipse.jface.dialogs IMessageProvider NONE
int NONE
To view the source code for org.eclipse.jface.dialogs IMessageProvider NONE.
Click Source Link
From source file:net.tourbook.ui.MessageRegion.java
License:Open Source License
/** * Show the new message in the message text and update the image. Base the background color on * whether or not there are errors.// ww w . j a va 2s.c o m * * @param newMessage * The new value for the message * @param newType * One of the IMessageProvider constants. If newType is IMessageProvider.NONE show * the title. * @see IMessageProvider */ public void updateText(final String newMessage, final int newType) { Image newImage = null; boolean showingError = false; switch (newType) { case IMessageProvider.NONE: hideRegion(); return; case IMessageProvider.INFORMATION: newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO); break; case IMessageProvider.WARNING: newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); break; case IMessageProvider.ERROR: newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); showingError = true; break; } if (newMessage == null) {//No message so clear the area hideRegion(); return; } showRegion(); // Any more updates required if (newMessage.equals(messageText.getText()) && newImage == messageImageLabel.getImage()) { return; } messageImageLabel.setImage(newImage); messageText.setText(newMessage); if (showingError) { setMessageColors(JFaceColors.getErrorBackground(messageComposite.getDisplay())); } else { lastMessageText = newMessage; setMessageColors(JFaceColors.getBannerBackground(messageComposite.getDisplay())); } }
From source file:org.apache.felix.sigil.eclipse.ui.internal.editors.project.VersionRangeComponent.java
License:Apache License
private void setVersions() { try {//from ww w. ja va 2 s .c o m if (specificButton.getSelection()) { if ("*".equals(specificText.getText())) { versions = VersionRange.ANY_VERSION; } else if (specificText.getText().trim().length() == 0) { versions = null; } else { Version v = VersionTable.getVersion(specificText.getText().trim()); versions = new VersionRange(false, v, v, false); } } else { Version min = VersionTable.getVersion(minimumText.getText()); Version max = "*".equals(maximumText.getText()) ? VersionRange.INFINITE_VERSION : VersionTable.getVersion(maximumText.getText()); versions = new VersionRange(!minInclusiveButton.getSelection(), min, max, !maxInclusiveButton.getSelection()); } fireValidationMessage(null, IMessageProvider.NONE); } catch (IllegalArgumentException e) { versions = null; fireValidationMessage("Invalid version", IMessageProvider.ERROR); } fireVersionChange(); }
From source file:org.apache.felix.sigil.ui.eclipse.ui.editors.project.VersionRangeComponent.java
License:Apache License
private void setVersions() { try {// w w w . ja v a 2s . co m if (specificButton.getSelection()) { if ("*".equals(specificText.getText())) { versions = VersionRange.ANY_VERSION; } else if (specificText.getText().trim().length() == 0) { versions = null; } else { Version v = Version.parseVersion(specificText.getText().trim()); versions = new VersionRange(false, v, v, false); } } else { Version min = Version.parseVersion(minimumText.getText()); Version max = "*".equals(maximumText.getText()) ? VersionRange.INFINITE_VERSION : Version.parseVersion(maximumText.getText()); versions = new VersionRange(!minInclusiveButton.getSelection(), min, max, !maxInclusiveButton.getSelection()); } fireValidationMessage(null, IMessageProvider.NONE); } catch (IllegalArgumentException e) { versions = null; fireValidationMessage("Invalid version", IMessageProvider.ERROR); } fireVersionChange(); }
From source file:org.becausecucumber.eclipse.plugin.ui.preference.searcherPage.ValidationResult.java
License:Open Source License
/** * Convert the status code of this validation results into an * IMessageProvider status code./*from w w w .j a v a 2 s . c o m*/ */ public int getMessageProviderStatus() { switch (status) { case IStatus.OK: return IMessageProvider.NONE; case IStatus.CANCEL: // There's no corresponding statis in IMessageProvider. Treat // cancelation like an error. return IMessageProvider.ERROR; case IStatus.ERROR: return IMessageProvider.ERROR; case IStatus.INFO: return IMessageProvider.INFORMATION; case IStatus.WARNING: return IMessageProvider.WARNING; default: // Shouldn't happen since all cases should be covered above... byt // anyhow return IMessageProvider.ERROR; } }
From source file:org.cloudfoundry.ide.eclipse.internal.server.ui.actions.CloudFoundryEditorAction.java
License:Open Source License
@Override public void run() { Job job = new Job(getJobName()) { @Override//from w w w . ja v a 2s .com protected IStatus run(IProgressMonitor monitor) { IStatus status = null; try { IModule module = editorPage.getMasterDetailsBlock().getCurrentModule(); status = performAction(monitor); if (status != null && status.isOK()) { return editorPage.refreshStates(module, area, monitor); } } catch (CoreException e) { if (shouldLogException(e)) { StatusManager.getManager().handle(new Status(Status.ERROR, CloudFoundryServerUiPlugin.PLUGIN_ID, "Failed to perform server editor action", e), StatusManager.LOG); } return new Status(Status.CANCEL, CloudFoundryServerUiPlugin.PLUGIN_ID, e.getMessage(), e); } return status; } }; job.addJobChangeListener(new JobChangeAdapter() { @Override public void done(final IJobChangeEvent event) { Display.getDefault().asyncExec(new Runnable() { public void run() { if (editorPage.isDisposed()) return; if (masterDetailsBlock.getMasterPart().getManagedForm().getForm().isDisposed()) return; masterDetailsBlock.refreshUI(area); IStatus status = event.getResult(); Throwable exception = status.getException(); if (!userAction) { return; } if (exception != null) { if (exception instanceof CoreException) { if (CloudUtil.isNotFoundException((CoreException) exception)) { display404Error(status); return; } if (userAction && CloudUtil.isWrongCredentialsException((CoreException) exception)) { CloudFoundryCredentialsWizard wizard = new CloudFoundryCredentialsWizard( editorPage.getCloudServer(), "Access to Cloud Foundry was denied. Make sure your Cloud Foundry credentials are correct."); WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard); if (dialog.open() == Dialog.OK) { CloudFoundryEditorAction.this.run(); return; } } } editorPage.setMessage(status.getMessage(), IMessageProvider.ERROR); } else { IModule currentModule = editorPage.getMasterDetailsBlock().getCurrentModule(); if (currentModule != null) { ApplicationModule appModule = editorPage.getCloudServer() .getApplication(currentModule); if (appModule != null && appModule.getErrorMessage() != null) { editorPage.setMessage(appModule.getErrorMessage(), IMessageProvider.ERROR); return; } } editorPage.setMessage(null, IMessageProvider.NONE); } } }); } }); IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) editorPage.getEditorSite() .getService(IWorkbenchSiteProgressService.class); if (service != null) { service.schedule(job, 0L, true); } else { job.schedule(); } }
From source file:org.cloudfoundry.ide.eclipse.internal.server.ui.editor.CloudFoundryApplicationsEditorPage.java
License:Open Source License
public void setMessage(String message, int messageType) { if (message == null) { sform.setMessage(null, IMessageProvider.NONE); } else {/* w w w. ja va2 s . com*/ sform.setMessage(message, messageType); } }
From source file:org.cloudfoundry.ide.eclipse.server.ui.internal.editor.CloudFoundryApplicationsEditorPage.java
License:Open Source License
public void setMessage(String message, int messageType) { String messageToDisplay = message; if (messageToDisplay == null) { sform.setMessage(null, IMessageProvider.NONE); } else {/*from w w w . j av a 2s . c o m*/ // First replace all return carriages, or new lines with spaces StringBuffer buffer = new StringBuffer(messageToDisplay); for (int i = 0; i < buffer.length(); i++) { char ch = buffer.charAt(i); if (ch == '\r' || ch == '\n') { buffer.replace(i, i + 1, " "); //$NON-NLS-1$ } } if (buffer.length() > MAX_ERROR_MESSAGE) { String endingSegment = Messages.CloudFoundryApplicationsEditorPage_TEXT_SEE_ERRORLOG; messageToDisplay = buffer.substring(0, MAX_ERROR_MESSAGE).trim() + endingSegment; CloudFoundryPlugin.logError(message); } else { messageToDisplay = buffer.toString(); } sform.setMessage(messageToDisplay, messageType); } }
From source file:org.codecover.eclipse.exportWizards.MainExportPage.java
License:Open Source License
private void handleErrors() { String fileError = checkFile(); if (getSelectedTestSessionContainer() == null) { setErrorMessage(ERROR_NO_TEST_SESSION_CONTAINER_SELECTED); setPageComplete(false);// w w w . j av a 2s . co m } else if (this.getSelectedTestCases().size() == 0) { setErrorMessage(ERROR_NO_TEST_CASES_SELECTED); setPageComplete(false); } else if (fileError != null) { setErrorMessage(fileError); setPageComplete(false); } else { setErrorMessage(null); setPageComplete(true); if (this.getSelectedType() == Types.TEST_SESSION_CONTAINER && this.containsNotFullySelectedTestSession()) { setMessage(WARNING_INCOMPLETE_TEST_SESSION_SELECTION, IMessageProvider.WARNING); } else { this.setMessage(DESCRIPTION, IMessageProvider.NONE); } } }
From source file:org.codecover.eclipse.views.controls.MergeWizardPage.java
License:Open Source License
/** * Checks the selected elements, and sets errors or warnings to be * displayed://from w w w .ja v a2s . c om * <ul> * <li>Error if there are less than two test elements of the selected type * (test session or test case) selected.</li> * <li>Error if the selected type to merge is test case and there are test * cases of different test sessions selected.</li> * <li>Warning if there are test cases selected although test sessions * are the selected type to be merged or vice versa.</li> * </ul> * The name field is not checked. This is done by * {@link ElementNameFieldListener}. */ private void checkElements() { String error = null; // if test sessions are to be merged... if (this.bttTestSession.getSelection()) { if (this.selectedTestSessions.size() < 2) { error = ERROR_TEST_ELEMENTS_UNDER_2_SELECTED; } /* * check if test cases are selected although test sessions are * to be merged */ if (!this.selectedTestCases.isEmpty()) { this.setMessage(WARNING_TEST_CASES_SELECTED, IMessageProvider.WARNING); } else { this.setMessage(DESCRIPTION, IMessageProvider.NONE); } } else /* if test cases are to be merged... */ { if (this.selectedTestCases.size() < 2) { error = ERROR_TEST_ELEMENTS_UNDER_2_SELECTED; } else if (this.isTestCasesWithDifferentParentsSelected()) { error = ERROR_TEST_CASES_OF_DIFFERENT_TEST_SESSIONS; } /* * check if test sessions are selected although test cases are * to be merged */ if (!this.selectedTestSessions.isEmpty()) { this.setMessage(WARNING_TEST_SESSIONS_SELECTED, IMessageProvider.WARNING); } else { this.setMessage(DESCRIPTION, IMessageProvider.NONE); } } this.elementsError = error; }
From source file:org.cs3.pdt.connector.internal.preferences.EditConfigurationDialog.java
License:Open Source License
@Override public void updateMessage() { String message = null;/*from w ww.j av a 2 s. c o m*/ String errorMessage = null; if (page != null) { message = page.getMessage(); errorMessage = page.getErrorMessage(); } int messageType = IMessageProvider.NONE; if (message != null && page instanceof IMessageProvider) { messageType = ((IMessageProvider) page).getMessageType(); } if (errorMessage == null) { if (showingError) { // we were previously showing an error showingError = false; } } else { message = errorMessage; messageType = IMessageProvider.ERROR; if (!showingError) { // we were not previously showing an error showingError = true; } } messageArea.updateText(message, messageType); }