Beispiel #1
0
  /**
   * Handle the keys which change the terminal font size.
   *
   * @param event The key event (key pressed/released/typed)
   * @param ch The key code (for pressed/release events) or character (for key typed events)
   */
  private boolean handleFontsizeKeys(KeyEvent event, int ch) {
    boolean handled = false;

    // Note the following works because VK_EQUALS, VK_PLUS and VK_MINUS
    // are actually defined as their ASCII (and thus unicode) equivalent.
    // Since they are final constants this cannot become untrue in the
    // future.

    switch (ch) {
      case KeyEvent.VK_EQUALS: // increase the font size
      case KeyEvent.VK_PLUS: // increase the font size (non-uk keyboards)
        if (event.getModifiers() == SHORTCUT_MASK) {
          PrefMgr.setEditorFontSize(terminalFontSize + 1);
          event.consume();
          handled = true;
          break;
        }

      case KeyEvent.VK_MINUS: // decrease the font size
        if (event.getModifiers() == SHORTCUT_MASK) {
          PrefMgr.setEditorFontSize(terminalFontSize - 1);
          event.consume();
          handled = true;
          break;
        }
    }

    return handled;
  }
Beispiel #2
0
 private void PrecioKeyTyped(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_PrecioKeyTyped
   // TODO add your handling code here:
   int cont = 0;
   char caracter = evt.getKeyChar();
   if (cont == 0) {
     if (((caracter < '0') || (caracter > '9'))
         && (caracter != KeyEvent.VK_BACK_SPACE)
         && (caracter != '.')) {
       evt.consume();
     } else if (caracter == '.') {
       String s = Precio.getText();
       if (s.length() == 0) {
         Precio.setText(0 + s);
       }
       cont++;
     }
   } else {
     if ((caracter < '0' || caracter > '9')) evt.consume();
   }
   if ((int) caracter == 8) {
     if (Precio.getText().equals("")) {
       cont = 0;
     }
   }
 } // GEN-LAST:event_PrecioKeyTyped
Beispiel #3
0
    @Override
    public void keyPressed(KeyEvent e, Point2D imagePoint, IcyCanvas canvas) {
      if (!isActiveFor(canvas)) return;

      if (!e.isConsumed()) {
        switch (e.getKeyCode()) {
          case KeyEvent.VK_ESCAPE:
            // shape selected ? --> unselect the ROI
            if (ROI2D.this.selected) {
              ROI2D.this.setSelected(false, false);
              e.consume();
            }
            break;

          case KeyEvent.VK_DELETE:
          case KeyEvent.VK_BACK_SPACE:
            // roi selected ?
            if (ROI2D.this.selected) {
              // remove selected control point if there is one
              if (removeSelectedPoint(canvas, imagePoint)) e.consume();
              else {
                // else simply delete ROI
                ROI2D.this.delete();
                e.consume();
              }
            }
            // roi focused ? --> delete ROI
            else if (ROI2D.this.focused) {
              ROI2D.this.delete();
              e.consume();
            }
            break;
        }
      }
    }
 private void tf_valorKeyTyped(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_tf_valorKeyTyped
   // TODO add your handling code here:
   if (list_filtros.getSelectedItem() == "Nombre") {
     ch = evt.getKeyChar();
     if (Character.isDigit(ch)) {
       getToolkit().beep();
       evt.consume();
     }
   }
   if (list_filtros.getSelectedItem() == "Empleado") {
     ch = evt.getKeyChar();
     if (Character.isDigit(ch)) {
       getToolkit().beep();
       evt.consume();
     } else {
       if (list_filtros.getSelectedItem() == "Código") {
         ch = evt.getKeyChar();
         if (!Character.isDigit(ch)) {
           getToolkit().beep();
           evt.consume();
         }
       }
     }
   }
 } // GEN-LAST:event_tf_valorKeyTyped
