Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21873/treeview
Modified Files:
GenericTreeView.java
Log Message:
added stuff from the space contex menu to the one in the treeview
Index: GenericTreeView.java
===================================================================
RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/GenericTreeView.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** GenericTreeView.java 15 May 2006 10:28:49 -0000 1.26
--- GenericTreeView.java 15 May 2006 12:12:15 -0000 1.27
***************
*** 46,49 ****
--- 46,50 ----
import net.sourceforge.bprocessor.model.Surface;
import net.sourceforge.bprocessor.model.Vertex;
+ import net.sourceforge.bprocessor.model.Geometry;
/**
***************
*** 351,355 ****
}
! /**
* Context menu for this EntityNode
* @return the menu
--- 352,356 ----
}
! /**
* Context menu for this EntityNode
* @return the menu
***************
*** 358,398 ****
JPopupMenu pm = new JPopupMenu();
Object object = this.getUserObject();
! if (object instanceof Entity) {
! pm.add(new EntityDeleteAction((Entity)object));
}
return pm;
}
}
!
/**
! * The Entity delete action
*/
! public class EntityDeleteAction extends AbstractAction {
!
! /**
! * The entity
! */
! private Entity entity;
/**
* The constructor
* @param ent the entity
*/
! public EntityDeleteAction(Entity ent) {
! super("Delte");
this.entity = ent;
}
!
! /**
! * Invoked when a action is performed
! * @param event ActionEvent
! */
! public void actionPerformed(ActionEvent event) {
! info("deleting: " + entity);
! entity.delete();
! Project.getInstance().checkpoint();
! }
! }
!
/**
* SpaceNode
--- 359,395 ----
JPopupMenu pm = new JPopupMenu();
Object object = this.getUserObject();
! if (object instanceof Entity) {
! AbstractAction delete = new EntityAction((Entity)object, "Delete") {
! public void actionPerformed(ActionEvent arg0) {
! if (entity != null) {
! entity.delete();
! Project.getInstance().checkpoint();
! }
! }
! };
! pm.add(delete);
}
return pm;
}
}
!
/**
! * Actions for a entity
*/
! public abstract class EntityAction extends AbstractAction {
! /** The entity */
! protected Entity entity;
/**
* The constructor
* @param ent the entity
+ * @param name the name of the action
*/
! public EntityAction(Entity ent, String name) {
! super(name);
this.entity = ent;
}
! }
!
/**
* SpaceNode
***************
*** 437,440 ****
--- 434,480 ----
return spaceicon;
}
+
+ /**
+ * Context menu for this SpaceNode
+ * @return the menu
+ */
+ public JPopupMenu menu() {
+ JPopupMenu pm = super.menu();
+ Object object = this.getUserObject();
+ if (object != null) {
+ AbstractAction copy = new EntityAction((Entity)object, "Copy") {
+ public void actionPerformed(ActionEvent arg0) {
+ if (entity != null) {
+ Space spaceCopy = ((Space)entity).copy();
+ select(spaceCopy);
+ }
+ }
+ };
+ pm.add(copy);
+ AbstractAction edit = new EntityAction((Entity)object, "Edit") {
+ public void actionPerformed(ActionEvent arg0) {
+ Selection.primary().clear();
+ Project.getInstance().setActiveSpace((Space)entity);
+ }
+ };
+ pm.add(edit);
+ AbstractAction flip = new EntityAction((Entity)object, "Rotate 90degrees CCW") {
+ public void actionPerformed(ActionEvent arg0) {
+ Space space = (Space)entity;
+ Iterator it = space.collect().iterator();
+ Vertex center = space.center();
+ while (it.hasNext()) {
+ Geometry.rotate(Math.PI / 2,
+ 0, 0, 1,
+ (Vertex)it.next(),
+ center);
+ }
+ space.changed();
+ }
+ };
+ pm.add(flip);
+ }
+ return pm;
+ }
}
***************
*** 802,806 ****
DefaultMutableTreeNode node = (DefaultMutableTreeNode) object;
Object target = node.getUserObject();
- log.info("value-changed " + event);
select(target);
}
--- 842,845 ----
|