Blizzaaard
A notepad...
Saturday, September 27, 2008
EPMS BIRT
package process.parser.dialogs;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
public class ActCostAnalyzeDialog extends Dialog {
protected Shell shell;
private Tree actTree;
private List selectedList = null;
private static void accessElement(Element parentElement, NodeAct parentNodeAct) {
List listChild = parentElement.getChildren();
int iChild = listChild.size();
for (int i = 0; i < iChild; i++) {
Element childElement = (Element)listChild.get(i);
ActRecord actRecordChild = new ActRecord(
childElement.getAttributeValue("type"),
childElement.getAttributeValue("id"),
childElement.getAttributeValue("name"),
childElement.getAttributeValue("path"));
NodeAct childNodeAct = new NodeAct(actRecordChild);
parentNodeAct.addChild(childNodeAct);
accessElement(childElement, childNodeAct);
}
}
private NodeAct createDummyModel() {
SAXBuilder saxBuilder = new SAXBuilder();
try {
Document document = saxBuilder
.build("E:\\workspace\\pomes.process.parser\\process.xml");
// Get Element of "process"
Element processElement = document.getRootElement();
ActRecord processActRecord = new ActRecord(
null,
null,
"process",
null);
NodeAct processNodeAct = new NodeAct(processActRecord);
// Get Element of "activities"
Element activitiesElement = processElement.getChild("activities");
ActRecord activitiesActRecord = new ActRecord(
"activities",
null,
"活动",
null);
NodeAct activitiesNodeAct = new NodeAct(activitiesActRecord);
processNodeAct.addChild(activitiesNodeAct);
accessElement(activitiesElement, activitiesNodeAct);
//return activitiesNodeAct;
return processNodeAct;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public ActCostAnalyzeDialog(Shell parent, int style) {
super(parent, style);
}
public ActCostAnalyzeDialog(Shell parent) {
this(parent, SWT.NONE);
}
public List open() {
createContents();
shell.open();
shell.layout();
Display display = getParent().getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
return selectedList;
}
protected void createContents() {
shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
shell.setSize(433, 433);
shell.setText("活动成本分析");
shell.setLocation(200, 200);
// Label "请选择:"
final Label actLabel = new Label(shell, SWT.NONE);
actLabel.setText("请选择:");
actLabel.setBounds(20 ,10 ,91 ,20);
// Act TreeViewer
final CheckboxTreeViewer actCheckboxTreeViewer = new CheckboxTreeViewer(shell,
SWT.BORDER |
SWT.H_SCROLL);
actCheckboxTreeViewer.setContentProvider(new ActContentProvider());
actCheckboxTreeViewer.setLabelProvider(new ActLabelProvider());
actCheckboxTreeViewer.setInput(createDummyModel());
actTree = actCheckboxTreeViewer.getTree();
actTree.setBounds(20, 35, 278, 300);
// Button [OK]
final Button okButton = new Button(shell, SWT.NONE);
okButton.setText("确定");
okButton.setBounds(220 ,365 ,91 ,26);
okButton.addSelectionListener( new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
selectedList = new ArrayList();
Object[] selectedObjectArray = actCheckboxTreeViewer.getCheckedElements();
int iLength = selectedObjectArray.length;
for (int i = 0; i < iLength; i++) {
Object selectedObject = selectedObjectArray[i];
NodeAct selectedNodeAct = (NodeAct)selectedObject;
selectedList.add(selectedNodeAct);
}
shell.dispose();
}
});
// Button [Cancel]
final Button cancelButton = new Button(shell, SWT.NONE);
cancelButton.setText("取消");
cancelButton.setBounds(320, 365, 91, 26);
cancelButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
selectedList = null;
shell.dispose();
}
});
// Button [Expand All]
final Button expandAllButton = new Button(shell, SWT.NONE);
expandAllButton.setText("全部展开");
expandAllButton.setBounds(320, 35, 91, 26);
expandAllButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
actCheckboxTreeViewer.expandAll();
}
});
// Button [Collapse All]
final Button collapseAllButton = new Button(shell, SWT.NONE);
collapseAllButton.setText("全部折叠");
collapseAllButton.setBounds(320, 65, 91, 26);
collapseAllButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
actCheckboxTreeViewer.collapseAll();
}
});
// Button [Select All]
final Button selectAllButton = new Button(shell, SWT.NONE);
selectAllButton.setText("全部选择");
selectAllButton.setBounds(320, 105, 91, 26);
selectAllButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
actCheckboxTreeViewer.setAllChecked(true);
}
});
// Button [De-Select All]
final Button deSelectAllButton = new Button(shell, SWT.NONE);
deSelectAllButton.setText("取消全选");
deSelectAllButton.setBounds(320, 135, 91, 26);
deSelectAllButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
actCheckboxTreeViewer.setAllChecked(false);
}
});
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
About Me
blizzaaard
Beijing, China
View my complete profile
Links
My Photo
My Video
Google Mail
Google Analytics
Subscribe To
Posts
Atom
Posts
Comments
Atom
Comments
Blog Archive
►
2009
(1)
►
February
(1)
▼
2008
(34)
►
October
(2)
▼
September
(8)
EPMS BIRT
Some theses to read
MP3 Player
Subclass and Superclass of Window
Inject Code into Another Process
The Execution of Switch and Case
Create Dialog-based Win32 Application
Use Syntax Highlighter in Blogspot
►
August
(15)
►
July
(9)
Labels
AW
(16)
Win32/64
(6)
No comments:
Post a Comment