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.cdt.internal.ui.wizards.settingswizards.ProjectSettingsImportStrategy.java

License:Open Source License

@Override
public void fileSelected(IProjectSettingsWizardPage page) {
    List<ImporterSectionPair> pairs = Collections.emptyList();
    try {//from ww  w . j  av  a  2 s .c o  m
        pairs = extractSectionsFromFile(page);
        page.setMessage(getMessage(MessageType.MESSAGE), IMessageProvider.NONE); // its all good
    } catch (FileNotFoundException e) {
        page.setMessage(Messages.ProjectSettingsWizardPage_Import_openError, IMessageProvider.ERROR);
    } catch (SettingsImportExportException e) {
        page.setMessage(Messages.ProjectSettingsWizardPage_Import_parseError, IMessageProvider.ERROR);
    }

    List<ISettingsProcessor> importersToDisplay = new ArrayList<ISettingsProcessor>();
    for (ImporterSectionPair pair : pairs) {
        importersToDisplay.add(pair.importer);
    }

    // if there was an error then importersToDisplay will be empty and this will clear the list
    page.setDisplayedSettingsProcessors(importersToDisplay);
}

From source file:org.eclipse.cdt.ui.tests.wizards.settingswizards.SettingsImportExportTest.java

License:Open Source License

public void testNormalExportImport() throws Exception {
    ICProject exportProject = CProjectHelper.createNewStileCProject("TempProject1", IPDOMManager.ID_NO_INDEXER);
    ICProject importProject = CProjectHelper.createNewStileCProject("TempProject2", IPDOMManager.ID_NO_INDEXER);
    setUpProjectSettings(exportProject);

    ProjectSettingsWizardPageMock page = new ProjectSettingsWizardPageMock() {
        @Override/*from  ww  w . j  ava  2s.  c om*/
        public void setMessage(String message, int flag) {
            if (flag == IMessageProvider.ERROR)
                fail("there should be no error message displayed");
        }

        @Override
        public void showErrorDialog(String dialogTitle, String message) {
            fail("the error dialog should not be displayed");
        }
    };

    page.setDestinationFilePath(getFilePath("settings.xml"));
    page.setSettingsProcessors(processors);
    page.setSelectedSettingsProcessors(processors);
    ICProjectDescription desc = CoreModel.getDefault().getProjectDescription(exportProject.getProject(), false);
    ICConfigurationDescription config = desc.getActiveConfiguration();
    page.setSelectedConfiguration(config);

    ProjectSettingsExportStrategy exporter = new ProjectSettingsExportStrategy();
    exporter.finish(page);

    // now import into another project

    desc = CoreModel.getDefault().getProjectDescription(importProject.getProject(), true);
    config = desc.getActiveConfiguration();
    page.setSelectedConfiguration(config);

    ProjectSettingsImportStrategy importer = new ProjectSettingsImportStrategy();
    importer.finish(page);

    desc = CoreModel.getDefault().getProjectDescription(importProject.getProject(), true);
    config = desc.getActiveConfiguration();
    ICFolderDescription folder = config.getRootFolderDescription();
    ICLanguageSetting languageSetting = folder.getLanguageSettings()[0];

    ICLanguageSettingEntry[] importedMacros = languageSetting.getSettingEntries(ICSettingEntry.MACRO);

    assertEquals(EXPORTED_MACROS.length, importedMacros.length);
    for (int i = 0; i < importedMacros.length; i++) {
        assertEquals(EXPORTED_MACROS[i].getName(), importedMacros[i].getName());
        assertEquals(EXPORTED_MACROS[i].getValue(), importedMacros[i].getValue());
    }

    ICLanguageSettingEntry[] importedIncludes = languageSetting.getSettingEntries(ICSettingEntry.INCLUDE_PATH);

    assertEquals(EXPORTED_INCLUDES.length, importedIncludes.length);
    for (int i = 0; i < importedIncludes.length; i++) {
        assertTrue(importedIncludes[i].getName().endsWith(EXPORTED_INCLUDES[i].getName()));
    }

    CProjectHelper.delete(importProject);
    CProjectHelper.delete(exportProject);
}

