Пример #1
0
  private void handlePopup(final MouseEvent e) {
    if (e.getClickCount() != 1 || !e.isPopupTrigger()) return;

    if (e.getX() < 0
        || e.getX() >= e.getComponent().getWidth()
        || e.getY() < 0
        || e.getY() >= e.getComponent().getHeight()) return;

    String place = myTabs.getPopupPlace();
    place = place != null ? place : ActionPlaces.UNKNOWN;
    myTabs.myPopupInfo = myInfo;

    final DefaultActionGroup toShow = new DefaultActionGroup();
    if (myTabs.getPopupGroup() != null) {
      toShow.addAll(myTabs.getPopupGroup());
      toShow.addSeparator();
    }

    JBTabsImpl tabs =
        JBTabsImpl.NAVIGATION_ACTIONS_KEY.getData(
            DataManager.getInstance().getDataContext(e.getComponent(), e.getX(), e.getY()));
    if (tabs == myTabs && myTabs.myAddNavigationGroup) {
      toShow.addAll(myTabs.myNavigationActions);
    }

    if (toShow.getChildrenCount() == 0) return;

    myTabs.myActivePopup =
        myTabs.myActionManager.createActionPopupMenu(place, toShow).getComponent();
    myTabs.myActivePopup.addPopupMenuListener(myTabs.myPopupListener);

    myTabs.myActivePopup.addPopupMenuListener(myTabs);
    myTabs.myActivePopup.show(e.getComponent(), e.getX(), e.getY());
  }
  @Override
  public void mouseMoved(MouseEvent e) {
    final MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, getParent());
    final boolean insideRec = getBounds().contains(event.getPoint());
    boolean buttonsNotPressed =
        (e.getModifiersEx()
                & (InputEvent.BUTTON1_DOWN_MASK
                    | InputEvent.BUTTON2_DOWN_MASK
                    | InputEvent.BUTTON3_DOWN_MASK))
            == 0;
    if (!myPopupIsShowing && insideRec && buttonsNotPressed) {
      showPopup(null, false);
    } else if (myPopupIsShowing && !insideRec) {
      final Component over =
          SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY());
      JPopupMenu popup = myUnderPopup.isShowing() ? myUnderPopup : myAbovePopup;
      if (over != null && popup.isShowing()) {
        final Rectangle rec = new Rectangle(popup.getLocationOnScreen(), popup.getSize());
        int delta = 15;
        rec.x -= delta;
        rec.width += delta * 2;
        rec.y -= delta;
        rec.height += delta * 2;

        final Point eventPoint = e.getPoint();
        SwingUtilities.convertPointToScreen(eventPoint, e.getComponent());

        if (rec.contains(eventPoint)) {
          return;
        }
      }

      closePopup();
    }
  }