Beispiel #5
0
    @Override
    public void keyPressed(KeyEvent evt) {
      if (evt.isConsumed()) return;
      Component comp = getFocusOwner();
      if (evt.getKeyCode() == KeyEvent.VK_ENTER && enterEnabled) {
        while (comp != null) {
          if (comp instanceof JComboBox) {
            JComboBox<?> combo = (JComboBox<?>) comp;
            if (combo.isEditable()) {
              Object selected = combo.getEditor().getItem();
              if (selected != null) combo.setSelectedItem(selected);
            }

            if (combo.isPopupVisible()) {
              evt.consume();
              combo.setPopupVisible(false);
            }
            return;
          }
          // TODO: add other classes that need custom key handling here.
          comp = comp.getParent();
        }
        evt.consume();
        ok();
      } else if (evt.getKeyCode() == KeyEvent.VK_ESCAPE || isCloseBufferShortcut(evt)) {
        evt.consume();
        if (comp instanceof JComboBox) {
          JComboBox<?> combo = (JComboBox<?>) comp;
          if (combo.isPopupVisible()) combo.setPopupVisible(false);
          else cancel();
        } else cancel();
      }
    }
Beispiel #6
0
 @Override
 public void keyTyped(KeyEvent ke) {
   if (ke.getSource() == jtxtCodigo) {
     char c;
     // capturar el caracter digitado
     c = ke.getKeyChar();
     if (jtxtCodigo.getText().length() >= 5
         || (c < '0' || c > '9')
             && (c != (char) KeyEvent.VK_BACK_SPACE)
             && (c != (char) KeyEvent.VK_DELETE)) {
       ke.consume(); // ignora el caracter digitado
       Toolkit.getDefaultToolkit().beep();
     }
   }
   if (ke.getSource() == jtxtPrecio) {
     char c;
     // capturar el caracter digitado
     c = ke.getKeyChar();
     if (jtxtPrecio.getText().length() >= 10
         || (c < '0' || c > '9')
             && (c < 'a' || c > 'z')
             && (c < 'A' || c > 'Z')
             && (c != (char) KeyEvent.VK_BACK_SPACE)
             && (c != (char) KeyEvent.VK_DELETE)) {
       ke.consume(); // ignora el caracter digitado
       Toolkit.getDefaultToolkit().beep();
     }
   }
 }
Beispiel #7
0
  @Override
  public void keyPressed(KeyEvent evt) {
    Figure f = getOwner();
    if (f.isTransformable()) {
      AffineTransform tx = new AffineTransform();

      switch (evt.getKeyCode()) {
        case KeyEvent.VK_UP:
          tx.translate(0, -1);
          evt.consume();
          break;
        case KeyEvent.VK_DOWN:
          tx.translate(0, +1);
          evt.consume();
          break;
        case KeyEvent.VK_LEFT:
          tx.translate(-1, 0);
          evt.consume();
          break;
        case KeyEvent.VK_RIGHT:
          tx.translate(+1, 0);
          evt.consume();
          break;
      }
      f.willChange();
      f.transform(tx);
      f.changed();
      fireUndoableEditHappened(new TransformEdit(f, tx));
    }
  }
