List of usage examples for org.eclipse.jface.dialogs IMessageProvider WARNING
int WARNING
To view the source code for org.eclipse.jface.dialogs IMessageProvider WARNING.
Click Source Link
From source file:org.eclipse.cdt.managedbuilder.xlc.ui.preferences.XLCompilerPreferencePage.java
License:Open Source License
/** * Creates the field editors. Field editors are abstractions of * the common GUI blocks needed to manipulate various types * of preferences. Each field editor knows how to save and * restore itself./*from www . ja v a 2 s . c om*/ */ @Override public void createFieldEditors() { DirectoryFieldEditor pathEditor = new DirectoryFieldEditor(PreferenceConstants.P_XL_COMPILER_ROOT, Messages.XLCompilerPreferencePage_1, getFieldEditorParent()) { @Override protected boolean doCheckState() { // always return true, as we don't want to fail cases when compiler is installed remotely // just warn user if (!super.doCheckState()) { setMessage(Messages.XLCompilerPreferencePage_3, IMessageProvider.WARNING); } else { setMessage(originalMessage); } return true; } @Override protected boolean checkState() { return doCheckState(); } }; addField(pathEditor); String[][] versionEntries = { { PreferenceConstants.P_XL_COMPILER_VERSION_8_NAME, PreferenceConstants.P_XL_COMPILER_VERSION_8 }, { PreferenceConstants.P_XL_COMPILER_VERSION_9_NAME, PreferenceConstants.P_XL_COMPILER_VERSION_9 }, { PreferenceConstants.P_XL_COMPILER_VERSION_10_NAME, PreferenceConstants.P_XL_COMPILER_VERSION_10 }, { PreferenceConstants.P_XL_COMPILER_VERSION_11_NAME, PreferenceConstants.P_XL_COMPILER_VERSION_11 } }; addField(new ComboFieldEditor(PreferenceConstants.P_XLC_COMPILER_VERSION, Messages.XLCompilerPreferencePage_2, versionEntries, getFieldEditorParent())); }
From source file:org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCompilerPropertyPage.java
License:Open Source License
protected void createPathEditor() { Composite parent = getFieldEditorParent(); fPathEditor = new DirectoryFieldEditor(PreferenceConstants.P_XL_COMPILER_ROOT, Messages.XLCompilerPropertyPage_0, parent) { @Override/* w ww .j a v a 2 s . com*/ protected boolean doCheckState() { // always return true, as we don't want to fail cases when // compiler is installed remotely // just warn user if (!super.doCheckState()) { setMessage(Messages.XLCompilerPropertyPage_2, IMessageProvider.WARNING); } else { setMessage(originalMessage); } return true; } @Override protected boolean checkState() { return doCheckState(); } }; addField(fPathEditor); IProject project = ((IResource) (getElement().getAdapter(IResource.class))).getProject(); String currentPath = null; try { currentPath = project.getPersistentProperty(new QualifiedName("", //$NON-NLS-1$ PreferenceConstants.P_XL_COMPILER_ROOT)); } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (currentPath == null) { // if the property isn't set, then use the workbench preference IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore(); currentPath = prefStore.getString(PreferenceConstants.P_XL_COMPILER_ROOT); } fPathEditor.setStringValue(currentPath); }
From source file:org.eclipse.cdt.ui.wizards.CDTMainWizardPage.java
License:Open Source License
/** * Returns whether this page's controls currently all contain valid * values./*w w w . j a v a 2s . c om*/ * * @return <code>true</code> if all controls are valid, and * <code>false</code> if at least one is invalid */ @Override protected boolean validatePage() { setMessage(null); if (!super.validatePage()) return false; if (getProjectName().indexOf('#') >= 0) { setErrorMessage(Messages.CDTMainWizardPage_0); return false; } boolean bad = true; // should we treat existing project as error IProject handle = getProjectHandle(); if (handle.exists()) { if (getWizard() instanceof IWizardWithMemory) { IWizardWithMemory w = (IWizardWithMemory) getWizard(); if (w.getLastProjectName() != null && w.getLastProjectName().equals(getProjectName())) bad = false; } if (bad) { setErrorMessage(Messages.CMainWizardPage_10); return false; } } if (bad) { // Skip this check if project already created try { IFileStore fs; URI p = getProjectLocation(); if (p == null) { fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI()); fs = fs.getChild(getProjectName()); } else fs = EFS.getStore(p); IFileInfo f = fs.fetchInfo(); if (f.exists()) { if (f.isDirectory()) { if (f.getAttribute(EFS.ATTRIBUTE_READ_ONLY)) { setErrorMessage(Messages.CMainWizardPage_DirReadOnlyError); return false; } else setMessage(Messages.CMainWizardPage_7, IMessageProvider.WARNING); } else { setErrorMessage(Messages.CMainWizardPage_6); return false; } } } catch (CoreException e) { CUIPlugin.log(e.getStatus()); } } if (!useDefaults()) { IStatus locationStatus = ResourcesPlugin.getWorkspace().validateProjectLocationURI(handle, getLocationURI()); if (!locationStatus.isOK()) { setErrorMessage(locationStatus.getMessage()); return false; } } if (tree.getItemCount() == 0) { setErrorMessage(Messages.CMainWizardPage_3); return false; } // it is not an error, but we cannot continue if (h_selected == null) { setErrorMessage(null); return false; } String s = h_selected.getErrorMessage(); if (s != null) { setErrorMessage(s); return false; } setErrorMessage(null); return true; }
From source file:org.eclipse.cft.server.ui.internal.editor.ApplicationDetailsPart.java
License:Open Source License
public void refreshUI() { logError(null);//from ww w . jav a 2 s . co m resizeTableColumns(); canUpdate = false; CloudFoundryApplicationModule appModule = cloudServer.getExistingCloudModule(module); // Refresh the state of the editor regardless of whether there is a // module or not refreshPublishState(appModule); if (appModule == null) { return; } if (saveManifest != null) { ManifestParser parser = new ManifestParser(appModule, cloudServer); if (!parser.canWriteToManifest()) { saveManifest.setEnabled(false); saveManifest.setToolTipText(Messages.ApplicationDetailsPart_TEXT_MANIFEST_SAVE_CREATE_TOOLTIP); } else { saveManifest.setEnabled(true); saveManifest.setToolTipText(Messages.ApplicationDetailsPart_TEXT_MANIFEST_UPDATE); } } int state = appModule.getState(); if (jrebelManualAppUrlUpdate != null) { // URL updating only is enabled when app is running jrebelManualAppUrlUpdate.setEnabled(CloudRebelAppHandler.isJRebelEnabled(module)); } // The rest of the refresh requires appModule to be non-null updateServerNameDisplay(appModule); instanceSpinner.setSelection(appModule.getInstanceCount()); refreshDeploymentButtons(appModule); mappedURIsLink.setEnabled(state == IServer.STATE_STARTED); CloudApplication cloudApplication = appModule.getApplication(); instanceSpinner.setEnabled(cloudApplication != null); instancesViewer.getTable().setEnabled(cloudApplication != null); instancesViewer.setInput(null); memoryText.setEnabled(cloudApplication != null); if (cloudApplication != null) { int appMemory = appModule.getApplication().getMemory(); if (appMemory > 0) { memoryText.setText(appMemory + ""); //$NON-NLS-1$ } } List<String> currentURIs = null; if (cloudApplication != null) { currentURIs = cloudApplication.getUris(); ApplicationStats applicationStats = appModule.getApplicationStats(); InstancesInfo instancesInfo = appModule.getInstancesInfo(); if (applicationStats != null) { List<InstanceStats> statss = applicationStats.getRecords(); List<InstanceInfo> infos = instancesInfo != null ? instancesInfo.getInstances() : null; InstanceStatsAndInfo[] statsAndInfos = new InstanceStatsAndInfo[statss.size()]; for (int i = 0; i < statss.size(); i++) { InstanceStats stats = statss.get(i); InstanceInfo info = null; if (infos != null && infos.size() > i) { info = infos.get(i); } statsAndInfos[i] = new InstanceStatsAndInfo(stats, info); } instancesViewer.setInput(statsAndInfos); } } if (currentURIs == null && !isPublished) { // At this stage, the app may not have deployed due to errors, but // there may already // be set URIs in an existing info currentURIs = appModule.getDeploymentInfo() != null ? appModule.getDeploymentInfo().getUris() : null; } if (currentURIs == null) { currentURIs = Collections.emptyList(); } if (!currentURIs.equals(this.appUrls)) { updateAppUrls(currentURIs); } refreshServices(appModule); instancesViewer.refresh(true); canUpdate = true; if (appModule.getStatus() != null && !appModule.getStatus().isOK()) { if (appModule.getStatus().getSeverity() == IStatus.ERROR) { editorPage.setMessage(appModule.getStatus().getMessage(), IMessageProvider.ERROR); } else if (appModule.getStatus().getSeverity() == IStatus.WARNING) { editorPage.setMessage(appModule.getStatus().getMessage(), IMessageProvider.WARNING); } } else { editorPage.setMessage(null, IMessageProvider.ERROR); editorPage.setMessage(null, IMessageProvider.WARNING); } }
From source file:org.eclipse.cft.server.ui.internal.editor.CloudFoundryApplicationsEditorPage.java
License:Open Source License
protected void setMessageInPage(IStatus status) { String message = status != null ? status.getMessage() : null; if (message == null || status == null || status.isOK()) { setMessage(null, IMessageProvider.NONE); } else {//from w w w .j a v a2 s. c o m int providerStatus = IMessageProvider.NONE; switch (status.getSeverity()) { case IStatus.INFO: providerStatus = IMessageProvider.INFORMATION; break; case IStatus.WARNING: providerStatus = IMessageProvider.WARNING; break; case IStatus.ERROR: providerStatus = IMessageProvider.ERROR; break; } setMessage(message, providerStatus); } }
From source file:org.eclipse.cft.server.ui.internal.editor.EditorMessageTypes.java
License:Open Source License
public static int getMessageProviderType(IStatus status) { if (status == null) { return IMessageProvider.NONE; }//from w w w . j av a 2s. c o m switch (status.getSeverity()) { case IStatus.INFO: return IMessageProvider.INFORMATION; case IStatus.WARNING: return IMessageProvider.WARNING; case IStatus.ERROR: return IMessageProvider.ERROR; } return IMessageProvider.NONE; }
From source file:org.eclipse.contribution.visualiser.internal.preference.VisualiserPreferencesDialog.java
License:Open Source License
/** * Sets the message for this dialog with an indication of what type * of message it is.//from w ww. j a v a2s. co m * <p> * The valid message types are one of <code>NONE</code>, * <code>INFORMATION</code>, <code>WARNING</code>, or <code>ERROR</code>. * </p> * <p> * Note that for backward compatibility, a message of type <code>ERROR</code> * is different than an error message (set using <code>setErrorMessage</code>). * An error message overrides the current message until the error message is * cleared. This method replaces the current message and does not affect the * error message. * </p> * * @param newMessage the message, or <code>null</code> to clear * the message * @param newType the message type */ public void setMessage(String newMessage, int newType) { Image newImage = null; if (newMessage != null) { switch (newType) { case IMessageProvider.NONE: break; case IMessageProvider.INFORMATION: newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_INFO); break; case IMessageProvider.WARNING: newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_WARNING); break; case IMessageProvider.ERROR: newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_ERROR); break; } } showMessage(newMessage, newImage); }
From source file:org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.db.DbProfilePropertyPage.java
License:Open Source License
private DataSourceEditorPage createDefaultPropertyPage(Properties profileProps) { DefaultDataSourcePropertyPage defaultPropPage = new DefaultDataSourcePropertyPage(); String errorMessage = isInOdaDesignSession() ? (m_canEditProps ? Messages.dbProfilePage_noCustomPage : Messages.dbProfilePage_invalidDataSource) : Messages.dbProfilePage_notInDesignSession; /*//from www .j a v a 2 s . c o m * Update page's initialized DataSourceDesign with specified profileProps, * so that the page can create controls with the profileProps values. */ OdaDesignSession requestSession = getDesignSession(); if (requestSession.getRequestDataSourceDesign() != null && !requestSession.getRequestDataSourceDesign().hasLinkToProfile()) // editing local properties { // makes a copy of the request session to update the data source design w/ local profileProps requestSession = (OdaDesignSession) EcoreUtil.copy(requestSession); DataSourceDesign localRequestDesign = requestSession.getRequestDataSourceDesign(); try { super.setDataSourceDesignProperties(localRequestDesign, profileProps); } catch (OdaException ex) { errorMessage += "\n"; //$NON-NLS-1$ errorMessage += ex.toString(); } } try { defaultPropPage.initEditSession(requestSession); } catch (OdaException ex) { errorMessage += "\n"; //$NON-NLS-1$ errorMessage += ex.toString(); } int messageType = m_canEditProps ? IMessageProvider.WARNING : IMessageProvider.ERROR; setMessage(errorMessage, messageType); // missing required properties to test connection if (!m_canEditProps) defaultPropPage.setPingButtonEnabled(false); return defaultPropPage; }
From source file:org.eclipse.datatools.connectivity.oda.design.ui.pages.impl.DefaultDataSourcePageHelper.java
License:Open Source License
protected void validatePropertyFields() { for (int i = 0; i < getPropCount(); i++) { String propVal = null;//w w w . ja v a 2 s .c o m if (m_propCtrls[i] instanceof Text) propVal = ((Text) m_propCtrls[i]).getText(); else if (m_propCtrls[i] instanceof Combo) { int index = ((Combo) m_propCtrls[i]).getSelectionIndex(); if (index == -1) propVal = EMPTY_STRING; else propVal = getPropChoiceSelection(i, index); } else if (m_propCtrls[i] == null) { // The property is hidden from the user. Therefore, just // return the default value. Notice that if the property // is a choice, the propVal will be the choice's name, not // the choice value. propVal = getPropDefaultValue(i); } else assert (false); if (isPropRequired(i) && isEmpty(propVal)) { setMessage(Messages.ui_requiredFieldsMissingValue, IMessageProvider.WARNING); return; } } // If the code reaches here, all the required fields are non-empty. setMessage(DEFAULT_MESSAGE, IMessageProvider.NONE); }
From source file:org.eclipse.datatools.sqltools.sqleditor.SQLEditor.java
License:Open Source License
protected void performSaveAs(IProgressMonitor progressMonitor) { // Using the SaveAsDialog defined in common.ui which provide "Create Project" button Shell shell = getSite().getShell();/*from www . j a v a2 s . c o m*/ final IEditorInput input = getEditorInput(); IDocumentProvider provider = getDocumentProvider(); final IEditorInput newInput; { SaveAsDialog dialog = new SaveAsDialog(shell, false); IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); if (provider.isDeleted(input) && original != null) { String message = NLS.bind(SQLEditorResources.SQLEditor_file_deleted_or_not_accessible, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); IFile file = workspace.getRoot().getFile(filePath); newInput = new FileEditorInput(file); } if (provider == null) { // editor has programmatically been closed while the dialog was open return; } boolean success = false; try { provider.aboutToChange(newInput); provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true); success = true; } catch (CoreException x) { final IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { String title = SQLEditorResources.SQLEditor_problem_save_as; String msg = NLS.bind(SQLEditorResources.SQLEditor_could_not_save_as, x.getMessage()); MessageDialog.openError(shell, title, msg); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }