public void drop(DropTargetDropEvent dropTargetDropEvent) {
    resetGlassPane();

    Point p = list.getMousePosition();

    int dstRow = list.locationToIndex(p);

    int srcRow = list.locationToIndex(from);
    ProfileListModel m = (ProfileListModel) list.getModel();

    if (dstRow < 0) {
      dstRow = 0;
    }
    if (dstRow > m.getSize() - 1) {
      dstRow = m.getSize() - 1;
    }

    m.insertElementAt((File) m.getElementAt(srcRow), dstRow);
    if (dstRow <= srcRow) {
      m.removeElementAt(srcRow + 1);
      list.setSelectedIndex(dstRow);
    } else {
      m.removeElementAt(srcRow);
      list.setSelectedIndex(dstRow - 1);
    }
  }
    /*
     * Handles the checkbox selection process. Uses the bounds property of the
     * check box within the selected cell to determine whether the checkbox should
     * be selected or not
     **/
    public void mouseReleased(MouseEvent e) {
      if (list == null
          || list.getSelectedIndex() == -1
          || !isEnabled(list.locationToIndex(e.getPoint()))) {
        return;
      }

      int[] indices = list.getSelectedIndices();

      // get the current relative position of the check box
      // rect = box.getBounds(rect);

      for (int i = 0; i < indices.length; i++) {

        // get the current relative position of the check box
        int loc = list.locationToIndex(e.getPoint());
        rect = list.getCellBounds(loc, loc);

        // ensure the point clicked in within the checkBox
        /*if(e.getX() < (rect.getX() + 20) ) {
        	selState[indices[i]] = !selState[indices[i]];
        	setSelStateList(selState);
        } */
      }

      list.revalidate();
      list.repaint();
    }
Beispiel #3
0
    @Override
    @SuppressWarnings({"deprecation", "unchecked"}) // FIXME in Java7
    public void mousePressed(MouseEvent e) {
      if (!enabled && e.getClickCount() == 1 && !e.isConsumed()) {
        enabled = true;
      }

      if (enabled) {
        JList source = (JList) e.getSource();
        if ((e.getButton() == MouseEvent.BUTTON3 || e.isPopupTrigger())) {
          int index = source.locationToIndex(e.getPoint());
          BuildableType type = (BuildableType) source.getModel().getElementAt(index);
          getGUI().showColopediaPanel(type.getId());
        } else if ((e.getClickCount() > 1 && !e.isConsumed())) {
          DefaultListModel model = (DefaultListModel) buildQueueList.getModel();
          if (source.getSelectedIndex() == -1) {
            source.setSelectedIndex(source.locationToIndex(e.getPoint()));
          }
          for (Object type : source.getSelectedValues()) {
            if (add) {
              model.addElement(type);
            } else {
              model.removeElement(type);
            }
          }
          updateAllLists();
        }
      }
    }
Beispiel #4
0
 void endSelection(Point point) {
   last = mainView.locationToIndex(point);
   if (first != last) {
     mainView.setSelectionInterval(first, last);
     // Debug.println(first + ", " + last);
   }
 }
 @Override
 public void mousePressed(MouseEvent e) {
   rightClick = AppD.isRightClick(e);
   table.stopEditing();
   mousePressedRow = rowHeader.locationToIndex(e.getPoint());
   rowHeader.requestFocus();
 }
  /**
   * Shows the PopUp
   *
   * @param e MouseEvent
   */
  protected void showPopUpMenu(MouseEvent e) {
    if (!(e.getSource() instanceof JList)) {
      return;
    }

    JList list = (JList) e.getSource();

    int i = list.locationToIndex(e.getPoint());
    list.setSelectedIndex(i);

    JPopupMenu menu = new JPopupMenu();

    Rating selRating = (Rating) list.getSelectedValue();

    JMenuItem item = new JMenuItem(mLocalizer.msg("showDetails", "Show Details"));
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            view();
          }
        });
    item.setFont(item.getFont().deriveFont(Font.BOLD));

    menu.add(item);
    menu.add(new ListAction(this, selRating.getTitle()));
    menu.add(new ShowDetailsAction(selRating.getRatingId()));

    menu.show(list, e.getX(), e.getY());
  }
    public void mousePressed(MouseEvent e) {
      if (e.getClickCount() == 2) {
        JList list = (JList) e.getSource();
        int index = list.locationToIndex(e.getPoint());

        optionPane.setInputValue(list.getModel().getElementAt(index));
      }
    }
