Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Tree tree = new Tree(composite_1, SWT.NONE);
- tree.setHeaderVisible(true);
- tree.setLinesVisible(true);
- TreeColumn trclmnProperty = new TreeColumn(tree, SWT.NONE);
- trclmnProperty.setWidth(100);
- trclmnProperty.setText(Messages.AppWindow_trclmnProperty_text);
- TreeColumn trclmnValue = new TreeColumn(tree, SWT.NONE);
- trclmnValue.setWidth(100);
- trclmnValue.setText(Messages.AppWindow_trclmnValue_text);
- // Reading contents of a tree
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder;
- try {
- builder = factory.newDocumentBuilder();
- File f = new File("ftplist.xml");
- org.w3c.dom.Document doc = builder.parse(f);
- NodeList ftpList = doc.getElementsByTagName("ftp");
- for (int i = 0; i < ftpList.getLength(); i++) {
- NodeList nodeList = ((Element) ftpList.item(i)).getElementsByTagName("ftpName");
- TreeItem treeItemRootNode = new TreeItem(tree, SWT.NONE);
- TreeEditor treeRootNodeEditor = new TreeEditor(tree);
- final Button button = new Button(tree, SWT.CHECK);
- button.setText(nodeList.item(0).getTextContent());
- nodeList = ((Element) ftpList.item(0)).getElementsByTagName("ftpEnabled");
- button.setSelection(nodeList.item(0).getTextContent().equalsIgnoreCase("true"));
- button.pack();
- treeRootNodeEditor.minimumWidth = button.getSize().x;
- treeRootNodeEditor.horizontalAlignment = SWT.LEFT;
- treeRootNodeEditor.setEditor(button, treeItemRootNode, 0);
- nodeList = ((Element) ftpList.item(0)).getElementsByTagName("ftpHost");
- TreeItem treeItemFtpHost = new TreeItem(treeItemRootNode, SWT.NONE);
- treeItemFtpHost.setText(new String[] { "Host", nodeList.item(0).getTextContent() });
- }
- } catch (ParserConfigurationException e1) {
- e1.printStackTrace();
- } catch (SAXException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- <?xml version="1.0"?>
- <ftps>
- <ftp>
- <ftpName>SuperFtp</ftpName>
- <ftpEnabled>true</ftpEnabled>
- <ftpHost>ftp.com</ftpHost>
- <ftpPort>21</ftpPort>
- <ftpLogin>Login</ftpLogin>
- <ftpPassword>Pass</ftpPassword>
- <ftpUsePassiveMode>true</ftpUsePassiveMode>
- <ftpRemoteDir>/</ftpRemoteDir>
- <localSyncDir>C:/</localSyncDir>
- </ftp>
- <ftp>
- <ftpName>SuperFtp2</ftpName>
- <ftpEnabled>true</ftpEnabled>
- <ftpHost>ftp.com</ftpHost>
- <ftpPort>21</ftpPort>
- <ftpLogin>Login</ftpLogin>
- <ftpPassword>Pass</ftpPassword>
- <ftpUsePassiveMode>true</ftpUsePassiveMode>
- <ftpRemoteDir>/</ftpRemoteDir>
- <localSyncDir>C:/</localSyncDir>
- </ftp>
- <ftps>
- tree.addListener(SWT.EraseItem, new Listener()
- {
- public void handleEvent(Event event)
- {
- if ((event.detail & SWT.SELECTED) != 0)
- {
- event.detail &= ~SWT.SELECTED;
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement