/** Invoked when an action occurs. */
    public void actionPerformed(final ActionEvent e) {
      final CreateNewRepositoryFolderDialog newFolderDialog =
          new CreateNewRepositoryFolderDialog(RepositoryPublishDialog.this);

      if (!newFolderDialog.performEdit()) {
        return;
      }

      final FileObject treeNode = getSelectedView();
      if (treeNode == null) {
        return;
      }

      if (!StringUtils.isEmpty(newFolderDialog.getName())) {
        final Component glassPane =
            SwingUtilities.getRootPane(RepositoryPublishDialog.this).getGlassPane();
        try {
          glassPane.setVisible(true);
          glassPane.setCursor(new Cursor(Cursor.WAIT_CURSOR));
          final FileObject child = treeNode.resolveFile(newFolderDialog.getFolderName());
          child.createFolder();
          if (child instanceof WebSolutionFileObject) {
            final WebSolutionFileObject webSolutionFileObject = (WebSolutionFileObject) child;
            webSolutionFileObject.setDescription(newFolderDialog.getDescription());
          }
          getTable().refresh();
        } catch (Exception e1) {
          UncaughtExceptionsModel.getInstance().addException(e1);
        } finally {
          glassPane.setVisible(false);
          glassPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
      }
    }
  @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);
    }
  }
 /**
  * Long operations need to display an hourglass.
  *
  * @param comp The <code>JComponent</code> on which to apply the hour glass cursor
  * @param on If true, we set the cursor on the hourglass
  */
 public static void setCursorOnWait(Component comp, boolean on) {
   if (on) {
     if (comp instanceof AbstractEditorPanel) ((AbstractEditorPanel) comp).showWaitCursor();
     else comp.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
   } else {
     if (comp instanceof AbstractEditorPanel) ((AbstractEditorPanel) comp).hideWaitCursor();
     else comp.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
   }
 }
Esempio n. 4
0
 public void setWaitingCursor(final boolean waiting) {
   Component glassPane = getRootPane().getGlassPane();
   if (waiting) {
     glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
     glassPane.setVisible(true);
   } else {
     glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
     glassPane.setVisible(false);
   }
 }
 @Override
 public void mouseMoved(MouseEvent e) {
   Component component = e.getComponent();
   if (component != null) {
     if (getRootColumnOrNull(e) != null) {
       component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
     } else {
       component.setCursor(null);
     }
   }
 }
Esempio n. 6
0
  /** Handles the clicking of the <b>Add</b> button on the GUI. */
  public void handleOpen() {
    File defaultFile = new File(PCGenSettings.getPcgDir());
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(defaultFile);

    String[] pcgs = new String[] {FILENAME_PCG, FILENAME_PCP};
    SimpleFileFilter ff =
        new SimpleFileFilter(pcgs, LanguageBundle.getString("in_pcgen_file")); // $NON-NLS-1$
    chooser.addChoosableFileFilter(ff);
    chooser.setFileFilter(ff);
    chooser.setMultiSelectionEnabled(true);
    Component component = GMGenSystem.inst;
    Cursor originalCursor = component.getCursor();
    component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    int option = chooser.showOpenDialog(GMGenSystem.inst);

    if (option == JFileChooser.APPROVE_OPTION) {
      for (File selectedFile : chooser.getSelectedFiles()) {
        if (PCGFile.isPCGenCharacterOrPartyFile(selectedFile)) {
          messageHandler.handleMessage(
              new RequestOpenPlayerCharacterMessage(this, selectedFile, false));
        }
      }
    } else {
      /* this means the file is invalid */
    }

    GMGenSystem.inst.setCursor(originalCursor);
  }
 @Override
 public void mouseExited(MouseEvent e) {
   if (!resizing) {
     Component source = e.getComponent();
     source.setCursor(sourceCursor);
   }
 }
Esempio n. 8
0
  /** Restore the original state of the Component */
  @Override
  public void mouseReleased(MouseEvent e) {
    if (!potentialDrag) {
      return;
    }

    source.removeMouseMotionListener(this);
    potentialDrag = false;

    if (changeCursor) {
      source.setCursor(originalCursor);
    }

    if (destination instanceof JComponent) {
      ((JComponent) destination).setAutoscrolls(autoscrolls);
    }

    // Layout the components on the parent container

    if (autoLayout) {
      if (destination instanceof JComponent) {
        ((JComponent) destination).revalidate();
      } else {
        destination.validate();
      }
    }
  }
