Ejemplo n.º 1
0
  /** Hides the popup */
  public void hidePopup() {
    // Only hide the popup if the glass pane is
    // visible (i.e. if the popup is being displayed)
    if (glassPane.isVisible() == true) {
      glassPane.setVisible(false);

      firePopupClosedEvent();
    }
  }
Ejemplo n.º 2
0
  public void mouseDragged(java.awt.event.MouseEvent e) {
    if (!org.nlogo.awt.Mouse.hasButton1(e)) {
      return;
    }
    java.awt.Point p = e.getPoint();
    java.awt.Rectangle rect = this.getBounds();

    p.x += rect.x;
    p.y += rect.y;

    if (newWidget != null) {
      if (workspace.snapOn()) {
        startDragPoint.x = (startDragPoint.x / GRID_SNAP) * GRID_SNAP;
        startDragPoint.y = (startDragPoint.y / GRID_SNAP) * GRID_SNAP;
      }
      java.awt.Point p2 =
          restrictDrag(
              new java.awt.Point(e.getX() - startDragPoint.x, e.getY() - startDragPoint.y),
              newWidget);
      newWidget.setLocation(startDragPoint.x + p2.x, startDragPoint.y + p2.y);
    } else if (null != startDragPoint) {
      if (!glassPane.isVisible()) {
        glassPane.setBounds(0, 0, getWidth(), getHeight());
        glassPane.setVisible(true);
      }
      scrollRectToVisible(new java.awt.Rectangle(e.getX() - 20, e.getY() - 20, 40, 40));
      java.awt.Rectangle oldSelectionRect = selectionRect;
      int x = StrictMath.min(getWidth(), StrictMath.max(e.getX(), 0));
      int y = StrictMath.min(getHeight(), StrictMath.max(e.getY(), 0));
      selectionRect =
          new java.awt.Rectangle(
              StrictMath.min(startDragPoint.x, x),
              StrictMath.min(startDragPoint.y, y),
              StrictMath.abs(x - startDragPoint.x),
              StrictMath.abs(y - startDragPoint.y));
      selectWidgets(selectionRect);
      if (oldSelectionRect != null) {
        glassPane.repaint(oldSelectionRect);
      }
      glassPane.repaint(selectionRect);
    }
  }
Ejemplo n.º 3
0
  /** Rebuilds the table. */
  private void rebuildTable() {
    table.saveSelection(extModRefColIdx);

    final ModulesBean modules = ScelightLauncher.INSTANCE().getModules();

    // Only build table if modules bean has been retrieved.
    if (waitInfoWrapper.isVisible()) {
      if (modules == null) {
        if (recheckTimer == null) {
          // Start timer to periodically check if modules been has been retrieved
          recheckTimer =
              new Timer(
                  250,
                  new ActionAdapter() {
                    @Override
                    public void actionPerformed(final ActionEvent event) {
                      rebuildTable();
                    }
                  });
          recheckTimer.start();
        }
        return;
      } else {
        if (recheckTimer != null) recheckTimer.stop();
        waitInfoWrapper.setVisible(false);
        tableWrapperBox.setVisible(true);
      }
    }

    final Vector<Vector<Object>> data = new Vector<>();

    final OffExtModConfsBean offExtModConfsBean =
        LEnv.LAUNCHER_SETTINGS.get(LSettings.OFF_EXT_MOD_CONFS);
    if (modules.getExtModRefList() != null) // This might be null if no internet connection...
    for (final ExtModRefBean emr : modules.getExtModRefList()) {
        final OffExtModConfBean conf = offExtModConfsBean.getModuleConfForFolder(emr.getFolder());

        final StringBuilder authorsBuilder = new StringBuilder();
        for (final PersonBean author : emr.getAuthorList()) {
          if (authorsBuilder.length() > 0) authorsBuilder.append(", ");
          authorsBuilder.append(LEnv.LANG.formatPersonName(author.getPersonName()));
        }

        data.add(
            LUtils.vector(
                emr,
                emr.getIcon(),
                emr.getName(),
                conf == null ? Boolean.FALSE : conf.getAutoUpdate(),
                authorsBuilder.toString(),
                LUtils.tryMakingUrl(emr.getHomePage()),
                emr.getShortDesc()));
      }

    table
        .getXTableModel()
        .setDataVector(
            data,
            LUtils.vector(
                "ExtModRef",
                "I",
                "Name",
                "Auto-updated?",
                "Author",
                "Home page",
                "Short description"));

    extModRefColIdx = 0;
    final int autoUpdateColIdx = 3;
    table.getXTableRowSorter().setColumnDefaultDesc(autoUpdateColIdx, true);
    table.getColumnModel().removeColumn(table.getColumnModel().getColumn(extModRefColIdx));
    table.packColumnsExceptLast();

    table.restoreSelection(extModRefColIdx);
  }