Beispiel #8
0
 void profileList_mouseClicked(MouseEvent e) {
   JList theList = (JList) e.getSource();
   ListModel aModel = theList.getModel();
   int index = theList.locationToIndex(e.getPoint());
   if (index < 0) return;
   UniProfile aProfile = (UniProfile) aModel.getElementAt(index);
   nameTextField.setText(aProfile.toString());
 }
Beispiel #9
0
 public void listClicked(MouseEvent e) {
   Point p = new Point(e.getX(), e.getY());
   int index = list.locationToIndex(p);
   Rectangle inside = list.getCellBounds(index, index);
   if (inside.contains(p) && (!newSelection)) {
     list.clearSelection();
   }
   newSelection = false;
 }
Beispiel #10
0
  private void hovered(final MouseEvent e, final boolean entered) {

    hoveredIndex = myList.locationToIndex(e.getPoint());
    if (!entered
        || hoveredIndex != -1
            && !myList.getCellBounds(hoveredIndex, hoveredIndex).contains(e.getPoint()))
      hoveredIndex = -1;

    myList.repaint();
  }
Beispiel #11
0
  private void showContextMenu(JList characterList, MouseEvent mouseEvent) {
    // TODO: handle right-click outside of selected range correctly (should treat as single
    // selection, but not deselect)
    boolean multipleSelected = herolabsCharacterList.getSelectedValues().length > 1;
    if (mouseEvent.isPopupTrigger() && mouseEvent.getClickCount() == 1) {
      if (!multipleSelected) {
        herolabsCharacterList.setSelectedIndex(
            herolabsCharacterList.locationToIndex(mouseEvent.getPoint()));
      }

      if (contextMenuEnabled) {
        JPopupMenu menu = new JPopupMenu();
        JMenuItem menuItem;

        menuItem = new JMenuItem("Configure character" + (multipleSelected ? "s" : "") + "...");
        menuItem.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent actionEvent) {
                configureSelectedCharacters();
              }
            });
        menu.add(menuItem);

        menuItem = new JMenuItem("Configure using portfolio defaults");
        menuItem.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent actionEvent) {
                resetToDefaultsForSelectedCharacters();
              }
            });
        menu.add(menuItem);

        menuItem = new JMenuItem("Export character" + (multipleSelected ? "s" : ""));
        menuItem.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent actionEvent) {
                exportSelectedCharacters();
              }
            });
        menu.add(menuItem);

        menuItem = new JMenuItem("Clear configuration" + (multipleSelected ? "s" : ""));
        menuItem.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent actionEvent) {
                clearConfigForSelectedCharacters();
              }
            });
        menu.add(menuItem);

        menu.show(characterList, mouseEvent.getX(), mouseEvent.getY());
      }
    }
  }
 @Override
 public void mousePressed(MouseEvent e) {
   JList list = (JList) e.getComponent();
   Point pt = e.getPoint();
   int index = list.locationToIndex(pt);
   if (index >= 0) {
     JButton button = getButton(list, pt, index);
     if (Objects.nonNull(button)) {
       listRepaint(list, list.getCellBounds(index, index));
     }
   }
 }
  private void onInfoRouteListMosueOver(Point point) {
    Object value = null;
    try {
      int pos = infoRouteJList.locationToIndex(point);
      value = ((DefaultListModel) infoRouteJList.getModel()).get(pos);

      if (value != null && value instanceof InfoRouteStretchBean) {
        InfoRouteStretchBean actualStretchBean = (InfoRouteStretchBean) value;
        ArrayList<Geometry> geoArrayList = new ArrayList<Geometry>();
        if (actualStretchBean != null
            && actualStretchBean.getGeometries() != null
            && !actualStretchBean.getGeometries().isEmpty()) {
          geoArrayList.addAll(actualStretchBean.getGeometries());
        }

        if (value instanceof TurnRouteStreetchBean) {
          GeometryFactory geoFactory = new GeometryFactory();
          if (((TurnRouteStreetchBean) value).getTurnNode() != null) {
            geoArrayList.add(
                geoFactory.createPoint(
                    ((XYNode) ((TurnRouteStreetchBean) value).getTurnNode()).getCoordinate()));
          }
        }

        GeometryFactory geoFactory = new GeometryFactory();
        GeometryCollection geoCollection =
            new GeometryCollection(
                geoArrayList.toArray(new Geometry[geoArrayList.size()]), geoFactory);

        pluginContext.getLayerViewPanel().flash(geoCollection);

        try {
          //					Component comp = getInfoListPanel().getComponentAt(point);
          //					 if (comp != null){
          //						comp.setBackground(Color.LIGHT_GRAY);
          //						 comp.setForeground(Color.RED);
          //					 }
        } catch (Exception e) {
          e.printStackTrace();
        }
      }

    } catch (Exception ex) {
      ex.printStackTrace();
      ErrorDialog.show(
          null,
          "Error resaltar un tramo de la ruta.",
          I18N.get(
              "routedescription", "routeengine.route.description.error.route.not.zoom.message"),
          StringUtil.stackTrace(ex));
    }
  }
 public static int loc2IndexFileList(JList list, Point point) {
   int i = list.locationToIndex(point);
   if (i != -1) {
     Object localObject = list.getClientProperty("List.isFileList");
     if ((localObject instanceof Boolean)
         && (((Boolean) localObject).booleanValue())
         // PENDING JW: this isn't aware of sorting/filtering - fix!
         && (!(pointIsInActualBounds(list, i, point)))) {
       i = -1;
     }
   }
   return i;
 }