Esempio n. 9
0
  private void setupForDragging(MouseEvent e) {
    source.addMouseMotionListener(this);
    potentialDrag = true;

    // Determine the component that will ultimately be moved

    if (destinationComponent != null) {
      destination = destinationComponent;
    } else if (destinationClass == null) {
      destination = source;
    } else // forward events to destination component
    {
      destination = SwingUtilities.getAncestorOfClass(destinationClass, source);
    }

    pressed = e.getLocationOnScreen();
    location = destination.getLocation();

    if (changeCursor) {
      originalCursor = source.getCursor();
      source.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
    }

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

    if (destination instanceof JComponent) {
      JComponent jc = (JComponent) destination;
      autoscrolls = jc.getAutoscrolls();
      jc.setAutoscrolls(false);
    }
  }
Esempio n. 10
0
  private void maybeShowPopup(MouseEvent e) {
    if (e.isPopupTrigger()) {
      Component c = e.getComponent();
      JPopupMenu popup = null;

      Cursor oldCursor = c.getCursor();
      c.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      try {
        popup = menuBuilder.getPopupMenu(e);
      } finally {
        c.setCursor(oldCursor);
      }

      if (popup != null) {
        popup.show(e.getComponent(), e.getX(), e.getY());
      }
    }
  }
Esempio n. 11
0
  private static void setComponentCursor(final Component comp, final Cursor cursor) {

    if (comp instanceof Container) {
      Component[] comps = ((Container) comp).getComponents();
      for (Component c : comps) {
        setComponentCursor(c, cursor);
      }
    }
    comp.setCursor(cursor);
  }
  /** Restore the original state of the Component */
  @Override
  public void mouseReleased(MouseEvent e) {
    resizing = false;

    Component source = e.getComponent();
    source.setCursor(sourceCursor);

    if (source instanceof JComponent) {
      ((JComponent) source).setAutoscrolls(autoscrolls);
    }
  }
Esempio n. 13
0
    public void uninstall() {
      for (RangeHighlighter highlighter : myHighlighters) {
        highlighter.dispose();
      }

      Component internalComponent = myHighlighterView.getContentComponent();
      internalComponent.setCursor(myStoredCursor);
      internalComponent.removeKeyListener(myEditorKeyListener);
      myHighlighterView.getScrollingModel().removeVisibleAreaListener(myVisibleAreaListener);
      myFileEditorManager.removeFileEditorManagerListener(myFileEditorManagerListener);
    }
Esempio n. 14
0
  // Release picture box. Let the factory model know about this change.
  private void mouseUp(MouseEvent e) {
    if (e.getButton() != MouseEvent.BUTTON1) return;

    Component parent = ((Component) e.getSource()).getParent();
    parent.setCursor(originalCursor);

    isMouseDown = false;
    factoryModel.drag(
        initLocation,
        new Point(initLocation.x + e.getX() - initX, initLocation.y + e.getY() - initY));
  }
  /** thread run method that is called when the thread start method is called */
  @Override
  public void run() {
    for (; k < vecSequence.size(); k++) {
      // set it to say its not in this thread so the user cannot click on the
      // progress bar at the perfect time and freeze the program in the waiting
      // cursor stage
      if (k == (vecSequence.size() - 1)) {
        theApp.setThreadStatus(false);
        theApp.setPlayPauseOff();
      }

      if (((Component) theApp).getCursor().getType() == Cursor.WAIT_CURSOR) {
        int jpbIncrement = Math.round(1.0f * theApp.getBarMax() / vecSequence.size());
        k = Math.round(theApp.getBarValue() / jpbIncrement);

        ((Component) theApp).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      }

      AePlayWave thread = new AePlayWave(vecSequence.get(k));
      theApp.incrementProgressBarValue();

      thread.start(); // play the selected audio clip
      try {
        thread.join(); // wait for the thread playing to clip to die
      } catch (InterruptedException ie) {
        ((Component) theApp).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      }

      if (theApp.playPausePressed()) {
        k = vecSequence.size();
      }
    }
    if (!theApp.playPausePressed()) {
      theApp.setButtonsOutOfThread();
      theApp.fillBarValue();
    }
  }
