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

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

Introduction

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

Prototype

int INFORMATION

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

Click Source Link

Document

Constant for an info message (value 1).

Usage

From source file:org.eclipse.sirius.ui.tools.internal.views.interpreterview.DesignerInterpreterView.java

License:Open Source License

private void handleNewExpression() {
    if (interpreter != null && current != null) {
        try {// w  w w.  j  a  v  a  2 s . co m
            final ECrossReferenceAdapter crosser = retrieveCrosser(current);
            if (crosser != null) {
                interpreter.setCrossReferencer(crosser);
            }
            final Resource resource = current.eResource();
            if (resource != null) {
                final String path = resource.getURI().toPlatformString(true);
                interpreter.setProperty("file", path);
            }

            final long now = new Date().getTime();

            final Object result = interpreter.evaluate(current, acceleoExpression.getText());
            final long ellapseTime = new Date().getTime() - now;
            final int numberOfResults = handleExpressionResult(result);
            final DecimalFormat decimalFormat = new DecimalFormat("###,###,###.###");
            this.interpreterForm
                    .setMessage(
                            "Evaluation successful. Number of returned elements : " + numberOfResults
                                    + ". Time to evaluate : "
                                    + decimalFormat.format(ellapseTime / (double) 1000) + " second(s)",
                            IMessageProvider.INFORMATION);
        } catch (final EvaluationException e) {
            this.interpreterForm.setMessage("Invalid expression. " + e.getMessage(), IMessageProvider.ERROR);
        }
    }
}

From source file:org.eclipse.sirius.ui.tools.internal.wizards.pages.RepresentationsSelectionWizardPage.java

License:Open Source License

/**
 * Create a new <code>DescDiagramSelectionWizardPage</code>.
 * //from w ww  . j a  v a 2  s .c  om
 * @param root
 *            the root object
 * @param representations
 *            the preselection.
 */
public RepresentationsSelectionWizardPage(final Session root,
        final Collection<DRepresentation> representations) {
    super(PAGE_TITLE);
    this.setTitle(PAGE_TITLE);
    this.root = root;
    this.preselection = representations;
    if (preselection.size() > 0) {
        setPageComplete(true);
    }
    setMessage(SELECT_REPRESENTATIONS_TO_EXPORT, IMessageProvider.INFORMATION);
}

From source file:org.eclipse.tcf.te.tcf.filesystem.ui.internal.wizards.NameValidator.java

License:Open Source License

@Override
public boolean isValid(String newText) {
    IFSTreeNode folder = wizard.getInputDir();
    if (folder == null) {
        setMessage(Messages.NameValidator_SpecifyFolder, IMessageProvider.INFORMATION);
        return false;
    }/*from  www  .  j av  a2  s  . com*/
    if (newText == null || newText.trim().length() == 0) {
        setMessage(Messages.FSRenamingAssistant_SpecifyNonEmptyName, IMessageProvider.ERROR);
        return false;
    }
    String text = newText.trim();
    if (hasChild(text)) {
        setMessage(Messages.FSRenamingAssistant_NameAlreadyExists, IMessageProvider.ERROR);
        return false;
    }
    String formatRegex = folder.isWindowsNode() ? FSCellValidator.WIN_FILENAME_REGEX
            : FSCellValidator.UNIX_FILENAME_REGEX;
    if (!text.matches(formatRegex)) {
        setMessage(folder.isWindowsNode() ? Messages.FSRenamingAssistant_WinIllegalCharacters
                : Messages.FSRenamingAssistant_UnixIllegalCharacters, IMessageProvider.ERROR);
        return false;
    }
    setMessage(null, IMessageProvider.NONE);
    return true;
}

From source file:org.eclipse.tcf.te.tcf.launch.ui.filetransfer.AddEditFileTransferDialog.java

License:Open Source License

