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

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

Introduction

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

Prototype

int ERROR

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

Click Source Link

Document

Constant for an error message (value 3).

Usage

From source file:org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.ProfileSelectionPageHelper.java

License:Open Source License

private void setDefaultMessageAsError(boolean isError) {
    int newType = isError ? IMessageProvider.ERROR : IMessageProvider.NONE;
    setMessage(Messages.profilePage_selectProfileDefaultMessage, newType);
}

From source file:org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.ProfileSelectionPageHelper.java

License:Open Source License

private void setupConnectionProfilePath(Composite composite) {
    Label label = new Label(composite, SWT.NONE);
    label.setText(Messages.profilePage_label_profileStore);
    label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));

    m_connectionProfilePath = new Text(composite, SWT.BORDER);
    GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.widthHint = 260;// w  ww .j  a  va2 s .c  om
    m_connectionProfilePath.setLayoutData(layoutData);
    m_connectionProfilePath.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            BusyIndicator.showWhile(getShell() == null ? null : getShell().getDisplay(), new Runnable() {

                public void run() {
                    populateTree();
                    setExternalLinkDefaultState();

                    // clear any previously selected profile settings
                    clearSelectedProfile();
                    setSelectedDataSourceName(EMPTY_STRING);
                    setDefaultMessageAsError(hasConnectionProfilePath());

                    if (hasConnectionProfilePath()
                            && !new Path(getResolvedConnProfilePathControlText()).toFile().exists())
                        setMessage(Messages.profilePage_error_invalidProfileStorePath, IMessageProvider.ERROR);

                    // check if profile tree has only one profile item, 
                    // automatically select it if feature is not disabled
                    if (hasConnectionProfilePath()
                            && m_connectionProfilePath.getData(DISABLE_AUTO_SELECT_ITEM) != Boolean.TRUE) {
                        TreeItem singleProfileItem = findSingleProfileInTree();
                        if (singleProfileItem != null) {
                            m_odaDataSourceTree.setSelection(singleProfileItem);
                            handleTreeSelection();
                        }
                    }
                }
            });
        }
    });

    // Browse... button
    IMenuButtonProvider provider = new MenuButtonProvider(false);
    m_browseButton = new ProfileStoreBrowseButton(composite, SWT.PUSH, provider, this);
    GridData data = new GridData();
    data.widthHint = m_browseButton.computeButtonWidth();
    m_browseButton.setLayoutData(data);

    if (m_wizardPage != null && m_wizardPage instanceof ProfileSelectionWizardPage) {
        m_hostResourceIdentifiers = ((ProfileSelectionWizardPage) m_wizardPage).getHostResourceIdentifiers();
    }
    if (m_propertyPage != null && m_propertyPage instanceof ProfileSelectionEditorPage) {
        m_hostResourceIdentifiers = ((ProfileSelectionEditorPage) m_propertyPage).getHostResourceIdentifiers();
    }
    if (m_hostResourceIdentifiers != null) {
        File resourceBase = new File(m_hostResourceIdentifiers.getApplResourceBaseURI());
        m_browseButton.getMenuButtonProvider().setProperty(RESOURCE_FILE_DIR, resourceBase);
    }
    m_browseButton.getMenuButtonProvider().setProperty(IS_CREATE_PROFILE, Boolean.FALSE);

    m_browseButton.refreshMenuItems();

    // New... button
    createNewProfileStoreButton(composite);
}

From source file:org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.ProfileSelectionPageHelper.java

License:Open Source License

private Map<String, String> getProfileIdentifiersByCategory(String categoryId) {
    try {/*w  w  w. ja v  a 2  s. c o m*/
        return OdaProfileExplorer.getInstance().getProfileIdsAndNamesByCategory(categoryId,
                new Path(getResolvedConnProfilePathControlText()).toFile());
    } catch (OdaException ex) {
        setMessage(Messages.profilePage_error_invalidProfileStorePath, IMessageProvider.ERROR);
    }

    return null;
}

From source file:org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.ProfileSelectionPageHelper.java

License:Open Source License

/**
 * Setup DataSourceName layout//from  ww w. ja  v  a 2s  .c  o  m
 */
