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.andmore.android.packaging.ui.export.PackageExportWizardArea.java
License:Apache License
/** * Get all projects severities to avoid user selects erroneous projects *//*from w w w .j a v a 2 s. c om*/ private void validateProjects() { try { for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { if (project.isOpen()) { int sev = project.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE); int projectSev; switch (sev) { case IMarker.SEVERITY_ERROR: projectSev = IMessageProvider.ERROR; break; case IMarker.SEVERITY_INFO: projectSev = IMessageProvider.INFORMATION; break; case IMarker.SEVERITY_WARNING: projectSev = IMessageProvider.WARNING; break; default: projectSev = IMessageProvider.NONE; break; } projectSeverity.put(project, new Integer(projectSev)); } } } catch (CoreException e) { AndmoreLogger.error(PackageExportWizardArea.class, "Impossible to get project severity"); //$NON-NLS-1$ } }
From source file:org.eclipse.andmore.android.propertypage.AndmorePropertyPage.java
License:Apache License
private void addObfuscateSection(Composite parent) { Composite group = createDefaultComposite(parent, AndroidNLS.UI_ProjectPropertyPage_ObfuscateGroup); Composite composite = new Composite(group, SWT.NULL); GridLayout layout = new GridLayout(); layout.numColumns = 2;/*from w w w .j a v a 2 s . c o m*/ composite.setLayout(layout); GridData data = new GridData(); data.verticalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL; composite.setLayoutData(data); obfuscateCkbox = new Button(composite, SWT.CHECK); setDefaultObfuscate(); Label obfuscateLabel = new Label(composite, SWT.NONE); obfuscateLabel.setText(AndroidNLS.UI_ProjectPropertyPage_Obfuscate); obfuscateCkbox.addSelectionListener(new SelectionAdapter() { /* * (non-Javadoc) * * @see * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse * .swt.events.SelectionEvent) */ @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); boolean showWarningMessage = false; if (obfuscateCkbox.getSelection()) { if ((project != null) && project.getLocation().toOSString().contains(" ")) //$NON-NLS-1$ { showWarningMessage = true; } } if (showWarningMessage) { setMessage(AndroidNLS.WRN_Obfuscation_ProjectLocationContainWhitespaces, IMessageProvider.WARNING); } else { setMessage("Eclipse Andmore"); //$NON-NLS-1$ } } }); }
From source file:org.eclipse.andmore.android.propertypage.AndmorePropertyPage.java
License:Apache License
private void addMultiDexSection(Composite parent) { Composite group = createDefaultComposite(parent, AndroidNLS.UI_ProjectPropertyPage_MultiDexGroup); Composite composite = new Composite(group, SWT.NULL); GridLayout layout = new GridLayout(); layout.numColumns = 2;//from ww w. j ava2 s . c o m composite.setLayout(layout); GridData data = new GridData(); data.verticalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL; composite.setLayoutData(data); multiDexCkbox = new Button(composite, SWT.CHECK); setDefaultMultiDex(); Label obfuscateLabel = new Label(composite, SWT.NONE); obfuscateLabel.setText(AndroidNLS.UI_ProjectPropertyPage_MultiDex); multiDexCkbox.addSelectionListener(new SelectionAdapter() { /* * (non-Javadoc) * * @see * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse * .swt.events.SelectionEvent) */ @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); boolean showWarningMessage = false; if (multiDexCkbox.getSelection()) { if ((project != null) && project.getLocation().toOSString().contains(" ")) //$NON-NLS-1$ { showWarningMessage = true; } } if (showWarningMessage) { setMessage(AndroidNLS.WRN_Obfuscation_ProjectLocationContainWhitespaces, IMessageProvider.WARNING); } else { setMessage("Eclipse Andmore"); //$NON-NLS-1$ } } }); }
From source file:org.eclipse.andmore.internal.refactorings.extractstring.ExtractStringInputPage.java
License:Open Source License
/** * Validates fields of the wizard input page. Displays errors as appropriate and * enable the "Next" button (or not) by calling {@link #setPageComplete(boolean)}. * * If validation succeeds, this updates the text id & value in the refactoring object. * * @return True if the page has been positively validated. It may still have warnings. *///from www . j a v a 2 s. co m private boolean validatePage() { boolean success = true; ExtractStringRefactoring ref = getOurRefactoring(); ref.setReplaceAllJava(mReplaceAllJava.getSelection()); ref.setReplaceAllXml(mReplaceAllXml.isEnabled() && mReplaceAllXml.getSelection()); // Analyze fatal errors. String text = mStringIdCombo.getText().trim(); if (text == null || text.length() < 1) { setErrorMessage("Please provide a resource ID."); success = false; } else { for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); boolean ok = i == 0 ? Character.isJavaIdentifierStart(c) : Character.isJavaIdentifierPart(c); if (!ok) { setErrorMessage(String.format( "The resource ID must be a valid Java identifier. The character %1$c at position %2$d is not acceptable.", c, i + 1)); success = false; break; } } // update the field in the refactoring object in case of success if (success) { ref.setNewStringId(text); } } String resFile = mResFileCombo.getText(); if (success) { if (resFile == null || resFile.length() == 0) { setErrorMessage("A resource file name is required."); success = false; } else if (!RES_XML_FILE_REGEX.matcher(resFile).matches()) { setErrorMessage("The XML file name is not valid."); success = false; } } // Analyze info & warnings. if (success) { setErrorMessage(null); ref.setTargetFile(resFile); sLastResFilePath.put(mProject.getFullPath().toPortableString(), resFile); String idValue = mXmlHelper.valueOfStringId(mProject, resFile, text); if (idValue != null) { String msg = String.format("%1$s already contains a string ID '%2$s' with value '%3$s'.", resFile, text, idValue); if (ref.getMode() == ExtractStringRefactoring.Mode.SELECT_NEW_ID) { setErrorMessage(msg); success = false; } else { setMessage(msg, IMessageProvider.WARNING); } } else if (mProject.findMember(resFile) == null) { setMessage(String.format("File %2$s does not exist and will be created.", text, resFile), IMessageProvider.INFORMATION); } else { setMessage(null); } } if (success) { // Also update the text value in case of success. ref.setNewStringValue(mStringValueField.getText()); } setPageComplete(success); return success; }
From source file:org.eclipse.andmore.internal.welcome.WelcomeWizardPage.java
License:Open Source License
private void validatePage() { String error = null;/*from w w w . j ava 2 s .co m*/ String warning = null; if (isCreateNew()) { // Make sure that the target installation directory is empty or doesn't exist // (and that it can be created) String path = mNewDirText.getText().trim(); if (path.length() == 0) { error = "Please enter a new directory to install the SDK into"; } else { File file = new File(path); if (file.exists()) { if (file.isDirectory()) { if (!file.canWrite()) { error = "Missing write permission in target directory"; } File[] children = file.listFiles(); if (children != null && children.length > 0) { warning = "The directory is not empty"; } } else { error = "The target must be a directory"; } } else { File parent = file.getParentFile(); if (parent == null || !parent.exists()) { error = "The parent directory does not exist"; } else if (!parent.canWrite()) { error = "No write permission in parent directory"; } } } if (error == null && !mInstallLatestCheckbox.getSelection() && !mInstallCommonCheckbox.getSelection()) { error = "You must choose at least one Android version to install"; } } else { // Make sure that the existing installation directory exists and is valid String path = mExistingDirText.getText().trim(); if (path.length() == 0) { error = "Please enter an existing SDK installation directory"; } else { File file = new File(path); if (!file.exists()) { error = "The chosen installation directory does not exist"; } else { final AtomicReference<String> errorReference = new AtomicReference<String>(); final AtomicReference<String> warningReference = new AtomicReference<String>(); AndmoreAndroidPlugin.getDefault().checkSdkLocationAndId(path, new AndmoreAndroidPlugin.CheckSdkErrorHandler() { @Override public boolean handleError(CheckSdkErrorHandler.Solution solution, String message) { message = message.replaceAll("\n", " "); //$NON-NLS-1$ //$NON-NLS-2$ errorReference.set(message); return false; // Apply/OK must be disabled } @Override public boolean handleWarning(CheckSdkErrorHandler.Solution solution, String message) { message = message.replaceAll("\n", " "); //$NON-NLS-1$ //$NON-NLS-2$ warningReference.set(message); return true; // Apply/OK must be enabled } }); error = errorReference.get(); if (warning == null) { warning = warningReference.get(); } } } } setPageComplete(error == null); if (error != null) { setMessage(error, IMessageProvider.ERROR); } else if (warning != null) { setMessage(warning, IMessageProvider.WARNING); } else { setErrorMessage(null); setMessage(null); } }
From source file:org.eclipse.andmore.internal.wizards.newproject.ApplicationInfoPage.java
License:Open Source License
private void validatePage() { IStatus status = validatePackage(mValues.packageName); if (status == null || status.getSeverity() != IStatus.ERROR) { IStatus validActivity = validateActivity(); if (validActivity != null) { status = validActivity;//from w ww .j av a 2s .c om } } if (status == null || status.getSeverity() != IStatus.ERROR) { IStatus validMinSdk = validateMinSdk(); if (validMinSdk != null) { status = validMinSdk; } } if (status == null || status.getSeverity() != IStatus.ERROR) { IStatus validSourceFolder = validateSourceFolder(); if (validSourceFolder != null) { status = validSourceFolder; } } // If creating a test project to go along with the main project, also validate // the additional test project parameters if (status == null || status.getSeverity() != IStatus.ERROR) { if (mValues.createPairProject) { IStatus validTestProject = ProjectNamePage.validateProjectName(mValues.testProjectName); if (validTestProject != null) { status = validTestProject; } if (status == null || status.getSeverity() != IStatus.ERROR) { IStatus validTestLocation = validateTestProjectLocation(); if (validTestLocation != null) { status = validTestLocation; } } if (status == null || status.getSeverity() != IStatus.ERROR) { IStatus validTestPackage = validatePackage(mValues.testPackageName); if (validTestPackage != null) { status = new Status(validTestPackage.getSeverity(), AndmoreAndroidPlugin.PLUGIN_ID, validTestPackage.getMessage() + " (in test package)"); } } if (status == null || status.getSeverity() != IStatus.ERROR) { if (mValues.projectName.equals(mValues.testProjectName)) { status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID, "The main project name and the test project name must be different."); } } } } // -- update UI & enable finish if there's no error setPageComplete(status == null || status.getSeverity() != IStatus.ERROR); if (status != null) { setMessage(status.getMessage(), status.getSeverity() == IStatus.ERROR ? IMessageProvider.ERROR : IMessageProvider.WARNING); } else { setErrorMessage(null); setMessage(null); } }
From source file:org.eclipse.andmore.internal.wizards.newproject.ImportPage.java
License:Open Source License
private void validatePage() { IStatus status = null;/*from w ww . j a v a 2 s .c o m*/ // Validate project name -- unless we're creating a sample, in which case // the user will get a chance to pick the name on the Sample page if (mProjectPaths == null || mProjectPaths.isEmpty()) { status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID, "Select a directory to search for existing Android projects"); } else if (mValues.importProjects == null || mValues.importProjects.isEmpty()) { status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID, "Select at least one project"); } else { for (ImportedProject project : mValues.importProjects) { if (mCheckboxTableViewer.getGrayed(project)) { status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID, String.format( "Cannot import %1$s because the project name is in use", project.getProjectName())); break; } else { status = ProjectNamePage.validateProjectName(project.getProjectName()); if (status != null && !status.isOK()) { // Need to insert project name to make it clear which project name // is in violation if (mValues.importProjects.size() > 1) { String message = String.format("%1$s: %2$s", project.getProjectName(), status.getMessage()); status = new Status(status.getSeverity(), AndmoreAndroidPlugin.PLUGIN_ID, message); } break; } else { status = null; // Don't leave non null status with isOK() == true } } } } // -- update UI & enable finish if there's no error setPageComplete(status == null || status.getSeverity() != IStatus.ERROR); if (status != null) { setMessage(status.getMessage(), status.getSeverity() == IStatus.ERROR ? IMessageProvider.ERROR : IMessageProvider.WARNING); } else { setErrorMessage(null); setMessage(null); } }
From source file:org.eclipse.andmore.internal.wizards.newproject.ProjectNamePage.java
License:Open Source License
private void validatePage() { IStatus status = null;/*from ww w. j a v a 2 s.c o m*/ // Validate project name -- unless we're creating a sample, in which case // the user will get a chance to pick the name on the Sample page if (mValues.mode != Mode.SAMPLE) { status = validateProjectName(mValues.projectName); } if (status == null || status.getSeverity() != IStatus.ERROR) { IStatus validLocation = validateLocation(); if (validLocation != null) { status = validLocation; } } if (!mCheckedSdkUptodate) { // Ensure that we have a recent enough version of the Tools that the right templates // are available File file = new File(AndmoreAndroidPlugin.getOsSdkFolder(), OS_SDK_TOOLS_LIB_FOLDER + File.separator + FN_PROJECT_PROGUARD_FILE); if (!file.exists()) { status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID, String.format("You do not have the latest version of the " + "SDK Tools installed: Please update. (Missing %1$s)", file.getPath())); } else { mCheckedSdkUptodate = true; } } // -- update UI & enable finish if there's no error setPageComplete(status == null || status.getSeverity() != IStatus.ERROR); if (status != null) { setMessage(status.getMessage(), status.getSeverity() == IStatus.ERROR ? IMessageProvider.ERROR : IMessageProvider.WARNING); } else { setErrorMessage(null); setMessage(null); } }
From source file:org.eclipse.andmore.internal.wizards.newproject.SampleSelectionPage.java
License:Open Source License
private void validatePage() { IStatus status = null;//from w w w. j a v a 2s . co m if (mValues.samples == null || mValues.samples.size() == 0) { status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID, "The chosen SDK does not contain any samples"); } else if (mValues.chosenSample == null) { status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID, "Choose a sample"); } else if (!mValues.chosenSample.exists()) { status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID, String.format("Sample does not exist: %1$s", mValues.chosenSample.getPath())); } else { status = ProjectNamePage.validateProjectName(mValues.projectName); } // -- update UI & enable finish if there's no error setPageComplete(status == null || status.getSeverity() != IStatus.ERROR); if (status != null) { setMessage(status.getMessage(), status.getSeverity() == IStatus.ERROR ? IMessageProvider.ERROR : IMessageProvider.WARNING); } else { setErrorMessage(null); setMessage(null); } }
From source file:org.eclipse.andmore.internal.wizards.templates.ActivityPage.java
License:Open Source License
private void validatePage() { IStatus status = null;/* w w w . j a v a 2s . c o m*/ if (mValues.createActivity) { if (mList.getSelectionCount() < 1) { status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID, "Select an activity type"); } else { TemplateHandler templateHandler = mValues.activityValues.getTemplateHandler(); status = templateHandler.validateTemplate(mValues.minSdkLevel, mValues.getBuildApi()); } } setPageComplete(status == null || status.getSeverity() != IStatus.ERROR); if (status != null) { setMessage(status.getMessage(), status.getSeverity() == IStatus.ERROR ? IMessageProvider.ERROR : IMessageProvider.WARNING); } else { setErrorMessage(null); setMessage(null); } }