private static JTree createTree() {
   JTree resultsTree = new JTree();
   resultsTree.setName("TREEVIEW");
   resultsTree.setRootVisible(false);
   resultsTree.setEditable(false);
   resultsTree.setShowsRootHandles(true);
   resultsTree.setCellRenderer(new FailureCellRenderer());
   ToolTipManager tipManager = ToolTipManager.sharedInstance();
   tipManager.registerComponent(resultsTree);
   resultsTree.addKeyListener(new EnterPressListener());
   return resultsTree;
 }
  public BulkDownloadPanel(WorldWindow wwd) {
    this.wwd = wwd;

    // Init retievable list
    this.retrievables = new ArrayList<BulkRetrievablePanel>();
    // Layers
    for (Layer layer : this.wwd.getModel().getLayers()) {
      if (layer instanceof BulkRetrievable)
        this.retrievables.add(new BulkRetrievablePanel((BulkRetrievable) layer));
    }
    // Elevation models
    CompoundElevationModel cem =
        (CompoundElevationModel) wwd.getModel().getGlobe().getElevationModel();
    for (ElevationModel elevationModel : cem.getElevationModels()) {
      if (elevationModel instanceof BulkRetrievable)
        this.retrievables.add(new BulkRetrievablePanel((BulkRetrievable) elevationModel));
    }

    // Init sector selector
    this.selector = new SectorSelector(wwd);
    this.selector.setInteriorColor(new Color(1f, 1f, 1f, 0.1f));
    this.selector.setBorderColor(new Color(1f, 0f, 0f, 0.5f));
    this.selector.setBorderWidth(3);
    this.selector.addPropertyChangeListener(
        SectorSelector.SECTOR_PROPERTY,
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            updateSector();
          }
        });

    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
    this.initComponents();
  }
  /**
   * 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 MagicGlassPane() {
   super(null);
   setOpaque(false);
   enableEvents(AWTEvent.MOUSE_EVENT_MASK);
   enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
   enableEvents(AWTEvent.MOUSE_WHEEL_EVENT_MASK);
   ToolTipManager.sharedInstance().registerComponent(this);
 }
 @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;
     }
   }
 }
  /** 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);
  }
Пример #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)));
  }
Пример #8
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);
  }