Beispiel #8
0
 // #{GxwCbkHost_
 public static final boolean ExecKeyEvent(GxwCbkHost host, KeyEvent e) {
   boolean rv = true;
   int id = e.getID(), val = e.getKeyCode();
   boolean isAltF4 = false;
   if (e.isAltDown() && val == IptKey_.F4.Val()) {
     isAltF4 = true;
   }
   if (id == KeyEvent.KEY_TYPED) {
     IptEvtDataKeyHeld keyHeldData = IptEvtDataKeyHeld.char_(e.getKeyChar());
     rv = host.KeyHeldCbk(keyHeldData);
     if (keyHeldData.Handled()) rv = false;
   } else {
     if (e.isShiftDown()) val |= IptKey_.Shift.Val();
     if (e.isControlDown()) val |= IptKey_.Ctrl.Val();
     if (e.isAltDown()) val |= IptKey_.Alt.Val();
     IptEvtDataKey keyData = IptEvtDataKey.int_(val);
     //			Tfds.Write(e.getKeyChar(), e.getKeyCode(), val, id);
     if (id == KeyEvent.KEY_PRESSED) rv = host.KeyDownCbk(keyData);
     else if (id == KeyEvent.KEY_RELEASED) rv = host.KeyUpCbk(keyData);
     if (keyData.Handled()) rv = false; // was false
   }
   if (isAltF4) {
     e.consume();
   }
   if (e.getKeyCode() == KeyEvent.VK_ALT)
     e.consume(); // force consume of alt-keys; occurs when alt-f4ing out of video app (though
   // not audio app)
   return rv;
 }
 @Override
 public void keyPressed(KeyEvent e) {
   TreePath path = myTree.getLeadSelectionPath();
   if (path == null) return;
   final Object lastComponent = path.getLastPathComponent();
   if (e.getKeyCode() == KeyEvent.VK_ENTER) {
     if (lastComponent instanceof ParentNode) return;
     doOKAction();
     e.consume();
   } else if (e.getKeyCode() == KeyEvent.VK_INSERT) {
     if (lastComponent instanceof ElementNode) {
       final DefaultMutableTreeNode node = (DefaultMutableTreeNode) lastComponent;
       if (!mySelectedNodes.contains(node)) {
         if (node.getNextNode() != null) {
           myTree.setSelectionPath(new TreePath(node.getNextNode().getPath()));
         }
       } else {
         if (node.getNextNode() != null) {
           myTree.removeSelectionPath(new TreePath(node.getPath()));
           myTree.setSelectionPath(new TreePath(node.getNextNode().getPath()));
           myTree.repaint();
         }
       }
       e.consume();
     }
   }
 }
Beispiel #10
0
    @Override
    public void keyPressed(KeyEvent evt) {
      switch (evt.getKeyCode()) {
        case KeyEvent.VK_SPACE:
          goToSelectedNode(M_OPEN);

          // f**k me dead
          EventQueue.invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  resultTree.requestFocus();
                }
              });

          evt.consume();
          break;
        case KeyEvent.VK_ENTER:
          goToSelectedNode(M_OPEN);
          evt.consume();
          break;
        case KeyEvent.VK_DELETE:
          removeSelectedNode();
          evt.consume();
          break;
        default:
          break;
      }
    }
    /**
     * I made this method public in order to be able to call it from the outside. This is needed for
     * delegating calls.
     */
    public void processKeyEvent(KeyEvent e) {
      int i = e.getKeyCode();
      if (i == KeyEvent.VK_BACK_SPACE && getDocument().getLength() == 0) {
        e.consume();
        return;
      }
      if (i == KeyEvent.VK_ENTER
          || i == KeyEvent.VK_ESCAPE
          || i == KeyEvent.VK_PAGE_UP
          || i == KeyEvent.VK_PAGE_DOWN
          || i == KeyEvent.VK_LEFT
          || i == KeyEvent.VK_RIGHT) {
        manageSearchPopup(null);
        if (i == KeyEvent.VK_ESCAPE) {
          e.consume();
        }
        return;
      }

      if (isUpDownHomeEnd(i)) {
        e.consume();
        return;
      }

      super.processKeyEvent(e);
      if (i == KeyEvent.VK_BACK_SPACE) {
        e.consume();
      }
    }