Beispiel #15
0
 @Override
 public void mousePressed(MouseEvent e) {
   // JList list = (JList) e.getComponent();
   Point pt = e.getPoint();
   int index = list.locationToIndex(pt);
   if (index >= 0) {
     JButton button = getButton(list, pt, index);
     if (Objects.nonNull(button)) {
       ButtonsRenderer renderer = (ButtonsRenderer) list.getCellRenderer();
       renderer.pressedIndex = index;
       renderer.button = button;
       listRepaint(list, list.getCellBounds(index, index));
     }
   }
 }
  public void mouseDragged(MouseEvent e) {
    e.consume();

    // update selection
    int mouseDraggedRow = rowHeader.locationToIndex(e.getPoint());

    // make sure mouse pressed is initialized, this may not be the case
    // after closing the popup menu
    if (mousePressedRow < 0) {
      table.stopEditing();
      mousePressedRow = mouseDraggedRow;
    }
    if (AppD.isControlDown(e)) rowHeader.addSelectionInterval(mousePressedRow, mouseDraggedRow);
    else rowHeader.setSelectionInterval(mousePressedRow, mouseDraggedRow);
  }
    @Override
    public void mouseClicked(final MouseEvent e) {

      final int index = _list.locationToIndex(e.getPoint());
      if (index == -1) {
        return;
      }
      final Object element = _list.getModel().getElementAt(index);
      if (element == null) return;
      if (element instanceof ApplicationSubscriptionInfo.ApplicationSendingSubscription) {
        showSubscriptionInfo((ApplicationSubscriptionInfo.ApplicationSendingSubscription) element);
      }
      if (element instanceof ApplicationSubscriptionInfo.ApplicationReceivingSubscription) {
        showSubscriptionInfo(
            (ApplicationSubscriptionInfo.ApplicationReceivingSubscription) element);
      }
    }
 @Override
 public void mouseMoved(MouseEvent e) {
   JList list = (JList) e.getComponent();
   Point pt = e.getPoint();
   int index = list.locationToIndex(pt);
   if (!list.getCellBounds(index, index).contains(pt)) {
     if (prevIndex >= 0) {
       Rectangle r = list.getCellBounds(prevIndex, prevIndex);
       listRepaint(list, r);
     }
     index = -1;
     prevButton = null;
     return;
   }
   if (index >= 0) {
     JButton button = getButton(list, pt, index);
     ButtonsRenderer renderer = (ButtonsRenderer) list.getCellRenderer();
     if (Objects.nonNull(button)) {
       renderer.rolloverIndex = index;
       if (!button.equals(prevButton)) {
         Rectangle r = list.getCellBounds(prevIndex, index);
         listRepaint(list, r);
       }
     } else {
       renderer.rolloverIndex = -1;
       Rectangle r = null;
       if (prevIndex == index) {
         if (prevIndex >= 0 && Objects.nonNull(prevButton)) {
           r = list.getCellBounds(prevIndex, prevIndex);
         }
       } else {
         r = list.getCellBounds(index, index);
       }
       listRepaint(list, r);
       prevIndex = -1;
     }
     prevButton = button;
   }
   prevIndex = index;
 }
