use of org.eclipse.swt.widgets.TreeItem in project yyl_example by Relucent.
the class DispelTreeEditorBug method hideControlInTableTreeItem.
private void hideControlInTableTreeItem(TreeItem treeItem, boolean pVisible) {
TreeItem parentItem = treeItem.getParentItem();
boolean visible = pVisible && (parentItem == null || parentItem.getExpanded());
setVisibilityTreeEditor(treeItem, visible);
for (int len = treeItem.getItemCount(), i = 0; i < len; i++) {
hideControlInTableTreeItem(treeItem.getItem(i), visible);
}
}
use of org.eclipse.swt.widgets.TreeItem in project tdi-studio-se by Talend.
the class TreePopulator method populateTreeItems.
/**
* populate tree items.
*
* @param tree
* @param node
*/
private void populateTreeItems(Object tree, Node element, int level, String parentXPath) {
level++;
if (level > 10) {
return;
} else {
NodeList nodeList = element.getChildNodes();
// Object[] chidrenTreeNode = aTreeNode.getChildren();
for (int i = 0; i < nodeList.getLength(); i++) {
final Node subNode = nodeList.item(i);
if (subNode.getNodeName().equals(TEXT_CONST)) {
continue;
}
TreeItem treeItem;
if (tree instanceof Tree) {
treeItem = new TreeItem((Tree) tree, 0);
} else {
treeItem = new TreeItem((TreeItem) tree, 0);
}
TreeNodeData treeNodeData = storeNodeAttrData(subNode);
treeItem.setData(treeNodeData);
treeItem.setText(subNode.getNodeName());
//$NON-NLS-1$
String currentTreePath = parentXPath + "/" + treeItem.getText();
treeNodeData.setTreePath(currentTreePath);
treeNodeData.setTreeNode(ATreeNodeUtil.getTreeNodeByPath(currentTreePath));
if (subNode.getChildNodes() != null && subNode.getChildNodes().getLength() > 0) {
populateTreeItems(treeItem, subNode, level, currentTreePath);
}
setExpanded(treeItem);
}
}
}
use of org.eclipse.swt.widgets.TreeItem in project tdi-studio-se by Talend.
the class AbstractXMLConfigPage method initialize.
/*
* (non-Javadoc)
*
* @see org.talend.componentdesigner.ui.wizard.creatcomponent.AbstractComponentPage#initialize()
*/
protected void initialize() {
availableXmlTree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (availableXmlTree.getMenu() != null) {
availableXmlTree.getMenu().dispose();
}
final TreeItem[] treeItem = ((Tree) event.getSource()).getSelection();
Menu popMenu = new Menu(availableXmlTree);
MenuItem itemNew = new MenuItem(popMenu, SWT.CASCADE);
//$NON-NLS-1$
itemNew.setText(Messages.getString("AbstractXMLConfigPage.New"));
MenuItem itemDel = new MenuItem(popMenu, SWT.CASCADE);
//$NON-NLS-1$
itemDel.setText(Messages.getString("AbstractXMLConfigPage.Delete"));
itemDel.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TreeNodeData currentNodeData = (TreeNodeData) treeItem[0].getParentItem().getData();
currentNodeData.getXMLNode().removeChild(((TreeNodeData) treeItem[0].getData()).getXMLNode());
treeItem[0].dispose();
}
});
final TreeNodeData treeNodeData = ((TreeNodeData) treeItem[0].getData());
if (treeNodeData.isHasChildTreeNode()) {
Menu subNewMenu = new Menu(itemNew);
itemNew.setMenu(subNewMenu);
Object[] subNodeNames = treeNodeData.getChildNodeNames();
for (Object nodeName : subNodeNames) {
final MenuItem nodeMenuItem = new MenuItem(subNewMenu, SWT.CASCADE);
final String itemName = (String) nodeName;
nodeMenuItem.setText(itemName);
nodeMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TreeItem newItem = new TreeItem(treeItem[0], 0);
newItem.setText(itemName);
TreeNodeData newNodeData = null;
newNodeData = new TreeNodeData();
Node parentNode = treeNodeData.getXMLNode();
newNodeData.setXMLNode(parentNode.appendChild(parentNode.getOwnerDocument().createElement(itemName)));
//$NON-NLS-1$
newNodeData.setTreePath(treeNodeData.getTreePath() + "/" + itemName);
newNodeData.setTreeNode(ATreeNodeUtil.getTreeNodeByPath(newNodeData.getTreePath()));
newItem.setData(newNodeData);
}
});
}
} else {
itemNew.setEnabled(false);
}
availableXmlTree.setMenu(popMenu);
if (nodeAttrCompsite != null) {
nodeAttrCompsite.dispose();
}
rebuildAttrComposite(treeNodeData);
setComponentMinSize(treeNodeData.getTreeNode().getLabel());
rightComposite.layout();
}
});
}
use of org.eclipse.swt.widgets.TreeItem in project ACS by ACS-Community.
the class AlarmsView method createFCWidgets.
private void createFCWidgets() {
Listener updateFaultCode = new Listener() {
public void handleEvent(Event event) {
int val;
if (_tree.getSelection() == null || _tree.getSelection().length == 0)
return;
TreeItem tmp = _tree.getSelection()[0];
int tfc = Integer.parseInt(tmp.getText());
String tff = tmp.getParentItem().getParentItem().getText();
FaultCode fct = new FaultCode();
try {
val = Integer.parseInt(_fcValueText.getText());
if (val <= 0) {
_fcErrorMessageLabel.setText("FaultCode is Negative or Zero. A positive number is required.");
return;
}
fct.setValue(val);
} catch (NumberFormatException e) {
_fcErrorMessageLabel.setText("FaultCode is not a Number. A positive number is required.");
return;
}
try {
val = Integer.parseInt(_fcPriorityText.getText());
if (val < 0 || val > 3) {
_fcErrorMessageLabel.setText("Incorrect Priority. A number in the range [0;3] is required.");
return;
}
fct.setPriority(val);
} catch (NumberFormatException e) {
_fcErrorMessageLabel.setText("Priority is not a number. A number in the range [0;3] is required.");
return;
}
if (!_fcCauseText.getText().isEmpty())
fct.setCause(_fcCauseText.getText());
if (!_fcActionText.getText().isEmpty())
fct.setAction(_fcActionText.getText());
if (!_fcConsequenceText.getText().isEmpty())
fct.setConsequence(_fcConsequenceText.getText());
if (_fcProblemText.getText().isEmpty()) {
_fcErrorMessageLabel.setText("Problem Description is Required.");
return;
}
fct.setProblemDescription(_fcProblemText.getText());
_fcErrorMessageLabel.setText("");
try {
_alarmManager.updateFaultCode(_alarmManager.getFaultFamily(tff), _alarmManager.getFaultCode(tff, tfc), fct);
tmp.setText(_fcValueText.getText());
if (fct.getValue() != tfc) {
sortFaultFamilyList();
selectElementFromTree(tff, null, Integer.toString(fct.getValue()));
}
} catch (IllegalOperationException e) {
_fcErrorMessageLabel.setText(e.getMessage());
} catch (NullPointerException e) {
_fcErrorMessageLabel.setText(e.getMessage());
}
}
};
_FCgroup = new Group(_compInitial, SWT.SHADOW_ETCHED_IN);
_FCgroup.setText("Fault Code detail");
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
_FCgroup.setLayoutData(gd);
GridLayout gl = new GridLayout();
gl.numColumns = 2;
_FCgroup.setLayout(gl);
_fcValueLabel = new Label(_FCgroup, SWT.NONE);
_fcValueLabel.setText("Value");
_fcValueText = new Text(_FCgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_fcValueText.setLayoutData(gd);
_fcValueText.addListener(SWT.Modify, updateFaultCode);
_fcPriorityLabel = new Label(_FCgroup, SWT.NONE);
_fcPriorityLabel.setText("Priority");
_fcPriorityText = new Text(_FCgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_fcPriorityText.setLayoutData(gd);
_fcPriorityText.addListener(SWT.Modify, updateFaultCode);
_fcCauseLabel = new Label(_FCgroup, SWT.NONE);
_fcCauseLabel.setText("Cause");
_fcCauseText = new Text(_FCgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_fcCauseText.setLayoutData(gd);
_fcCauseText.addListener(SWT.Modify, updateFaultCode);
_fcActionLabel = new Label(_FCgroup, SWT.NONE);
_fcActionLabel.setText("Action");
_fcActionText = new Text(_FCgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_fcActionText.setLayoutData(gd);
_fcActionText.addListener(SWT.Modify, updateFaultCode);
_fcConsequenceLabel = new Label(_FCgroup, SWT.NONE);
_fcConsequenceLabel.setText("Consequence");
_fcConsequenceText = new Text(_FCgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_fcConsequenceText.setLayoutData(gd);
_fcConsequenceText.addListener(SWT.Modify, updateFaultCode);
_fcProblemLabel = new Label(_FCgroup, SWT.NONE);
_fcProblemLabel.setText("Problem description");
_fcProblemText = new Text(_FCgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_fcProblemText.setLayoutData(gd);
_fcProblemText.addListener(SWT.Modify, updateFaultCode);
_fcErrorMessageLabel = new Label(_FCgroup, SWT.NONE);
_fcErrorMessageLabel.setText("");
_fcErrorMessageLabel.setForeground(getViewSite().getShell().getDisplay().getSystemColor(SWT.COLOR_RED));
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.horizontalSpan = 2;
_fcErrorMessageLabel.setLayoutData(gd);
}
use of org.eclipse.swt.widgets.TreeItem in project ACS by ACS-Community.
the class AlarmsView method sortFaultFamilyList.
public void sortFaultFamilyList() {
List<FaultFamily> ffList = _alarmManager.getAllAlarms();
List<FaultFamily> sortedFFList = new ArrayList<FaultFamily>();
/* We get a separate tmp list with the names,
* sort it, and then sort the original ffList */
List<String> tmp = new ArrayList<String>();
for (FaultFamily ff : ffList) tmp.add(ff.getName().toLowerCase());
Collections.sort(tmp);
for (String sff : tmp) for (FaultFamily ff : ffList) if (ff.getName().toLowerCase().compareTo(sff) == 0)
sortedFFList.add(ff);
ffList = sortedFFList;
_tree.removeAll();
for (FaultFamily family : ffList) {
TreeItem iTree = new TreeItem(_tree, SWT.NONE);
iTree.setData(NodeType.FAULT_FAMILY);
iTree.setText(family.getName());
iTree.setImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_ALARM));
for (int j = 0; j != 2; j++) {
TreeItem jTree = new TreeItem(iTree, SWT.NONE);
jTree.setText((j == 0 ? "Fault Codes" : "Fault Members"));
jTree.setData((j == 0 ? NodeType.FAULT_CODE_LIST : NodeType.FAULT_MEMBER_LIST));
jTree.setImage((j == 0 ? Activator.getDefault().getImageRegistry().get(Activator.IMG_FAULTCODES) : Activator.getDefault().getImageRegistry().get(Activator.IMG_FAULTMEMBERS)));
if (j == 0)
sortFaultCodeList(family, jTree);
else
sortFaultMemberList(family, jTree);
}
}
}
Aggregations