Beispiel #12
0
  public void keyPressed(KeyEvent e) {
    KeyStroke currentStroke = KeyStroke.getKeyStrokeForEvent(e);

    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
      TreePath path = ((JTree) e.getSource()).getSelectionPath();
      if (path == null) {
        return;
      }
      AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();

      if (node instanceof IWorkspaceNodeActionListener) {
        ((IWorkspaceNodeActionListener) node)
            .handleAction(
                new WorkspaceActionEvent(
                    node, WorkspaceActionEvent.WSNODE_OPEN_DOCUMENT, 0, 0, e.getComponent()));
        e.consume();
      }
    } else {
      for (HotKeyIdentifier id : actionKeyMap.keySet()) {
        if (currentStroke.equals(id.getKeyStroke())) {
          if (id.accept(e)) {
            AFreeplaneAction action = WorkspaceController.getAction(actionKeyMap.get(id));
            if (action != null) {
              action.actionPerformed(new ActionEvent(e.getSource(), 0, null));
            } else {
              LogUtils.info("No action set for: " + id.getKeyStroke());
            }
          }
          e.consume();
          break;
        }
      }
    }
  }
Beispiel #13
0
    public void keyTyped(KeyEvent e) {
      char c = e.getKeyChar();

      // as a coding convenience, create a reference to the text component
      // that is typecast to JTextComponent.  this is not essential, as we
      // could typecast every reference, but this makes the code cleaner
      JTextComponent _theComponent = (JTextComponent) DataTypeTime.this._textComponent;
      String text = _theComponent.getText();

      // tabs and newlines get put into the text before this check,
      // so remove them
      // This only applies to Popup editing since these chars are
      // not passed to this level by the in-cell editor.
      if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) {
        // remove all instances of the offending char
        int index = text.indexOf(c);
        if (index == text.length() - 1) {
          text = text.substring(0, text.length() - 1); // truncate string
        } else {
          text = text.substring(0, index) + text.substring(index + 1);
        }
        ((IRestorableTextComponent) _theComponent).updateText(text);
        _beepHelper.beep(_theComponent);
        e.consume();
      }

      // handle cases of null
      // The processing is different when nulls are allowed and when they are not.
      //

      if (DataTypeTime.this._isNullable) {

        // user enters something when field is null
        if (text.equals("<null>")) {
          if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
            // delete when null => original value
            DataTypeTime.this._textComponent.restoreText();
            e.consume();
          } else {
            // non-delete when null => clear field and add text
            DataTypeTime.this._textComponent.updateText("");
            // fall through to normal processing of this key stroke
          }
        } else {
          // check for user deletes last thing in field
          if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {
            if (text.length() <= 1) {
              // about to delete last thing in field, so replace with null
              DataTypeTime.this._textComponent.updateText("<null>");
              e.consume();
            }
          }
        }
      } else {
        // field is not nullable
        //
        handleNotNullableField(text, c, e, _textComponent);
      }
    }
Beispiel #14
0
  @Override
  public void keyTyped(KeyEvent event) {
    // We handle most things we are interested in here. The InputMap filters out
    // most other unwanted actions (but allows copy/paste).

    char ch = event.getKeyChar();

    if ((!isMacOs) && handleFontsizeKeys(event, ch)) {
      // Note: On Mac OS with Java 7+, we don't see command+= / command+- as a
      // key-typed event and so we handle it in keyReleased instead.
      return;
    }

    if ((event.getModifiers() & Event.META_MASK) != 0) {
      return; // return without consuming the event
    }
    if (isActive) {
      switch (ch) {
        case 4: // CTRL-D (unix/Mac EOF)
        case 26: // CTRL-Z (DOS/Windows EOF)
          buffer.signalEOF();
          writeToTerminal("\n");
          event.consume();
          break;

        case '\b': // backspace
          if (buffer.backSpace()) {
            try {
              int length = text.getDocument().getLength();
              text.replaceRange("", length - 1, length);
            } catch (Exception exc) {
              Debug.reportError("bad location " + exc);
            }
          }
          event.consume();
          break;

        case '\r': // carriage return
        case '\n': // newline
          if (buffer.putChar('\n')) {
            writeToTerminal(String.valueOf(ch));
            buffer.notifyReaders();
          }
          event.consume();
          break;

        default:
          if (ch >= 32) {
            if (buffer.putChar(ch)) {
              writeToTerminal(String.valueOf(ch));
            }
            event.consume();
          }
          break;
      }
    }
  }
