Search in sources :

Example 6 with AbstractElementPropertySectionController

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

the class MultipleThreadDynamicComposite method estimatePropertyHeightSize.

/**
     * DOC nrousseau Comment method "estimatePropertyHeightSize".
     * 
     * @param maxRow
     * @param listParam
     * @param tabbedPropertyComposite
     */
private int estimatePropertyHeightSize(int maxRow, List<? extends IElementParameter> listParam) {
    int estimatedHeightSize = 0, estimatedMaxRowSize = 0;
    int additionalHeightSize = 0;
    int compositeHeight = getParent().getBounds().height;
    // System.out.println("size composite:" + compositeHeight);
    int nbDynamic = 0;
    for (int curRow = 1; curRow <= maxRow; curRow++) {
        estimatedMaxRowSize = 0;
        for (int i = 0; i < listParam.size(); i++) {
            IElementParameter curParam = listParam.get(i);
            if (curParam.getCategory() == section) {
                if (curParam.getNumRow() == curRow && (curParam.getFieldType() != EParameterFieldType.TECHNICAL)) {
                    // field:"+curParam.getField());
                    if (curParam.isShow(listParam)) {
                        // System.out.println("show:" + curParam.getName()+
                        // " field:"+curParam.getField());
                        AbstractElementPropertySectionController controller = generator.getController(curParam.getFieldType(), this);
                        if (controller == null) {
                            break;
                        }
                        int estimatedSize = controller.estimateRowSize(composite, curParam);
                        if (controller.hasDynamicRowSize()) {
                            nbDynamic++;
                        }
                        if (estimatedSize > estimatedMaxRowSize) {
                            estimatedMaxRowSize = estimatedSize;
                        }
                    }
                }
            }
        }
        estimatedHeightSize += estimatedMaxRowSize;
    }
    // System.out.println("*** ESTIMATED SIZE:" + estimatedHeightSize + "
    // ***");
    int emptySpace = compositeHeight - estimatedHeightSize;
    // System.out.println("--- EMPTY SPACE:" + emptySpace);
    if (emptySpace > 0 && nbDynamic > 0) {
        additionalHeightSize = emptySpace / nbDynamic;
    // System.out.println("--- DIVIDED ADDITIONAL HEIGHT (for each
    // dynamic):" + additionalHeightSize);
    }
    return additionalHeightSize;
}
Also used : AbstractElementPropertySectionController(org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 7 with AbstractElementPropertySectionController

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

the class MultipleThreadDynamicComposite method operationInThread.

// refactore to be synchonized with the dispose() method because of TDI-24184
// the synchronized methodis a quick fix but not the ideal one because this method is accessing many attributes
// of the current class that may be modified by other thread (just like "elem" modified by the dispose() method.
protected synchronized void operationInThread() {
    if (elem == null) {
        return;
    }
    // hywang modified for
    List<? extends IElementParameter> listParam = elem.getElementParametersWithChildrens();
    Boolean updateNeeded = (Boolean) elem.getPropertyValue(updataComponentParamName);
    if (updateNeeded != null) {
        if (updateNeeded) {
            if (elem != null) {
                addComponents(forceRedraw);
                elem.setPropertyValue(updataComponentParamName, new Boolean(false));
                forceRedraw = false;
            }
        }
    }
    final ECodeLanguage language = ((RepositoryContext) org.talend.core.CorePlugin.getContext().getProperty(org.talend.core.context.Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
    IRunProcessService service = DesignerPlugin.getDefault().getRunProcessService();
    final ICodeProblemsChecker syntaxChecker = service.getSyntaxChecker(language);
    List<Problem> javaProblem = null;
    for (int i = 0; i < listParam.size(); i++) {
        if (listParam.get(i).getCategory() == section) {
            if (listParam.get(i).isShow(listParam)) {
                final IElementParameter e = listParam.get(i);
                e.isReadOnly();
                e.isNoCheck();
                if (language == ECodeLanguage.JAVA && javaProblem == null) {
                    if (!e.isReadOnly() && !e.isNoCheck()) {
                        javaProblem = syntaxChecker.checkProblems(null);
                    }
                }
                final List<Problem> nodePros = javaProblem;
                if (generator != null) {
                    AbstractElementPropertySectionController controller = generator.getController(e.getFieldType(), MultipleThreadDynamicComposite.this);
                    if (controller != null) {
                        controller.updateCodeProblems(nodePros);
                        controller.refresh(e, checkErrorsWhenViewRefreshed);
                    }
                }
            }
        }
    }
    if (propertyResized) {
        try {
            removeListener(SWT.Resize, resizeListener);
            getParent().layout();
            composite.pack();
            propertyResized = false;
            addListener(SWT.Resize, resizeListener);
        } catch (Exception e) {
        }
    }
    checkErrorsWhenViewRefreshed = false;
//        long time = TimeMeasure.timeSinceBegin("DC:refresh:" + getCurrentComponent()); //$NON-NLS-1$
//        TimeMeasure.end("DC:refresh:" + getCurrentComponent()); //$NON-NLS-1$
// if (DynamicTabbedPropertySection.DEBUG_TIME) {
//            System.out.println("DC;total;" + getCurrentComponent() + ";" + time); //$NON-NLS-1$ //$NON-NLS-2$
// }
}
Also used : AbstractElementPropertySectionController(org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ICodeProblemsChecker(org.talend.core.language.ICodeProblemsChecker) IElementParameter(org.talend.core.model.process.IElementParameter) Problem(org.talend.core.model.process.Problem) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 8 with AbstractElementPropertySectionController

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

the class DynamicComposite method estimatePropertyHeightSize.

/**
     * DOC nrousseau Comment method "estimatePropertyHeightSize".
     * 
     * @param maxRow
     * @param listParam
     * @param tabbedPropertyComposite
     */
private int estimatePropertyHeightSize(int maxRow, List<? extends IElementParameter> listParam) {
    int estimatedHeightSize = 0, estimatedMaxRowSize = 0;
    int additionalHeightSize = 0;
    int compositeHeight = getParent().getBounds().height;
    // System.out.println("size composite:" + compositeHeight);
    int nbDynamic = 0;
    for (int curRow = 1; curRow <= maxRow; curRow++) {
        estimatedMaxRowSize = 0;
        for (int i = 0; i < listParam.size(); i++) {
            IElementParameter curParam = listParam.get(i);
            if (curParam.getCategory() == section) {
                if (curParam.getNumRow() == curRow && (curParam.getFieldType() != EParameterFieldType.TECHNICAL)) {
                    // field:"+curParam.getField());
                    if (curParam.isShow(listParam)) {
                        // System.out.println("show:" + curParam.getName()+
                        // " field:"+curParam.getField());
                        AbstractElementPropertySectionController controller = generator.getController(curParam.getFieldType(), this);
                        if (controller == null) {
                            break;
                        }
                        int estimatedSize = controller.estimateRowSize(composite, curParam);
                        if (controller.hasDynamicRowSize()) {
                            nbDynamic++;
                        }
                        if (estimatedSize > estimatedMaxRowSize) {
                            estimatedMaxRowSize = estimatedSize;
                        }
                    }
                }
            }
        }
        estimatedHeightSize += estimatedMaxRowSize;
    }
    // System.out.println("*** ESTIMATED SIZE:" + estimatedHeightSize + "
    // ***");
    int emptySpace = compositeHeight - estimatedHeightSize;
    // System.out.println("--- EMPTY SPACE:" + emptySpace);
    if (emptySpace > 0 && nbDynamic > 0) {
        additionalHeightSize = emptySpace / nbDynamic;
    // System.out.println("--- DIVIDED ADDITIONAL HEIGHT (for each
    // dynamic):" + additionalHeightSize);
    }
    return additionalHeightSize;
}
Also used : AbstractElementPropertySectionController(org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 9 with AbstractElementPropertySectionController

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

the class DynamicPropertyGenerator method initController.

/**
     * DOC yzhang Comment method "initController".
     */
public void initController(IDynamicProperty dp) {
    if (!initialized) {
        for (IConfigurationElement element : extensionElements) {
            try {
                //$NON-NLS-1$
                String controllerName = element.getAttribute("mapping");
                EParameterFieldType key = EParameterFieldType.getFieldTypeByName(controllerName);
                if (!dtpControls.containsKey(key)) {
                    if (!controllerName.equals(key.toString())) {
                        throw new RuntimeException(//$NON-NLS-1$
                        "Mapping attribute " + controllerName + //$NON-NLS-1$
                        " not included in eumn EParameterFieldType");
                    }
                    //$NON-NLS-1$
                    IControllerGenerator generator = (IControllerGenerator) element.createExecutableExtension("class");
                    generator.setDynamicProperty(dp);
                    AbstractElementPropertySectionController controller = generator.generate();
                    dtpControls.put(key, controller);
                    if (controller instanceof AbstractRepositoryController) {
                        ControllerRepositoryValueHander repositoryValueHander = ((AbstractRepositoryController) controller).getRepositoryValueHander();
                        ControllerRepositoryValueHander.getRepositoryValueHandlerMap().put(key, repositoryValueHander);
                    }
                }
            } catch (CoreException e) {
                ExceptionHandler.process(e);
            }
        }
        initialized = true;
    }
}
Also used : EParameterFieldType(org.talend.core.model.process.EParameterFieldType) CoreException(org.eclipse.core.runtime.CoreException) IControllerGenerator(org.talend.designer.core.ui.editor.properties.controllers.generator.IControllerGenerator) AbstractElementPropertySectionController(org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController) AbstractRepositoryController(org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController) ControllerRepositoryValueHander(org.talend.designer.core.ui.editor.properties.controllers.ControllerRepositoryValueHander) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 10 with AbstractElementPropertySectionController

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

the class MultipleThreadDynamicComposite method addComponents.

/**
     * Initialize all components for the defined section for this node.
     */
public synchronized void addComponents(boolean forceRedraw, boolean reInitialize, int height) {
    // achen modifed to fix feature 0005991 if composite.isDisposed return
    if (elem == null || composite.isDisposed()) {
        return;
    }
    checkErrorsWhenViewRefreshed = true;
    int heightSize = 0, maxRowSize = 0, nbInRow, numInRow;
    int maxRow;
    boolean isCompute = false;
    if (!forceRedraw) {
        boolean needRedraw = isNeedRedraw();
        if (!needRedraw) {
            // System.out.println("no need redraw");
            return;
        }
    }
    Control lastControl = null;
    if (reInitialize) {
        if (currentComponent != null) {
            disposeChildren();
        }
    } else {
        heightSize = height;
    }
    final List<IElementParameter> currentValidParameters = new ArrayList<IElementParameter>(20);
    hashCurControls = new DualHashBidiMap();
    maxRow = 0;
    List<? extends IElementParameter> listParam = elem.getElementParametersWithChildrens();
    Map<String, Integer> groupPosition = new HashMap<String, Integer>();
    for (int i = 0; i < listParam.size(); i++) {
        IElementParameter param = listParam.get(i);
        if (param.getCategory() == section && param.getFieldType() != EParameterFieldType.TECHNICAL && param.isShow(listParam)) {
            currentValidParameters.add(param);
            if (param.getNumRow() > maxRow) {
                maxRow = param.getNumRow();
            }
        }
    }
    IElementParameter synchronizeSchemaParam = elem.getElementParameter(EParameterName.NOT_SYNCHRONIZED_SCHEMA.getName());
    if (synchronizeSchemaParam != null) {
        // if the node don't contains a schema type and accept an input flow and is not synchronized
        // display a schema on the first line just the type to synchronize the schema
        synchronizeSchemaParam.setShow(!((Node) elem).isSchemaSynchronized());
        IElementParameter schemaTypeParam = synchronizeSchemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName());
        if (schemaTypeParam != null) {
            schemaTypeParam.setReadOnly(((Node) elem).isSchemaSynchronized());
        }
    }
    generator.initController(this);
    int additionalHeightSize = 0;
    boolean hasDynamicRow = false;
    for (int i = 0; i < currentValidParameters.size(); i++) {
        IElementParameter curParam = currentValidParameters.get(i);
        AbstractElementPropertySectionController controller = generator.getController(curParam.getFieldType(), this);
        if (controller == null) {
            continue;
        }
        if (controller.hasDynamicRowSize()) {
            hasDynamicRow = true;
            break;
        }
    }
    if (hasDynamicRow) {
        additionalHeightSize = estimatePropertyHeightSize(maxRow, listParam);
    }
    for (int curRow = 1; curRow <= maxRow; curRow++) {
        maxRowSize = 0;
        nbInRow = 0;
        for (int i = 0; i < currentValidParameters.size(); i++) {
            IElementParameter curParam = currentValidParameters.get(i);
            if (curParam.getNumRow() == curRow) {
                nbInRow++;
            }
        }
        numInRow = 0;
        lastControl = null;
        curRowSize = 0;
        for (int i = 0; i < currentValidParameters.size(); i++) {
            IElementParameter curParam = currentValidParameters.get(i);
            updateParameter(curParam);
            if (curParam.getNumRow() == curRow && isShouldDisParameter(curParam)) {
                numInRow++;
                AbstractElementPropertySectionController controller = generator.getController(curParam.getFieldType(), this);
                if (controller == null) {
                    continue;
                }
                if (controller.hasDynamicRowSize()) {
                    controller.setAdditionalHeightSize(additionalHeightSize);
                }
                String groupName = curParam.getGroup();
                Composite subComposite = null;
                Control cutLastControl = lastControl;
                int curNumInRow = numInRow;
                int curNbInRow = nbInRow;
                int curTop = 0;
                if (!isCompactView()) {
                    if (numInRow > 1 && nbInRow > 1) {
                        heightSize += maxRowSize;
                    }
                    curNumInRow = 1;
                    curNbInRow = 1;
                    cutLastControl = null;
                }
                if (groupName != null) {
                    if (!hashCurControls.containsKey(groupName)) {
                        if (groupPosition.size() > 0) {
                            heightSize += DEFAULT_GROUP_HEIGHT;
                        }
                        new GroupController(this).createControl(composite, curParam, numInRow, nbInRow, heightSize, lastControl);
                        groupPosition.put(groupName, heightSize);
                    }
                    subComposite = (Composite) hashCurControls.get(groupName);
                    curTop = heightSize - groupPosition.get(groupName);
                } else {
                    subComposite = composite;
                    curTop = DEFAULT_GROUP_HEIGHT * (groupPosition.size() > 0 ? 1 : 0) + heightSize;
                }
                lastControl = controller.createControl(subComposite, curParam, curNumInRow, curNbInRow, curTop, cutLastControl);
                if (curRowSize > maxRowSize) {
                    maxRowSize = curRowSize;
                }
            }
        }
        heightSize += maxRowSize;
    }
    if (synchronizeSchemaParam != null) {
        synchronizeSchemaParam.setShow(false);
    }
    minHeight = heightSize;
    resizeScrolledComposite();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) HashMap(java.util.HashMap) GroupController(org.talend.designer.core.ui.editor.properties.controllers.GroupController) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) Control(org.eclipse.swt.widgets.Control) DualHashBidiMap(org.apache.commons.collections.bidimap.DualHashBidiMap) AbstractElementPropertySectionController(org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController) IElementParameter(org.talend.core.model.process.IElementParameter)

Aggregations

AbstractElementPropertySectionController (org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController)12 IElementParameter (org.talend.core.model.process.IElementParameter)9 Composite (org.eclipse.swt.widgets.Composite)4 Node (org.talend.designer.core.ui.editor.nodes.Node)4 DualHashBidiMap (org.apache.commons.collections.bidimap.DualHashBidiMap)3 Point (org.eclipse.swt.graphics.Point)3 Control (org.eclipse.swt.widgets.Control)3 HashMap (java.util.HashMap)2 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 FormData (org.eclipse.swt.layout.FormData)2 Table (org.eclipse.swt.widgets.Table)2 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 INode (org.talend.core.model.process.INode)2 MetadataTableEditor (org.talend.core.ui.metadata.editor.MetadataTableEditor)2 MetadataTableEditorView (org.talend.core.ui.metadata.editor.MetadataTableEditorView)2 Connection (org.talend.designer.core.ui.editor.connections.Connection)2 GroupController (org.talend.designer.core.ui.editor.properties.controllers.GroupController)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1