View Javadoc
1 package net.sf.panoptes.view.configurator; 2 3 import java.util.HashMap; 4 5 import net.sf.panoptes.controller.MainController; 6 import net.sf.panoptes.model.node.Node; 7 import net.sf.panoptes.model.node.NodeUpdateEvent; 8 9 import org.eclipse.swt.SWT; 10 import org.eclipse.swt.layout.FillLayout; 11 import org.eclipse.swt.layout.GridData; 12 import org.eclipse.swt.layout.GridLayout; 13 import org.eclipse.swt.widgets.Composite; 14 import org.eclipse.swt.widgets.Label; 15 import org.eclipse.swt.widgets.Table; 16 import org.eclipse.swt.widgets.TableColumn; 17 import org.eclipse.swt.widgets.TableItem; 18 19 /*** 20 * DefaultConfigurator.java 21 * 22 * A simple <code>NodeConfigurator</code> that just displays the children of a 23 * <code>Node</code> in a table. 24 * 25 * @see net.sf.panoptes.model.node.Node 26 * 27 * @author Dag Liodden 28 * @version 0.1 29 */ 30 public class DefaultConfigurator extends NodeConfigurator { 31 Table table; 32 private Node node = null; 33 34 public DefaultConfigurator(MainController controller, Composite parent, int style, HashMap attributes) { 35 super(controller, parent, style, attributes); 36 this.setLayout(new GridLayout()); 37 38 Composite title = new Composite(this, SWT.NULL); 39 title.setLayout(new FillLayout()); 40 title.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 41 Label titleString = new Label(title, SWT.NULL); 42 titleString.setText("Children:"); 43 44 table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION); 45 table.setLayoutData(new GridData(GridData.FILL_BOTH)); 46 table.setHeaderVisible(true); 47 TableColumn tc; 48 tc = new TableColumn(table, SWT.BORDER); 49 tc.setText("Name"); 50 tc.setWidth(200); 51 52 tc = new TableColumn(table, SWT.BORDER); 53 tc.setText("Description"); 54 tc.setWidth(400); 55 56 } 57 58 public void setNode(Node component) { 59 table.removeAll(); 60 this.node = component; 61 Node[] children = component.getChildren(); 62 if (children != null) 63 for (int i = 0; i < children.length; i++) { 64 TableItem ti = 65 createItem( 66 children[i].getConfigDescriptor().getName(), 67 children[i].getConfigDescriptor().getDescription()); 68 ti.setImage(children[i].getIcon()); 69 } 70 } 71 72 private TableItem createItem(String name, String value) { 73 TableItem t = new TableItem(table, SWT.NULL); 74 t.setText(0, name); 75 t.setText(1, value); 76 return t; 77 } 78 79 /* (non-Javadoc) 80 * @see net.sf.panoptes.view.configurator.NodeConfigurator#refresh() 81 */ 82 public void refresh() { 83 if (node != null) setNode(node); 84 85 } 86 87 /* (non-Javadoc) 88 * @see net.sf.panoptes.model.node.NodeUpdateListener#nodeUpdated(net.sf.panoptes.model.node.NodeUpdateEvent) 89 */ 90 public void nodeUpdated(NodeUpdateEvent event) { 91 } 92 93 }

This page was automatically generated by Maven