Search in sources :

Example 31 with TreeEditor

use of org.eclipse.swt.custom.TreeEditor in project tdq-studio-se by Talend.

the class AbstractColumnDropTree method createOneUnit.

/**
 * DOC qzhang Comment method "createOneUnit".
 *
 * @param treeItem
 * @param indicatorUnit
 */
public void createOneUnit(final TreeItem treeItem, IndicatorUnit indicatorUnit) {
    final TreeItem indicatorItem = new TreeItem(treeItem, SWT.NONE);
    final IndicatorUnit unit = indicatorUnit;
    IndicatorEnum indicatorType = indicatorUnit.getType();
    indicatorItem.setData(MODELELEMENT_INDICATOR_KEY, treeItem.getData(MODELELEMENT_INDICATOR_KEY));
    indicatorItem.setData(INDICATOR_UNIT_KEY, unit);
    indicatorItem.setData(viewKey, this);
    indicatorItem.setImage(0, getIndicatorImage(unit));
    String indicatorName = getIndicatorName(indicatorUnit);
    // $NON-NLS-1$
    String label = indicatorName == null ? "unknown indicator" : indicatorName;
    indicatorItem.setText(0, label);
    TreeEditor optionEditor = new TreeEditor(tree);
    // $NON-NLS-1$
    final Label optionLabel = createTreeItemLabel(tree, ImageLib.OPTION, "AnalysisColumnTreeViewer.options");
    optionLabel.setData(indicatorUnit);
    optionLabel.addMouseListener(new MouseAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.MouseAdapter#mouseDown(org.eclipse.swt .events.MouseEvent)
             */
        @Override
        public void mouseDown(MouseEvent e) {
            boolean hasIndicatorParameters = openIndicatorOptionDialog(Display.getCurrent().getActiveShell(), indicatorItem);
            if (hasIndicatorParameters) {
                optionLabel.setImage(ImageLib.getImage(ImageLib.INDICATOR_OPTION_CHECKED));
            }
        }
    });
    optionEditor.minimumWidth = optionLabel.getImage().getBounds().width;
    optionEditor.horizontalAlignment = SWT.CENTER;
    optionEditor.setEditor(optionLabel, indicatorItem, 1);
    // }
    TreeEditor delEditor = new TreeEditor(tree);
    // $NON-NLS-1$
    Label delLabel = createTreeItemLabel(tree, ImageLib.DELETE_ACTION, "AnalysisColumnTreeViewer.delete");
    delLabel.addMouseListener(new MouseAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.MouseAdapter#mouseDown(org.eclipse.swt .events.MouseEvent)
             */
        @Override
        public void mouseDown(MouseEvent e) {
            // current delLabel is behind of one indicator item.
            ModelElementIndicator meIndicator = (ModelElementIndicator) treeItem.getData(MODELELEMENT_INDICATOR_KEY);
            deleteIndicatorItems(meIndicator, unit);
            if (indicatorItem.getParentItem() != null && indicatorItem.getParentItem().getData(INDICATOR_UNIT_KEY) != null) {
                setElements(modelElementIndicators);
            } else {
                removeItemBranch(indicatorItem);
            }
        }
    });
    delEditor.minimumWidth = delLabel.getImage().getBounds().width;
    delEditor.horizontalAlignment = SWT.CENTER;
    // MOD mzhao feature 13040, column analysis have 5 columns, whereas columnset have 4 columns.
    if (AnalysisColumnTreeViewer.VIEWER_KEY.equals(viewKey)) {
        delEditor.setEditor(delLabel, indicatorItem, 4);
    } else if (AnalysisColumnSetTreeViewer.VIEWER_KEY.equals(viewKey)) {
        delEditor.setEditor(delLabel, indicatorItem, 3);
    }
    indicatorItem.setData(ITEM_EDITOR_KEY, new TreeEditor[] { optionEditor, delEditor });
    if (indicatorType.hasChildren()) {
        indicatorItem.setData(treeItem.getData(MODELELEMENT_INDICATOR_KEY));
        createIndicatorItems(indicatorItem, indicatorUnit.getChildren());
    }
    if (hasIndicatorParameters(indicatorUnit)) {
        optionLabel.setImage(ImageLib.getImage(ImageLib.INDICATOR_OPTION_CHECKED));
    }
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) TreeEditor(org.eclipse.swt.custom.TreeEditor) TreeItem(org.eclipse.swt.widgets.TreeItem) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 32 with TreeEditor

use of org.eclipse.swt.custom.TreeEditor in project yyl_example by Relucent.

the class DispelTreeEditorBug method freshTableTree.

