Search in sources :

Example 1 with IDataModelListener

use of org.eclipse.wst.common.frameworks.datamodel.IDataModelListener in project liferay-ide by liferay.

the class NewLayoutTplWizardPage method createTemplateInfoGroup.

protected void createTemplateInfoGroup(Composite parent) {
    SWTUtil.createLabel(parent, SWT.RIGHT, Msgs.name, 1);
    name = SWTUtil.createText(parent, 1);
    this.synchHelper.synchText(name, LAYOUT_TEMPLATE_NAME, null);
    SWTUtil.createLabel(parent, StringPool.EMPTY, 1);
    SWTUtil.createLabel(parent, SWT.RIGHT, Msgs.id, 1);
    id = SWTUtil.createText(parent, 1);
    this.synchHelper.synchText(id, LAYOUT_TEMPLATE_ID, null);
    SWTUtil.createLabel(parent, StringPool.EMPTY, 1);
    SWTUtil.createLabel(parent, SWT.RIGHT, Msgs.templateFile, 1);
    templateFile = SWTUtil.createText(parent, 1);
    this.synchHelper.synchText(templateFile, LAYOUT_TEMPLATE_FILE, null);
    Button templateFileBrowse = SWTUtil.createPushButton(parent, Msgs.browse, null);
    templateFileBrowse.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleFileBrowseButton(NewLayoutTplWizardPage.this.templateFile, Msgs.templateFileSelection, Msgs.chooseTemplateFile);
        }
    });
    IProject layoutProject = ProjectUtil.getProject(projectName);
    String pluginVersion = LiferayDescriptorHelper.getDescriptorVersion(layoutProject);
    if (pluginVersion.equals("6.2.0")) {
        SWTUtil.createLabel(parent, SWT.RIGHT, Msgs.wapTemplateFile, 1);
        wapTemplateFile = SWTUtil.createText(parent, 1);
        this.synchHelper.synchText(wapTemplateFile, LAYOUT_WAP_TEMPLATE_FILE, null);
        Button wapTemplateFileBrowse = SWTUtil.createPushButton(parent, Msgs.browse, null);
        wapTemplateFileBrowse.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                handleFileBrowseButton(NewLayoutTplWizardPage.this.wapTemplateFile, Msgs.wapTemplateFileSelection, Msgs.chooseWAPTemplateFile);
            }
        });
    }
    SWTUtil.createLabel(parent, SWT.RIGHT, Msgs.thumbnailFile, 1);
    thumbnailFile = SWTUtil.createText(parent, 1);
    this.synchHelper.synchText(thumbnailFile, LAYOUT_THUMBNAIL_FILE, null);
    Button thumbnailFileBrowse = SWTUtil.createPushButton(parent, Msgs.browse, null);
    thumbnailFileBrowse.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleFileBrowseButton(NewLayoutTplWizardPage.this.thumbnailFile, Msgs.wapTemplateFileSelection, Msgs.chooseThumbnailFile);
        }
    });
    synchHelper.getDataModel().addListener(new IDataModelListener() {

        public void propertyChanged(DataModelEvent event) {
            if (LAYOUT_TEMPLATE_NAME.equals(event.getPropertyName()) || LAYOUT_TEMPLATE_ID.equals(event.getPropertyName())) {
                synchHelper.synchAllUIWithModel();
            }
        }
    });
}
Also used : IDataModelListener(org.eclipse.wst.common.frameworks.datamodel.IDataModelListener) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DataModelEvent(org.eclipse.wst.common.frameworks.datamodel.DataModelEvent) IProject(org.eclipse.core.resources.IProject)

Example 2 with IDataModelListener

use of org.eclipse.wst.common.frameworks.datamodel.IDataModelListener in project liferay-ide by liferay.

the class NewJSFPortletOptionsWizardPage method createTopLevelComposite.

@Override
protected Composite createTopLevelComposite(Composite parent) {
    Composite top = super.createTopLevelComposite(parent);
    IDataModelListener listener = new IDataModelListener() {

        public void propertyChanged(DataModelEvent event) {
            if (PORTLET_NAME.equals(event.getPropertyName())) {
                synchHelper.synchAllUIWithModel();
            }
        }
    };
    this.synchHelper.getDataModel().addListener(listener);
    return top;
}
Also used : IDataModelListener(org.eclipse.wst.common.frameworks.datamodel.IDataModelListener) Composite(org.eclipse.swt.widgets.Composite) DataModelEvent(org.eclipse.wst.common.frameworks.datamodel.DataModelEvent)

Example 3 with IDataModelListener

use of org.eclipse.wst.common.frameworks.datamodel.IDataModelListener in project webtools.sourceediting by eclipse.