@Override
protected void createDialogAreaContent(Composite parent) {
    super.createDialogAreaContent(parent);

    // Set dialog title and default message
    setDialogTitle(modeNew ? Messages.AddEditFileTransferDialog_add_dialogTitle
            : Messages.AddEditFileTransferDialog_edit_dialogTitle);
    setTitle(modeNew ? Messages.AddEditFileTransferDialog_add_title
            : Messages.AddEditFileTransferDialog_edit_title);
    setDefaultMessage(modeNew ? Messages.AddEditFileTransferDialog_add_message
            : Messages.AddEditFileTransferDialog_edit_message, IMessageProvider.INFORMATION);

    // Create the inner panel
    Composite panel = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;/* w  w w.jav a 2s.  c o m*/
    layout.marginWidth = 0;
    panel.setLayout(layout);
    panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    @SuppressWarnings("unused")
    Label spacer = new Label(panel, SWT.NONE);

    toTarget = new Button(panel, SWT.RADIO);
    toTarget.setText(Messages.AddEditFileTransferDialog_toTarget_checkbox);
    toTarget.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            validate();
        }
    });

    spacer = new Label(panel, SWT.NONE);

    toHost = new Button(panel, SWT.RADIO);
    toHost.setText(Messages.AddEditFileTransferDialog_toHost_checkbox);
    toHost.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            validate();
        }
    });

    // Create the section sub controls
    host = new BaseEditBrowseTextControl(null) {
        @Override
        protected void onButtonControlSelected() {
            @SuppressWarnings("synthetic-access")
            int direction = toTarget.getSelection() ? IFileTransferItem.HOST_TO_TARGET
                    : IFileTransferItem.TARGET_TO_HOST;
            if (direction == IFileTransferItem.HOST_TO_TARGET) {
                FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN);
                fileDialog.setFilterPath(getEditFieldControlText());
                fileDialog.setFileName(getEditFieldControlText());
                String file = fileDialog.open();
                if (file != null) {
                    setEditFieldControlText(file);
                }
            } else {
                DirectoryDialog directoryDialog = new DirectoryDialog(getShell(), SWT.OPEN);
                directoryDialog.setFilterPath(getEditFieldControlText());
                String directory = directoryDialog.open();
                if (directory != null) {
                    setEditFieldControlText(directory);
                }
            }
        }

        @Override
        public void modifyText(ModifyEvent e) {
            validate();
        }
    };
    host.setEditFieldLabel(Messages.AddEditFileTransferDialog_host_label);
    host.setIsGroup(false);
    host.setHideBrowseButton(false);
    host.setAdjustBackgroundColor(true);
    host.setParentControlIsInnerPanel(true);
    host.setupPanel(panel);
    host.doCreateControlDecoration(host.getEditFieldControl());

    // Create the section sub controls
    target = new BaseEditBrowseTextControl(null) {
        @Override
        protected void onButtonControlSelected() {
            @SuppressWarnings("synthetic-access")
            int direction = toTarget.getSelection() ? IFileTransferItem.HOST_TO_TARGET
                    : IFileTransferItem.TARGET_TO_HOST;
            ElementTreeSelectionDialog dialog = direction == IFileTransferItem.HOST_TO_TARGET
                    ? new FSFolderSelectionDialog(getShell())
                    : new FSOpenFileDialog(getShell());
            dialog.setInput(getEditFieldControlText());
            dialog.setInput(launchContext);
            if (dialog.open() == Window.OK) {
                Object candidate = dialog.getFirstResult();
                if (candidate instanceof IFSTreeNode) {
                    String absPath = ((IFSTreeNode) candidate).getLocation();
                    if (absPath != null) {
                        setEditFieldControlText(absPath);
                    }
                }
            }
        }

        @Override
        public void modifyText(ModifyEvent e) {
            validate();
        }
    };
    target.setEditFieldLabel(Messages.AddEditFileTransferDialog_target_label);
    target.setIsGroup(false);
    target.setHideBrowseButton(false);
    target.setAdjustBackgroundColor(true);
    target.setParentControlIsInnerPanel(true);
    target.setupPanel(panel);
    target.doCreateControlDecoration(target.getEditFieldControl());

    spacer = new Label(panel, SWT.NONE);
    spacer = new Label(panel, SWT.NONE);

    options = new BaseEditBrowseTextControl(null) {
        @Override
        public void modifyText(ModifyEvent e) {
            validate();
        }
    };
    options.setEditFieldLabel(Messages.AddEditFileTransferDialog_options_label);
    options.setIsGroup(false);
    options.setHideBrowseButton(true);
    options.setHasHistory(false);
    options.setAdjustBackgroundColor(true);
    options.setParentControlIsInnerPanel(true);
    options.setupPanel(panel);
    options.doCreateControlDecoration(target.getEditFieldControl());

    applyDialogFont(panel);
}

