[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/attrview OperationAttribute.java, NONE,
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-10-19 08:28:38
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5465/src/net/sourceforge/bprocessor/gui/attrview Modified Files: GenericPanel.java Added Files: OperationAttribute.java Log Message: cube command --- NEW FILE: OperationAttribute.java --- //--------------------------------------------------------------------------------- // $Id: OperationAttribute.java,v 1.1 2007/10/19 08:28:33 henryml Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gui.attrview; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JComponent; import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Operation; /** * The BooleanAttributeView */ public class OperationAttribute extends GenericAttribute implements ActionListener { /** * Default serial version UID */ private static final long serialVersionUID = 1L; /** The listeners */ private List listeners; /** The attribute this gui represents */ private Attribute attribute; /** The component */ private JComponent component; /** The valueLabel */ private JButton button; /** * Constructor for BooleanAttribute * @param attribute The attribute */ public OperationAttribute(Attribute attribute) { super(BoxLayout.X_AXIS); this.attribute = attribute; this.listeners = new LinkedList(); Box header = Box.createHorizontalBox(); Box column = Box.createVerticalBox(); header.add(Box.createHorizontalStrut(7)); header.add(Box.createHorizontalGlue()); column.add(Box.createRigidArea(new Dimension(70, 3))); column.add(header); column.add(Box.createRigidArea(new Dimension(70, 3))); column.setMaximumSize(new Dimension(60, Short.MAX_VALUE)); this.add(column); component = Box.createHorizontalBox(); component.add(createButton(attribute.getName())); this.add(component); } /** * Add a listener that are notified when the value is changed * @param listener The listener */ public void addBooleanAttributeListener(AttributeListener listener) { listeners.add(listener); } /** * Remove a listener * @param listener The listener */ public void removeBooleanAttributeListener(AttributeListener listener) { listeners.remove(listener); } /** * Send valueChanged to all listeners */ protected void valueChanged() { Iterator iter = listeners.iterator(); while (iter.hasNext()) { AttributeListener current = (AttributeListener) iter.next(); current.valueChanged(attribute); } } /** * Create a value label * @param value The value * @return The label */ private JComponent createButton(String name) { button = new JButton(); button.setText(name); button.addActionListener(this); return button; } /** * Return the attribute * @return The attribute */ public Attribute attribute() { return attribute; } /** * {@inheritDoc} */ public void startEditing() { } /** * {@inheritDoc} */ public void stopEditing() { } /** * {@inheritDoc} */ public void cancelEditing() { } /** {@inheritDoc} */ public void actionPerformed(ActionEvent event) { Operation operation = (Operation) attribute.getValue(); operation.perform(); } } Index: GenericPanel.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/GenericPanel.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** GenericPanel.java 18 Oct 2007 13:47:43 -0000 1.44 --- GenericPanel.java 19 Oct 2007 08:28:33 -0000 1.45 *************** *** 30,33 **** --- 30,34 ---- import net.sourceforge.bprocessor.model.Entity; import net.sourceforge.bprocessor.model.Material; + import net.sourceforge.bprocessor.model.Operation; import net.sourceforge.bprocessor.model.Parametric; import net.sourceforge.bprocessor.model.Project; *************** *** 235,238 **** --- 236,245 ---- } + private void handleOperation(Attribute attribute, JComponent where) { + GenericAttribute generic = new OperationAttribute(attribute); + genAttributes.add(generic); + where.add(new AttributeRow(generic)); + } + private void generateContent(List what, JComponent where) { Iterator iter = what.iterator(); *************** *** 255,258 **** --- 262,269 ---- } else if (a.getValue() instanceof Parametric) { handleLink(a, where); + } else if (a.getValue() instanceof Operation) { + handleOperation(a, where); + } else { + System.out.println("-- " + a.getValue() + " --"); } } |