Пример #3
0
 public void mouseExited(MouseEvent event) {
   if (event.getComponent() instanceof ConectorUI) {
     ConectorUI con = (ConectorUI) event.getComponent();
     con.setMouseOver(false);
     con.repaint();
   }
 }
    public boolean isEnabled(@NotNull final Project project, final AnActionEvent event) {
      if (!myHandler.isEnabled(project)) return false;

      Editor editor = event.getData(PlatformDataKeys.EDITOR);
      if (editor == null) return false;

      InputEvent inputEvent = event.getInputEvent();
      if (inputEvent instanceof MouseEvent && inputEvent.isAltDown()) {
        MouseEvent mouseEvent = (MouseEvent) inputEvent;
        Component component =
            SwingUtilities.getDeepestComponentAt(
                mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
        if (SwingUtilities.isDescendingFrom(component, editor.getComponent())) {
          MouseEvent convertedEvent =
              SwingUtilities.convertMouseEvent(mouseEvent.getComponent(), mouseEvent, component);
          EditorMouseEventArea area = editor.getMouseEventArea(convertedEvent);
          if (area != EditorMouseEventArea.EDITING_AREA) {
            return false;
          }
        }
      } else {
        if (StringUtil.isEmptyOrSpaces(editor.getSelectionModel().getSelectedText())) {
          return false;
        }
      }

      return true;
    }
 private void maybeShowPopup(MouseEvent e) {
   if (e.isPopupTrigger()) {
     selectTable(e.getComponent(), e.getPoint());
     make();
     show(e.getComponent(), e.getX(), e.getY());
   }
 }
Пример #6
0
    public void mousePressed(MouseEvent e) {
      dragType = 0;
      Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), getContentPane());
      /*if (p.y < 10){
        dragType |= DRAG_TOP;
      }
      if (p.x < 5){
        dragType |= DRAG_LEFT;
      }
      if (p.x > getWidth() - 5){
        dragType |= DRAG_RIGHT;
      }
      if (p.y > getHeight() - 5){
        dragType |= DRAG_BOTTOM;
      }*/
      if (p.y < title.getY() + title.getHeight()) {
        dragType |= DRAG_TOP;
      }
      if (p.x < left.getX() + left.getWidth()) {
        dragType |= DRAG_LEFT;
      }
      if (p.x >= right.getX()) { // getWidth() - 5){
        dragType |= DRAG_RIGHT;
      }
      if (p.y >= bottom.getY()) {
        dragType |= DRAG_BOTTOM;
      }

      lastPoint = e.getPoint();
      SwingUtilities.convertPointToScreen(lastPoint, e.getComponent());
    }
Пример #7
0
 private void maybeShowPopup(MouseEvent e) {
   if (e.isPopupTrigger()) {
     lastMenuComponent = (JComponent) e.getComponent();
     lastMenuX = e.getX();
     lastMenuY = e.getY();
     popup.show(e.getComponent(), e.getX(), e.getY());
   }
 }
Пример #8
0
 /**
  * Invoked when a mouse button has been pressed on a component.
  *
  * @param e MouseEvent object pertaining to the component on which mouse button was pressed
  */
 @Override
 public void mousePressed(MouseEvent e) {
   pressed = true;
   getButton(e.getComponent(), false).setVisible(false);
   ((JLabel) e.getComponent()).setIcon(new ImageIcon(invisibleImage));
   getButton(e.getComponent(), true).setVisible(true);
   tempComp = e.getComponent(); // component user has pressed on
   tempEntered = true; // mouse is in component area
 }
Пример #9
0
 /**
  * Invoked when the mouse enters a component.
  *
  * @param e MouseEvent object pertaining to the component on which mouse entered
  */
 @Override
 public void mouseEntered(MouseEvent e) {
   if (!pressed) {
     getButton(e.getComponent(), false).setVisible(true);
     ((JLabel) e.getComponent()).setIcon(new ImageIcon(invisibleImage));
   }
   if (e.getComponent().equals(tempComp)) // mouse has entered pressed component's area
   tempEntered = true;
 }