Beispiel #15
0
    public void processKeyEvent(KeyEvent evt) {
      evt = KeyEventWorkaround.processKeyEvent(evt);
      if (evt == null) return;

      switch (evt.getID()) {
        case KeyEvent.KEY_TYPED:
          char ch = evt.getKeyChar();
          if (!nonDigit && Character.isDigit(ch)) {
            super.processKeyEvent(evt);
            repeat = true;
            repeatCount = Integer.parseInt(action.getText());
          } else {
            nonDigit = true;
            if (repeat) {
              passToView(evt);
            } else super.processKeyEvent(evt);
          }
          break;
        case KeyEvent.KEY_PRESSED:
          int keyCode = evt.getKeyCode();
          if (evt.isActionKey()
              || evt.isControlDown()
              || evt.isAltDown()
              || evt.isMetaDown()
              || keyCode == KeyEvent.VK_BACK_SPACE
              || keyCode == KeyEvent.VK_DELETE
              || keyCode == KeyEvent.VK_ENTER
              || keyCode == KeyEvent.VK_TAB
              || keyCode == KeyEvent.VK_ESCAPE) {
            nonDigit = true;
            if (repeat) {
              passToView(evt);
              break;
            } else if (keyCode == KeyEvent.VK_TAB) {
              complete(true);
              evt.consume();
            } else if (keyCode == KeyEvent.VK_ESCAPE) {
              evt.consume();
              if (popup != null) {
                popup.dispose();
                popup = null;
                action.requestFocus();
              } else {
                if (temp) view.removeToolBar(ActionBar.this);
                view.getEditPane().focusOnTextArea();
              }
              break;
            } else if ((keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN)
                && popup != null) {
              popup.list.processKeyEvent(evt);
              break;
            }
          }
          super.processKeyEvent(evt);
          break;
      }
    }
 public void keyTyped(KeyEvent e) {
   String numStr = "0123456789" + (char) 8; // 只允许输入数字与退格键
   if (numStr.indexOf(e.getKeyChar()) < 0) {
     e.consume();
   }
   if (keepmoney.getText().length() > 2 || keepmoney.getText().length() < 0) {
     e.consume();
   }
 }
  /**
   * Handle a key pressed event. This will look up the binding for the key stroke and execute it.
   */
  @Override
  @SuppressWarnings("unchecked")
  public void keyPressed(KeyEvent evt) {
    int keyCode = evt.getKeyCode();
    int modifiers = evt.getModifiers();

    if (keyCode == KeyEvent.VK_CONTROL
        || keyCode == KeyEvent.VK_SHIFT
        || keyCode == KeyEvent.VK_ALT
        || keyCode == KeyEvent.VK_META) return;

    if ((modifiers & InputEvent.SHIFT_MASK) != 0
        || (modifiers & InputEvent.CTRL_MASK) != 0
        || evt.isActionKey()
        || keyCode == KeyEvent.VK_BACK_SPACE
        || keyCode == KeyEvent.VK_DELETE
        || keyCode == KeyEvent.VK_ENTER
        || keyCode == KeyEvent.VK_TAB
        || keyCode == KeyEvent.VK_ESCAPE) {

      if (grabAction != null) {
        handleGrabAction(evt);
        return;
      }

      KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, modifiers);
      Object o = currentBindings.get(keyStroke);
      if (o == null) {
        // Don't beep if the user presses some
        // key we don't know about unless a
        // prefix is active. Otherwise it will
        // beep when caps lock is pressed, etc.
        if (currentBindings != bindings) {
          Toolkit.getDefaultToolkit().beep();
          // F10 should be passed on, but C+e F10
          // shouldn't
          repeatCount = 0;
          repeat = false;
          evt.consume();
        }
        currentBindings = bindings;
        return;
      } else if (o instanceof ActionListener) {
        currentBindings = bindings;

        executeAction(((ActionListener) o), evt.getSource(), null);

        evt.consume();
        return;
      } else if (o instanceof Hashtable) {
        currentBindings = (Hashtable) o;
        evt.consume();
        return;
      }
    }
  }
 public void validarNumerosETamanho(
     java.awt.event.KeyEvent evt, javax.swing.JTextField campo, int maxCaracteres) {
   if (!numeros.contains(
       evt.getKeyChar() + "")) { // se o carácter que gerou o evento não estiver na lista
     evt.consume();
   }
   if (campo.getText().length() >= maxCaracteres) {
     evt.consume();
   }
 }
