/**
   * Initializes custom contact action buttons.
   *
   * @param contactActionButtons the list of buttons to initialize
   * @param gridX the X grid of the first button
   * @param xBounds the x bounds of the first button
   * @return the new grid X coordinate after adding all the buttons
   */
  private int initGroupActionButtons(
      Collection<SIPCommButton> contactActionButtons, int gridX, int xBounds) {
    // Reinit the labels to take the whole horizontal space.
    addLabels(gridX + contactActionButtons.size());

    Iterator<SIPCommButton> actionsIter = contactActionButtons.iterator();
    while (actionsIter.hasNext()) {
      final SIPCommButton actionButton = actionsIter.next();

      // We need to explicitly remove the buttons from the tooltip manager,
      // because we're going to manager the tooltip ourselves in the
      // DefaultTreeContactList class. We need to do this in order to have
      // a different tooltip for every button and for non button area.
      ToolTipManager.sharedInstance().unregisterComponent(actionButton);

      if (customActionButtonsUIGroup == null)
        customActionButtonsUIGroup = new LinkedList<JButton>();

      customActionButtonsUIGroup.add(actionButton);

      xBounds += addButton(actionButton, ++gridX, xBounds, false);
    }

    return gridX;
  }
 public ReferencePropertyWidget(boolean containedByListReferenceGUI) {
   this.containedByListReferenceGUI = containedByListReferenceGUI;
   // get Options
   m_comboBox = new JComboBox();
   m_comboBox.setEditable(false);
   m_comboBox.setPreferredSize(new Dimension(300, 20));
   // m_comboBox.setMinimumSize(new Dimension(260, 20));
   m_comboBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 20));
   KeyStroke controlT = KeyStroke.getKeyStroke("control SPACE");
   getTextField().getInputMap().put(controlT, controlT);
   getTextField().getActionMap().put(controlT, new CodeCompleteAction());
   ToolTipManager.sharedInstance().registerComponent(m_comboBox);
 }
 @Override
 public void dispose() {
   synchronized (lock) {
     isDisposed = true;
     ToolTipManager.sharedInstance().unregisterComponent(myTree);
     myModelTracker.removeListener(this);
     myUpdateAlarm.cancelAllRequests();
     if (myUsagePreviewPanel != null) {
       UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS =
           ((Splitter) myUsagePreviewPanel.getParent()).getProportion();
       myUsagePreviewPanel = null;
     }
   }
 }