Пример #10
0
  /**
   * ********************************************************************************* REQUIRED
   * METHODS FOR INTERFACES
   * ********************************************************************************
   */
  public void mouseClicked(MouseEvent e) {
    if (e.isConsumed()) {
      return;
    }
    TreePath path = ((JTree) e.getSource()).getClosestPathForLocation(e.getX(), e.getY());

    ((TreeView) WorkspaceController.getCurrentModeExtension().getView()).addSelectionPath(path);
    if (path != null) {
      AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
      // encode buttons
      int eventType = 0;
      if (e.getButton() == MouseEvent.BUTTON1) {
        eventType += WorkspaceActionEvent.MOUSE_LEFT;
      }
      if (e.getButton() == MouseEvent.BUTTON3) {
        eventType += WorkspaceActionEvent.MOUSE_RIGHT;
      }
      if (e.getClickCount() % 2 == 0) {
        eventType += WorkspaceActionEvent.MOUSE_DBLCLICK;
      } else {
        eventType += WorkspaceActionEvent.MOUSE_CLICK;
      }

      if (e.isPopupTrigger()) {
        eventType += WorkspaceActionEvent.POPUP_TRIGGER;
      }

      WorkspaceActionEvent event =
          new WorkspaceActionEvent(node, eventType, e.getX(), e.getY(), e.getComponent());

      List<IWorkspaceNodeActionListener> nodeEventListeners =
          WorkspaceController.getCurrentModeExtension()
              .getIOController()
              .getNodeActionListeners(node.getClass(), eventType);
      if (nodeEventListeners != null) {
        for (IWorkspaceNodeActionListener listener : nodeEventListeners) {
          if (event.isConsumed()) {
            break;
          }
          listener.handleAction(event);
        }
      }

      if (!event.isConsumed() && node instanceof IWorkspaceNodeActionListener) {
        ((IWorkspaceNodeActionListener) node).handleAction(event);
      }

    } else {
      if (e.getButton() == MouseEvent.BUTTON3) {
        // WorkspaceController.getController().getPopups().showWorkspacePopup(e.getComponent(),
        // e.getX(), e.getY());
        ((AWorkspaceTreeNode) WorkspaceController.getCurrentModel().getRoot())
            .showPopup(e.getComponent(), e.getX(), e.getY());
      }
    }
  }
Пример #11
0
  /**
   * Show popup menu in response to a mouse event.
   * 
   * @param e Event.
   */
  @Override
  protected void showPopup(MouseEvent e) {

    // Retrieve information
    if (!(e.getComponent() instanceof MWPane)) {
      return;
    }
    MWPane textPane = (MWPane) e.getComponent();
    showPopup(textPane, textPane.viewToModel(e.getPoint()), e.getX(), e.getY());
  }
    private JPopupItemI getItem(MouseEvent e) {
      JPopupItemI item = null;
      if (e.getSource() instanceof JPopupItemI) {
        item = (JPopupItemI) e.getSource();
      } else if (e.getComponent().getParent() instanceof JPopupItemI) {
        item = (JPopupItemI) e.getComponent().getParent();
      }

      return item;
    }
Пример #13
0
 private MouseEvent transformMouseEvent(MouseEvent e) {
   if (this == e.getComponent()) {
     return e;
   } else {
     Point lp = getLocationInQueryTextArea(e.getComponent());
     e.setSource(this);
     e.translatePoint(lp.x, lp.y);
     return e;
   }
 }
Пример #14
0
 private void showCorrectPopup(Edge edge, MouseEvent arg0) {
   if (edge != null) {
     targetEdge = edge;
     edgeMenu.show(arg0.getComponent(), arg0.getX(), arg0.getY());
   } else {
     mouseX = arg0.getX();
     mouseY = arg0.getY();
     popupMenu.show(arg0.getComponent(), arg0.getX(), arg0.getY());
   }
 }
Пример #15
0
    @Override
    public void mousePressed(MouseEvent e) {
      draggedComponent = e.getComponent();
      lastLocation =
          SwingUtilities.convertPoint(draggedComponent, e.getPoint(), draggedComponent.getParent());

      draggedComponent1 = e.getComponent();
      lastLocation1 =
          SwingUtilities.convertPoint(
              draggedComponent1, e.getPoint(), draggedComponent1.getParent());
    }
Пример #16
0
 private void doPopUp(MouseEvent e) {
   if (e.isPopupTrigger()) {
     this.button = (ColorIndexSupplier) e.getComponent();
     int colorIndex = button.getColorCell();
     for (int i = 0; i < groups.length; i++) {
       JMenuItem m = (JMenuItem) getSubElements()[Palette.split(colorIndex, i) + 64 * i];
       m.setSelected(true);
     }
     show(e.getComponent(), e.getX(), e.getY());
   }
 }
