Changeset 84 for java/main/src/main/java/com/framsticks/gui/Panel.java
- Timestamp:
- 06/22/13 21:51:33 (11 years ago)
- Location:
- java/main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main
-
Property
svn:ignore
set to
target
-
Property
svn:ignore
set to
-
java/main/src/main/java/com/framsticks/gui/Panel.java
r77 r84 2 2 3 3 import com.framsticks.params.AccessInterface; 4 import org.apache.log4j.Logger; 4 import com.framsticks.params.CompositeParam; 5 import com.framsticks.params.FramsClass; 6 // import org.apache.log4j.Logger; 5 7 6 8 import javax.swing.*; 7 import java.awt.*;8 import java.awt.event.ActionEvent;9 import java.awt.event.ActionListener;10 9 11 10 /** 12 * @author Piotr Sniegowski11 * Author: Piotr Śniegowski 13 12 */ 13 @SuppressWarnings("serial") 14 14 public abstract class Panel extends JPanel { 15 15 16 private static final Logger LOGGER = Logger.getLogger(Panel.class.getName()); 16 public static class Parameters { 17 public final EndpointAtFrame endpoint; 18 public final CompositeParam param; 19 public final FramsClass framsClass; 17 20 18 /** 19 * Pane to which components will be added. 20 */ 21 protected JPanel contentPanel; 21 public Parameters(EndpointAtFrame endpoint, CompositeParam param, FramsClass framsClass) { 22 this.endpoint = endpoint; 23 this.param = param; 24 this.framsClass = framsClass; 25 } 26 } 27 28 // private static final Logger log = Logger.getLogger(Panel.class.getName()); 22 29 23 30 protected TreeNode currentTreeNode; 24 protectedEndpointAtFrame endpoint;25 31 protected final EndpointAtFrame endpoint; 32 protected final Frame frame; 26 33 protected final String className; 27 final protected JLabel label; 28 final protected JButton applyButton; 34 protected final FramsClass framsClass; 35 protected final CompositeParam param; 36 protected String uniqueName = "?"; 29 37 30 public Panel(EndpointAtFrame endpoint, String className) { 31 this.endpoint = endpoint; 32 this.frame = endpoint.getFrame(); 33 this.className = className; 34 LOGGER.debug("create panel for type: " + className); 35 36 endpoint.registerPanel(this); 37 38 contentPanel = new JPanel(); 39 contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.PAGE_AXIS)); 40 JScrollPane scroll = new JScrollPane(contentPanel); 41 //scroll.setBorder(BorderFactory.createEtchedBorder()); 42 43 JPanel pageEndPanel = new JPanel(); 44 pageEndPanel.setLayout(new BoxLayout(pageEndPanel, BoxLayout.X_AXIS)); 45 pageEndPanel.add(Box.createHorizontalGlue()); 46 47 applyButton = new JButton("Apply"); 48 applyButton.addActionListener(new ActionListener() { 49 public void actionPerformed(ActionEvent e) { 50 applyChanges(); 51 } 52 }); 53 pageEndPanel.add(applyButton); 54 55 pageEndPanel.add(Box.createHorizontalStrut(10)); 56 pageEndPanel.setPreferredSize(new Dimension(0, 30)); 57 58 label = new JLabel(); 59 JPanel centerPanel = new JPanel(); 60 centerPanel.setLayout(new BorderLayout()); 61 centerPanel.add(Box.createHorizontalStrut(10), BorderLayout.LINE_START); 62 centerPanel.add(Box.createHorizontalStrut(10), BorderLayout.LINE_END); 63 centerPanel.add(label, BorderLayout.PAGE_START); 64 centerPanel.add(scroll, BorderLayout.CENTER); 65 centerPanel.add(pageEndPanel, BorderLayout.PAGE_END); 66 67 this.setLayout(new BorderLayout()); 68 this.add(centerPanel, BorderLayout.CENTER); 69 70 38 public Panel(Parameters parameters) { 39 this.endpoint = parameters.endpoint; 40 this.frame = parameters.endpoint.getFrame(); 41 this.framsClass = parameters.framsClass; 42 this.param = parameters.param; 43 this.className = parameters.param.getContainedTypeName(); 44 this.setName(parameters.param.getFramsTypeName()); 71 45 } 72 46 73 public void setCurrentTreeNode(TreeNode node) { 74 currentTreeNode = node; 75 //label.setText(node.getNode().getPath()); 76 //this.revalidate(); 47 public void setCurrentTreeNode(TreeNode currentTreeNode) { 48 this.currentTreeNode = currentTreeNode; 77 49 } 78 50 … … 81 53 } 82 54 83 protected abstract void applyChanges(); 84 public abstract void refreshComponents(AccessInterface access); 55 public final Frame getFrame() { 56 return frame; 57 } 58 59 public final EndpointAtFrame getEndpointAtFrame() { 60 return endpoint; 61 } 62 63 64 public final String getClassName() { 65 return className; 66 } 67 68 public abstract void pullValuesFromLocalToUser(AccessInterface access); 85 69 86 70 @Override 87 71 public String toString() { 88 return currentTreeNode == null ? "?" : currentTreeNode.toString();72 return uniqueName; 89 73 } 90 74 91 public final Frame getFrame() {92 return frame;93 75 public final String getUniqueName() { 76 return uniqueName; 77 } 94 78 95 96 public final String getClassName() { 97 return className; 98 } 99 100 public final String getFullName() { 101 return className + "@" + endpoint.getName(); 102 } 103 79 public abstract String getTitle(); 104 80 }
Note: See TracChangeset
for help on using the changeset viewer.