Search in sources :

Example 1 with BasicNotePropertyComposite

use of org.talend.designer.core.ui.editor.properties.notes.BasicNotePropertyComposite in project tdi-studio-se by Talend.

the class ComponentSettingsView method createDynamicComposite.

/**
     * yzhang Comment method "createDynamicComposite".
     * 
     * @param parent
     * @param element
     * @param category
     */
private void createDynamicComposite(final Composite parent, Element element, EComponentCategory category) {
    // DynamicComposite dc = null;
    getParentMap().put(ComponentSettingsView.PARENT, parent);
    getCategoryMap().put(ComponentSettingsView.CATEGORY, category);
    if (element instanceof Node) {
        IComponent component = ((Node) element).getComponent();
        IGenericWizardService wizardService = null;
        boolean generic = false;
        if (EComponentType.GENERIC.equals(component.getComponentType())) {
            generic = true;
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
                wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
            }
        }
        tabFactory.getTabbedPropertyComposite().setCompactViewVisible(false);
        if (category == EComponentCategory.BASIC) {
            // getElementMap().put(ComponentSettingsView.ELEMENT, element);
            createButtonListener();
            boolean isCompactView = true;
            if (ComponentSettingsView.TABLEVIEW.equals(getPreference().getString(TalendDesignerPrefConstants.VIEW_OPTIONS))) {
                isCompactView = false;
            }
            tabFactory.getTabbedPropertyComposite().setCompactViewVisible(true);
            tabFactory.getTabbedPropertyComposite().setCompactView(isCompactView);
            // Generic
            if (generic && wizardService != null) {
                Composite composite = wizardService.creatDynamicComposite(parent, element, EComponentCategory.BASIC, true);
                if (composite instanceof MultipleThreadDynamicComposite) {
                    dc = (MultipleThreadDynamicComposite) composite;
                }
            } else {
                dc = new MissingSettingsMultiThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, isCompactView);
            }
        } else if (category == EComponentCategory.DYNAMICS_SETTINGS) {
            dc = new AdvancedContextComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
        } else if (category == EComponentCategory.SQL_PATTERN) {
            dc = new SQLPatternComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
        } else if (category == EComponentCategory.ADVANCED) {
            dc = new MissingSettingsMultiThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
            // Generic
            if (generic && wizardService != null) {
                Composite composite = wizardService.creatDynamicComposite(parent, element, EComponentCategory.ADVANCED, true);
                if (composite instanceof MultipleThreadDynamicComposite) {
                    dc = (MultipleThreadDynamicComposite) composite;
                }
            }
        } else {
            dc = new MultipleThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
        }
    } else if (element instanceof Connection) {
        dc = new MainConnectionComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element);
    } else if (element instanceof Note) {
        if (category == EComponentCategory.BASIC) {
            if (parent.getLayout() instanceof FillLayout) {
                FillLayout layout = (FillLayout) parent.getLayout();
                layout.type = SWT.VERTICAL;
                layout.marginHeight = 0;
                layout.marginWidth = 0;
                layout.spacing = 0;
            }
            ScrolledComposite scrolled = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
            scrolled.setExpandHorizontal(true);
            scrolled.setExpandVertical(true);
            scrolled.setMinWidth(600);
            scrolled.setMinHeight(400);
            Composite composite = tabFactory.getWidgetFactory().createComposite(scrolled);
            scrolled.setContent(composite);
            composite.setLayout(new FormLayout());
            FormData d = new FormData();
            d.left = new FormAttachment(0, 0);
            d.right = new FormAttachment(100, 0);
            d.top = new FormAttachment(0, 0);
            d.bottom = new FormAttachment(100, 0);
            composite.setLayoutData(d);
            AbstractNotePropertyComposite c1 = new BasicNotePropertyComposite(composite, (Note) element, tabFactory);
            // AbstractNotePropertyComposite c2 = new TextNotePropertyComposite(composite, (Note) element,
            // tabFactory);
            // FormData data = new FormData();
            // data.top = new FormAttachment(c1.getComposite(), 20, SWT.DOWN);
            // data.left = new FormAttachment(0, 0);
            // data.right = new FormAttachment(100, 0);
            // c2.getComposite().setLayoutData(data);
            parent.layout();
        }
    } else if (element instanceof SubjobContainer) {
        if (category == EComponentCategory.BASIC) {
            dc = new SubjobBasicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
        }
    } else {
        tabFactory.getTabbedPropertyComposite().setCompactViewVisible(false);
        dc = new MultipleThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
    }
    if (parent.getChildren().length == 0) {
        if (parent.getLayout() instanceof FillLayout) {
            FillLayout layout = (FillLayout) parent.getLayout();
            layout.type = SWT.VERTICAL;
            layout.marginHeight = 0;
            layout.marginWidth = 0;
            layout.spacing = 0;
        }
        Composite composite = tabFactory.getWidgetFactory().createComposite(parent);
        composite.setLayout(new FormLayout());
        FormData d = new FormData();
        d.left = new FormAttachment(2, 0);
        d.right = new FormAttachment(100, 0);
        d.top = new FormAttachment(5, 0);
        d.bottom = new FormAttachment(100, 0);
        composite.setLayoutData(d);
        Label alertText = new Label(composite, SWT.NONE);
        //$NON-NLS-1$
        alertText.setText(Messages.getString("ComponentSettingsView.noAdvancedSetting"));
        alertText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
        parent.layout();
    }
    if (dc != null) {
        dc.refresh();
    }
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) MainConnectionComposite(org.talend.designer.core.ui.editor.properties.connections.MainConnectionComposite) Composite(org.eclipse.swt.widgets.Composite) SubjobBasicComposite(org.talend.designer.core.ui.views.subjob.SubjobBasicComposite) AbstractNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.AbstractNotePropertyComposite) MissingSettingsMultiThreadDynamicComposite(org.talend.designer.core.ui.views.properties.composites.MissingSettingsMultiThreadDynamicComposite) BasicNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.BasicNotePropertyComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) AbstractNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.AbstractNotePropertyComposite) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) Label(org.eclipse.swt.widgets.Label) MissingSettingsMultiThreadDynamicComposite(org.talend.designer.core.ui.views.properties.composites.MissingSettingsMultiThreadDynamicComposite) FillLayout(org.eclipse.swt.layout.FillLayout) SubjobBasicComposite(org.talend.designer.core.ui.views.subjob.SubjobBasicComposite) BasicNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.BasicNotePropertyComposite) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Note(org.talend.designer.core.ui.editor.notes.Note) IGenericWizardService(org.talend.core.runtime.services.IGenericWizardService) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) MainConnectionComposite(org.talend.designer.core.ui.editor.properties.connections.MainConnectionComposite) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 IComponent (org.talend.core.model.components.IComponent)1 IConnection (org.talend.core.model.process.IConnection)1 INode (org.talend.core.model.process.INode)1 IGenericWizardService (org.talend.core.runtime.services.IGenericWizardService)1 Connection (org.talend.designer.core.ui.editor.connections.Connection)1 ConnectionLabel (org.talend.designer.core.ui.editor.connections.ConnectionLabel)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1 Note (org.talend.designer.core.ui.editor.notes.Note)1 MainConnectionComposite (org.talend.designer.core.ui.editor.properties.connections.MainConnectionComposite)1 AbstractNotePropertyComposite (org.talend.designer.core.ui.editor.properties.notes.AbstractNotePropertyComposite)1 BasicNotePropertyComposite (org.talend.designer.core.ui.editor.properties.notes.BasicNotePropertyComposite)1 SubjobContainer (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer)1 MissingSettingsMultiThreadDynamicComposite (org.talend.designer.core.ui.views.properties.composites.MissingSettingsMultiThreadDynamicComposite)1