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));
}
}
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();
}
}
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;
}
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();
}
}
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));
}
}
Aggregations