Example #4
0
  public UpdateAssetGUI() {
    try {
      PluginMgrClient.init();
      mclient = new MasterMgrClient();
      queue = new QueueMgrClient();
      plug = PluginMgrClient.getInstance();
      log = LogMgr.getInstance();

      pAssetManager = new TreeMap<String, AssetInfo>();

      project = "lr";
      charList = new TreeMap<String, String>();
      setsList = new TreeMap<String, String>();
      propsList = new TreeMap<String, String>();

      potentialUpdates = new TreeSet<String>();
      pSubstituteFields = new TreeMap<String, LinkedList<JBooleanField>>();

      /* load the look-and-feel */
      {
        try {
          SynthLookAndFeel synth = new SynthLookAndFeel();
          synth.load(
              LookAndFeelLoader.class.getResourceAsStream("synth.xml"), LookAndFeelLoader.class);
          UIManager.setLookAndFeel(synth);
        } catch (java.text.ParseException ex) {
          log.log(
              LogMgr.Kind.Ops,
              LogMgr.Level.Severe,
              "Unable to parse the look-and-feel XML file (synth.xml):\n" + "  " + ex.getMessage());
          System.exit(1);
        } catch (UnsupportedLookAndFeelException ex) {
          log.log(
              LogMgr.Kind.Ops,
              LogMgr.Level.Severe,
              "Unable to load the Pipeline look-and-feel:\n" + "  " + ex.getMessage());
          System.exit(1);
        }
      }

      /* application wide UI settings */
      {
        JPopupMenu.setDefaultLightWeightPopupEnabled(false);
        ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
      }
    } catch (PipelineException ex) {
      ex.printStackTrace();
    } // end try/catch
  } // end constructor
  protected void initTree() {
    if (myWasTreeInitialized) return;
    myWasTreeInitialized = true;

    super.initTree();
    new TreeSpeedSearch(
        myTree,
        new Convertor<TreePath, String>() {
          public String convert(final TreePath treePath) {
            return ((MyNode) treePath.getLastPathComponent()).getDisplayName();
          }
        },
        true);
    ToolTipManager.sharedInstance().registerComponent(myTree);
    myTree.setCellRenderer(new ProjectStructureElementRenderer(myContext));
  }
  /** Inializes button tool tips. */
  private void initButtonToolTips() {
    callButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT"));
    callVideoButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.VIDEO_CALL"));
    desktopSharingButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SHARE_DESKTOP"));
    chatButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SEND_MESSAGE"));
    addContactButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.ADD_CONTACT"));

    // We need to explicitly remove the buttons from the tooltip manager,
    // because we're going to manager the tooltip ourselves in the
    // DefaultTreeContactList class. We need to do this in order to have
    // a different tooltip for every button and for non button area.
    ToolTipManager ttManager = ToolTipManager.sharedInstance();
    ttManager.unregisterComponent(callButton);
    ttManager.unregisterComponent(callVideoButton);
    ttManager.unregisterComponent(desktopSharingButton);
    ttManager.unregisterComponent(chatButton);
    ttManager.unregisterComponent(addContactButton);
  }