From source file:org.eclipse.tcf.te.tcf.processes.ui.internal.dialogs.AttachContextSelectionDialog.java

License:Open Source License

@Override
protected void createDialogAreaContent(Composite parent) {
    super.createDialogAreaContent(parent);

    // Set dialog title and default message
    setDialogTitle(Messages.AttachContextSelectionDialog_dialogTitle);
    setTitle(Messages.AttachContextSelectionDialog_title);
    setDefaultMessage(Messages.AttachContextSelectionDialog_message, IMessageProvider.INFORMATION);

    // Create the inner panel
    Composite panel = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 0;//from  w  w  w .ja  v  a 2  s . c o  m
    layout.marginWidth = 0;
    panel.setLayout(layout);
    panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Label filterLabel = new Label(panel, SWT.NONE);
    filterLabel.setText(Messages.AttachContextSelectionDialog_filter_label);

    PatternFilter filter = new PatternFilter() {
        @Override
        public boolean isElementSelectable(final Object element) {
            final AtomicBoolean canAttach = new AtomicBoolean();
            if (element instanceof IProcessContextNode) {
                Protocol.invokeAndWait(new Runnable() {
                    @Override
                    public void run() {
                        canAttach.set(canAttach(element));
                    }
                });
            }
            return element instanceof IProcessContextNode;
        }

        @Override
        protected boolean isLeafMatch(Viewer viewer, final Object element) {
            if (element instanceof IProcessContextNode) {
                final AtomicBoolean canAttach = new AtomicBoolean();
                Protocol.invokeAndWait(new Runnable() {
                    @Override
                    public void run() {
                        canAttach.set(canAttach(element));
                    }
                });
                return canAttach.get() && super.isLeafMatch(viewer, element);
            }
            return true;
        }
    };
    filter.setIncludeLeadingWildcard(true);
    filter.setPattern("org.eclipse.ui.keys.optimization.false"); //$NON-NLS-1$

    filteredTree = new FilteredTree(panel, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filter, true) {
        /* (non-Javadoc)
         * @see org.eclipse.ui.dialogs.FilteredTree#getFilterString()
         */
        @Override
        protected String getFilterString() {
            String filter = super.getFilterString();
            if (filter != null) {
                filter = filter.trim();
                if (filter.length() == 0) {
                    return "*"; //$NON-NLS-1$
                }
                return filter;
            }
            return null;
        }
    };
    viewer = filteredTree.getViewer();
    GridData gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
    gd.minimumHeight = 250;
    gd.minimumWidth = 300;
    gd.widthHint = 300;
    gd.heightHint = 300;
    filteredTree.setLayoutData(gd);
    // needs to be set using reflection as it is e4
    // filteredTree.setQuickSelectionMode(true);
    try {
        Method method = filteredTree.getClass().getMethod("setQuickSelectionMode", Boolean.TYPE); //$NON-NLS-1$
        method.invoke(filteredTree, Boolean.TRUE);
    } catch (Throwable e) {
    }

    viewer.setContentProvider(new ContentProvider());
    DelegatingLabelProvider labelProvider = new DelegatingLabelProvider() {
        /* (non-Javadoc)
         * @see org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider#decorateText(java.lang.String, java.lang.Object)
         */
        @Override
        public String decorateText(String text, final Object element) {
            if (element instanceof IProcessContextNode) {

                final AtomicBoolean isAttached = new AtomicBoolean();
                final AtomicLong pid = new AtomicLong();
                Protocol.invokeAndWait(new Runnable() {
                    @Override
                    public void run() {
                        isAttached.set(isAttached(element));
                        pid.set(((IProcessContextNode) element).getSysMonitorContext().getPID());
                    }
                });

                String id = pid.get() >= 0 ? Long.toString(pid.get()) : ""; //$NON-NLS-1$
                if (id.startsWith("P")) //$NON-NLS-1$
                    id = id.substring(1);
                IPeerNode peerNode = (IPeerNode) ((IProcessContextNode) element).getAdapter(IPeerNode.class);
                IProcessMonitorUIDelegate delegate = ServiceUtils.getUIServiceDelegate(peerNode, peerNode,
                        IProcessMonitorUIDelegate.class);
                String newId = delegate != null ? delegate.getText(element, "PID", id) : null; //$NON-NLS-1$
                if (newId != null) {
                    text = NLS.bind(Messages.AttachContextSelectionDialog_pid_decoration, text, newId);
                }
                if (isAttached.get()) {
                    text = NLS.bind(Messages.AttachContextSelectionDialog_allReadyAttached_decoration, text);
                }
            }
            return text;
        }

        /* (non-Javadoc)
         * @see org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider#getForeground(java.lang.Object)
         */
        @Override
        public Color getForeground(final Object element) {
            final AtomicBoolean canAttach = new AtomicBoolean();
            final AtomicBoolean isAttached = new AtomicBoolean();
            Protocol.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    canAttach.set(canAttach(element));
                    isAttached.set(isAttached(element));
                }
            });
            if (!canAttach.get() || isAttached.get()) {
                return PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
            }
            return null;
        }
    };
    viewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            validate();
        }
    });
    viewer.addDoubleClickListener(new IDoubleClickListener() {
        @Override
        public void doubleClick(DoubleClickEvent event) {
            if (event.getSelection() instanceof IStructuredSelection
                    && ((IStructuredSelection) event.getSelection()).size() > 0) {
                final Object selected = ((IStructuredSelection) event.getSelection()).getFirstElement();
                final AtomicBoolean valid = new AtomicBoolean();
                Protocol.invokeAndWait(new Runnable() {
                    @Override
                    public void run() {
                        valid.set(isValid(selected));
                    }
                });
                if (valid.get()) {
                    okPressed();
                }
            }
        }
    });

    viewer.setSorter(new TreeViewerSorterCaseInsensitive());

    EventManager.getInstance().addEventListener(this, ChangeEvent.class);

    restoreWidgetValues();
    setupData(data);
    applyDialogFont(panel);

    initDone = true;
}

