Example usage for org.eclipse.jface.preference IPreferencePageContainer IPreferencePageContainer

List of usage examples for org.eclipse.jface.preference IPreferencePageContainer IPreferencePageContainer

Introduction

In this page you can find the example usage for org.eclipse.jface.preference IPreferencePageContainer IPreferencePageContainer.

Prototype

IPreferencePageContainer

Source Link

Usage

From source file:org.polymap.core.data.ui.PipelinePropertyPage.java

License:Open Source License

protected void showPropertyPage(PipelineProcessorConfiguration config) throws CoreException {
    if (propertyPage != null) {
        propertyPage.performOk();//from w  w  w .  java  2s  . c om
        propertyPage.dispose();
        propertyPage = null;
    }
    for (Control child : propertiesSection.getChildren()) {
        child.dispose();
    }
    if (config == null) {
        return;
    }

    ProcessorExtension ext = ProcessorExtension.forExtensionId(config.getExtensionId());
    try {
        if (ext == null) {
            Label l = new Label(propertiesSection, SWT.NONE);
            l.setText(Messages.get("PipelinePropertyPage_noExtension"));
        } else if (ext.hasPropertyPage()) {
            propertyPage = ext.newPropertyPage();

            PipelineHolder elm = (PipelineHolder) getElement();
            propertyPage.init(elm, config.getConfig());
            propertyPage.createControl(propertiesSection);

            propertyPage.setContainer(new IPreferencePageContainer() {
                public void updateTitle() {
                    setTitle(propertyPage.getTitle());
                }

                public void updateMessage() {
                    if (propertyPage.getErrorMessage() != null) {
                        setMessage(propertyPage.getErrorMessage(), ERROR);
                    } else if (propertyPage.getMessage() != null) {
                        setMessage(propertyPage.getMessage(), INFORMATION);
                    } else {
                        setMessage(null);
                    }
                }

                public void updateButtons() {
                    setValid(propertyPage.isValid());
                }

                public IPreferenceStore getPreferenceStore() {
                    return null;
                }
            });
        } else {
            Label l = new Label(propertiesSection, SWT.NONE);
            l.setText(Messages.get("PipelinePropertyPage_noConfig"));
        }
        propertiesSection.getParent().layout(true);
        propertiesSection.layout(true);
    } catch (Exception e) {
        // XXX Auto-generated catch block

    }
}