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:com.mobilesorcery.sdk.ui.DefaultMessageProvider.java
License:Open Source License
public static boolean isEmpty(IMessageProvider provider) { if (provider == null) { return true; }//from w w w.ja va2 s . c om return Util.isEmpty(provider.getMessage()) && provider.getMessageType() == IMessageProvider.NONE; }
From source file:com.mobilesorcery.sdk.ui.MoSyncPropertyPage.java
License:Open Source License
protected void setMessage(IMessageProvider message) { String messageStr = message == null ? null : message.getMessage(); int messageType = message == null ? IMessageProvider.NONE : message.getMessageType(); setMessage(messageStr, messageType); setValid(DefaultMessageProvider.isEmpty(message) || message.getMessageType() != IMessageProvider.ERROR); if (message instanceof ValidationMessageProvider) { validationHelper.setMessage((ValidationMessageProvider) message); }//from w w w . j av a 2s . co m }
From source file:com.motorola.studio.android.common.utilities.ui.PasswordInputDialog.java
License:Apache License
public void updateStatus() { String errorMessage = null;//from ww w . jav a 2 s . c o m int severity = IMessageProvider.NONE; if (oldPasswordText.getText().length() > 0) { oldPassword = oldPasswordText.getText(); } else { errorMessage = ""; oldPassword = null; } if ((errorMessage == null) && changePassword) { if (newPasswordText.getText().length() < passwordMinimumSize) { errorMessage = UtilitiesNLS.bind(UtilitiesNLS.Passwordinput_Error_PasswordMinimumSize, passwordMinimumSize); severity = IMessageProvider.ERROR; } else { if (!newPasswordText.getText().equals(newPasswordConfirmText.getText())) { errorMessage = UtilitiesNLS.Passwordinput_Error_Passwordnotmatch; severity = IMessageProvider.ERROR; } else { newPassword = newPasswordText.getText(); } } } setErrorMessage(errorMessage, severity); }
From source file:com.motorola.studio.android.common.utilities.ui.PasswordInputDialog.java
License:Apache License
private void setErrorMessage(String errorMsg, int severity) { if ((errorMsg == null) || (severity == IMessageProvider.NONE)) { image.setImage(null);// w ww. j ava2 s. co m image.setVisible(false); message.setText(description); getButton(OK).setEnabled(errorMsg == null); } else { message.setText(errorMsg); message.setVisible(true); switch (severity) { case IMessageProvider.ERROR: image.setImage( PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); break; case IMessageProvider.INFORMATION: image.setImage( PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK)); break; case IMessageProvider.WARNING: image.setImage( PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK)); break; default: image.setImage( PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); break; } image.setVisible(true); getButton(OK).setEnabled(false); } message.getParent().layout(); }
From source file:com.motorola.studio.android.generatemenucode.ui.GenerateMenuCodeDialog.java
License:Apache License
/** * Populate the combobox that holds menu file names. *///from ww w .jav a2 s .c o m private void populateMenuFileNames() { if ((menuFileNameComboBox != null) && (getJavaFile() != null)) { menuFileNameComboBox.removeAll(); menuFileErrorMessage = null; CompilationUnit cpAstNode = JDTUtils.parse(getJavaFile()); if (!JDTUtils.hasErrorInCompilationUnitAstUtils(cpAstNode)) { IProject prj = (IProject) this.projectNameComboBox.getData(this.projectNameComboBox.getText()); IFolder menuFolder = prj.getFolder(IAndroidConstants.FD_RESOURCES) .getFolder(IAndroidConstants.FD_MENU); String inflatedMenu = JDTUtils.getInflatedMenuFileName(getJavaProject(), getJavaFile()); if ((inflatedMenu != null) && (inflatedMenu.length() > 0)) { //the activity/fragment already inflates a menu //select this menu on the combo box try { inflatedMenu = inflatedMenu + '.' + IAndroidConstants.MENU_FILE_EXTENSION; menuFileNameComboBox.add(inflatedMenu); CodeGeneratorDataBasedOnMenu codeGeneratorData; codeGeneratorData = JDTUtils.createMenuFile(getJavaProject(), getJavaFile(), inflatedMenu, getTypeAssociatedToJavaFile()); menuFileNameComboBox.setData(inflatedMenu, codeGeneratorData); menuFileNameComboBox.select(0); setMessage(CodeUtilsNLS.GenerateMenuCodeDialog_InflatedMessage, IMessageProvider.NONE); } catch (AndroidException e) { menuFileErrorMessage = e.getMessage(); menuFileNameComboBox.setData(inflatedMenu, menuFileErrorMessage); } //Disable the menu combo box so the user cannot change the menu file menuFileNameComboBox.select(0); menuFileNameComboBox.setEnabled(false); } else { //there is no inflated menu setMessage(defaultMessage, IMessageProvider.NONE); //iterate over all files inside res/menu try { for (IResource menuFile : menuFolder.members()) { //only consider xml files if ((menuFile.getType() == IResource.FILE) && menuFile.getFileExtension().equals(IAndroidConstants.MENU_FILE_EXTENSION)) { menuFileNameComboBox.add(menuFile.getName()); try { CodeGeneratorDataBasedOnMenu codeGeneratorData = JDTUtils.createMenuFile( getJavaProject(), getJavaFile(), menuFile.getName(), getTypeAssociatedToJavaFile()); menuFileNameComboBox.setData(menuFile.getName(), codeGeneratorData); } catch (AndroidException e) { // The malformed xml files menuFileErrorMessage = e.getMessage(); menuFileNameComboBox.setData(menuFile.getName(), menuFileErrorMessage); } } } } catch (CoreException e) { menuFileErrorMessage = CodeUtilsNLS.GenerateMenuCodeDialog_Error_MenuFolderDoesNotExist; } menuFileNameComboBox.select(0); //if the combo box is empty, the selection is ignored menuFileNameComboBox.setEnabled(menuFileNameComboBox.getItemCount() > 0); } } else { menuFileErrorMessage = CodeUtilsNLS.GenerateMenuCodeDialog_Class_Error; this.javaFile = null; menuFileNameComboBox.setEnabled(false); } } else { menuFileNameComboBox.setEnabled(false); } validate(); }
From source file:com.motorola.studio.android.generatemenucode.ui.GenerateMenuCodeDialog.java
License:Apache License
/** * Validate the UI/*from w w w. j a v a 2s .c o m*/ * @return */ protected void validate() { String errorMessage = null; if ((projectNameComboBox != null) && (projectNameComboBox.getItemCount() == 0)) { errorMessage = CodeUtilsNLS.GenerateMenuCodeDialog_NoSuitableProjects; } if ((errorMessage == null) && (classNameComboBox != null) && (classNameComboBox.getItemCount() == 0)) { errorMessage = CodeUtilsNLS.GenerateMenuCodeDialog_NoSuitableClasses; } if ((errorMessage == null) && (menuFileNameComboBox != null)) { if ((menuFileErrorMessage != null) && (menuFileNameComboBox.getSelectionIndex() >= 0) && (menuFileNameComboBox.getData(menuFileNameComboBox .getItem(menuFileNameComboBox.getSelectionIndex())) instanceof String)) { errorMessage = (String) menuFileNameComboBox .getData(menuFileNameComboBox.getItem(menuFileNameComboBox.getSelectionIndex())); } else { if ((menuFileNameComboBox.getItemCount() == 0) && (getJavaFile() != null)) { errorMessage = CodeUtilsNLS.GenerateMenuCodeDialog_NoSuitableMenus; } else if (getJavaFile() == null) { errorMessage = menuFileErrorMessage; } } } this.setMessage(errorMessage, IMessageProvider.ERROR); if (errorMessage == null) { if ((this.getMessage() == null) || (this.getMessage().length() == 0)) { this.setMessage(defaultMessage, IMessageProvider.NONE); } } if (getButton(OK) != null) { getButton(OK).setEnabled((getErrorMessage() == null) || ((getErrorMessage() != null) && (getErrorMessage().trim().isEmpty()))); } }
From source file:com.motorola.studio.android.generateviewbylayout.ui.ChooseLayoutItemsDialog.java
License:Apache License
/** * Handles the enablement of the Ok button. * It will only be enabled when at least one table item is checked. *///from www . j a v a 2s. c o m @Override protected void validate() { super.validate(); if ((getViewer() != null) && (getErrorMessage() == null)) { // set the appropriate message String message = ""; //$NON-NLS-1$ int messageType = IMessageProvider.NONE; //check if at least one table item was selected for (TableItem item : getViewer().getTable().getItems()) { LayoutNode node = (LayoutNode) item.getData(); if (item.getChecked() && (getCodeGeneratorData() != null) && getCodeGeneratorData() .getJavaLayoutData().getVisitor().checkIfAttributeAlreadyDeclared(node, true)) { message = NLS.bind(CodeUtilsNLS.ChooseLayoutItemsDialog_VariableNameInUse_Error, node.getNodeId()); messageType = IMessageProvider.ERROR; break; } } if (messageType == IMessageProvider.NONE) { if (getViewer().getTable().getItemCount() == 0) { message = CodeUtilsNLS.UI_ChooseLayoutItemsDialog_No_Gui_Items_Available; messageType = IMessageProvider.INFORMATION; } else if (hasGuiItemsWithoutId) { message = CodeUtilsNLS.ChooseLayoutItemsDialog_Gui_Items_Available_No_Id; messageType = IMessageProvider.INFORMATION; } else { message = CodeUtilsNLS.ChooseLayoutItemsDialog_DefaultMessage; } } this.setMessage(message, messageType); } }
From source file:com.motorola.studio.android.obfuscate.ui.ObfuscateDialog.java
License:Apache License
@Override protected Control createDialogArea(Composite parent) { super.createDialogArea(parent).setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(1, false); mainComposite.setLayout(layout);//ww w . ja v a 2 s . co m treeViewer = new CheckboxTreeViewer(mainComposite, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL); treeViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // Set content and label provider treeViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { String label = null; if (element instanceof IProject) { label = ((IProject) element).getName(); } return label; } }); treeViewer.setContentProvider(new TreeViewerContentProvider()); ArrayList<IProject> projectsList = generateInputForTree(); treeViewer.setInput(projectsList); for (IProject p : projectsList) { treeViewer.setChecked(p, ObfuscatorManager.isProguardSet(p)); } treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { selectedProjects = treeViewer.getCheckedElements(); } }); treeViewer.expandAll(); mainComposite.layout(true); setTitle(AndroidNLS.ObfuscateProjectsHandler_2); setMessage(AndroidNLS.ObfuscateProjectsHandler_3, IMessageProvider.NONE); PlatformUI.getWorkbench().getHelpSystem().setHelp(mainComposite, OBFUSCATION_DIALOG_HELP); return mainComposite; }
From source file:com.motorola.studio.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 a2s.c o m*/ 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) { StudioLogger.error(PackageExportWizardArea.class, "Impossible to get project severity"); //$NON-NLS-1$ } }
From source file:com.motorola.studio.android.packaging.ui.export.PackageExportWizardArea.java
License:Apache License
/** * Can finish used in {@link IWizardPage} This method validate the page and * change the severity/message./*w ww.j a va 2 s .co m*/ * * @return true if can finish this wizard, false otherwise */ public boolean canFinish() { String messageAux = null; int severity_aux = IMessageProvider.NONE; /* * Check is has selected items */ if (!hasItemChecked()) { messageAux = Messages.SELECTOR_MESSAGE_NO_SELECTION; if (treeSelectionChanged) { severity_aux = IMessageProvider.ERROR; } else { severity_aux = IMessageProvider.INFORMATION; } } // validate if some selected project has errors if (messageAux == null) { Iterator<IProject> iterator = getSelectedProjects().iterator(); while (iterator.hasNext() && (severity_aux != IMessageProvider.ERROR)) { severity_aux = projectSeverity.get(iterator.next()); } if (severity_aux == IMessageProvider.ERROR) { messageAux = Messages.PACKAGE_EXPORT_WIZARD_AREA_PROJECTS_WITH_ERRORS_SELECTED; } } /* * Check if the selected location is valid, even if non existent. */ IPath path = new Path(this.destinationText.getText()); if (!this.defaultDestination.getSelection() && (messageAux == null)) { // Test if path is blank, to warn user instead of show an error // message if (this.destinationText.getText().equals("")) //$NON-NLS-1$ { messageAux = Messages.SELECTOR_MESSAGE_LOCATION_ERROR_INVALID; severity_aux = IMessageProvider.INFORMATION; } /* * Do Win32 Validation */ if ((messageAux == null) && Platform.getOS().equalsIgnoreCase(Platform.OS_WIN32)) { // test path size if (path.toString().length() > 255) { messageAux = Messages.SELECTOR_MESSAGE_LOCATION_ERROR_PATH_TOO_LONG; severity_aux = IMessageProvider.ERROR; } String device = path.getDevice(); File deviceFile = null; if (device != null) { deviceFile = new File(path.getDevice()); } if ((device != null) && !deviceFile.exists()) { messageAux = Messages.SELECTOR_MESSAGE_LOCATION_ERROR_INVALID_DEVICE + " [" + device //$NON-NLS-1$ + "]"; //$NON-NLS-1$ severity_aux = IMessageProvider.ERROR; } } // test if path is absolute if (messageAux == null) { if (!path.isAbsolute()) { messageAux = Messages.SELECTOR_MESSAGE_LOCATION_ERROR_INVALID; severity_aux = IMessageProvider.ERROR; } } if (messageAux == null) { for (String folderName : path.segments()) { if (!ResourcesPlugin.getWorkspace().validateName(folderName, IResource.FOLDER).isOK()) { messageAux = Messages.SELECTOR_MESSAGE_LOCATION_ERROR_INVALID; severity_aux = IMessageProvider.ERROR; } } } if ((messageAux == null) && path.toFile().exists() && !path.toFile().isDirectory()) { messageAux = Messages.SELECTOR_MESSAGE_LOCATION_ERROR_NOT_DIRECTORY; severity_aux = IMessageProvider.ERROR; } } /* * Check if there are available certificates and if selection isn't null */ if (messageAux == null) { if (this.signingEnabled && (this.signCheckBox != null) && this.signCheckBox.getSelection() && !((this.keystores != null) && (this.keystores.getItemCount() > 0))) { messageAux = Messages.PACKAGE_EXPORT_WIZARD_AREA_SIGN_NO_KEYSTORE_AVAILABLE; severity_aux = IMessageProvider.ERROR; } else if (this.signCheckBox.getSelection() && !((this.keysCombo != null) && (this.keysCombo.getItemCount() > 0) && (this.keysCombo.getSelectionIndex() >= 0) && (this.keysCombo.getItem(this.keysCombo.getSelectionIndex()) != null) && !this.keysCombo.getItem(this.keysCombo.getSelectionIndex()).equals(""))) //$NON-NLS-1$ { messageAux = Messages.PACKAGE_EXPORT_WIZARD_AREA_SIGN_NO_KEYSTORE_OR_KEY_SELECTED; severity_aux = IMessageProvider.ERROR; } } if (messageAux == null) { if (!this.signCheckBox.getSelection()) { messageAux = Messages.PACKAGE_EXPORT_WIZARD_AREA_UNSIGNEDPACKAGE_WARNING; severity_aux = IMessageProvider.WARNING; } } /* * Setting message */ if (messageAux == null) { messageAux = Messages.PACKAGE_EXPORT_WIZARD_AREA_DESCRIPTION; severity_aux = IMessageProvider.NONE; } this.message = messageAux; this.severity = severity_aux; boolean result; switch (severity_aux) { case IMessageProvider.ERROR: // ERROR. can't finish wizard result = false; break; case IMessageProvider.WARNING: // WARNING. ok to finish the wizard result = true; break; case IMessageProvider.INFORMATION: // INFORMATION. Path is empty, so it's NOT OK to finish the wizard result = false; break; default: // by default, canFinish returns true result = true; break; } return result; }