From source file:org.eclipse.tcf.te.ui.controls.BaseControl.java

License:Open Source License

/**
 * Returns the controls default message type or {@link IMessageProvider#NONE} if none.
 *
 * @return The controls default message type.
 *///from   ww w  .  j av a2 s .  co  m
public int getDefaultMessageType() {
    return IMessageProvider.INFORMATION;
}

From source file:org.eclipse.tcf.te.ui.controls.net.RemoteHostAddressControl.java

License:Open Source License

/**
 * If the user entered a host name, we have to validate that we can really resolve the name
 * to an IP address. Because this may really take a while, give the user the feedback what
 * we are actually doing.// w w  w . jav  a2s . co m
 */
private void onCheckAddress() {
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getParentControl().getShell());
    try {
        dialog.run(false, false, new IRunnableWithProgress() {
            private final String address = getEditFieldControlText();
            private final Control control = getEditFieldControl();
            private final IDialogPage parentPage = getParentPage();

            /* (non-Javadoc)
             * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
             */
            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    monitor.setTaskName(getTaskNameCheckNameAddress());
                    InetAddress[] addresses = InetAddress.getAllByName(address);
                    if (Platform.inDebugMode() && addresses != null) {
                        StringBuilder message = new StringBuilder();
                        message.append("RemoteHostAddressControl: Name '"); //$NON-NLS-1$
                        message.append(address);
                        message.append("' resolves to: "); //$NON-NLS-1$
                        boolean firstAddress = true;
                        for (InetAddress address : addresses) {
                            if (!firstAddress)
                                message.append(", "); //$NON-NLS-1$
                            message.append(address.getHostAddress());
                            firstAddress = false;
                        }

                        IStatus status = new Status(IStatus.WARNING, UIPlugin.getUniqueIdentifier(),
                                message.toString());
                        UIPlugin.getDefault().getLog().log(status);
                    }

                    setCheckResultMessage(IMessageProvider.INFORMATION,
                            getInformationTextCheckNameAddressSuccess());
                } catch (Exception e) {
                    setCheckResultMessage(IMessageProvider.WARNING, getErrorTextCheckNameAddressFailed());
                    control.setFocus();
                } finally {
                    // Trigger the wizard container update
                    IWizardContainer container = null;

                    try {
                        // Try to get the wizard container from the parent page
                        if (parentPage != null) {
                            Class<?>[] paramTypes = new Class[0];
                            Object[] args = new Object[0];
                            final Method method = parentPage.getClass().getMethod("getContainer", paramTypes); //$NON-NLS-1$
                            if (!method.isAccessible()) {
                                AccessController.doPrivileged(new PrivilegedAction<Object>() {
                                    @Override
                                    public Object run() {
                                        method.setAccessible(true);
                                        return null;
                                    }
                                });
                            }
                            Object result = method.invoke(parentPage, args);
                            if (result instanceof IWizardContainer) {
                                container = (IWizardContainer) result;
                            }
                        }
                    } catch (Exception e) {
                        // If the object does not have a "getContainer()" method,
                        // or the invocation fails or the access to the method
                        // is denied, we are done here and break the loop
                        container = null;
                    }

                    if (container != null) {
                        container.updateButtons();
                        container.updateMessage();
                    }
                }
            }
        });
    } catch (Exception e) {
    }
}