Ejemplo n.º 4
0
  public static void main(String args[]) {
    JComponent ch = new JComponent() {};
    ch.getAccessibleContext();
    ch.isFocusTraversable();
    ch.setEnabled(false);
    ch.setEnabled(true);
    ch.requestFocus();
    ch.requestFocusInWindow();
    ch.getPreferredSize();
    ch.getMaximumSize();
    ch.getMinimumSize();
    ch.contains(1, 2);
    Component c1 = ch.add(new Component() {});
    Component c2 = ch.add(new Component() {});
    Component c3 = ch.add(new Component() {});
    Insets ins = ch.getInsets();
    ch.getAlignmentY();
    ch.getAlignmentX();
    ch.getGraphics();
    ch.setVisible(false);
    ch.setVisible(true);
    ch.setForeground(Color.red);
    ch.setBackground(Color.red);
    for (String font : Toolkit.getDefaultToolkit().getFontList()) {
      for (int j = 8; j < 17; j++) {
        Font f1 = new Font(font, Font.PLAIN, j);
        Font f2 = new Font(font, Font.BOLD, j);
        Font f3 = new Font(font, Font.ITALIC, j);
        Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j);

        ch.setFont(f1);
        ch.setFont(f2);
        ch.setFont(f3);
        ch.setFont(f4);

        ch.getFontMetrics(f1);
        ch.getFontMetrics(f2);
        ch.getFontMetrics(f3);
        ch.getFontMetrics(f4);
      }
    }
    ch.enable();
    ch.disable();
    ch.reshape(10, 10, 10, 10);
    ch.getBounds(new Rectangle(1, 1, 1, 1));
    ch.getSize(new Dimension(1, 2));
    ch.getLocation(new Point(1, 2));
    ch.getX();
    ch.getY();
    ch.getWidth();
    ch.getHeight();
    ch.isOpaque();
    ch.isValidateRoot();
    ch.isOptimizedDrawingEnabled();
    ch.isDoubleBuffered();
    ch.getComponentCount();
    ch.countComponents();
    ch.getComponent(1);
    ch.getComponent(2);
    Component[] cs = ch.getComponents();
    ch.getLayout();
    ch.setLayout(new FlowLayout());
    ch.doLayout();
    ch.layout();
    ch.invalidate();
    ch.validate();
    ch.remove(0);
    ch.remove(c2);
    ch.removeAll();
    ch.preferredSize();
    ch.minimumSize();
    ch.getComponentAt(1, 2);
    ch.locate(1, 2);
    ch.getComponentAt(new Point(1, 2));
    ch.isFocusCycleRoot(new Container());
    ch.transferFocusBackward();
    ch.setName("goober");
    ch.getName();
    ch.getParent();
    ch.getGraphicsConfiguration();
    ch.getTreeLock();
    ch.getToolkit();
    ch.isValid();
    ch.isDisplayable();
    ch.isVisible();
    ch.isShowing();
    ch.isEnabled();
    ch.enable(false);
    ch.enable(true);
    ch.enableInputMethods(false);
    ch.enableInputMethods(true);
    ch.show();
    ch.show(false);
    ch.show(true);
    ch.hide();
    ch.getForeground();
    ch.isForegroundSet();
    ch.getBackground();
    ch.isBackgroundSet();
    ch.getFont();
    ch.isFontSet();
    Container c = new Container();
    c.add(ch);
    ch.getLocale();
    for (Locale locale : Locale.getAvailableLocales()) ch.setLocale(locale);

    ch.getColorModel();
    ch.getLocation();

    boolean exceptions = false;
    try {
      ch.getLocationOnScreen();
    } catch (IllegalComponentStateException e) {
      exceptions = true;
    }
    if (!exceptions)
      throw new RuntimeException("IllegalComponentStateException did not occur when expected");

    ch.location();
    ch.setLocation(1, 2);
    ch.move(1, 2);
    ch.setLocation(new Point(1, 2));
    ch.getSize();
    ch.size();
    ch.setSize(1, 32);
    ch.resize(1, 32);
    ch.setSize(new Dimension(1, 32));
    ch.resize(new Dimension(1, 32));
    ch.getBounds();
    ch.bounds();
    ch.setBounds(10, 10, 10, 10);
    ch.setBounds(new Rectangle(10, 10, 10, 10));
    ch.isLightweight();
    ch.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
    ch.getCursor();
    ch.isCursorSet();
    ch.inside(1, 2);
    ch.contains(new Point(1, 2));
    ch.isFocusable();
    ch.setFocusable(true);
    ch.setFocusable(false);
    ch.transferFocus();
    ch.getFocusCycleRootAncestor();
    ch.nextFocus();
    ch.transferFocusUpCycle();
    ch.hasFocus();
    ch.isFocusOwner();
    ch.toString();
    ch.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    ch.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    ch.setComponentOrientation(ComponentOrientation.UNKNOWN);
    ch.getComponentOrientation();
  }
 private boolean lastVisible() {
   return !Splitter.isNull(myLastComponent) && myLastComponent.isVisible();
 }
 private boolean innerVisible() {
   return !Splitter.isNull(myInnerComponent) && myInnerComponent.isVisible();
 }
Ejemplo n.º 7
0
 public boolean popupIsDisplayed() {
   return glassPane.isVisible();
 }