From source file:org.eclipse.cft.server.ui.internal.editor.ApplicationDetailsPart.java

License:Open Source License

public void refreshUI() {
    logError(null);//from w w  w.j  a va  2 s .  c o  m
    resizeTableColumns();

    canUpdate = false;
    CloudFoundryApplicationModule appModule = cloudServer.getExistingCloudModule(module);

    // Refresh the state of the editor regardless of whether there is a
    // module or not
    refreshPublishState(appModule);

    if (appModule == null) {
        return;
    }

    if (saveManifest != null) {
        ManifestParser parser = new ManifestParser(appModule, cloudServer);
        if (!parser.canWriteToManifest()) {
            saveManifest.setEnabled(false);
            saveManifest.setToolTipText(Messages.ApplicationDetailsPart_TEXT_MANIFEST_SAVE_CREATE_TOOLTIP);
        } else {
            saveManifest.setEnabled(true);
            saveManifest.setToolTipText(Messages.ApplicationDetailsPart_TEXT_MANIFEST_UPDATE);
        }
    }
    int state = appModule.getState();

    if (jrebelManualAppUrlUpdate != null) {
        // URL updating only is enabled when app is running
        jrebelManualAppUrlUpdate.setEnabled(CloudRebelAppHandler.isJRebelEnabled(module));
    }

    // The rest of the refresh requires appModule to be non-null
    updateServerNameDisplay(appModule);

    instanceSpinner.setSelection(appModule.getInstanceCount());

    refreshDeploymentButtons(appModule);

    mappedURIsLink.setEnabled(state == IServer.STATE_STARTED);

    CloudApplication cloudApplication = appModule.getApplication();

    instanceSpinner.setEnabled(cloudApplication != null);
    instancesViewer.getTable().setEnabled(cloudApplication != null);

    instancesViewer.setInput(null);

    memoryText.setEnabled(cloudApplication != null);
    if (cloudApplication != null) {
        int appMemory = appModule.getApplication().getMemory();

        if (appMemory > 0) {
            memoryText.setText(appMemory + ""); //$NON-NLS-1$
        }
    }

    List<String> currentURIs = null;
    if (cloudApplication != null) {
        currentURIs = cloudApplication.getUris();

        ApplicationStats applicationStats = appModule.getApplicationStats();
        InstancesInfo instancesInfo = appModule.getInstancesInfo();
        if (applicationStats != null) {
            List<InstanceStats> statss = applicationStats.getRecords();
            List<InstanceInfo> infos = instancesInfo != null ? instancesInfo.getInstances() : null;
            InstanceStatsAndInfo[] statsAndInfos = new InstanceStatsAndInfo[statss.size()];

            for (int i = 0; i < statss.size(); i++) {
                InstanceStats stats = statss.get(i);
                InstanceInfo info = null;
                if (infos != null && infos.size() > i) {
                    info = infos.get(i);
                }

                statsAndInfos[i] = new InstanceStatsAndInfo(stats, info);
            }
            instancesViewer.setInput(statsAndInfos);
        }
    }

    if (currentURIs == null && !isPublished) {
        // At this stage, the app may not have deployed due to errors, but
        // there may already
        // be set URIs in an existing info
        currentURIs = appModule.getDeploymentInfo() != null ? appModule.getDeploymentInfo().getUris() : null;
    }

    if (currentURIs == null) {
        currentURIs = Collections.emptyList();
    }

    if (!currentURIs.equals(this.appUrls)) {
        updateAppUrls(currentURIs);
    }

    refreshServices(appModule);
    instancesViewer.refresh(true);

    canUpdate = true;

    if (appModule.getStatus() != null && !appModule.getStatus().isOK()) {

        if (appModule.getStatus().getSeverity() == IStatus.ERROR) {
            editorPage.setMessage(appModule.getStatus().getMessage(), IMessageProvider.ERROR);
        } else if (appModule.getStatus().getSeverity() == IStatus.WARNING) {
            editorPage.setMessage(appModule.getStatus().getMessage(), IMessageProvider.WARNING);
        }
    } else {
        editorPage.setMessage(null, IMessageProvider.ERROR);
        editorPage.setMessage(null, IMessageProvider.WARNING);
    }
}

