Thread: [Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/attrview AttributeView.java,1.14,1.15
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-01-06 15:36:26
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25204/src/net/sourceforge/bprocessor/gui/attrview Modified Files: AttributeView.java Log Message: Selection refactored. Selection is now a special observable collection. Views responds to changed in the selection. Index: AttributeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/AttributeView.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** AttributeView.java 6 Jan 2006 11:21:41 -0000 1.14 --- AttributeView.java 6 Jan 2006 15:36:19 -0000 1.15 *************** *** 7,14 **** package net.sourceforge.bprocessor.gui.attrview; ! import net.sourceforge.bprocessor.kernel.notification.Notification; ! import net.sourceforge.bprocessor.kernel.notification.NotificationListener; ! import net.sourceforge.bprocessor.kernel.notification.Notifier; ! import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; --- 7,12 ---- package net.sourceforge.bprocessor.gui.attrview; ! import net.sourceforge.bprocessor.model.Observer; ! import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; *************** *** 34,38 **** * The attribute view */ ! public class AttributeView extends JTabbedPane implements NotificationListener { /** The logger */ private static Logger log = Logger.getLogger(AttributeView.class); --- 32,36 ---- * The attribute view */ ! public class AttributeView extends JTabbedPane implements Observer { /** The logger */ private static Logger log = Logger.getLogger(AttributeView.class); *************** *** 52,108 **** setMinimumSize(new Dimension(120, 240)); setPreferredSize(new Dimension(120, 240)); ! Notifier.getInstance().addListener(this); } ! /** ! * Handle a notification ! * @param n The notification */ ! public void handleNotification(Notification n) { ! if (log.isDebugEnabled()) { ! log.debug(n); ! } ! ! String type = n.getType(); ! if (type.equals(Notification.FUNCTIONAL_SPACE_SELECTED)) { ! Space current = Project.getInstance().findFunctionalSpaceById(n.getObject()); ! ap.displayFuncSpace(current); ! } else if (type.equals(Notification.CONSTRUCTION_SPACE_SELECTED)) { ! Space current = Project.getInstance().findConstructionSpaceById(n.getObject()); ! ap.displayConsSpace(current); ! } else if (type.equals(Notification.SURFACE_SELECTED)) { ! Surface current = Project.getInstance().findSurfaceById(n.getObject()); ! ap.displaySurface(current); ! } else if (type.equals(Notification.FUNCTIONAL_SPACE_DESELECTED) || ! type.equals(Notification.CONSTRUCTION_SPACE_DESELECTED) || ! type.equals(Notification.ELEMENT_DESELECTED) || ! type.equals(Notification.PART_DESELECTED) || ! type.equals(Notification.SURFACE_DESELECTED)) { ! ! ap.display(null); } - repaint(); ! } ! ! /** ! * Should the listener handle this notification ! * @param type The notification type ! * @return True if it should handle it; otherwise false ! */ ! public boolean isNotificationEnabled(String type) { ! if (type.equals(Notification.FUNCTIONAL_SPACE_SELECTED) || ! type.equals(Notification.FUNCTIONAL_SPACE_DESELECTED) || ! type.equals(Notification.CONSTRUCTION_SPACE_SELECTED) || ! type.equals(Notification.CONSTRUCTION_SPACE_DESELECTED) || ! type.equals(Notification.ELEMENT_SELECTED) || ! type.equals(Notification.ELEMENT_DESELECTED) || ! type.equals(Notification.PART_SELECTED) || ! type.equals(Notification.PART_DESELECTED) || ! type.equals(Notification.SURFACE_SELECTED) || ! type.equals(Notification.SURFACE_DESELECTED)) { ! return true; ! } ! return false; } --- 50,83 ---- setMinimumSize(new Dimension(120, 240)); setPreferredSize(new Dimension(120, 240)); ! Selection.primary().addObserver(this); } ! /** ! * @param object The changed object */ ! public void update(Object object) { ! Selection selection = Selection.primary(); ! if (object == selection) { ! if (selection.size() == 1) { ! Object target = selection.iterator().next(); ! if (target instanceof Space) { ! Space space = (Space) target; ! if (space.isConstructionSpace()) { ! ap.displayConsSpace(space); ! } ! if (space.isFunctionalSpace()) { ! ap.displayFuncSpace(space); ! } ! } else if (target instanceof Surface) { ! ap.displaySurface((Surface) target); ! } else { ! ap.display(null); ! } ! } else { ! ap.display(null); ! } } repaint(); ! //FIXME should re-display if anything else is changed } *************** *** 250,253 **** --- 225,229 ---- add((JLabel)components.get(i)); } + revalidate(); } |