Esempio n. 16
0
  // A click on a picture box
  private void mouseDown(MouseEvent e) {
    if (e.getButton() != MouseEvent.BUTTON1) return;

    Component source = (Component) e.getSource();

    Component parent = source.getParent();
    originalCursor = parent.getCursor();
    parent.setCursor(new Cursor(Cursor.MOVE_CURSOR));

    initLocation = source.getLocation();
    initX = e.getX();
    initY = e.getY();

    isMouseDown = true;
  }
  /**
   * Mouse listener for the progress bar. It will go to the position that it is clicked on.
   *
   * @param evt a java Mouse event
   */
  private void jbrProgressMousePressed(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_jbrProgressMousePressed
    // only move the bar if it is getting updated
    if (!getThreadStatus()) {
      return;
    }

    ((Component) this).setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    int x = evt.getX();

    Rectangle rec = jbrProgress.getBounds();
    double nx = rec.getX();
    double width = rec.getWidth(); // rec.

    int value = (int) (100 * (x / width));
    // jbrProgress.setValue(value);

    // get the value back into the correct increment segment
    int jpbIncrement;
    switch (nSequenceToPlay) {
      case 1:
        jpbIncrement = Math.round(1.0f * jbrProgress.getMaximum() / vecStoredSequence.size());
        value = jpbIncrement * Math.round(1.0f * value / jpbIncrement);
        jbrProgress.setValue(value);
        break;
      case 2:
        jpbIncrement = Math.round(1.0f * jbrProgress.getMaximum() / vecAllNumbersSequence.size());
        value = jpbIncrement * Math.round(1.0f * value / jpbIncrement);
        jbrProgress.setValue(value);
        break;
    }

    if (ppPressed) {
      jbtnPlayPauseActionPerformed(null);
    }
  } // GEN-LAST:event_jbrProgressMousePressed
Esempio n. 18
0
    private void showHint(Info info) {
      if (myDisposed) return;
      Component internalComponent = myEditor.getContentComponent();
      if (myHighlighter != null) {
        if (!info.isSimilarTo(myHighlighter.getStoredInfo())) {
          disposeHighlighter();
        } else {
          // highlighter already set
          internalComponent.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
          return;
        }
      }

      if (info.isValid(myEditor.getDocument())) {
        myHighlighter = installHighlighterSet(info, myEditor);

        String text = info.getInfo();

        if (text == null) return;

        JComponent label = HintUtil.createInformationLabel(text);
        final LightweightHint hint = new LightweightHint(label);
        final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
        Point p = HintManagerImpl.getHintPosition(hint, myEditor, myPosition, HintManager.ABOVE);
        hintManager.showEditorHint(
            hint,
            myEditor,
            p,
            HintManager.HIDE_BY_ANY_KEY
                | HintManager.HIDE_BY_TEXT_CHANGE
                | HintManager.HIDE_BY_SCROLLING,
            0,
            false,
            HintManagerImpl.createHintHint(myEditor, p, hint, HintManager.ABOVE)
                .setContentActive(false));
      }
    }
 /**
  * Sets the current cursor of this window
  *
  * @param cursor the cursor
  * @see Component#setCursor(Cursor)
  */
 protected void setCursor(Cursor cursor) {
   window.setCursor(cursor);
 }
Esempio n. 20
0
 /**
  * Call before beginning a lengthy operation in the UI thread. The effect might for example be to
  * set the cursor to the "busy" cursor (hourglass on windows).
  */
 public void beginBusyOperation(Component target) {
   if (busyCount++ >= 0) {
     target.setCursor(new Cursor(Cursor.WAIT_CURSOR));
   }
 }
Esempio n. 21
0
 /**
  * Call after completing a lengthy operation in the UI thread. If this is the last such operation
  * the default cursor is restored.
  */
 public void endBusyOperation(Component target) {
   if (--busyCount < 1) {
     target.setCursor(null);
   }
 }
Esempio n. 22
0
 public void setCursor(Cursor cursor) {
   component.setCursor(cursor);
 }