Пример #17
0
  protected void internalDoubleClick(MouseEvent e) {
    if (!(e.getComponent() instanceof JComponent)) return;
    JComponent inComponent = (JComponent) e.getComponent();

    if (inComponent instanceof JTable) {
      JTable thisTable = (JTable) inComponent;
      int rowPoint = thisTable.rowAtPoint(new Point(e.getX(), e.getY()));
      Searcher whichSearch = (Searcher) thisTable.getValueAt(rowPoint, -1);

      whichSearch.execute();
    }
  }
Пример #18
0
    public void mouseMoved(MouseEvent e) {
      Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), getContentPane());

      int dragType = 0;

      if (p.y < title.getY() + title.getHeight()) {
        dragType |= DRAG_TOP;
      }
      if (p.x < left.getX() + left.getWidth()) {
        dragType |= DRAG_LEFT;
      }
      if (p.x >= right.getX()) { // getWidth() - 5){
        dragType |= DRAG_RIGHT;
      }
      if (p.y >= bottom.getY()) {
        dragType |= DRAG_BOTTOM;
      }
      Cursor c = null;
      switch (dragType) {
        case 0:
          c = Cursor.getDefaultCursor();
          break;
        case DRAG_TOP:
          c = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
          break;
        case DRAG_TOP | DRAG_LEFT:
          c = Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR);
          break;
        case DRAG_TOP | DRAG_RIGHT:
          c = Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR);
          break;
        case DRAG_RIGHT:
          c = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
          break;
        case DRAG_RIGHT | DRAG_BOTTOM:
          c = Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR);
          break;
        case DRAG_BOTTOM:
          c = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
          break;
        case DRAG_BOTTOM | DRAG_LEFT:
          c = Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR);
          break;
        case DRAG_LEFT:
          c = Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR);
          break;
      }
      if (!e.getComponent().getCursor().equals(c)) {
        e.getComponent().setCursor(c);
      }
    }
Пример #19
0
 /**
  * On left-click, record the state in the current path On right click, begin recording a new path
  *
  * @param eventDescription
  * @param e
  * @param button
  */
 public void eventOutput(String eventDescription, MouseEvent e, int button) {
   if (eventDescription.startsWith("Mouse clicked")) {
     // end of path
     if (button == 3) {
       reset();
     } else {
       // the button being pressed on the grid
       int x = e.getComponent().getX() / e.getComponent().getWidth() / 2;
       int y = e.getComponent().getY() / e.getComponent().getHeight();
       e.getComponent().setBackground(Color.red);
       path.add(new Point(x, y));
     }
   }
 }
Пример #20
0
 /**
  * Invoked when the mouse exits a component.
  *
  * @param e MouseEvent object pertaining to the component on which mouse exited
  */
 @Override
 public void mouseExited(MouseEvent e) {
   boolean notOnMain =
       introPanel.isVisible()
           || highScoresPanel.isVisible()
           || achievementsPanel.isVisible()
           || helpPanel.isVisible()
           || aboutPanel.isVisible();
   if (!pressed && !notOnMain) {
     ((JLabel) e.getComponent()).setIcon(new ImageIcon(getImage(e.getComponent())));
     getButton(e.getComponent(), false).setVisible(false);
   }
   tempEntered = false; // mouse has left component area
 }
Пример #21
0
 /**
  * Called when there is a mouse event. Updates the mini-calendar.
  *
  * @param e The mouse event generated.
  */
 public void mouseClicked(MouseEvent e) {
   if (e.getClickCount() == 2 && !e.getComponent().getName().trim().equals("")) {
     viewChanger.show(center, DAY);
     int s = Integer.parseInt(e.getComponent().getName());
     mview.updateSelectedDay(s);
     dayView.updateDay();
     highlightToday(s);
   }
   if (!e.getComponent().getName().trim().equals("")) {
     int s = Integer.parseInt(e.getComponent().getName());
     mview.updateSelectedDay(s);
     dayView.updateDay();
     highlightToday(s);
   }
 }
