Пример #1
0
 private void initKeyMap() {
   InputMap map = this.getInputMap();
   int shift = InputEvent.SHIFT_MASK;
   int ctrl = InputEvent.CTRL_MASK;
   map.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, shift), SikuliEditorKit.deIndentAction);
   map.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, ctrl), SikuliEditorKit.deIndentAction);
 }
Пример #2
0
 /**
  * The Excel Adapter is constructed with a JTable on which it enables Copy-Paste and acts as a
  * Clipboard listener.
  */
 public ExcelAdapter(JTable myJTable) {
   jTable1 = myJTable;
   KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
   // Identifying the copy KeyStroke user can modify this
   // to copy on some other Key combination.
   KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
   // Identifying the Paste KeyStroke user can modify this
   // to copy on some other Key combination.
   jTable1.registerKeyboardAction(this, "Copy", copy, JComponent.WHEN_FOCUSED);
   jTable1.registerKeyboardAction(this, "Paste", paste, JComponent.WHEN_FOCUSED);
   system = Toolkit.getDefaultToolkit().getSystemClipboard();
 }
Пример #3
0
  /**
   * Returns a keystroke for the specified string.
   *
   * @param cmd command
   * @return keystroke
   */
  public static KeyStroke keyStroke(final GUICommand cmd) {
    final Object sc = cmd.shortcuts();
    if (sc == null) return null;

    final String scut;
    if (sc instanceof BaseXKeys[]) {
      final BaseXKeys[] scs = (BaseXKeys[]) sc;
      if (scs.length == 0) return null;
      scut = scs[0].shortCut();
    } else {
      scut = Util.info(sc, META);
    }
    final KeyStroke ks = KeyStroke.getKeyStroke(scut);
    if (ks == null) Util.errln("Could not assign shortcut: " + sc + " / " + scut);
    return ks;
  }
Пример #4
0
  // {{{ HyperSearchResults constructor
  public HyperSearchResults(View view) {
    super(new BorderLayout());

    this.view = view;

    caption = new JLabel();

    Box toolBar = new Box(BoxLayout.X_AXIS);
    toolBar.add(caption);
    toolBar.add(Box.createGlue());

    ActionHandler ah = new ActionHandler();

    highlight = new RolloverButton();
    highlight.setToolTipText(jEdit.getProperty("hypersearch-results.highlight.label"));
    highlight.addActionListener(ah);
    toolBar.add(highlight);

    clear =
        new RolloverButton(
            GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.clear.icon")));
    clear.setToolTipText(jEdit.getProperty("hypersearch-results.clear.label"));
    clear.addActionListener(ah);
    toolBar.add(clear);

    multi = new RolloverButton();
    multi.setToolTipText(jEdit.getProperty("hypersearch-results.multi.label"));
    multi.addActionListener(ah);
    toolBar.add(multi);

    stop =
        new RolloverButton(
            GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.stop.icon")));
    stop.setToolTipText(jEdit.getProperty("hypersearch-results.stop.label"));
    stop.addActionListener(ah);
    toolBar.add(stop);
    stop.setEnabled(false);

    add(BorderLayout.NORTH, toolBar);

    resultTreeRoot = new DefaultMutableTreeNode();
    resultTreeModel = new DefaultTreeModel(resultTreeRoot);
    resultTree = new HighlightingTree(resultTreeModel);
    resultTree.setToolTipText(null);
    resultTree.setCellRenderer(new ResultCellRenderer());
    resultTree.setVisibleRowCount(16);
    resultTree.setRootVisible(false);
    resultTree.setShowsRootHandles(true);
    // the ESCAPE keystroke is assigned to hideTip action by swing
    // it breaks the action usually assigned to close-docking-area by jEdit,
    // so we remove this keystroke binding bug #1955140
    KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    resultTree.getInputMap().remove(keyStroke);
    // looks bad with the OS X L&F, apparently...
    if (!OperatingSystem.isMacOSLF()) resultTree.putClientProperty("JTree.lineStyle", "Angled");

    resultTree.setEditable(false);

    resultTree.addKeyListener(new KeyHandler());
    resultTree.addMouseListener(new MouseHandler());

    JScrollPane scrollPane = new JScrollPane(resultTree);
    Dimension dim = scrollPane.getPreferredSize();
    dim.width = 400;
    scrollPane.setPreferredSize(dim);
    add(BorderLayout.CENTER, scrollPane);
    resultTree.setTransferHandler(new ResultTreeTransferHandler());
  } // }}}
Пример #5
0
  public HtmlBlock(
      int listNesting,
      Color background,
      RenderState parentRenderState,
      boolean opaque,
      HtmlParserContext pcontext,
      FrameContext frameContext) {
    this.frameContext = frameContext;
    this.rblock = new RBlock(listNesting, parentRenderState, pcontext, frameContext, this, null);
    this.setOpaque(opaque);
    this.setBackground(background);
    ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = e.getActionCommand();
            if ("copy".equals(command)) {
              String selection = HtmlBlock.this.getSelectionText();
              if (selection != null) {
                Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                clipboard.setContents(new StringSelection(selection), HtmlBlock.this);
              }
            }
          }
        };
    this.registerKeyboardAction(
        actionListener,
        "copy",
        KeyStroke.getKeyStroke(KeyEvent.VK_COPY, 0),
        JComponent.WHEN_FOCUSED);
    this.registerKeyboardAction(
        actionListener,
        "copy",
        KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
        JComponent.WHEN_FOCUSED);
    this.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent e) {
            onMouseClick(e);
          }

          public void mouseEntered(MouseEvent e) {}

          public void mouseExited(MouseEvent e) {
            onMouseExited(e);
          }

          public void mousePressed(MouseEvent e) {
            onMousePressed(e);
          }

          public void mouseReleased(MouseEvent e) {
            onMouseReleased(e);
          }
        });
    this.addMouseMotionListener(
        new MouseMotionListener() {
          /* (non-Javadoc)
           * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
           */
          public void mouseDragged(MouseEvent e) {
            onMouseDragged(e);
          }

          /* (non-Javadoc)
           * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
           */
          public void mouseMoved(MouseEvent arg0) {}
        });
  }