Beispiel #19
0
 public void processKeyEvent(KeyEvent ev) {
   char c = ev.getKeyChar();
   if ((Character.isLetter(c) && !ev.isAltDown()) || badchars.indexOf(c) > -1) {
     ev.consume();
     return;
   }
   if (c == '-' && getDocument().getLength() > 0) ev.consume();
   else {
     super.processKeyEvent(ev);
   }
 }
Beispiel #20
0
 private void diafinKeyTyped(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_diafinKeyTyped
   int Limite = 2;
   char K;
   K = evt.getKeyChar();
   if (diafin.getText().length() == Limite) {
     evt.consume();
   }
   if (K < '0' || K > '9') {
     evt.consume();
   }
 } // GEN-LAST:event_diafinKeyTyped
Beispiel #21
0
  @Override
  public void keyTyped(KeyEvent e) {
    // ���ڸ� �޵���
    char c = e.getKeyChar();

    if (!Character.isDigit(c)) {
      e.consume();
      return;
    }

    if (m_LidText.getText().length() == 3) e.consume();
  }
Beispiel #22
0
 private void camponombreKeyTyped(
     java.awt.event.KeyEvent evt) { // GEN-FIRST:event_camponombreKeyTyped
   int Limite = 50;
   char K;
   K = evt.getKeyChar();
   if (camponombre.getText().length() == Limite) {
     evt.consume();
   }
   if (!(K < '0' || K > '9')) {
     evt.consume();
   }
 } // GEN-LAST:event_camponombreKeyTyped
 @Override
 public void keyPressed(KeyEvent e) {
   if (!e.isConsumed()) {
     if (e.getKeyCode() == 38) { // UP
       parentForm.focusPreviousColumnPanel(DatasetRecordEditorColumnForm.this);
       e.consume();
     } else if (e.getKeyCode() == 40) { // DOWN
       parentForm.focusNextColumnPanel(DatasetRecordEditorColumnForm.this);
       e.consume();
     }
   }
 }
Beispiel #24
0
  @Override
  public void keyPressed(KeyEvent e) {
    if (e.isConsumed()) return;
    if (ren.VisibleActorCount() == 0) return;

    vtkActorCollection ac;
    vtkActor anActor;
    int i;

    switch (e.getKeyChar()) {
      case 'r': // reset camera
        resetCamera();
        repaint();
        // consume event
        e.consume();
        break;

      case 'w': // wireframe mode
        lock();
        try {
          ac = ren.GetActors();
          ac.InitTraversal();
          for (i = 0; i < ac.GetNumberOfItems(); i++) {
            anActor = ac.GetNextActor();
            anActor.GetProperty().SetRepresentationToWireframe();
          }
        } finally {
          unlock();
        }
        repaint();
        // consume event
        e.consume();
        break;

      case 's':
        lock();
        try {
          ac = ren.GetActors();
          ac.InitTraversal();
          for (i = 0; i < ac.GetNumberOfItems(); i++) {
            anActor = ac.GetNextActor();
            anActor.GetProperty().SetRepresentationToSurface();
          }
        } finally {
          unlock();
        }
        repaint();
        // consume event
        e.consume();
        break;
    }
  }
 private void tf_telefKeyTyped(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_tf_telefKeyTyped
   // TODO add your handling code here:
   int limite = 10;
   if (tf_telef.getText().length() == limite) {
     getToolkit().beep();
     evt.consume(); // se le ignora
   }
   ch = evt.getKeyChar();
   if (!Character.isDigit(ch)) {
     getToolkit().beep();
     evt.consume();
   }
 } // GEN-LAST:event_tf_telefKeyTyped