private void setupDataSourceName(Composite composite) {
    GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.horizontalSpan = 3;
    m_useDefaultDSNameCheckBox = new Button(composite, SWT.CHECK);
    m_useDefaultDSNameCheckBox.setText(Messages.profilePage_checkboxLabel_useDefaultName);
    m_useDefaultDSNameCheckBox.setSelection(true);
    m_useDefaultDSNameCheckBox.setLayoutData(layoutData);
    m_useDefaultDSNameCheckBox.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (m_useDefaultDSNameCheckBox.getSelection()) {
                // reset the design name to the default
                TreeItem item = getSelectedProfileItem();
                if (item != null)
                    setSelectedDataSourceName(item.getText());
            }

            enableDataSourceNameEditor(!m_useDefaultDSNameCheckBox.getSelection());
        }
    });

    m_dataSourceNameLabel = new Label(composite, SWT.NONE);
    m_dataSourceNameLabel.setText(Messages.profilePage_label_dataSourceName);
    m_dataSourceNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));

    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.horizontalSpan = 2;
    m_dataSourceDesignNameControl = new Text(composite, SWT.BORDER);
    m_dataSourceDesignNameControl.setLayoutData(layoutData);
    m_dataSourceDesignNameControl.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            setDataSourceDesignName(m_dataSourceDesignNameControl.getText());

            String invalidMessage = null;
            if (isDesignNameBlank()) {
                setPageComplete(false);
                setMessage(Messages.profilePage_error_emptyName, IMessageProvider.ERROR);
            } else if ((invalidMessage = validateAndGetErrorMessage()) != null) {
                setPageComplete(false);
                setMessage(invalidMessage, IMessageProvider.ERROR);
            } else // name value is ok
            {
                // when creating a new data source, the name must be associated
                // with a profile selection either by import or reference
                boolean isNameOk = inEditMode() ? true : hasSelectedProfile();
                setPageComplete(isNameOk);
            }
        }
    });

    enableDataSourceNameEditor(false);
}