the class NewProjectDataModelFacetWizard method synchRuntimes.

protected void synchRuntimes() {
    final Boolean[] suppressBackEvents = { Boolean.FALSE };
    model.addListener(new IDataModelListener() {

        @Override
        public void propertyChanged(DataModelEvent event) {
            if (IDataModel.VALUE_CHG == event.getFlag() || IDataModel.DEFAULT_CHG == event.getFlag()) {
                if (FACET_RUNTIME.equals(event.getPropertyName())) {
                    if (!suppressBackEvents[0].booleanValue()) {
                        IRuntime runtime = (IRuntime) event.getProperty();
                        setRuntimeAndDefaultFacets(runtime);
                    }
                }
            }
        }
    });
    getFacetedProjectWorkingCopy().addListener(new IFacetedProjectListener() {

        @Override
        public void handleEvent(final IFacetedProjectEvent event) {
            suppressBackEvents[0] = Boolean.TRUE;
            model.setProperty(FACET_RUNTIME, getFacetedProjectWorkingCopy().getPrimaryRuntime());
            suppressBackEvents[0] = Boolean.FALSE;
        }
    }, IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED);
}
Also used : IFacetedProjectListener(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener) IDataModelListener(org.eclipse.wst.common.frameworks.datamodel.IDataModelListener) IFacetedProjectEvent(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent) DataModelEvent(org.eclipse.wst.common.frameworks.datamodel.DataModelEvent) IRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime)

Example 4 with IDataModelListener

use of org.eclipse.wst.common.frameworks.datamodel.IDataModelListener in project webtools.sourceediting by eclipse.

the class DataModelFacetCreationWizardPage method launchNewRuntimeWizard.

public static boolean launchNewRuntimeWizard(Shell shell, final IDataModel model, String serverTypeID) {
    if (model == null) {
        return false;
    }
    final DataModelPropertyDescriptor[] preAdditionDescriptors = model.getValidPropertyDescriptors(FACET_RUNTIME);
    final boolean[] keepWaiting = { true };
    final IDataModelListener listener = new IDataModelListener() {

        @Override
        public void propertyChanged(final DataModelEvent event) {
            if (event.getPropertyName().equals(FACET_RUNTIME) && event.getFlag() == DataModelEvent.VALID_VALUES_CHG) {
                synchronized (keepWaiting) {
                    keepWaiting[0] = false;
                    keepWaiting.notify();
                }
                model.removeListener(this);
            }
        }
    };
    model.addListener(listener);
    boolean isOK = ServerUIUtil.showNewRuntimeWizard(shell, serverTypeID, null);
    if (isOK) {
        // Do the rest of the processing in a separate thread. Since we are going to block
        // and wait, doing this on the UI thread can cause hangs.
        final Thread newRuntimeSelectionThread = new Thread() {

            @Override
            public void run() {
                // Causes the list of runtimes held by the RuntimeManager to be refreshed and
                // triggers events to listeners on that list.
                RuntimeManager.getRuntimes();
                synchronized (keepWaiting) {
                    while (keepWaiting[0] == true) {
                        try {
                            keepWaiting.wait();
                        } catch (InterruptedException e) {
                        }
                    }
                }
                // Select the new runtime.
                DataModelPropertyDescriptor[] postAdditionDescriptors = model.getValidPropertyDescriptors(FACET_RUNTIME);
                Object[] preAddition = new Object[preAdditionDescriptors.length];
                for (int i = 0; i < preAddition.length; i++) {
                    preAddition[i] = preAdditionDescriptors[i].getPropertyValue();
                }
                Object[] postAddition = new Object[postAdditionDescriptors.length];
                for (int i = 0; i < postAddition.length; i++) {
                    postAddition[i] = postAdditionDescriptors[i].getPropertyValue();
                }
                Object newAddition = getNewObject(preAddition, postAddition);
                if (// can this ever be null?
                newAddition != null)
                    model.setProperty(FACET_RUNTIME, newAddition);
            }
        };
        newRuntimeSelectionThread.start();
        return true;
    }
    model.removeListener(listener);
    return false;
}
Also used : IDataModelListener(org.eclipse.wst.common.frameworks.datamodel.IDataModelListener) DataModelEvent(org.eclipse.wst.common.frameworks.datamodel.DataModelEvent) DataModelPropertyDescriptor(org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor)

Example 5 with IDataModelListener

use of org.eclipse.wst.common.frameworks.datamodel.IDataModelListener in project liferay-ide by liferay.

the class NewLiferayPortletWizardPage method createLiferayPortletInfoGroup.