From source file:org.eclipse.tcf.te.ui.dialogs.NameValuePairDialog.java

License:Open Source License

/**
 * Enable the OK button if valid input/*  w  ww. ja v  a 2s.c om*/
 */
protected void updateButtons() {
    String name = SWTControlUtil.getText(nameText).trim();
    String value = SWTControlUtil.getText(valueText).trim();

    if (name.trim().length() == 0) {
        setMessage(getErrorMissingName(), IMessageProvider.INFORMATION);
    } else if (usedNames.contains(name.trim())) {
        setMessage(NLS.bind(getErrorUsedOrIllegalName(), name), IMessageProvider.ERROR);
    } else if (value.trim().length() == 0) {
        setMessage(NLS.bind(getErrorMissingValue(), name), IMessageProvider.INFORMATION);
    } else {
        setMessage(message, IMessageProvider.NONE);
    }
    getButton(IDialogConstants.OK_ID).setEnabled(getMessageType() == IMessageProvider.NONE);
}

From source file:org.eclipse.tcf.te.ui.dialogs.RenameDialog.java

License:Open Source License

@Override
protected void createDialogAreaContent(Composite parent) {
    super.createDialogAreaContent(parent);

    setDialogTitle(dialogTitle);/*  www . j  a va  2 s  .c o  m*/
    setTitle(title);
    setDefaultMessage(defaultMessage, IMessageProvider.INFORMATION);

    //we need two columns
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));
    comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    new Label(comp, SWT.NONE).setText(label);
    name = new Text(comp, SWT.BORDER | SWT.SINGLE);
    name.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    name.setText(oldName);
    name.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            if (usedNames.contains(name.getText().trim().toUpperCase())) {
                setButtonEnabled(OK, false);
                setMessage(usedErrorMessage, IMessageProvider.ERROR);
            } else if (!name.getText().matches(formatRegex)) {
                setButtonEnabled(OK, false);
                setMessage(formatErrorMessage, IMessageProvider.ERROR);
            } else {
                setButtonEnabled(OK, true);
                setMessage(defaultMessage, IMessageProvider.INFORMATION);
            }
        }
    });

    applyDialogFont(comp);
}

From source file:org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage.java

License:Open Source License

/**
 * Get the image for the given message type.
 * @param messageType The message type.// w w w.  ja  va2 s  . c  o m
 * @return The image.
 */
protected Image getMessageImage(int messageType) {
    switch (messageType) {
    case IMessageProvider.INFORMATION:
        return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
    case IMessageProvider.WARNING:
        return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
    case IMessageProvider.ERROR:
        return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
    default:
        return null;
    }
}