From source file:org.eclipse.datatools.enablement.sybase.asa.schemaobjecteditor.examples.tableeditor.commonui.ColumnDefaultValueInputDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    parent.setLayout(new GridLayout());

    Composite outter = new Composite(parent, SWT.NONE);
    outter.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;/*from w  ww.j  av  a 2  s .c o  m*/
    layout.marginWidth = 0;
    layout.numColumns = 1;
    outter.setLayout(layout);

    _noDefaultRadio = new Button(outter, SWT.RADIO);
    _noDefaultRadio.setText(Messages.ColumnDefaultValueInputDialog_no_default);
    _noDefaultRadio.setToolTipText(Messages.ColumnDefaultValueInputDialog_no_default_tip);
    _noDefaultRadio.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            enableDefaultValue(_defaultValueRadio.getSelection());
            _computedText.setEnabled(_computedValueRadio.getSelection());
            validateDefaultAndUpdate();
        }
    });

    _defaultValueRadio = new Button(outter, SWT.RADIO);
    _defaultValueRadio.setText(Messages.ColumnDefaultValueInputDialog_default_value_radio);
    _defaultValueRadio.setToolTipText(Messages.ColumnDefaultValueInputDialog_default_tip);
    _defaultValueRadio.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            enableDefaultValue(_defaultValueRadio.getSelection());
            _computedText.setEnabled(_computedValueRadio.getSelection());
            if (_defaultValueRadio.getSelection()) {
                _userDefinedDefaultRadio.notifyListeners(SWT.Selection, new Event());
            }
            validateDefaultAndUpdate();
        }
    });

    Composite comp = new Composite(outter, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 5;
    comp.setLayout(layout);
    comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label blankLabel = new Label(comp, SWT.NONE);
    GridData gd = new GridData();
    gd.widthHint = Constants.BLANK_WIDTH;
    blankLabel.setLayoutData(gd);

    _userDefinedDefaultRadio = new Button(comp, SWT.RADIO);
    _userDefinedDefaultRadio.setSelection(true);
    _userDefinedDefaultRadio.setText(Messages.ColumnDefaultValueInputDialog_user_defined);
    _userDefinedDefaultRadio.setToolTipText(Messages.ColumnDefaultValueInputDialog_ud_default_tip);
    _userDefinedDefaultRadio.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            _defaultValueTxt.notifyListeners(SWT.Modify, new Event());
            enableUserDefinedPart(_userDefinedDefaultRadio.getSelection());
            validateDefaultAndUpdate();
        }
    });

    _defaultValueTxt = new Text(comp, SWT.BORDER);
    gd = new GridData();
    gd.widthHint = Constants.WIDGET_WIDTH_TEXT_NARROW;
    _defaultValueTxt.setLayoutData(gd);
    _defaultValueTxt.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            validateDefaultAndUpdate();
        }
    });

    _isDefaultLiteralButton = new Button(comp, SWT.CHECK);
    _isDefaultLiteralButton.setText(Messages.ColumnDefaultValueInputDialog_literal_string);
    _isDefaultLiteralButton.setToolTipText(Messages.ColumnDefaultValueInputDialog_literal_tip);
    _isDefaultLiteralButton.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
            validateDefaultAndUpdate();
        }

        public void widgetSelected(SelectionEvent e) {
            validateDefaultAndUpdate();
        }
    });
    gd = new GridData();
    gd.horizontalSpan = 2;
    _isDefaultLiteralButton.setLayoutData(gd);

    blankLabel = new Label(comp, SWT.NONE);
    gd = new GridData();
    gd.widthHint = Constants.BLANK_WIDTH;
    blankLabel.setLayoutData(gd);

    _sysDefinedDefaultRadio = new Button(comp, SWT.RADIO);
    _sysDefinedDefaultRadio.setText(Messages.ColumnDefaultValueInputDialog_system_defined);
    _sysDefinedDefaultRadio.setToolTipText(Messages.ColumnDefaultValueInputDialog_system_defined_default_tip);
    _sysDefinedDefaultRadio.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
            validateDefaultAndUpdate();
        }

        public void widgetSelected(SelectionEvent e) {
            enableUserDefinedPart(_userDefinedDefaultRadio.getSelection());
            validateDefaultAndUpdate();
        }
    });

    _sysDefinedValuesCombo = new Combo(comp, SWT.READ_ONLY);
    gd = new GridData();
    gd.widthHint = Constants.WIDGET_WIDTH_NARROW;
    _sysDefinedValuesCombo.setLayoutData(gd);
    _sysDefinedValuesCombo.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
            //
        }

        public void widgetSelected(SelectionEvent e) {
            if (_sysDefinedDefaultRadio.getSelection()
                    && _sysDefinedValuesCombo.getText().equals(SybaseASADefaultWrapper.GLOBAL_AUTOINCREMENT)) {
                _partionSizeLabel.setEnabled(true);
                _partitionSizeTxt.setEnabled(true);

                // the value may be invalid
                _partitionSizeTxt.notifyListeners(SWT.Modify, new Event());
            } else {
                _partionSizeLabel.setEnabled(false);
                _partitionSizeTxt.setEnabled(false);

                // the OK button may be disabled
                getButton(IDialogConstants.OK_ID).setEnabled(true);
                setMessage(_message);
            }
        }
    });

    _partionSizeLabel = new Label(comp, SWT.NONE);
    _partionSizeLabel.setText(Messages.ColumnDefaultValueInputDialog_partition_size);

    _partitionSizeTxt = new Text(comp, SWT.BORDER);
    gd = new GridData();
    gd.widthHint = Constants.WIDGET_WIDTH_TEXT_NARROW;
    _partitionSizeTxt.setLayoutData(gd);
    _partitionSizeTxt.setToolTipText(Messages.ColumnDefaultValueInputDialog_partition_size_tip);
    _partitionSizeTxt.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (!_partitionSizeTxt.getText().trim().equals("")) //$NON-NLS-1$
            {
                try {
                    int partitionSize = Integer.parseInt(_partitionSizeTxt.getText().trim());
                    if (partitionSize > 0) {
                        setMessage(_message);
                        getButton(IDialogConstants.OK_ID).setEnabled(true);
                    } else {
                        setMessage(Messages.ColumnDefaultValueInputDialog_should_be_positive,
                                IMessageProvider.ERROR);
                        getButton(IDialogConstants.OK_ID).setEnabled(false);
                    }
                } catch (Exception ex) {
                    setMessage(Messages.ColumnDefaultValueInputDialog_not_valid_number
                            + _partitionSizeTxt.getText(), IMessageProvider.ERROR);
                    getButton(IDialogConstants.OK_ID).setEnabled(false);
                }
            } else {
                setMessage(_message);
                getButton(IDialogConstants.OK_ID).setEnabled(true);
            }
        }
    });

    _computedValueRadio = new Button(outter, SWT.RADIO);
    _computedValueRadio.setText(Messages.ColumnDefaultValueInputDialog_computed_value);
    _computedValueRadio.setToolTipText(Messages.ColumnDefaultValueInputDialog_computed_value_tip);
    _computedValueRadio.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            _computedText.setEnabled(_computedValueRadio.getSelection());
            enableDefaultValue(_defaultValueRadio.getSelection());
            validateDefaultAndUpdate();
        }
    });

    Composite computedTextComp = new Composite(outter, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    computedTextComp.setLayout(layout);
    computedTextComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    blankLabel = new Label(computedTextComp, SWT.NONE);
    gd = new GridData();
    gd.widthHint = Constants.BLANK_WIDTH;
    blankLabel.setLayoutData(gd);

    _computedText = new Text(computedTextComp, SWT.BORDER | SWT.MULTI);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.heightHint = 60;
    _computedText.setLayoutData(gd);
    _computedText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            validateDefaultAndUpdate();
        }
    });

    Label sep = new Label(outter, SWT.SEPARATOR | SWT.HORIZONTAL);
    sep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Composite buttonComp = new Composite(outter, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 3;
    buttonComp.setLayout(layout);
    buttonComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    blankLabel = new Label(buttonComp, SWT.NONE);
    blankLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    return outter;
}