Beispiel #19
0
  public void mouseClicked(MouseEvent e) {

    list.setSelectedIndex(-1);
    list.setRequestFocusEnabled(false);
    // changedField = null;

    if (selComp == text || selComp == text2) {
      selComp.setBackground(Color.WHITE);
      ((JTextField) selComp).setEditable(false);
      ((JTextField) selComp).getCaret().setVisible(false);
    }

    text2.setBackground(Color.WHITE);
    // cBox.repaint();

    if (selComp instanceof MyButton) {
      ((MyButton) selComp).setSelected(false);
      ((MyButton) selComp).setFocusable(false);
    }

    selComp = (Component) e.getSource();

    if (selComp == text || selComp == text2) {

      ((JTextField) selComp).setRequestFocusEnabled(true);

      selComp.setBackground(vLightBlue);
      ((JTextField) selComp).getCaret().setVisible(true);
      ((JTextField) selComp).setEditable(true);
      // ((JTextField) selComp).requestFocusInWindow();

    }

    if (e.getSource() instanceof JList) {
      selComp = list;
      int rowNo = list.locationToIndex(e.getPoint());
      if (rowNo == -1) return;

      list.setRequestFocusEnabled(true);

      list.setSelectedIndex(rowNo);
      text.setBackground(Color.WHITE);
      // text2.setBackground(textBackground);

      // http://stackoverflow.com/questions/16392212/unable-to-type-or-delete-text-in-jtextfield
      // http://stackoverflow.com/questions/13415150/java-swing-form-and-cannot-type-text-in-newly-added-jtextfield
      // (this says don't use keylistener!)
      //		http://stackoverflow.com/questions/22642401/jtextfield-and-keylistener-java-swing?rq=1
      //		textField.getDocument().addDocumentListener(...);
      // new code

      // text2.requestFocusInWindow();
      // text2.setBackground(vLightBlue);
      // text2.getCaret().setVisible(true);

      // String fn = listHead + File.separator + nodeNames[rowNo];

      if (e.getClickCount() == 1) {
        mLoc = e.getLocationOnScreen();

        if (nodeNames[rowNo].equals("(empty folder")) return;

      } else if (e.getClickCount() == 2) {

        Point p = e.getLocationOnScreen();

        if (mLoc != null && Math.abs(p.x - mLoc.x) < 6 && Math.abs(p.y - mLoc.y) < 6) {

          enterAction.actionPerformed(new ActionEvent(e, 0, ""));
        }
      }
    }

    if (selComp == cBox) {
      selComp.setFocusable(true);
      cBox.requestFocusInWindow();
      cBox.setEnabled(true);
      cBox.setBackground(vLightBlue);
    }

    if (selComp instanceof MyButton) {
      ((MyButton) selComp).setSelected(false);
    }
    paintList();
    list.repaint();
  }
Beispiel #20
0
 public int locationToIndex(Point location) {
   return list.locationToIndex(location);
 }
 private void record(MouseEvent e, Action action) {
   JList list = (JList) e.getSource();
   recorder.record(new ListEvent(list.getName(), list.locationToIndex(e.getPoint()), action));
 }
Beispiel #22
0
 void startSelection(Point point) {
   first = mainView.locationToIndex(point);
   // Debug.println(first);
 }
Beispiel #23
0
 void continueSelection(Point point) {
   last = mainView.locationToIndex(point);
   mainView.setSelectionInterval(first, last);
   // Debug.println(first + ", " + last);
 }