protected void createLiferayPortletInfoGroup(Composite composite) {
    SelectionAdapter adapter;
    Group group = SWTUtil.createGroup(composite, Msgs.liferayPortletInfo, 3);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 3;
    group.setLayoutData(gd);
    // we don't need to create the name as it can never be anything different than
    // the portlet name on 2nd page
    // SWTUtil.createLabel(group, SWT.RIGHT, "Name:", 1);
    // 
    // this.name = SWTUtil.createText(group, 1);
    // this.synchHelper.synchText(name, LIFERAY_PORTLET_NAME, null);
    // SWTUtil.createLabel(group, StringUtil.EMPTY, 1);
    SWTUtil.createLabel(group, SWT.RIGHT, Msgs.iconLabel, 1);
    iconFile = SWTUtil.createText(group, 1);
    this.synchHelper.synchText(iconFile, ICON_FILE, null);
    if (fragment) {
        SWTUtil.createLabel(group, StringPool.EMPTY, 1);
    } else {
        Button iconFileBrowse = SWTUtil.createPushButton(group, Msgs.browse, null);
        adapter = new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                handleFileBrowseButton(NewLiferayPortletWizardPage.this.iconFile, Msgs.iconSelection, Msgs.chooseIconFileLabel);
            }
        };
        iconFileBrowse.addSelectionListener(adapter);
    }
    SWTUtil.createLabel(group, StringPool.EMPTY, 1);
    allowMultiInstanceButton = SWTUtil.createCheckButton(group, Msgs.allowMultipleInstances, null, true, 2);
    this.synchHelper.synchCheckbox(allowMultiInstanceButton, ALLOW_MULTIPLE, null);
    SWTUtil.createLabel(group, SWT.RIGHT, Msgs.cssLabel, 1);
    cssFile = SWTUtil.createText(group, 1);
    this.synchHelper.synchText(cssFile, CSS_FILE, null);
    if (fragment) {
        SWTUtil.createLabel(group, StringPool.EMPTY, 1);
    } else {
        Button cssFileBrowse = SWTUtil.createPushButton(group, Msgs.browse, null);
        SelectionAdapter selectionAdapter = new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                handleFileBrowseButton(NewLiferayPortletWizardPage.this.cssFile, Msgs.cssSelection, Msgs.chooseCssFileLabel);
            }
        };
        cssFileBrowse.addSelectionListener(selectionAdapter);
    }
    SWTUtil.createLabel(group, SWT.RIGHT, Msgs.javascriptLabel, 1);
    javascriptFile = SWTUtil.createText(group, 1);
    this.synchHelper.synchText(javascriptFile, JAVASCRIPT_FILE, null);
    if (fragment) {
        SWTUtil.createLabel(group, StringPool.EMPTY, 1);
    } else {
        Button javascriptFileBrowse = SWTUtil.createPushButton(group, Msgs.browse, null);
        adapter = new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                handleFileBrowseButton(NewLiferayPortletWizardPage.this.javascriptFile, Msgs.javascriptSelection, Msgs.chooseJavascriptFileLabel);
            }
        };
        javascriptFileBrowse.addSelectionListener(adapter);
    }
    SWTUtil.createLabel(group, SWT.RIGHT, Msgs.cssClassWrapperLabel, 1);
    cssClassWrapper = SWTUtil.createText(group, 1);
    this.synchHelper.synchText(cssClassWrapper, CSS_CLASS_WRAPPER, null);
    SWTUtil.createLabel(group, StringPool.EMPTY, 1);
    IDataModelListener listener = new IDataModelListener() {

        public void propertyChanged(DataModelEvent event) {
            if (INewJavaClassDataModelProperties.CLASS_NAME.equals(event.getPropertyName()) || PORTLET_NAME.equals(event.getPropertyName())) {
                synchHelper.synchAllUIWithModel();
            }
        }
    };
    this.synchHelper.getDataModel().addListener(listener);
}
Also used : Group(org.eclipse.swt.widgets.Group) IDataModelListener(org.eclipse.wst.common.frameworks.datamodel.IDataModelListener) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DataModelEvent(org.eclipse.wst.common.frameworks.datamodel.DataModelEvent)

Aggregations

DataModelEvent (org.eclipse.wst.common.frameworks.datamodel.DataModelEvent)7 IDataModelListener (org.eclipse.wst.common.frameworks.datamodel.IDataModelListener)7 GridData (org.eclipse.swt.layout.GridData)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 Group (org.eclipse.swt.widgets.Group)2 IProject (org.eclipse.core.resources.IProject)1 Font (org.eclipse.swt.graphics.Font)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1 DataModelPropertyDescriptor (org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor)1 IFacetedProjectEvent (org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent)1 IFacetedProjectListener (org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener)1 IRuntime (org.eclipse.wst.common.project.facet.core.runtime.IRuntime)1