From source file:org.eclipse.datatools.enablement.sybase.asa.schemaobjecteditor.examples.tableeditor.commonui.ColumnDefaultValueInputDialog.java

License:Open Source License

private void validateDefaultAndUpdate() {
    if (_noDefaultRadio.getSelection()
            || (_computedValueRadio.getSelection() && _computedText.getText().trim().length() != 0)) {
        setMessage(_message);//from ww w .  ja  v a2  s  . com
        getButton(IDialogConstants.OK_ID).setEnabled(true);
        return;
    } else if (_defaultValueRadio.getSelection() && _sysDefinedDefaultRadio.getSelection()) {
        if (_sysDefinedValuesCombo.getText().equals("")) //$NON-NLS-1$
        {
            setMessage(Messages.ColumnDefaultValueInputDialog_select_a_system_default,
                    IMessageProvider.INFORMATION);
            getButton(IDialogConstants.OK_ID).setEnabled(false);
        } else {
            getButton(IDialogConstants.OK_ID).setEnabled(true);
        }
        return;
    } else if (_defaultValueRadio.getSelection() && _userDefinedDefaultRadio.getSelection()) {
        if (_defaultValueTxt.getText().trim().length() == 0) {
            setMessage(Messages.ColumnDefaultValueInputDialog_input_default, IMessageProvider.INFORMATION);
            getButton(IDialogConstants.OK_ID).setEnabled(false);
            return;
        } else {
            setMessage(_message);
            getButton(IDialogConstants.OK_ID).setEnabled(true);

            ISQLDataOfflineValidator validator = new ASASQLDataOfflineValidator();
            String errorMsg = validator.validate(_column.getDataType(),
                    _isDefaultLiteralButton.getSelection() ? SQLUtil.quote(_defaultValueTxt.getText(), "'") //$NON-NLS-1$
                            : _defaultValueTxt.getText());
            if (errorMsg != null) {
                setMessage(errorMsg, IMessageProvider.ERROR);
                getButton(IDialogConstants.OK_ID).setEnabled(false);
            } else {
                setMessage(_message);
                getButton(IDialogConstants.OK_ID).setEnabled(true);
            }
        }
    } else {
        setMessage(Messages.ColumnDefaultValueInputDialog_input_compute, IMessageProvider.INFORMATION);
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        return;
    }
}

From source file:org.eclipse.datatools.engagement.marklogic.ui.wizards.XmlDataSetSelectionPage.java

License:Open Source License

/**
 * set page status based on row number//w w  w.j  a  va  2s  .c  om
 *
 */