Beispiel #26
0
  // Handle the keystrokes
  public void keyTyped(KeyEvent e) {

    switch (e.getKeyChar()) {
      case 'h':
        gl.matrixMode(GL.MODELVIEW); /* manipulate modelview matrix  */
        gl.rotate(15.0, 0.0, 1.0, 0.0);
        break;
      case 'j':
        gl.matrixMode(GL.MODELVIEW); /* manipulate modelview matrix  */
        gl.rotate(15.0, 1.0, 0.0, 0.0);
        break;
      case 'k':
        gl.matrixMode(GL.MODELVIEW); /* manipulate modelview matrix  */
        gl.rotate(-15.0, 1.0, 0.0, 0.0);
        break;
      case 'l':
        gl.matrixMode(GL.MODELVIEW); /* manipulate modelview matrix  */
        gl.rotate(-15.0, 0.0, 1.0, 0.0);
        break;
      case '+':
        gl.matrixMode(GL.PROJECTION); /* manipulate Projection matrix  */
        gl.translate(0.0, 0.0, 0.5);
        e.consume();
        break;
      case '-':
        gl.matrixMode(GL.PROJECTION); /* manipulate Projection matrix  */
        gl.translate(0.0, 0.0, -0.5);
        e.consume();
        break;
      case 's':
        if (r_thread == null) {
          r_thread = new Thread(this);
          r_thread.start();
        }
        break;
      case 'p':
        if (r_thread != null) {
          r_thread.interrupt();
          r_thread = null;
        }
        break;
      case 27: /* Esc will quit */
        System.exit(1);
        break;
      default:
        break;
    }
    e.consume();
    display();
  }
 @Override
 protected void processKeyEvent(KeyEvent e) {
   // TODO: Convert into Actions and put into InputMap/ActionMap?
   final int hexColumns = model.getNumberOfHexColumns();
   final long lastOffset = model.getSize() - 1;
   final boolean extend = e.isShiftDown();
   if (e.getID() == KeyEvent.KEY_PRESSED) {
     switch (e.getKeyCode()) {
       case KeyEvent.VK_LEFT:
         long offs = leadSelectionIndex > 0 ? leadSelectionIndex - 1 : 0;
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_RIGHT:
         offs = Math.min(leadSelectionIndex + 1, lastOffset);
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_UP:
         offs = Math.max(leadSelectionIndex - hexColumns, 0);
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_DOWN:
         offs = Math.min(leadSelectionIndex + hexColumns, lastOffset);
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_PAGE_DOWN:
         int visibleRowCount = getVisibleRect().height / getRowHeight();
         offs = Math.min(leadSelectionIndex + visibleRowCount * hexColumns, lastOffset);
         changeSelectionByOffset(offs, extend);
         e.consume();
         break;
       case KeyEvent.VK_PAGE_UP:
         visibleRowCount = getVisibleRect().height / getRowHeight();
         offs = Math.max(leadSelectionIndex - visibleRowCount * hexColumns, 0);
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_HOME:
         offs = (leadSelectionIndex / hexColumns) * hexColumns;
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_END:
         offs = (leadSelectionIndex / hexColumns) * hexColumns + hexColumns - 1;
         offs = Math.min(offs, lastOffset);
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_BACK_SPACE:
         // System.out.println();
         // Profiler.print();
         // System.out.println(Profiler.getTime());
         return;
     }
   }
   super.processKeyEvent(e);
 }
  public boolean processKeyTyped(EditorContext editorContext, final KeyEvent keyEvent) {
    EditorComponent nodeEditor = editorContext.getNodeEditorComponent();
    nodeEditor.hideMessageToolTip();

    if (processKeyMaps(editorContext, keyEvent)) {
      return true;
    }

    final EditorCell selectedCell = editorContext.getSelectedCell();
    if (selectedCell != null
        && ((jetbrains.mps.nodeEditor.cells.EditorCell) selectedCell)
            .processKeyTyped(keyEvent, false)) {
      keyEvent.consume();
      return true;
    }

    jetbrains.mps.openapi.editor.cells.CellActionType actionType =
        editorContext.getNodeEditorComponent().getActionType(keyEvent, editorContext);

    if (selectedCell != null) {
      boolean strictMatching =
          jetbrains.mps.openapi.editor.cells.CellActionType.RIGHT_TRANSFORM.equals(actionType)
              || jetbrains.mps.openapi.editor.cells.CellActionType.LEFT_TRANSFORM.equals(
                  actionType);

      if (selectedCell.isErrorState() && strictMatching) {
        if (APICellAdapter.validate(selectedCell, strictMatching, false)) {
          return true;
        }
      }

      if (actionType != null) {
        if (editorContext
            .getEditorComponent()
            .getActionHandler()
            .executeAction(selectedCell, actionType)) {
          return true;
        }
      }
    }

    if (selectedCell != null
        && ((jetbrains.mps.nodeEditor.cells.EditorCell) selectedCell)
            .processKeyTyped(keyEvent, true)) {
      keyEvent.consume();
      return true;
    }

    return false;
  }