From source file:org.eclipse.cft.server.ui.internal.editor.CloudFoundryApplicationsEditorPage.java

License:Open Source License

protected void setMessageInPage(IStatus status) {
    String message = status != null ? status.getMessage() : null;
    if (message == null || status == null || status.isOK()) {
        setMessage(null, IMessageProvider.NONE);
    } else {/*from   w ww.  j  ava 2 s. c  o m*/
        int providerStatus = IMessageProvider.NONE;
        switch (status.getSeverity()) {
        case IStatus.INFO:
            providerStatus = IMessageProvider.INFORMATION;
            break;
        case IStatus.WARNING:
            providerStatus = IMessageProvider.WARNING;
            break;
        case IStatus.ERROR:
            providerStatus = IMessageProvider.ERROR;
            break;
        }

        setMessage(message, providerStatus);
    }

}

From source file:org.eclipse.cft.server.ui.internal.editor.EditorMessageTypes.java

License:Open Source License

public static int getMessageProviderType(IStatus status) {
    if (status == null) {
        return IMessageProvider.NONE;
    }//from   w  w w  .j  a  v a2  s  .co m

    switch (status.getSeverity()) {
    case IStatus.INFO:
        return IMessageProvider.INFORMATION;
    case IStatus.WARNING:
        return IMessageProvider.WARNING;
    case IStatus.ERROR:
        return IMessageProvider.ERROR;
    }
    return IMessageProvider.NONE;
}

From source file:org.eclipse.contribution.visualiser.internal.preference.VisualiserPreferencesDialog.java

License:Open Source License

/**
 * Sets the message for this dialog with an indication of what type
 * of message it is./*  w ww.  j ava  2s  . c  o m*/
 * <p>
 * The valid message types are one of <code>NONE</code>, 
 * <code>INFORMATION</code>, <code>WARNING</code>, or <code>ERROR</code>.
 * </p>
 * <p>
 * Note that for backward compatibility, a message of type <code>ERROR</code> 
 * is different than an error message (set using <code>setErrorMessage</code>). 
 * An error message overrides the current message until the error message is 
 * cleared. This method replaces the current message and does not affect the 
 * error message.
 * </p>
 *
 * @param newMessage the message, or <code>null</code> to clear
 *   the message
 * @param newType the message type
 */
public void setMessage(String newMessage, int newType) {
    Image newImage = null;

    if (newMessage != null) {
        switch (newType) {
        case IMessageProvider.NONE:
            break;
        case IMessageProvider.INFORMATION:
            newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_INFO);
            break;
        case IMessageProvider.WARNING:
            newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_WARNING);
            break;
        case IMessageProvider.ERROR:
            newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_ERROR);
            break;
        }
    }

    showMessage(newMessage, newImage);
}

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

License:Open Source License

public void setErrorMessage(String newMessage) {
    super.setErrorMessage(newMessage);

    // if this is being used in a preference dialog,
    // set the message with an error type 
    if (getEditorContainer() != null)
        setMessage(newMessage, IMessageProvider.ERROR);
}

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

License:Open Source License