private void updatePageStatus() {
    if (numberText == null) {
        setMessage(DEFAULT_MESSAGE);
        return;
    }

    if (enterXMLSourceButton != null && enterXMLSourceButton.getSelection()) {
        if (fileLocation == null || fileLocation.trim().length() == 0) {
            setDetailsMessage(Messages.getString("error.dataset.Error.MissingFileLocation"), //$NON-NLS-1$
                    IMessageProvider.ERROR);
            setPageComplete(false);
            return;
        }
    }
    String rowNumber = numberText.getText();
    maxRow = validateRowNumber(rowNumber);
    if (maxRow == INVALID_ROW_NUMBER || maxRow == NEGATIVE_ROW_NUMBER) {
        setPageComplete(false);
        setDetailsMessage(Messages.getString("error.dataset.maxRowNumberError"), //$NON-NLS-1$
                IMessageProvider.ERROR);
    } else {
        XMLInformationHolder.setPropertyValue(Constants.CONST_PROP_MAX_ROW, Integer.toString(maxRow));
        setPageComplete(true);
        setMessage(DEFAULT_MESSAGE);
    }
}

From source file:org.eclipse.datatools.engagement.marklogic.ui.wizards.XmlDataSetSelectionPage.java

License:Open Source License

/**
 * verify the file location//from   w w w  .j av  a  2s.c o  m
 * @param fileLocation
 * @return
 */
private int varifyFileLocation(String fileLocation) {
    int result = 0;
    // TODO For migrate into ODA3.0,the relative path is not supported
    // if( this.dataSetHandle.getModuleHandle( ).findResource( fileLocation,
    // IResourceLocator.LIBRARY )!= null)
    // return result;

    if (fileLocation != null && fileLocation.trim().length() > 0) {
        try {
            new URL(fileLocation);
        } catch (MalformedURLException e) {
            File file = new File(fileLocation);
            if (file.exists()) {
                setMessage(DEFAULT_MESSAGE);
            } else {
                setDetailsMessage(Messages.getString("error.selectFolder"), //$NON-NLS-1$
                        IMessageProvider.ERROR);
                result = ERROR_FOLDER;
            }
        }
    } else if (!this.useXMLDataSourceButton.getSelection()) {
        setDetailsMessage(Messages.getString("error.emptyPath"), //$NON-NLS-1$
                IMessageProvider.ERROR);
        result = ERROR_EMPTY_PATH;
    }
    return result;
}

From source file:org.eclipse.datatools.engagement.marklogic.ui.wizards.XMLSelectionPageHelper.java

License:Open Source License

private void validatePageStatus() {
    if (getFolderLocation().trim().length() == 0) {
        if (m_wizardPage != null) {
            m_wizardPage.setMessage(Messages.getString("XMLSelectionWizardPage.message.error.emptyXMLSource"), //$NON-NLS-1$
                    IMessageProvider.ERROR);
            m_wizardPage.setPageComplete(false);
        } else if (m_propertyPage != null) {
            m_propertyPage.setMessage(Messages.getString("XMLSelectionWizardPage.message.error.emptyXMLSource"), //$NON-NLS-1$
                    IMessageProvider.ERROR);
        }//from  w w  w  .java  2 s .c o  m
    } else {
        if (m_wizardPage != null) {
            m_wizardPage.setMessage(DEFAULT_MESSAGE);
            m_wizardPage.setPageComplete(true);
        } else if (m_propertyPage != null) {
            m_propertyPage.setMessage(DEFAULT_MESSAGE);
        }

    }
}

From source file:org.eclipse.datatools.engagement.marklogic.ui.wizards.XPathChoosePage.java

License:Open Source License

/**
 * set page status based on row number/*w  w  w .j  a v  a 2s  .  c  om*/
 * 
 */
private void updatePageStatus() {
    if ((xsdFileName == null || xsdFileName.trim().length() == 0)
            && (xmlFileName == null || xmlFileName.trim().length() == 0)) {
        this.setErrorMessage(Messages.getString("xPathChoosePage.messages.noURLOfSourceOrSchema")); //$NON-NLS-1$
        setPageComplete(false);
    } else if (!isRootPathValid()) {
        this.setMessage(Messages.getFormattedString("error.invalidXpath", //$NON-NLS-1$
                new Object[] { rootPath == null ? EMPTY_STRING : rootPath }), IMessageProvider.ERROR);
        setPageComplete(false);
    } else {
        if (initRootPath != null && !initRootPath.equals(EMPTY_STRING) && !initRootPath.equals(rootPath)) {
            setMessage(Messages.getString("xPathChoosePage.messages.xpathChange"), //$NON-NLS-1$
                    INFORMATION);
        } else {
            setMessage(pageDefaultMessage);
        }
        setPageComplete(true);
    }
}