Exemplo n.º 1
0
    protected void setup() {
      clear();
      if (model != null) {
        // Add transformers buttons, separate them by element group
        for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) {
          ButtonGroup buttonGroup = new ButtonGroup();
          for (final TransformerCategory c : controller.getCategories(elmtType)) {
            // Build button
            Icon icon = c.getIcon();
            //                        DecoratedIcon decoratedIcon = getDecoratedIcon(icon, t);
            //                        JToggleButton btn = new JToggleButton(decoratedIcon);
            JToggleButton btn = new JToggleButton(icon);

            btn.setToolTipText(c.getDisplayName());
            btn.addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    controller.setSelectedCategory(c);
                  }
                });
            btn.setName(c.getDisplayName());
            btn.setFocusPainted(false);
            buttonGroup.add(btn);
            add(btn);
          }

          buttonGroups.add(buttonGroup);
        }
      } else {
        elementGroup.clearSelection();
      }
    }
Exemplo n.º 2
0
 protected void refreshTransformers() {
   if (model != null) {
     // Select the right transformer
     int index = 0;
     for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) {
       ButtonGroup g = buttonGroups.get(index);
       boolean active = model.getSelectedElementClass().equals(elmtType);
       g.clearSelection();
       TransformerCategory c = model.getSelectedCategory();
       String selected = c.getDisplayName();
       for (Enumeration<AbstractButton> btns = g.getElements(); btns.hasMoreElements(); ) {
         AbstractButton btn = btns.nextElement();
         btn.setVisible(active);
         if (btn.getName().equals(selected)) {
           g.setSelected(btn.getModel(), true);
         }
       }
       index++;
     }
   }
 }