Пример #22
0
 /** Nayttaa halutun nakyman (tai lopettaa pelin), kun kyseista painiketta painetaan */
 @Override
 public void mousePressed(MouseEvent arg0) {
   if (arg0.getComponent().equals(this.aloitaPeliPainike)) {
     this.ikkuna.naytaPelivalikko();
   }
   if (arg0.getComponent().equals(this.lopetaPainike)) {
     System.exit(0);
   }
   if (arg0.getComponent().equals(this.tuloksetPainike)) {
     this.ikkuna.naytaTulosnakyma();
   }
   if (arg0.getComponent().equals(this.ohjeetPainike)) {
     this.ikkuna.naytaOhjenakyma();
   }
 }
Пример #23
0
  public void mousePressed(MouseEvent evt) {
    try {
      if (!neu && !wiedergeben && !verloren && !intro) {
        if (evt.getComponent() == rot) {
          if (farben[klick] != 1) verloren = true;
          else {
            klick++;
            rot.setIcon(new ImageIcon("files/Minigames/Senso/red_1.png"));
            soundAbspielen(soundR);
          }
        } else if (evt.getComponent() == gruen) {
          if (farben[klick] != 2) verloren = true;
          else {
            klick++;
            gruen.setIcon(new ImageIcon("files/Minigames/Senso/green_1.png"));
            soundAbspielen(soundG);
          }
        } else if (evt.getComponent() == blau) {
          if (farben[klick] != 3) verloren = true;
          else {
            klick++;
            blau.setIcon(new ImageIcon("files/Minigames/Senso/blue_1.png"));
            soundAbspielen(soundB);
          }
        } else if (evt.getComponent() == gelb) {
          if (farben[klick] != 4) verloren = true;
          else {
            klick++;
            gelb.setIcon(new ImageIcon("files/Minigames/Senso/yellow_1.png"));
            soundAbspielen(soundY);
          }
        }
        //				else if (evt.getComponent() == beenden)
        //				{
        //					this.setVisible(false);
        //					s.minispielEnde(null);
        //					if (spiel != null)
        //						spiel.interrupt();
        //					neustarten(false);
        //					spiel = new Thread(this);
        //					if (intro)
        //						spiel.start();
        //				}

      }
    } catch (Exception e) {
    }
  }
Пример #24
0
  /** Shows popup with forward history entries */
  private void showForwardHistory(MouseEvent e) {

    JPopupMenu forwardMenu = new JPopupMenu("Forward History");

    if (historyModel == null) {
      return;
    }

    Locale locale = ((JHelp) getControl()).getModel().getHelpSet().getLocale();
    Enumeration items = historyModel.getForwardHistory().elements();
    JMenuItem mi = null;
    int index = historyModel.getIndex() + 1;
    // while(items.hasMoreElements()){
    for (int i = 0; items.hasMoreElements(); i++) {
      HelpModelEvent item = (HelpModelEvent) items.nextElement();
      if (item != null) {
        String title = item.getHistoryName();
        if (title == null) {
          title = HelpUtilities.getString(locale, "history.unknownTitle");
        }
        mi = new JMenuItem(title);
        // mi.setToolTipText(item.getURL().getPath());
        mi.addActionListener(new HistoryActionListener(i + index));
        forwardMenu.add(mi);
      }
    }
    // if(e.isPopupTrigger())
    forwardMenu.show(e.getComponent(), e.getX(), e.getY());
  }
