Exemplo n.º 1
0
  /** Create a new config editor that isn't attached to any ViperData. */
  public ConfigEditor() {
    super(new JTree());
    popup = new ConfigEditPopup();
    getTree()
        .addMouseListener(
            new MouseAdapter() {
              public void mousePressed(MouseEvent e) {
                maybeShowPopup(e);
                TreePath p = getTree().getClosestPathForLocation(e.getX(), e.getY());
                Object end = p.getLastPathComponent();
                if (end instanceof Config) {
                  EventQueue.invokeLater(new CheckIfExpanded(p));
                }
              }

              public void mouseReleased(MouseEvent e) {
                maybeShowPopup(e);
              }

              private void maybeShowPopup(MouseEvent e) {
                if (e.isPopupTrigger()) {
                  popup.show(e.getComponent(), e.getX(), e.getY());
                }
              }
            });
    model = new ViperTreeModel(this);
    model.addTreeToSelect(getTree());
    // getTree().setRootVisible(false);
    expandedNodes = new HashSet();
    getTree().setModel(model);
    getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Listen for when the selection changes.
    getTree().addTreeSelectionListener(new MySelectionChangeListener());
  }
Exemplo n.º 2
0
 private void createAttrConfigForNode(Node selected) {
   Config parent = null;
   if (selected instanceof Config) {
     parent = (Config) selected;
   } else if (selected instanceof AttrConfig) {
     parent = (Config) ((AttrConfig) selected).getParent();
   }
   if (parent != null) {
     String newName = unusedName("Attr", new AttrNameIter(parent));
     String type = ViperData.ViPER_DATA_URI + "svalue";
     AttrValueWrapper params = model.getMediator().getDataFactory().getAttribute(type);
     Node n = parent.createAttrConfig(newName, type, false, null, params);
     select(n);
   }
 }
Exemplo n.º 3
0
 private void select(Node n) {
   model.enqueueNodeSelection(n);
 }
Exemplo n.º 4
0
 /**
  * Sets the view mediator.
  *
  * @param mediator The mediator
  */
 public void setMediator(ViperViewMediator mediator) {
   model.setMediator(mediator);
 }
Exemplo n.º 5
0
 /**
  * Get the viper view mediator.
  *
  * @return The mediator that the view is listening to.
  */
 public ViperViewMediator getMediator() {
   return model.getMediator();
 }