Beispiel #24
0
 public void mouseClicked(MouseEvent e) {
   if (e.getSource() == userList && e.getClickCount() == 2) {
     int index = userList.locationToIndex(e.getPoint());
     if (index > -1) {
       String userInfo = (String) ((DefaultListModel) userList.getModel()).get(index);
       link.running = false;
       userInfo = userInfo.substring(userInfo.indexOf("@") - 1);
       link =
           new LeetClient(
               userInfo.substring(userInfo.indexOf("@") + 1, userInfo.indexOf(":")),
               Integer.parseInt(userInfo.substring(userInfo.indexOf(":") + 1)),
               address,
               directory);
       link.setPasv(portItem.getState());
       link.command = "LIST";
       link.start();
     }
   }
   if (e.getSource() == fileList && e.getClickCount() == 2) {
     int index = fileList.locationToIndex(e.getPoint());
     if (index > -1) {
       String fileName = (String) ((DefaultListModel) fileList.getModel()).get(index);
       if (fileName.indexOf(" ") > -1) {
         fileName = fileName.substring(0, fileName.indexOf(" "));
       }
       link.command = "RETR " + fileName;
       System.out.println(link.command);
     }
   }
   if (e.getSource() == connectButton) {
     if (connectButton.getText().equals("Disconnect")) {
       active.running = false;
       connectButton.setText("Connect");
     } else {
       active =
           new LeetActive(
               serverTextField.getText(),
               Integer.parseInt(portTextField.getText()),
               SERVER_PORT);
       active.setUserName(nameTextField.getText());
       active.start();
       connectButton.setText("Disconnect");
     }
   }
   if (e.getSource() == searchInit) {
     search = new SearchUsers();
     search.start();
   }
   if (e.getSource() == searchList && e.getClickCount() == 2) {
     int index = searchList.locationToIndex(e.getPoint());
     if (index > -1) {
       String fileInfo = (String) ((DefaultListModel) searchList.getModel()).get(index);
       link.running = false;
       String userInfo = fileInfo.substring(fileInfo.indexOf("@") + 1);
       userInfo = userInfo.substring(userInfo.indexOf("@") - 1);
       fileInfo = fileInfo.substring(0, fileInfo.indexOf("@"));
       link =
           new LeetClient(
               userInfo.substring(userInfo.indexOf("@") + 1, userInfo.indexOf(":")),
               Integer.parseInt(userInfo.substring(userInfo.indexOf(":") + 1)),
               address,
               directory);
       link.setPasv(portItem.getState());
       link.command = "RETR " + fileInfo;
       link.start();
     }
   }
 }
  private void updateLine(Point pt) {
    if (list.locationToIndex(pt) < 0) list.clearSelection();

    list.repaint();
  }
        public void mouseClicked(MouseEvent e) {
          list.repaint();

          try {

            final int index = list.locationToIndex(e.getPoint());
            final SceneUnitTag<?> unit = (SceneUnitTag<?>) list.getModel().getElementAt(index);

            viewer.selected_unit = unit;

            if (unit != null) {
              text_unit_name.setText(unit.getSceneUnit().getID() + "");
            }

            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getClickCount() == 2) {
                // System.out.println("Double clicked on Item " +
                // index);
                viewer
                    .getViewObject()
                    .locationCameraCenter(unit.getSceneUnit().getX(), unit.getSceneUnit().getY());
              }
            } else if (e.getButton() == MouseEvent.BUTTON3) {
              // System.out.println("Right clicked on Item " + index);

              JPopupMenu menu = new JPopupMenu();

              JMenuItem rename = new JMenuItem("重命名");
              rename.addActionListener(
                  new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                      String new_name =
                          JOptionPane.showInputDialog("input name", unit.getSceneUnit().getID());
                      if (new_name != null) {
                        if (!unit.getSceneUnit().setID(scene.getWorld(), new_name)) {
                          JOptionPane.showMessageDialog(list, "bad name or duplicate !");
                        }
                        viewer.refreshAll();
                      }
                    }
                  });

              JMenuItem property = new JMenuItem("属性");
              property.addActionListener(
                  new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                      DisplayObjectEditor<?> editor = unit.getSceneUnit().getEditorForm();
                      editor.setCenter();
                      editor.setAlwaysOnTop(true);
                      editor.setVisible(true);
                    }
                  });

              menu.add(rename);
              menu.add(property);
              menu.show(list, e.getX(), e.getY());
            }

          } catch (Exception e2) {
            e2.printStackTrace();
          }
        }