Beispiel #29
0
    public void keyPressed(KeyEvent e) {
      TreePath selectionPath = mainTree.getSelectionPath();
      if (selectionPath == null || mainTree.getSelectionCount() == 0) {
        return;
      }

      if (mainTree.getSelectionCount() == 1) {
        SoapUITreeNode lastPathComponent = (SoapUITreeNode) selectionPath.getLastPathComponent();
        ActionList actions = lastPathComponent.getActions();
        if (actions != null) {
          actions.dispatchKeyEvent(e);
        }

        if (!e.isConsumed()) {
          KeyStroke ks = KeyStroke.getKeyStrokeForEvent(e);
          if (ks.equals(UISupport.getKeyStroke("alt C"))) {
            mainTree.collapsePath(selectionPath);
            e.consume();
          } else if (ks.equals(UISupport.getKeyStroke("alt E"))) {
            mainTree.collapsePath(selectionPath);
            int row = mainTree.getSelectionRows()[0];
            TreePath nextPath = mainTree.getPathForRow(row + 1);

            TreePath path = mainTree.getPathForRow(row);
            while (path != null && !path.equals(nextPath)) {
              mainTree.expandRow(row);
              path = mainTree.getPathForRow(++row);
            }

            e.consume();
          }
        }
      } else {
        TreePath[] selectionPaths = mainTree.getSelectionPaths();
        List<ModelItem> targets = new ArrayList<ModelItem>();
        for (TreePath treePath : selectionPaths) {
          SoapUITreeNode node = (SoapUITreeNode) treePath.getLastPathComponent();
          targets.add(node.getModelItem());
        }

        if (targets.size() > 0) {
          ActionList actions =
              ActionListBuilder.buildMultiActions(targets.toArray(new ModelItem[targets.size()]));
          if (actions.getActionCount() > 0) {
            actions.dispatchKeyEvent(e);
          }
        }
      }
    }
Beispiel #30
0
 private void jtfRacionAsignadaKeyTyped(
     java.awt.event.KeyEvent evt) { // GEN-FIRST:event_jtfRacionAsignadaKeyTyped
   // TODO add your handling code here:
   if (!Character.isDigit(evt.getKeyChar()) || evt.getKeyChar() != '.') {
     evt.consume();
   }
 } // GEN-LAST:event_jtfRacionAsignadaKeyTyped