public void freshTableTree(Tree tableTree) {
    tableTree.setHeaderVisible(true);
    tableTree.setLinesVisible(true);
    new TreeColumn(tableTree, SWT.LEFT).setText("Column-0");
    new TreeColumn(tableTree, SWT.LEFT).setText("Column-1");
    new TreeColumn(tableTree, SWT.LEFT).setText("Column-2");
    new TreeColumn(tableTree, SWT.LEFT).setText("Column-3");
    for (int i = 0; i < NUM; i++) {
        TreeItem parent = new TreeItem(tableTree, SWT.NONE);
        parent.setText(0, "#" + (i + 1));
        parent.setText(1, "");
        parent.setText(2, "");
        for (int j = 0; j < 10; j++) {
            TreeItem child = new TreeItem(parent, SWT.NONE);
            child.setText(0, "0");
            child.setText(1, "1");
            child.setText(2, "2");
            child.setText(3, "3");
            TreeEditor editor2 = createTreeEditor(tableTree, SWT.RIGHT);
            Button button2 = new Button(tableTree, SWT.CHECK);
            child.setData("EDITOR_3", editor2);
            editor2.setEditor(button2, child, 3);
            button2.setSelection(true);
            button2.setEnabled(true);
        }
        parent.setExpanded(true);
    // tableTree.setTopItem(parent);
    }
    TreeColumn[] columns = tableTree.getColumns();
    for (int i = 0, n = columns.length; i < n; i++) {
        columns[i].pack();
    }
}
Also used : TreeEditor(org.eclipse.swt.custom.TreeEditor) TreeItem(org.eclipse.swt.widgets.TreeItem) Button(org.eclipse.swt.widgets.Button) TreeColumn(org.eclipse.swt.widgets.TreeColumn)

Example 33 with TreeEditor

use of org.eclipse.swt.custom.TreeEditor in project yyl_example by Relucent.

the class DispelTreeEditorBug method createTreeEditor.

private TreeEditor createTreeEditor(Tree tree, int horizontalAlignment) {
    TreeEditor oTreeEditor = new TreeEditor(tree);
    oTreeEditor.horizontalAlignment = horizontalAlignment;
    oTreeEditor.grabHorizontal = false;
    oTreeEditor.minimumWidth = 12;
    oTreeEditor.minimumHeight = 10;
    return oTreeEditor;
}
Also used : TreeEditor(org.eclipse.swt.custom.TreeEditor)

Example 34 with TreeEditor

use of org.eclipse.swt.custom.TreeEditor in project yyl_example by Relucent.

the class TableTreeTest method setVisibilityTreeEditor.

private void setVisibilityTreeEditor(TreeItem treeItem, boolean visible) {
    // for(String sEditorName:{"EDITOR_3"}){
    String sEditorName = "EDITOR_3";
    Object obj = treeItem.getData(sEditorName);
    if (obj instanceof TreeEditor) {
        TreeEditor oTreeEditor = (TreeEditor) obj;
        oTreeEditor.minimumWidth = visible ? 12 : 0;
        oTreeEditor.layout();
    }
}
Also used : TreeEditor(org.eclipse.swt.custom.TreeEditor)

Example 35 with TreeEditor

use of org.eclipse.swt.custom.TreeEditor in project yyl_example by Relucent.

the class TableTreeTest method clearControlInTableTreeItem.

/**
 * <p>
 * 功能描述:销毁批核列表中的所有复选框按钮
 * </p>
 * @param treeItem TreeItem对象
 * @update YYL
 */
private void clearControlInTableTreeItem(TreeItem treeItem) {
    // 销毁内部控件
    Object obj = treeItem.getData("EDITOR_3");
    if (obj instanceof TreeEditor) {
        TreeEditor editor = (TreeEditor) obj;
        Control control = editor.getEditor();
        if (control != null)
            control.dispose();
        editor.dispose();
    }
    for (int len = treeItem.getItemCount(), i = 0; i < len; i++) {
        clearControlInTableTreeItem(treeItem.getItem(i));
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) TreeEditor(org.eclipse.swt.custom.TreeEditor)

Aggregations

TreeEditor (org.eclipse.swt.custom.TreeEditor)37 TreeItem (org.eclipse.swt.widgets.TreeItem)24 MouseEvent (org.eclipse.swt.events.MouseEvent)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)13 MouseAdapter (org.eclipse.swt.events.MouseAdapter)10 FocusEvent (org.eclipse.swt.events.FocusEvent)8 KeyEvent (org.eclipse.swt.events.KeyEvent)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 Point (org.eclipse.swt.graphics.Point)8 Label (org.eclipse.swt.widgets.Label)8 CCombo (org.eclipse.swt.custom.CCombo)5 Control (org.eclipse.swt.widgets.Control)5 FocusAdapter (org.eclipse.swt.events.FocusAdapter)4 KeyAdapter (org.eclipse.swt.events.KeyAdapter)4 Text (org.eclipse.swt.widgets.Text)4 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 CTabFolderEvent (org.eclipse.swt.custom.CTabFolderEvent)3 DragSourceEvent (org.eclipse.swt.dnd.DragSourceEvent)3