Esempio n. 23
0
 public void setCursor(Cursor cursor) {
   // sets the cursor to our component.
   comp.setCursor(cursor);
 }
 /**
  * Changes the cursor of {@link #getContainer() the base component}. Subclasses may override
  * this method to use custom cursors.
  *
  * @param cursor the cursor to set, may be <code>null</code>
  */
 protected void setCursor(Cursor cursor) {
   container.setCursor(cursor);
 }
Esempio n. 25
0
    private void showHint(Info info) {
      if (myDisposed || myEditor.isDisposed()) return;
      Component internalComponent = myEditor.getContentComponent();
      if (myHighlighter != null) {
        if (!info.isSimilarTo(myHighlighter.getStoredInfo())) {
          disposeHighlighter();
        } else {
          // highlighter already set
          internalComponent.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
          return;
        }
      }

      if (!info.isValid(myEditor.getDocument())) {
        return;
      }

      myHighlighter = installHighlighterSet(info, myEditor);

      DocInfo docInfo = info.getInfo();

      if (docInfo.text == null) return;

      if (myDocumentationManager.hasActiveDockedDocWindow()) {
        info.showDocInfo(myDocumentationManager);
      }

      HyperlinkListener hyperlinkListener =
          docInfo.docProvider == null
              ? null
              : new QuickDocHyperlinkListener(docInfo.docProvider, info.myElementAtPointer);
      final Ref<QuickDocInfoPane> quickDocPaneRef = new Ref<QuickDocInfoPane>();
      MouseListener mouseListener =
          new MouseAdapter() {
            @Override
            public void mouseEntered(MouseEvent e) {
              QuickDocInfoPane pane = quickDocPaneRef.get();
              if (pane != null) {
                pane.mouseEntered(e);
              }
            }

            @Override
            public void mouseExited(MouseEvent e) {
              QuickDocInfoPane pane = quickDocPaneRef.get();
              if (pane != null) {
                pane.mouseExited(e);
              }
            }

            @Override
            public void mouseClicked(MouseEvent e) {
              QuickDocInfoPane pane = quickDocPaneRef.get();
              if (pane != null) {
                pane.mouseClicked(e);
              }
            }
          };
      Ref<Consumer<String>> newTextConsumerRef = new Ref<Consumer<String>>();
      JComponent label =
          HintUtil.createInformationLabel(
              docInfo.text, hyperlinkListener, mouseListener, newTextConsumerRef);
      Consumer<String> newTextConsumer = newTextConsumerRef.get();
      QuickDocInfoPane quickDocPane = null;
      if (docInfo.documentationAnchor != null) {
        quickDocPane =
            new QuickDocInfoPane(docInfo.documentationAnchor, info.myElementAtPointer, label);
        quickDocPaneRef.set(quickDocPane);
      }

      JComponent hintContent = quickDocPane == null ? label : quickDocPane;

      final LightweightHint hint = new LightweightHint(hintContent);
      myHint = hint;
      hint.addHintListener(
          new HintListener() {
            @Override
            public void hintHidden(EventObject event) {
              myHint = null;
            }
          });
      myDocAlarm.cancelAllRequests();
      if (newTextConsumer != null
          && docInfo.docProvider != null
          && docInfo.documentationAnchor != null) {
        fulfillDocInfo(
            docInfo.text,
            docInfo.docProvider,
            info.myElementAtPointer,
            docInfo.documentationAnchor,
            newTextConsumer,
            hint);
      }

      showHint(hint);
    }
Esempio n. 26
0
  @Override
  public void mouseEntered(MouseEvent e) {
    source = e.getComponent();

    source.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  }
Esempio n. 27
0
  @Override
  public void mouseExited(MouseEvent e) {
    source = e.getComponent();

    source.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
  }
 @Override
 public void show() {
   component.setCursor(cursor);
 }
Esempio n. 29
0
 /** Sets the cursor on this InputManager's input component. */
 public void setCursor(Cursor cursor) {
   comp.setCursor(cursor);
 }
Esempio n. 30
0
 private void swapCursor() {
   Cursor tmp = borderOwner.getCursor();
   borderOwner.setCursor(otherCursor);
   otherCursor = tmp;
 }