Search in sources :

Example 1 with DataModelEvent

use of org.eclipse.wst.common.frameworks.datamodel.DataModelEvent 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 DataModelEvent

use of org.eclipse.wst.common.frameworks.datamodel.DataModelEvent 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 DataModelEvent

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

the class NewPluginProjectGroup method createUserSpecifiedProjectLocationField.

protected void createUserSpecifiedProjectLocationField(Composite projectGroup) {
    Font font = projectGroup.getFont();
    // location label
    final Label locationLabel = new Label(projectGroup, SWT.NONE);
    locationLabel.setFont(font);
    locationLabel.setText(Msgs.wizardNewProjectCreationPageLocationLabel);
    // project location entry field
    locationPathField = new Text(projectGroup, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = SIZING_TEXT_FIELD_WIDTH;
    locationPathField.setLayoutData(data);
    locationPathField.setFont(font);
    // browse button
    browseButton = new Button(projectGroup, SWT.PUSH);
    browseButton.setFont(font);
    browseButton.setText(Msgs.browse);
    browseButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            handleLocationBrowseButtonPressed();
        }
    });
    final IDataModel localModel = model;
    final IDataModel localNestedModel = nestedModel;
    LocationListener listener = new LocationListener(localModel, localNestedModel, locationLabel);
    listener.propertyChanged(new DataModelEvent(model, LIFERAY_USE_SDK_LOCATION, IDataModel.VALUE_CHG));
    locationPathField.addModifyListener(listener);
    model.addListener(listener);
    nestedModel.addListener(listener);
}
Also used : Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DataModelEvent(org.eclipse.wst.common.frameworks.datamodel.DataModelEvent) Text(org.eclipse.swt.widgets.Text) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) Font(org.eclipse.swt.graphics.Font)

Example 4 with DataModelEvent

use of org.eclipse.wst.common.frameworks.datamodel.DataModelEvent 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 5 with DataModelEvent

use of org.eclipse.wst.common.frameworks.datamodel.DataModelEvent 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)

Aggregations

DataModelEvent (org.eclipse.wst.common.frameworks.datamodel.DataModelEvent)8 IDataModelListener (org.eclipse.wst.common.frameworks.datamodel.IDataModelListener)7 GridData (org.eclipse.swt.layout.GridData)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Button (org.eclipse.swt.widgets.Button)3 Font (org.eclipse.swt.graphics.Font)2 Composite (org.eclipse.swt.widgets.Composite)2 Group (org.eclipse.swt.widgets.Group)2 Label (org.eclipse.swt.widgets.Label)2 Text (org.eclipse.swt.widgets.Text)2 IProject (org.eclipse.core.resources.IProject)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 DataModelPropertyDescriptor (org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor)1 IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)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