Example #7
0
  /** Initializes the layout and the ribbon. */
  private void initRibbon() {
    this.setLayout(new RibbonFrameLayout());
    this.ribbon = new JRibbon(this);
    this.add(this.ribbon, BorderLayout.NORTH);

    // this.keyTipManager = new KeyTipManager(this);
    Toolkit.getDefaultToolkit()
        .addAWTEventListener(
            new AWTEventListener() {
              private boolean prevAltModif = false;

              @Override
              public void eventDispatched(AWTEvent event) {
                Object src = event.getSource();
                if (src instanceof Component) {
                  Component c = (Component) src;
                  if ((c == JRibbonFrame.this)
                      || (SwingUtilities.getWindowAncestor(c) == JRibbonFrame.this)) {
                    if (event instanceof KeyEvent) {
                      KeyEvent keyEvent = (KeyEvent) event;
                      // System.out.println(keyEvent.getID() + ":"
                      // + keyEvent.getKeyCode());
                      switch (keyEvent.getID()) {
                        case KeyEvent.KEY_PRESSED:
                          // if (keyEvent.getKeyCode() ==
                          // KeyEvent.VK_ESCAPE) {
                          // keyTipManager.showPreviousChain();
                          // }

                          break;
                        case KeyEvent.KEY_RELEASED:
                          boolean wasAltModif = prevAltModif;
                          prevAltModif = keyEvent.getModifiersEx() == InputEvent.ALT_DOWN_MASK;
                          if (wasAltModif && keyEvent.getKeyCode() == KeyEvent.VK_ALT) break;
                          char keyChar = keyEvent.getKeyChar();
                          if (Character.isLetter(keyChar) || Character.isDigit(keyChar)) {
                            // System.out.println("Will handle key press "
                            // + keyChar);
                            KeyTipManager.defaultManager().handleKeyPress(keyChar);
                          }
                          if ((keyEvent.getKeyCode() == KeyEvent.VK_ALT)
                              || (keyEvent.getKeyCode() == KeyEvent.VK_F10)) {
                            if (keyEvent.getModifiers() != 0 || keyEvent.getModifiersEx() != 0)
                              break;
                            boolean hadPopups =
                                !PopupPanelManager.defaultManager().getShownPath().isEmpty();
                            PopupPanelManager.defaultManager().hidePopups(null);
                            if (hadPopups || KeyTipManager.defaultManager().isShowingKeyTips()) {
                              KeyTipManager.defaultManager().hideAllKeyTips();
                            } else {
                              KeyTipManager.defaultManager().showRootKeyTipChain(JRibbonFrame.this);
                            }
                          }
                          if (keyEvent.getKeyCode() == KeyEvent.VK_ESCAPE) {
                            // System.out.println("In KTM");
                            KeyTipManager.defaultManager().showPreviousChain();
                          }
                          break;
                      }
                    }
                    if (event instanceof MouseEvent) {
                      MouseEvent mouseEvent = (MouseEvent) event;
                      switch (mouseEvent.getID()) {
                        case MouseEvent.MOUSE_CLICKED:
                        case MouseEvent.MOUSE_DRAGGED:
                        case MouseEvent.MOUSE_PRESSED:
                        case MouseEvent.MOUSE_RELEASED:
                          KeyTipManager.defaultManager().hideAllKeyTips();
                      }
                    }
                  }
                }
              }
            },
            AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);

    final KeyTipLayer keyTipLayer = new KeyTipLayer();
    JRootPane rootPane = this.getRootPane();
    JLayeredPane layeredPane = rootPane.getLayeredPane();
    final LayoutManager currLM = rootPane.getLayout();
    rootPane.setLayout(
        new LayoutManager() {
          @Override
          public void addLayoutComponent(String name, Component comp) {
            currLM.addLayoutComponent(name, comp);
          }

          @Override
          public void layoutContainer(Container parent) {
            currLM.layoutContainer(parent);
            JRibbonFrame ribbonFrame = JRibbonFrame.this;
            if (ribbonFrame.getRootPane().getWindowDecorationStyle() != JRootPane.NONE)
              keyTipLayer.setBounds(ribbonFrame.getRootPane().getBounds());
            else keyTipLayer.setBounds(ribbonFrame.getRootPane().getContentPane().getBounds());
          }

          @Override
          public Dimension minimumLayoutSize(Container parent) {
            return currLM.minimumLayoutSize(parent);
          }

          @Override
          public Dimension preferredLayoutSize(Container parent) {
            return currLM.preferredLayoutSize(parent);
          }

          @Override
          public void removeLayoutComponent(Component comp) {
            currLM.removeLayoutComponent(comp);
          }
        });
    // layeredPane.setLayout(new OverlayLayout(layeredPane));
    layeredPane.add(keyTipLayer, (Integer) (JLayeredPane.DEFAULT_LAYER + 60));

    this.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowDeactivated(WindowEvent e) {
            // hide all key tips on window deactivation
            KeyTipManager keyTipManager = KeyTipManager.defaultManager();
            if (keyTipManager.isShowingKeyTips()) {
              keyTipManager.hideAllKeyTips();
            }
          }
        });

    KeyTipManager.defaultManager()
        .addKeyTipListener(
            new KeyTipManager.KeyTipListener() {
              @Override
              public void keyTipsHidden(KeyTipEvent event) {
                if (event.getSource() == JRibbonFrame.this) keyTipLayer.setVisible(false);
              }

              @Override
              public void keyTipsShown(KeyTipEvent event) {
                if (event.getSource() == JRibbonFrame.this) keyTipLayer.setVisible(true);
              }
            });

    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);

    super.setIconImages(Arrays.asList(FlamingoUtilities.getBlankImage(16, 16)));
  }
