[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/attrview ReferenceAttribute.java, 1.1, 1
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2007-12-19 09:03:33
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10069/src/net/sourceforge/bprocessor/gui/attrview Modified Files: ReferenceAttribute.java LinkAttribute.java Log Message: Refactored the material attribute in attribute view Index: LinkAttribute.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/LinkAttribute.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** LinkAttribute.java 18 Dec 2007 15:06:45 -0000 1.19 --- LinkAttribute.java 19 Dec 2007 09:03:31 -0000 1.20 *************** *** 91,95 **** component.add(createValueLabel(attribute.getValue())); ClassLoader classloader = Thread.currentThread().getContextClassLoader(); ! URL url = classloader.getResource("Biconarrow.gif"); icon = new JLabel(new ImageIcon(url)); this.add(component); --- 91,95 ---- component.add(createValueLabel(attribute.getValue())); ClassLoader classloader = Thread.currentThread().getContextClassLoader(); ! URL url = classloader.getResource("Biconarrowraised.gif"); icon = new JLabel(new ImageIcon(url)); this.add(component); Index: ReferenceAttribute.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/ReferenceAttribute.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ReferenceAttribute.java 18 Dec 2007 15:06:45 -0000 1.1 --- ReferenceAttribute.java 19 Dec 2007 09:03:31 -0000 1.2 *************** *** 10,15 **** --- 10,17 ---- import java.awt.Dimension; + import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; + import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; *************** *** 21,24 **** --- 23,28 ---- import java.util.List; + import javax.swing.AbstractAction; + import javax.swing.Action; import javax.swing.Box; import javax.swing.BoxLayout; *************** *** 26,29 **** --- 30,34 ---- import javax.swing.JComponent; import javax.swing.JLabel; + import javax.swing.JPopupMenu; import javax.swing.JTextField; import javax.swing.text.AttributeSet; *************** *** 59,63 **** /** The link icon */ ! private JLabel icon; /** The editor, when this EditableAttribute is being edited */ --- 64,71 ---- /** The link icon */ ! private JLabel link; ! ! private JLabel arrow; ! private MouseListener popup; /** The editor, when this EditableAttribute is being edited */ *************** *** 77,80 **** --- 85,90 ---- this.listeners = new LinkedList(); + popup = new HandlePopup(); + label = createLabel(attribute.getName()); *************** *** 92,100 **** component.add(createValueLabel((Reference) attribute.getValue())); ClassLoader classloader = Thread.currentThread().getContextClassLoader(); ! URL url = classloader.getResource("Biconarrow.gif"); ! icon = new JLabel(new ImageIcon(url)); this.add(component); ! this.add(icon); this.add(Box.createHorizontalGlue()); } --- 102,117 ---- component.add(createValueLabel((Reference) attribute.getValue())); ClassLoader classloader = Thread.currentThread().getContextClassLoader(); ! { ! URL url = classloader.getResource("Biconarrowraised.gif"); ! link = new JLabel(new ImageIcon(url)); ! } this.add(component); ! this.add(link); this.add(Box.createHorizontalGlue()); + { + URL url = classloader.getResource("Biconlink.gif"); + arrow = new JLabel(new ImageIcon(url)); + } + this.add(arrow); } *************** *** 106,110 **** protected double round(double value) { int i = (int) (value * 100000); ! return ((double) i) / 100000.0; } --- 123,127 ---- protected double round(double value) { int i = (int) (value * 100000); ! return i / 100000.0; } *************** *** 127,131 **** label.addMouseListener(mouseListener); component.addMouseListener(mouseListener); ! icon.addMouseListener(this); } --- 144,149 ---- label.addMouseListener(mouseListener); component.addMouseListener(mouseListener); ! link.addMouseListener(this); ! arrow.addMouseListener(popup); } *************** *** 137,140 **** --- 155,160 ---- label.removeMouseListener(mouseListener); component.removeMouseListener(mouseListener); + link.removeMouseListener(this); + arrow.removeMouseListener(popup); } *************** *** 291,294 **** --- 311,353 ---- } + private class ItemAction extends AbstractAction { + private Object object; + + /** + * Constructs an ItemAction + * @param object Object + */ + public ItemAction(Object object) { + super(object.toString()); + this.object = object; + } + + /** {@inheritDoc} */ + public void actionPerformed(ActionEvent event) { + Reference reference = (Reference) attribute.getValue(); + reference.setObject(object); + valueChanged(); + } + } + + private class HandlePopup extends MouseAdapter { + /** + * {@inheritDoc} + */ + public void mousePressed(MouseEvent event) { + Reference reference = (Reference) attribute.getValue(); + List legals = reference.getLegals(); + JPopupMenu menu; + { + menu = new JPopupMenu(); + for (Object current : legals) { + Action action = new ItemAction(current); + menu.add(action); + } + } + menu.show(event.getComponent(), event.getX(), event.getY()); + } + } + /** * Not in use |