Example usage for org.eclipse.jface.dialogs IMessageProvider WARNING

List of usage examples for org.eclipse.jface.dialogs IMessageProvider WARNING

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IMessageProvider WARNING.

Prototype

int WARNING

To view the source code for org.eclipse.jface.dialogs IMessageProvider WARNING.

Click Source Link

Document

Constant for a warning message (value 2).

Usage

From source file:org.eclipse.egit.ui.internal.history.CommitSelectionDialog.java

License:Open Source License

@Override
public void create() {
    super.create();
    getButton(OK).setEnabled(false);//  w w w  .j a v a2  s  . c  om
    try {
        PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    monitor.beginTask(UIText.CommitSelectionDialog_BuildingCommitListMessage,
                            IProgressMonitor.UNKNOWN);
                    SWTWalk currentWalk = new SWTWalk(repository);
                    currentWalk.setTreeFilter(createTreeFilter());
                    currentWalk.sort(RevSort.COMMIT_TIME_DESC, true);
                    currentWalk.sort(RevSort.BOUNDARY, true);
                    highlightFlag = currentWalk.newFlag("highlight"); //$NON-NLS-1$
                    allCommits.source(currentWalk);

                    try {

                        if (Activator.getDefault().getPreferenceStore()
                                .getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_ALL_BRANCHES)) {
                            markStartAllRefs(currentWalk, Constants.R_HEADS);
                            markStartAllRefs(currentWalk, Constants.R_REMOTES);
                        } else
                            currentWalk.markStart(currentWalk.parseCommit(repository.resolve(Constants.HEAD)));
                        for (;;) {
                            final int oldsz = allCommits.size();
                            allCommits.fillTo(oldsz + BATCH_SIZE - 1);

                            if (monitor.isCanceled() || oldsz == allCommits.size())
                                break;
                            String taskName = NLS.bind(UIText.CommitSelectionDialog_FoundCommitsMessage,
                                    Integer.valueOf(allCommits.size()));
                            monitor.setTaskName(taskName);

                        }
                    } catch (IOException e) {
                        throw new InvocationTargetException(e);
                    }
                    getShell().getDisplay().asyncExec(new Runnable() {
                        public void run() {
                            updateUi();
                        }
                    });
                    if (monitor.isCanceled())
                        throw new InterruptedException();
                } finally {
                    monitor.done();
                }
            }
        });
    } catch (InvocationTargetException e) {
        setErrorMessage(e.getCause().getMessage());
    } catch (InterruptedException e) {
        setMessage(UIText.CommitSelectionDialog_IncompleteListMessage, IMessageProvider.WARNING);
    }
}

From source file:org.eclipse.egit.ui.internal.pull.PullWizardPage.java

License:Open Source License

private void checkPage() {
    try {/*from   www  .j  ava2s  .c o m*/
        if (remoteConfig == null) {
            setErrorMessage(UIText.PushBranchPage_ChooseRemoteError);
            return;
        }
        String branchName = remoteBranchNameText.getText();
        String branchNameMessage = null;
        if (branchName.length() == 0) {
            branchNameMessage = MessageFormat.format(UIText.PullWizardPage_ChooseReference,
                    remoteConfig.getName());
        }
        if (branchNameMessage != null) {
            setErrorMessage(branchNameMessage);
            if (this.missingBranchDecorator == null) {
                this.missingBranchDecorator = new ControlDecoration(this.remoteBranchNameText,
                        SWT.TOP | SWT.LEFT);
                this.missingBranchDecorator.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
            }
            this.missingBranchDecorator.setDescriptionText(branchNameMessage);
            this.missingBranchDecorator.show();
            return;
        } else if (this.missingBranchDecorator != null) {
            this.missingBranchDecorator.hide();
        }

        if (overrideUpstreamConfiguration() && hasDifferentUpstreamConfiguration()) {
            setMessage(UIText.PushBranchPage_UpstreamConfigOverwriteWarning, IMessageProvider.WARNING);
        } else {
            setMessage(UIText.PullWizardPage_PageMessage);
        }
        setErrorMessage(null);
    } finally {
        setPageComplete(getErrorMessage() == null);
    }
}

From source file:org.eclipse.egit.ui.internal.push.PushBranchPage.java

License:Open Source License