Пример #25
0
 private void mousePressedInIconsArea(MouseEvent e) {
   EditorMessageIconRenderer iconRenderer = getIconRendererUnderMouse(e);
   if (iconRenderer != null) {
     if (e.getButton() == MouseEvent.BUTTON3) {
       JPopupMenu popupMenu = iconRenderer.getPopupMenu();
       if (popupMenu != null && e.getID() == MouseEvent.MOUSE_PRESSED) {
         e.consume();
         Component component = e.getComponent();
         popupMenu.show(component == null ? myEditorComponent : component, e.getX(), e.getY());
       }
       return;
     }
     AnAction action = iconRenderer.getClickAction();
     if (e.getButton() == MouseEvent.BUTTON1 && action != null) {
       if (e.getID() == MouseEvent.MOUSE_CLICKED) {
         AnActionEvent actionEvent =
             new AnActionEvent(
                 e,
                 new LeftEditorHighlighterDataContext(myEditorComponent, iconRenderer.getNode()),
                 ICON_AREA,
                 action.getTemplatePresentation(),
                 ActionManager.getInstance(),
                 e.getModifiers());
         action.update(actionEvent);
         action.actionPerformed(actionEvent);
       }
       e.consume();
     }
   }
 }
Пример #26
0
  @Override
  protected void processMouseEvent(MouseEvent e) {
    switch (e.getID()) {
      case MouseEvent.MOUSE_PRESSED:
      case MouseEvent.MOUSE_RELEASED:
      case MouseEvent.MOUSE_CLICKED:
        if (isInFoldingArea(e)) {
          mousePressedInFoldingArea(e);
        } else if (isInTextArea(e)) {
          mousePressedInTextArea(e);
        } else {
          mousePressedInIconsArea(e);
        }
        if (!e.isConsumed()
            && e.getButton() == MouseEvent.BUTTON3
            && e.getID() == MouseEvent.MOUSE_PRESSED) {
          DefaultActionGroup actionGroup =
              ActionUtils.getDefaultGroup(MPSActions.EDITOR_LEFTPANEL_GROUP);
          if (actionGroup != null) {
            ActionPopupMenu popupMenu =
                ActionManager.getInstance()
                    .createActionPopupMenu(ActionPlaces.EDITOR_POPUP, actionGroup);
            popupMenu.getComponent().show(e.getComponent(), e.getX(), e.getY());
            e.consume();
          }
        }
    }

    // suppressing future event processig in case event was consumed by one of LeftHighlighter
    // elements
    if (!e.isConsumed()) {
      super.processMouseEvent(e);
    }
  }
Пример #27
0
 public void mouseExited(MouseEvent e) {
   Component component = e.getComponent();
   if (component instanceof AbstractButton) {
     AbstractButton button = (AbstractButton) component;
     button.setBorderPainted(false);
   }
 }
  @Override
  public void mousePressed(MouseEvent e) {
    //	The mouseMoved event continually updates this variable

    if (direction == 0) return;

    //  Setup for resizing. All future dragging calculations are done based
    //  on the original bounds of the component and mouse pressed location.

    resizing = true;

    Component source = e.getComponent();
    pressed = e.getPoint();
    SwingUtilities.convertPointToScreen(pressed, source);
    bounds = source.getBounds();

    //  Making sure autoscrolls is false will allow for smoother resizing
    //  of components

    if (source instanceof JComponent) {
      JComponent jc = (JComponent) source;
      autoscrolls = jc.getAutoscrolls();
      jc.setAutoscrolls(false);
    }
  }
 @Override
 public void mouseExited(MouseEvent e) {
   if (!resizing) {
     Component source = e.getComponent();
     source.setCursor(sourceCursor);
   }
 }
  @Override
  public void mouseMoved(MouseEvent e) {
    Component source = e.getComponent();
    Point location = e.getPoint();
    direction = 0;

    if (location.x < dragInsets.left) direction += WEST;

    if (location.x > source.getWidth() - dragInsets.right - 1) direction += EAST;

    if (location.y < dragInsets.top) direction += NORTH;

    if (location.y > source.getHeight() - dragInsets.bottom - 1) direction += SOUTH;

    //  Mouse is no longer over a resizable border

    if (direction == 0) {
      source.setCursor(sourceCursor);
    } else // use the appropriate resizable cursor
    {
      int cursorType = cursors.get(direction);
      Cursor cursor = Cursor.getPredefinedCursor(cursorType);
      source.setCursor(cursor);
    }
  }