Example #8
0
  /**
   * Constructs a simple frame with the specified world and orientation.
   *
   * @param world the world view.
   * @param ao the axes orientation.
   */
  public RSFFrame(World world, AxesOrientation ao) {
    super(new PlotPanel());
    if (world == null) world = new World();
    if (ao == null) ao = AxesOrientation.XRIGHT_YOUT_ZDOWN;
    _world = world;
    _view = new OrbitView(_world);
    _view.setAxesOrientation(ao);
    _canvas = new ViewCanvas();
    _canvas.setView(_view);
    _canvas.setBackground(Color.WHITE);

    _points = new ArrayList<PointGroup>();
    _lines = new ArrayList<LineGroup>();

    _d = null;
    _tpx = null;
    _tpy = null;
    _ipg = null;

    _etc = null;
    _coord = null;

    ModeManager mm = new ModeManager();
    mm.add(_canvas);
    OrbitViewMode ovm = new OrbitViewMode(mm);
    SelectDragMode sdm = new SelectDragMode(mm);

    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);

    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('F');
    Action exitAction =
        new AbstractAction("Exit") {
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        };

    Action cubeAction =
        new AbstractAction("Add Cube") {
          public void actionPerformed(ActionEvent event) {
            String filename = chooseFile(".");
            if (filename != null) addRSFCube(filename);
          }
        };

    Action lineAction =
        new AbstractAction("Add Line") {
          public void actionPerformed(ActionEvent event) {
            String filename = chooseFile(".");
            if (filename != null) addRSFLine(filename);
          }
        };

    Action pointAction =
        new AbstractAction("Add Points") {
          public void actionPerformed(ActionEvent event) {
            String filename = chooseFile(".");
            if (filename != null) addRSFPoint(filename);
          }
        };

    Action loadViewAction =
        new AbstractAction("Load Viewpoint") {
          public void actionPerformed(ActionEvent event) {
            String filename = chooseFile(".");
            if (filename != null) loadView(filename);
          }
        };

    Action saveViewAction =
        new AbstractAction("Save Viewpoint") {
          public void actionPerformed(ActionEvent event) {
            JFileChooser chooser = new JFileChooser(new File("."));
            int returnVal = chooser.showSaveDialog(new JFrame());
            String filename = null;
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              filename = chooser.getSelectedFile().getPath();
              saveView(filename);
            }
          }
        };

    Action saveFrameAction =
        new AbstractAction("Save to PNG") {
          public void actionPerformed(ActionEvent event) {
            JFileChooser chooser = new JFileChooser(new File("."));
            int returnVal = chooser.showSaveDialog(new JFrame());
            String filename = null;
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              filename = chooser.getSelectedFile().getPath();
              saveFrametoPNG(filename);
            }
          }
        };

    JMenuItem cubeItem = fileMenu.add(cubeAction);
    cubeItem.setMnemonic('C');

    JMenuItem lineItem = fileMenu.add(lineAction);
    lineItem.setMnemonic('L');

    JMenuItem pointItem = fileMenu.add(pointAction);
    pointItem.setMnemonic('P');

    JMenuItem saveViewItem = fileMenu.add(saveViewAction);
    saveViewItem.setMnemonic('V');

    JMenuItem loadViewItem = fileMenu.add(loadViewAction);
    loadViewItem.setMnemonic('I');

    JMenuItem saveFrameItem = fileMenu.add(saveFrameAction);
    saveFrameItem.setMnemonic('S');

    JMenuItem exitItem = fileMenu.add(exitAction);
    exitItem.setMnemonic('X');

    JMenu colorMenu = new JMenu("Color");

    Action jetAction =
        new AbstractAction("Jet") {
          public void actionPerformed(ActionEvent event) {
            _color = ColorList.JET;
            setColorMap();
          }
        };

    Action prismAction =
        new AbstractAction("Prism") {
          public void actionPerformed(ActionEvent event) {
            _color = ColorList.PRISM;
            setColorMap();
          }
        };

    Action grayAction =
        new AbstractAction("Gray") {
          public void actionPerformed(ActionEvent event) {
            _color = ColorList.GRAY;
            setColorMap();
          }
        };

    Action rwbAction =
        new AbstractAction("Red-White-Blue") {
          public void actionPerformed(ActionEvent event) {
            _color = ColorList.RWB;
            setColorMap();
          }
        };

    colorMenu.add(jetAction);
    colorMenu.add(prismAction);
    colorMenu.add(grayAction);
    colorMenu.add(rwbAction);

    JMenu clipMenu = new JMenu("% Clip");
    Action clipUp =
        new AbstractAction("Set max pclip") {
          public void actionPerformed(ActionEvent event) {
            String value =
                JOptionPane.showInputDialog(new JFrame(), "Percentile Clip Max (0-100.0):", _pmax);
            try {
              _pmax = Float.parseFloat(value);
              if (_pmax > 100.0f) _pmax = 100.0f;
              if (_pmax < _pmin) _pmax = _pmin + 1.0f;
              System.out.printf("pclip: (%f,%f) \n", _pmin, _pmax);
              _ipg.setPercentiles(_pmin, _pmax);

            } catch (Exception e) {
              System.out.println(e);
            }
          }
        };
    Action clipDown =
        new AbstractAction("Set min pclip") {
          public void actionPerformed(ActionEvent event) {
            String value =
                JOptionPane.showInputDialog(
                    new JFrame(), String.format("Percentile Clip Min (0-%f):", _pmax), _pmin);
            try {
              _pmin = Float.parseFloat(value);
              if (_pmin < 0.0f) _pmin = 0.0f;
              if (_pmin > _pmax) _pmin = _pmax - 1.0f;
              System.out.printf("pclip: (%f,%f) \n", _pmin, _pmax);
              _ipg.setPercentiles(_pmin, _pmax);

            } catch (Exception e) {
              System.out.println(e);
            }
          }
        };

    clipMenu.add(clipUp);
    clipMenu.add(clipDown);

    JMenu modeMenu = new JMenu("Mode");
    modeMenu.setMnemonic('M');
    JMenuItem ovmItem = new JMenuItem(ovm);
    modeMenu.add(ovmItem);
    JMenuItem sdmItem = new JMenuItem(sdm);
    modeMenu.add(sdmItem);

    JMenu tensorMenu = new JMenu("Tensor");

    Action tenLoadAction =
        new AbstractAction("Load Tensors") {
          public void actionPerformed(ActionEvent event) {
            String filename = chooseFile(".");
            if (filename != null) loadTensors(filename);
          }
        };

    Action tenCoordLoadAction =
        new AbstractAction("Load Tensor Coordinates") {
          public void actionPerformed(ActionEvent event) {
            String filename = chooseFile(".");
            if (filename != null) loadTensorCoords(filename);
          }
        };

    Action showTenAction =
        new AbstractAction("Show Tensors at Coordinates") {
          public void actionPerformed(ActionEvent event) {

            String filename;
            int sel;

            if (_ipg == null) {
              sel =
                  JOptionPane.showConfirmDialog(
                      null,
                      "An RSF Cube (Image) needs to be loaded. " + " Would you like to load one?",
                      "Notice",
                      JOptionPane.OK_CANCEL_OPTION,
                      JOptionPane.QUESTION_MESSAGE);
              if (sel == JOptionPane.OK_OPTION) {
                filename = chooseFile(".");
                if (filename != null) addRSFCube(filename);
              } else {
                JOptionPane.showConfirmDialog(
                    null,
                    "Cannot load tensors because an RFC cube was not loaded.",
                    "Error",
                    JOptionPane.DEFAULT_OPTION,
                    JOptionPane.ERROR_MESSAGE);
                return;
              }
            }
            if (_coord == null) {
              sel =
                  JOptionPane.showConfirmDialog(
                      null,
                      "The tensors coordinates need to be loaded. "
                          + " Would you like to load them?",
                      "Notice",
                      JOptionPane.OK_CANCEL_OPTION,
                      JOptionPane.QUESTION_MESSAGE);
              if (sel == JOptionPane.OK_OPTION) {
                filename = chooseFile(".");
                if (filename != null) loadCoord(filename);
              } else {
                JOptionPane.showConfirmDialog(
                    null,
                    "Error loading coordinates.",
                    "Error",
                    JOptionPane.DEFAULT_OPTION,
                    JOptionPane.ERROR_MESSAGE);
                return;
              }
            }
            if (_etc == null) {
              sel =
                  JOptionPane.showConfirmDialog(
                      null,
                      "The tensors at coordinates need to be loaded. "
                          + " Would you like to load them?",
                      "Notice",
                      JOptionPane.OK_CANCEL_OPTION,
                      JOptionPane.QUESTION_MESSAGE);
              if (sel == JOptionPane.OK_OPTION) {
                filename = chooseFile(".");
                if (filename != null) loadTensorCoords(filename);
                return;
              } else {
                JOptionPane.showConfirmDialog(
                    null,
                    "Cannot show tensors because the tensors at coordinates" + " were not loaded.",
                    "Error",
                    JOptionPane.DEFAULT_OPTION,
                    JOptionPane.ERROR_MESSAGE);
                return;
              }
            }
            /*
            if(_d == null) {
            	sel = JOptionPane.showConfirmDialog(null,
            						"The tensors need to be loaded. "
            						+ " Would you like to load them?",
            						"Notice",
            						JOptionPane.OK_CANCEL_OPTION,
            						JOptionPane.QUESTION_MESSAGE);
            	if(sel == JOptionPane.OK_OPTION) {
            		filename = chooseFile(".");
            		if (filename != null) loadTensors(filename);
            	} else {
            		JOptionPane.showConfirmDialog(null,
            				"Cannot show tensors because the tensors were not loaded.",
            				"Error",
            				JOptionPane.DEFAULT_OPTION,
            				JOptionPane.ERROR_MESSAGE);
            		return;
            	}
            }
            if(_etg == null) {
            	sel = JOptionPane.showConfirmDialog(null,
            						"The tensor coordinates need to be loaded. "
            						+ " Would you like to load them?",
            						"Notice",
            						JOptionPane.OK_CANCEL_OPTION,
            						JOptionPane.QUESTION_MESSAGE);
            	if(sel == JOptionPane.OK_OPTION) {
            		filename = chooseFile(".");
            		if (filename != null) loadTensorCoords(filename);
            		return;
            	} else {
            		JOptionPane.showConfirmDialog(null,
            				"Cannot show tensors because the tensor coordinates"
            				+ " were not loaded.",
            				"Error",
            				JOptionPane.DEFAULT_OPTION,
            				JOptionPane.ERROR_MESSAGE);
            		return;
            	}
            }
            */
            _world.addChild(_etg);
          }
        };

    Action hideTenAction =
        new AbstractAction("Hide Tensors at Coordinates") {
          public void actionPerformed(ActionEvent event) {
            if (_etg != null) _world.removeChild(_etg);
          }
        };

    Action showTenPanAction =
        new AbstractAction("Show Tensor Panels") {
          public void actionPerformed(ActionEvent event) {

            String filename;
            int sel;
            if (_ipg == null) {
              sel =
                  JOptionPane.showConfirmDialog(
                      null,
                      "An RSF Cube (Image) needs to be loaded. " + " Would you like to load one?",
                      "Notice",
                      JOptionPane.OK_CANCEL_OPTION,
                      JOptionPane.QUESTION_MESSAGE);
              if (sel == JOptionPane.OK_OPTION) {
                filename = chooseFile(".");
                if (filename != null) addRSFCube(filename);
              } else {
                JOptionPane.showConfirmDialog(
                    null,
                    "Cannot load tensors because an RFC cube was not loaded.",
                    "Error",
                    JOptionPane.DEFAULT_OPTION,
                    JOptionPane.ERROR_MESSAGE);
                return;
              }
            }

            if (_d == null) {
              sel =
                  JOptionPane.showConfirmDialog(
                      null,
                      "The tensors need to be loaded. " + " Would you like to load them?",
                      "Notice",
                      JOptionPane.OK_CANCEL_OPTION,
                      JOptionPane.QUESTION_MESSAGE);
              if (sel == JOptionPane.OK_OPTION) {
                filename = chooseFile(".");
                if (filename != null) loadTensors(filename);
                addRSFTensorEllipsoids();
              } else {
                JOptionPane.showConfirmDialog(
                    null,
                    "Cannot show tensors because the tensors were not loaded.",
                    "Error",
                    JOptionPane.DEFAULT_OPTION,
                    JOptionPane.ERROR_MESSAGE);
                return;
              }
            } else if (_tpx == null || _tpy == null) {
              addRSFTensorEllipsoids();
            } else {
              ImagePanel ipx = _ipg.getImagePanel(Axis.X);
              ImagePanel ipy = _ipg.getImagePanel(Axis.Y);
              ipx.getFrame().addChild(_tpx);
              ipy.getFrame().addChild(_tpy);
            }
          }
        };

    Action hideTenPanAction =
        new AbstractAction("Hide Tensor Panels") {
          public void actionPerformed(ActionEvent event) {
            if (_tpx != null) {
              ImagePanel ipx = _ipg.getImagePanel(Axis.X);
              ipx.getFrame().removeChild(_tpx);
            }
            if (_tpy != null) {
              ImagePanel ipy = _ipg.getImagePanel(Axis.Y);
              ipy.getFrame().removeChild(_tpy);
            }
          }
        };

    JMenuItem tensorItem0 = tensorMenu.add(tenLoadAction);
    tensorItem0.setMnemonic('L');

    JMenuItem tensorItem2 = tensorMenu.add(tenCoordLoadAction);
    tensorItem2.setMnemonic('C');

    JMenuItem tensorItem1 = tensorMenu.add(showTenPanAction);
    tensorItem1.setMnemonic('T');

    JMenuItem tensorItem5 = tensorMenu.add(hideTenPanAction);
    tensorItem5.setMnemonic('R');

    JMenuItem tensorItem4 = tensorMenu.add(showTenAction);
    tensorItem4.setMnemonic('S');

    JMenuItem tensorItem3 = tensorMenu.add(hideTenAction);
    tensorItem3.setMnemonic('H');

    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    menuBar.add(modeMenu);
    menuBar.add(tensorMenu);
    menuBar.add(colorMenu);
    menuBar.add(clipMenu);

    JToolBar toolBar = new JToolBar(SwingConstants.VERTICAL);
    toolBar.setRollover(true);
    JToggleButton ovmButton = new ModeToggleButton(ovm);
    toolBar.add(ovmButton);
    JToggleButton sdmButton = new ModeToggleButton(sdm);
    toolBar.add(sdmButton);

    _cb = new ColorBar();
    _cb.setWidthMinimum(45);
    _cb.setFont(_cb.getFont().deriveFont(18.f));
    // _ipg.addColorMapListener(_cb);

    ovm.setActive(true);

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setSize(new Dimension(SIZE, SIZE));
    this.add(_canvas, BorderLayout.CENTER);
    this.add(toolBar, BorderLayout.WEST);
    this.add(_cb, BorderLayout.EAST);
    this.setJMenuBar(menuBar);
    this.setVisible(true);
  }
