com.ebmwebsourcing.petals.services.quartz.editor.QuartzConsumesEditorContribution.java Source code

Java tutorial

Introduction

Here is the source code for com.ebmwebsourcing.petals.services.quartz.editor.QuartzConsumesEditorContribution.java

Source

/******************************************************************************
 * Copyright (c) 2012-2013, Linagora
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *       Linagora - initial API and implementation
 *******************************************************************************/

package com.ebmwebsourcing.petals.services.quartz.editor;

import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;

import com.ebmwebsourcing.petals.common.internal.provisional.emf.EObjectUIHelper;
import com.ebmwebsourcing.petals.common.internal.provisional.formeditor.ISharedEdition;
import com.ebmwebsourcing.petals.services.cdk.editor.CDK5JBIEndpointUIHelper;
import com.ebmwebsourcing.petals.services.quartz.QuartzControls;
import com.ebmwebsourcing.petals.services.quartz.quartz.QuartzPackage;
import com.ebmwebsourcing.petals.services.su.editor.extensibility.JbiEditorDetailsContribution;
import com.ebmwebsourcing.petals.services.su.editor.su.JBIEndpointUIHelpers;
import com.ebmwebsourcing.petals.services.su.editor.su.JBIEndpointUIHelpers.CommonUIBean;
import com.sun.java.xml.ns.jbi.AbstractEndpoint;

/**
 * @author Mickael Istria - EBM WebSourcing
 */
public class QuartzConsumesEditorContribution extends JbiEditorDetailsContribution {

    /*
     * (non-Javadoc)
     * @see com.ebmwebsourcing.petals.services.su.editor.extensibility.JbiEditorDetailsContribution
     * #addMainSUContent(com.sun.java.xml.ns.jbi.AbstractEndpoint, org.eclipse.ui.forms.widgets.FormToolkit,
     * org.eclipse.swt.widgets.Composite, com.ebmwebsourcing.petals.common.internal.provisional.formeditor.ISharedEdition)
     */
    @Override
    public void addMainSUContent(final AbstractEndpoint endpoint, FormToolkit toolkit, final Composite mainTab,
            ISharedEdition ise) {
        Composite composite = createCommonConsumeSection(mainTab, toolkit);
        CommonUIBean commonUiBean = JBIEndpointUIHelpers.createCommonEndpointUI(endpoint, toolkit, composite, ise);

        composite = createEditorSection(mainTab, toolkit, CDK5JBIEndpointUIHelper.CONSUME_TITLE,
                CDK5JBIEndpointUIHelper.CONSUME_DESC, true);
        CDK5JBIEndpointUIHelper.createConsumesUI(endpoint, toolkit, composite, ise, commonUiBean);
    }

    /*
     * (non-Javadoc)
     * @see com.ebmwebsourcing.petals.services.su.editor.extensibility.JbiEditorDetailsContribution
     * #addAdvancedSUContent(com.sun.java.xml.ns.jbi.AbstractEndpoint, org.eclipse.ui.forms.widgets.FormToolkit,
     * org.eclipse.swt.widgets.Composite, com.ebmwebsourcing.petals.common.internal.provisional.formeditor.ISharedEdition)
     */
    @Override
    public void addAdvancedSUContent(AbstractEndpoint endpoint, FormToolkit toolkit, Composite advancedTab,
            ISharedEdition ise) {

        Composite composite = createEditorSection(advancedTab, toolkit, "Quartz Parameters");
        QuartzControls controls = new QuartzControls();
        controls.createControls(composite, true);

        IObservableValue widgetObservable = SWTObservables.observeDelayedValue(300,
                SWTObservables.observeText(controls.getCronText(), SWT.Modify));
        IObservableValue iov = EObjectUIHelper.createCustomEmfEditObservable(ise.getEditingDomain(), endpoint,
                QuartzPackage.Literals.QUARTZ_CONSUMES__CRON_EXPRESSION);
        ise.getDataBindingContext().bindValue(widgetObservable, iov);

        widgetObservable = SWTObservables.observeDelayedValue(300,
                SWTObservables.observeText(controls.getMsgText(), SWT.Modify));
        iov = EObjectUIHelper.createCustomEmfEditObservable(ise.getEditingDomain(), endpoint,
                QuartzPackage.Literals.QUARTZ_CONSUMES__CONTENT);
        ise.getDataBindingContext().bindValue(widgetObservable, iov);

        composite = createEditorSection(advancedTab, toolkit, "CDK Parameters");
        CDK5JBIEndpointUIHelper.generateDefaultCdkWidgetsForConsumesEditor(endpoint, toolkit, composite, ise);
    }
}