private DataSourceEditorPage createDefaultPropertyPage(Properties profileProps) {
    DefaultDataSourcePropertyPage defaultPropPage = new DefaultDataSourcePropertyPage();
    String errorMessage = isInOdaDesignSession()
            ? (m_canEditProps ? Messages.dbProfilePage_noCustomPage : Messages.dbProfilePage_invalidDataSource)
            : Messages.dbProfilePage_notInDesignSession;

    /*//from w w  w .  ja v a2  s.  co  m
     * Update page's initialized DataSourceDesign with specified profileProps, 
     * so that the page can create controls with the profileProps values.
     */
    OdaDesignSession requestSession = getDesignSession();
    if (requestSession.getRequestDataSourceDesign() != null
            && !requestSession.getRequestDataSourceDesign().hasLinkToProfile()) // editing local properties
    {
        // makes a copy of the request session to update the data source design w/ local profileProps
        requestSession = (OdaDesignSession) EcoreUtil.copy(requestSession);

        DataSourceDesign localRequestDesign = requestSession.getRequestDataSourceDesign();
        try {
            super.setDataSourceDesignProperties(localRequestDesign, profileProps);
        } catch (OdaException ex) {
            errorMessage += "\n"; //$NON-NLS-1$
            errorMessage += ex.toString();
        }
    }

    try {
        defaultPropPage.initEditSession(requestSession);
    } catch (OdaException ex) {
        errorMessage += "\n"; //$NON-NLS-1$
        errorMessage += ex.toString();
    }

    int messageType = m_canEditProps ? IMessageProvider.WARNING : IMessageProvider.ERROR;
    setMessage(errorMessage, messageType);

    // missing required properties to test connection
    if (!m_canEditProps)
        defaultPropPage.setPingButtonEnabled(false);

    return defaultPropPage;
}

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

License:Open Source License

void initControl(ProfileSelection selectedProfile) {
    if (selectedProfile == null)
        return; // nothing to initialize        

    // limits profile tree to include the selected oda data source type
    m_treeFilter = selectedProfile.getOdaDataSourceId();

    boolean hasInvalidProfileRef = false;
    ProfileReferenceBase profileRef = selectedProfile.getProfileRef();
    if (profileRef != null) {
        String profileStorePath = profileRef.getStorageFilePathPropertyValue();
        if (profileStorePath != null) {
            // triggers tree population; disable auto item selection
            setConnProfilePathControlText(profileStorePath, true);

            TreeItem profileItem = findProfileInTree(selectedProfile.getOdaDataSourceId(),
                    profileRef.getInstanceId());
            if (profileItem != null) {
                assert (m_odaDataSourceTree != null);
                m_odaDataSourceTree.setSelection(profileItem);
                m_odaDataSourceTree.showSelection();

                m_useDefaultDSNameCheckBox
                        .setSelection(profileItem.getText().equals(selectedProfile.getDataSourceDesignName()));
                m_profileID = profileItem.getData().toString();
                m_odaDataSourceID = getProfileItemDataSourceId(profileItem);
                setExternalLinkOption(m_odaDataSourceID);
                setPageComplete(true);//from   w w  w  . j a  v a 2 s  .  c om
            } else // did not find matching linked profile in profile tree
                hasInvalidProfileRef = true;
        }

        m_linkRefCheckBox.setSelection(profileRef.maintainExternalLink());
    }

    // initializes the designName variable first, which is checked 
    // by the name control's modify listener
    m_dataSourceDesignName = selectedProfile.getDataSourceDesignName();
    m_dataSourceDesignNameControl.setText(m_dataSourceDesignName);

    // when editing an existing data source design
    if (inEditMode()) {
        // hide controls to disallow user from changing the design name
        setDataSourceNameEditorVisible(false);

        // editing a design with invalid profile reference, set error message;
        // this is done last so the message won't be overwritten by controls' event handler
        if (profileRef != null && hasInvalidProfileRef) {
            String errorMessage = profileRef.getStorageFile() == null
                    ? Messages.profilePage_error_invalidProfileStorePath
                    : Messages.bind(Messages.designSession_invalidProfileName, profileRef.getName());
            setMessage(errorMessage, IMessageProvider.ERROR);
        }
    }
}

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

License:Open Source License

private boolean isPageComplete() {
    boolean isPageComplete = true;
    if (m_wizardPage != null)
        isPageComplete = m_wizardPage.isPageComplete();
    else if (m_propertyPage != null)
        isPageComplete = m_propertyPage.isValid();
    else//  w w w. jav a2s .com
        isPageComplete = (getMessageType() != IMessageProvider.ERROR);

    if (!isPageComplete) // page itself is not complete
        return isPageComplete; // no need to do extra checking

    // the page itself considers itself complete, next 
    // check if external reference is selected, must have a selected profile
    if (m_linkRefCheckBox != null && m_linkRefCheckBox.getSelection())
        isPageComplete = hasSelectedProfile();

    return isPageComplete;
}