Example #9
0
  /** @param type True for an online tree */
  public RosterTree(Backend backend, Jeti main, boolean onlineTree, TreeModel model) {
    super(model);
    this.onlineTree = onlineTree;
    this.backend = backend;
    this.main = main;

    ToolTipManager.sharedInstance().registerComponent(this);

    setRootVisible(false);
    setToggleClickCount(0); // set expanding on mouseclicks of because
    // detection needed for single or double click

    javax.swing.plaf.basic.BasicTreeUI basicTreeUI = (javax.swing.plaf.basic.BasicTreeUI) getUI();
    basicTreeUI.setRightChildIndent(1);
    basicTreeUI.setLeftChildIndent(1);
    basicTreeUI.setExpandedIcon(null);
    basicTreeUI.setCollapsedIcon(null);
    putClientProperty("JTree.lineStyle", "None");

    createPopupMenu();
    createGroupPopupMenu();
    if (System.getProperty("os.name").startsWith("Mac")) {
      setCellRenderer(new MacRenderer());
      if (onlineTree) {
        treeExpander = new TreeExpander(this, model);
      }
    } else setCellRenderer(new MyRenderer());

    addMouseListener(
        new MouseAdapter() {
          TreePath lastTreePath; // save tree path for single click event
          // timer needed to check if double or single mouseclick
          Timer timer =
              new Timer(
                  300,
                  new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                      if (isExpanded(lastTreePath)) collapsePath(lastTreePath);
                      else expandPath(lastTreePath);
                      timer.stop();
                    }
                  });

          public void mousePressed(MouseEvent e) {
            TreePath selPath = getPathForLocation(e.getX(), e.getY());
            if (selPath != null) {
              setSelectionPath(selPath);
              Object o = selPath.getLastPathComponent();
              if (o instanceof JIDStatusGroup) { // group
                maybeShowGroupPopup(e, (JIDStatusGroup) o);
                if (SwingUtilities.isLeftMouseButton(e)) {
                  if (isExpanded(selPath)) collapsePath(selPath);
                  else expandPath(selPath);
                }
              } else {
                JIDStatusGroup group = null;
                if (o instanceof PrimaryJIDStatus)
                  group = ((JIDStatusGroup) selPath.getPathComponent(selPath.getPathCount() - 2));
                else if (o instanceof JIDStatus)
                  group = ((JIDStatusGroup) selPath.getPathComponent(selPath.getPathCount() - 3));
                else return;
                maybeShowPopup(e, (JIDStatus) o, group); // cde
                if (SwingUtilities.isLeftMouseButton(e)) {
                  lastTreePath = selPath;
                  // check if double or single mouseclick, needed
                  // because double click= 2 single clicks
                  if (timer.isRunning()) {
                    timer.stop();
                    sendChat((JIDStatus) o);
                  } else {
                    timer.restart();
                  }
                }
              }
            }
          }

          public void mouseReleased(MouseEvent e) {
            TreePath selPath = getPathForLocation(e.getX(), e.getY());
            if (selPath != null) {
              Object o = selPath.getLastPathComponent();
              if (o instanceof JIDStatusGroup) { // group
                maybeShowGroupPopup(e, (JIDStatusGroup) o);
              }
              if (o instanceof PrimaryJIDStatus) {
                JIDStatusGroup group =
                    ((JIDStatusGroup) selPath.getPathComponent(selPath.getPathCount() - 2));
                maybeShowPopup(e, (PrimaryJIDStatus) o, group);
              } else if (o instanceof JIDStatus) {
                JIDStatusGroup group =
                    ((JIDStatusGroup) selPath.getPathComponent(selPath.getPathCount() - 3));
                maybeShowPopup(e, (JIDStatus) o, group);
              }
            }
          }

          public void mouseExited(MouseEvent e) {
            // if (popupPanel !=null) popupPanel.dispose();
            // timer.stop();
            clearSelection(); // weg als multi select?
          }
        });

    addMouseMotionListener(
        new MouseMotionAdapter() {
          public void mouseMoved(MouseEvent e) {
            // if (popupPanel !=null) popupPanel.dispose();
            // timer.stop();
            TreePath selPath = getPathForLocation(e.getX(), e.getY());
            if (selPath != null) {
              Object o = selPath.getLastPathComponent();
              if (o instanceof PrimaryJIDStatus || o instanceof JIDStatus)
                setSelectionPath(selPath);
              /*
               * if(o instanceof JIDStatus2) { //
               * timer.init(e.getPoint(),(JIDStatus)o);
               * setSelectionPath(selPath); }
               */
            }
          }
        });
    // setOpaque(false);
  }