private void checkPage() {
    try {// w  ww . j  av  a  2  s.  c  om
        if (remoteConfig == null) {
            setErrorMessage(UIText.PushBranchPage_ChooseRemoteError);
            return;
        }
        String branchName = remoteBranchNameText.getText();
        if (branchName.length() == 0) {
            setErrorMessage(
                    MessageFormat.format(UIText.PushBranchPage_ChooseBranchNameError, remoteConfig.getName()));
            return;
        }
        if (!Repository.isValidRefName(Constants.R_HEADS + branchName)) {
            setErrorMessage(UIText.PushBranchPage_InvalidBranchNameError);
            return;
        }
        if (getUpstreamConfig() != null && hasDifferentUpstreamConfiguration()) {
            setMessage(UIText.PushBranchPage_UpstreamConfigOverwriteWarning, IMessageProvider.WARNING);
        } else {
            setMessage(UIText.PushBranchPage_PageMessage);
        }
        setErrorMessage(null);
    } finally {
        setPageComplete(getErrorMessage() == null);
    }
}

From source file:org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreDiagramEditor.java

License:Open Source License

/**
 * @generated//  ww  w. j a  v  a2 s .  c  o m
 */
@Override
protected void performSaveAs(IProgressMonitor progressMonitor) {
    Shell shell = getSite().getShell();
    IEditorInput input = getEditorInput();
    SaveAsDialog dialog = new SaveAsDialog(shell);
    IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null;
    if (original != null) {
        dialog.setOriginalFile(original);
    }
    dialog.create();
    IDocumentProvider provider = getDocumentProvider();
    if (provider == null) {
        // editor has been programmatically closed while the dialog was open
        return;
    }
    if (provider.isDeleted(input) && original != null) {
        String message = NLS.bind(Messages.AcoreDiagramEditor_SavingDeletedFile, 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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell, Messages.AcoreDiagramEditor_SaveAsErrorTitle,
                    Messages.AcoreDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell, Messages.AcoreDiagramEditor_SaveErrorTitle,
                    Messages.AcoreDiagramEditor_SaveErrorMessage, x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}

From source file:org.eclipse.emf.ecoretools.legacy.diagram.part.EcoreCreationWizardPage.java

License:Open Source License

/**
 * Check if the created files does not already exist
 *//*from w w  w .  j  av  a  2 s.c om*/
private void validateExistingFiles() {
    if (modelFileExist()) {
        if (diagramFileExist()) {
            setMessage(
                    org.eclipse.emf.ecoretools.legacy.diagram.Messages.EcoreCreationWizardPage_FilesAlreadyExist,
                    IMessageProvider.WARNING);
        } else {
            setMessage(
                    org.eclipse.emf.ecoretools.legacy.diagram.Messages.EcoreCreationWizardPage_DomainFileAlreadyExists,
                    IMessageProvider.WARNING);
        }
    } else if (diagramFileExist()) {
        setMessage(
                org.eclipse.emf.ecoretools.legacy.diagram.Messages.EcoreCreationWizardPage_DiagramFileAlreadyExists,
                IMessageProvider.WARNING);
    }
}

From source file:org.eclipse.emf.ecoretools.legacy.diagram.part.EcoreCreationWizardPage.java

License:Open Source License

/**
 * Validate the group if the user has chosen to create a new diagram file
 * from an existing domain file/* w ww . ja  v a 2  s.  co  m*/
 * 
 * @return <code>true</code> if data is valid
 */
private boolean validateExistingModel() {
    // the user has chosen an existing domain file
    if (modelFd.getText() == null || "".equals(modelFd.getText())) { //$NON-NLS-1$
        setErrorMessage(
                org.eclipse.emf.ecoretools.legacy.diagram.Messages.EcoreCreationWizardPage_ChooseExistingDomainFile);
        return false;
    }

    if (!DOMAIN_EXT.equals(((IFile) ResourcesPlugin.getWorkspace().getRoot().findMember(modelFd.getText()))
            .getFileExtension())) {
        setErrorMessage(NLS.bind(Messages.EcoreCreationWizardPageExtensionError, DOMAIN_EXT));
        return false;
    }

    if (diagramFileExist()) {
        setMessage(
                org.eclipse.emf.ecoretools.legacy.diagram.Messages.EcoreCreationWizardPage_DiagramFileAlreadyExists,
                IMessageProvider.WARNING);
    }

    // Check whether the selected domain element is an EPackage
    if (!(getDiagramEObject() instanceof EPackage)) {
        setErrorMessage(
                org.eclipse.emf.ecoretools.legacy.diagram.Messages.EcoreCreationWizardPage_ChooseAnEPackageElement);
        return false;
    }

    return true;
}

From source file:org.eclipse.emf.ecoretools.legacy.diagram.part.EcoreDiagramEditor.java

License:Open Source License

/**
 * @generated//ww  w .ja v a2 s  .c  o  m
 */
protected void performSaveAs(IProgressMonitor progressMonitor) {
    Shell shell = getSite().getShell();
    IEditorInput input = getEditorInput();
    SaveAsDialog dialog = new SaveAsDialog(shell);
    IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null;
    if (original != null) {
        dialog.setOriginalFile(original);
    }
    dialog.create();
    IDocumentProvider provider = getDocumentProvider();
    if (provider == null) {
        // editor has been programmatically closed while the dialog was open
        return;
    }
    if (provider.isDeleted(input) && original != null) {
        String message = NLS.bind(Messages.EcoreDiagramEditor_SavingDeletedFile, 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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell, Messages.EcoreDiagramEditor_SaveAsErrorTitle,
                    Messages.EcoreDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell, Messages.EcoreDiagramEditor_SaveErrorTitle,
                    Messages.EcoreDiagramEditor_SaveErrorMessage, x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}

From source file:org.eclipse.emf.ecoretools.legacy.tabbedproperties.sections.AbstractTabbedPropertySection.java

License:Open Source License

/**
 * Add a decorator to the given control. A tool tip will display the given
 * message//from w w  w.  java 2 s . co  m
 * 
 * @param control
 * @param message
 * 
 * @since 1.0 M3
 */
protected void setWarningDecorator(Control control, String message) {
    setDecorator(control, message, IMessageProvider.WARNING);
}

From source file:org.eclipse.emf.ecp.view.model.presentation.ViewModelWizardNewFileCreationPage.java

License:Open Source License

private void checkProjectNature() {
    final IProject project = getModelFile().getProject();
    try {/*w  w  w. java2s . c  o m*/
        if (!project.hasNature("org.eclipse.pde.PluginNature")) { //$NON-NLS-1$
            setMessage(ViewEditorPlugin.INSTANCE.getString("_WARN_PluginProject"), IMessageProvider.WARNING); //$NON-NLS-1$
        }
    } catch (final CoreException ex) {
        // do nothing
    }
}

From source file:org.eclipse.emf.editor.ModelCheckor.java

License:Open Source License

public List<MessageData> check(ExtendedReflectiveItemProvider extendedReflectiveItemProvider, EditingDomain ed,
        IFile file) {//from   ww w .  jav  a  2  s .co m
    ResourceSet toCheck = ed.getResourceSet();
    List<MessageData> messages = new ArrayList<MessageData>();
    markerHandler.deleteMarkers(file, new NullProgressMonitor());

    try {
        // get copy
        EList<Resource> resources = toCheck.getResources();
        if (resources != null) {
            for (Resource res : resources) {
                // Clear Marker
                if (eclipseResourcesUtil != null) {
                    eclipseResourcesUtil.deleteMarkers(res);
                }
                ValidationInfoAdapter.removeAll(res);
                EList<EObject> contents = res.getContents();
                if (contents.isEmpty())
                    continue;
                EObject rootObject = contents.iterator().next();
                // xtend checks
                List<MessageData> checkValidation = checkValidation(rootObject);
                for (MessageData md : checkValidation) {
                    List<?> data = md.getData();
                    String location = null;
                    Iterator<?> iterator = data.iterator();
                    Object o = iterator.next();// object index 0
                    if (o instanceof EObject) {
                        EObject eO = (EObject) o;
                        EStructuralFeature f = null;
                        location = extendedReflectiveItemProvider.getText(eO);
                        if (iterator.hasNext()) {
                            Object obj = iterator.next();// feature index 1
                            // TODO get location using Element and Feature
                            // from
                            // md.getData()
                            if (obj instanceof EStructuralFeature) {
                                f = (EStructuralFeature) obj;
                                location += ("#" + f.getName());
                            }
                        }
                        eO.eAdapters().add(new ValidationInfoAdapter(md.getMessage(), f, md.getStatus()));
                    }
                    markerHandler.addMarker(file, md.getMessage(), md.getStatus(), location);
                }
                // ecore
                messages.addAll(checkValidation);
                messages.addAll(ecoreValidation(rootObject));
            }
        }
    } catch (Exception e) {
        String erMes = e.getLocalizedMessage();
        if (erMes == null) {
            erMes = e.toString();
        }
        messages.add(new MessageData(":(", "An Error occured during checking: " + erMes, null,
                IMessageProvider.WARNING));
    }
    return messages;
}