/**
     * There are two special cases where we need to override the default behavior when we begin cell
     * editing. For some reason, when you use the keyboard to enter a cell (tab, enter, arrow keys,
     * etc), the first character that you type after entering the field is NOT passed through the
     * KeyListener mechanism where we have the special handling in the DataTypes. Instead, it is
     * passed through the KeyMap and Action mechanism, and the default Action on the JTextField is
     * to add the character to the end of the existing text, or if it is delete to delete the last
     * character of the existing text. In most cases, this is ok, but there are three special cases
     * of which we only handle two here: - If the data field currently contains "<null>" and the
     * user types a character, we want that character to replace the string "<null>", which
     * represents the null value. In this case we process the event normally, which usually adds the
     * char to the end of the string, then remove the char afterwards. We take this approach rather
     * than just immediately replacing the "<null>" with the char because there are some chars that
     * should not be put into the editable text, such as control-characters. - If the data field
     * contains "<null>" and the user types a delete, we do not want to delete the last character
     * from the string "<null>" since that string represents the null value. In this case we simply
     * ignore the user input. - Whether or not the field initially contains null, we do not run the
     * input validation function for the DataType on the input character. This means that the user
     * can type an illegal character into the field. For example, after entering an Integer field by
     * typing a tab, the user can enter a letter (e.g. "a") into that field. The normal keyListener
     * processing prevents that, but we cannot call it from this point. (More accurately, I cannot
     * figure out how to do it easilly.) Thus the user may enter one character of invalid data into
     * the field. This is not too serious a problem, however, because the normal validation is still
     * done when the user leaves the field and it SQuirreL tries to convert the text into an object
     * of the correct type, so errors of this nature will still be caught. They just won't be
     * prevented.
     */
    public void processKeyEvent(KeyEvent e) {

      // handle special case of delete with <null> contents
      if (e.getKeyChar() == '\b'
          && getEditorComponent() != null
          && ((RestorableJTextField) getEditorComponent()).getText().equals("<null>")) {
        // ignore the user input
        return;
      }

      // generally for KEY_TYPED this means add the typed char to the end of the text,
      // but there are some things (e.g. control chars) that are ignored, so let the
      // normal processing do its thing
      super.processKeyEvent(e);

      // now check to see if the original contents were <null>
      // and we have actually added the input char to the end of it
      if (getEditorComponent() != null) {
        if (e.getID() == KeyEvent.KEY_TYPED
            && ((RestorableJTextField) getEditorComponent()).getText().length() == 7) {
          // check that we did not just add a char to a <null>
          if (((RestorableJTextField) getEditorComponent())
              .getText()
              .equals("<null>" + e.getKeyChar())) {
            // replace the null with just the char
            ((RestorableJTextField) getEditorComponent()).updateText("" + e.getKeyChar());
          }
        }
      }
    }
 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
Esempio n. 3
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();
     }
   }
 }
 private void txtEstablecimientoKeyTyped(
     java.awt.event.KeyEvent evt) { // GEN-FIRST:event_txtEstablecimientoKeyTyped
   // TODO add your handling code here:
   if (!Character.isDigit(evt.getKeyChar()) && evt.getKeyChar() != '\t') {
     evt.consume();
   }
 } // GEN-LAST:event_txtEstablecimientoKeyTyped
Esempio n. 5
0
  /** This method cannot be called directly. */
  public void keyTyped(KeyEvent e) {
    int keyCode = e.getKeyCode();
    System.out.println(keyCode);
    switch (keyCode) {
      case KeyEvent.VK_W:
        // handle up
        System.out.println("up?");
        break;
      case KeyEvent.VK_DOWN:
        // handle down
        break;
      case KeyEvent.VK_LEFT:
        // handle left
        break;
      case KeyEvent.VK_RIGHT:
        // handle right
        break;
    }
    System.out.println(e.getKeyChar());
    if (e.getKeyChar() == KeyEvent.VK_UP) {
      System.out.println("up arrow pressed");
    }

    synchronized (keyLock) {
      keysTyped.addFirst(e.getKeyChar());
    }
  }
Esempio n. 6
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
Esempio n. 7
0
  @Override
  public void keyTyped(final KeyEvent e) {
    if (undo == null || control(e) || DELNEXT.is(e) || DELPREV.is(e) || ESCAPE.is(e)) return;

    text.pos(text.cursor());
    // string to be added
    String ch = String.valueOf(e.getKeyChar());

    // remember if marked text is to be deleted
    boolean del = true;
    final byte[] txt = text.text();
    if (TAB.is(e)) {
      if (text.marked()) {
        // check if lines are to be indented
        final int s = Math.min(text.pos(), text.start());
        final int l = Math.max(text.pos(), text.start()) - 1;
        for (int p = s; p <= l && p < txt.length; p++) del &= txt[p] != '\n';
        if (!del) {
          text.indent(s, l, e.isShiftDown());
          ch = null;
        }
      } else {
        boolean c = true;
        for (int p = text.pos() - 1; p >= 0 && c; p--) {
          final byte b = txt[p];
          c = ws(b);
          if (b == '\n') break;
        }
        if (c) ch = "  ";
      }
    }

    // delete marked text
    if (text.marked() && del) text.delete();

    if (ENTER.is(e)) {
      // adopt indentation from previous line
      final StringBuilder sb = new StringBuilder(1).append(e.getKeyChar());
      int s = 0;
      for (int p = text.pos() - 1; p >= 0; p--) {
        final byte b = txt[p];
        if (b == '\n') break;
        if (b == '\t') {
          s += 2;
        } else if (b == ' ') {
          s++;
        } else {
          s = 0;
        }
      }
      for (int p = 0; p < s; p++) sb.append(' ');
      ch = sb.toString();
    }

    if (ch != null) text.add(ch);
    text.setCaret();
    rend.calc();
    showCursor(2);
    e.consume();
  }
Esempio n. 8
0
  protected boolean processKeyBinding(
      javax.swing.KeyStroke ks, java.awt.event.KeyEvent e, int condition, boolean pressed) {
    // live search in current parent node
    if ((Character.isLetterOrDigit(e.getKeyChar())) && ks.isOnKeyRelease()) {
      char keyChar = e.getKeyChar();

      // search term
      String search = ("" + keyChar).toLowerCase();

      // try to find node with matching searchterm plus the search before
      int nextIndexMatching = getNextIndexMatching(cachedSearchKey + search);

      // if we did not find anything, try to find search term only: restart!
      if (nextIndexMatching < 0) {
        nextIndexMatching = getNextIndexMatching(search);
        cachedSearchKey = "";
      }
      // if we found a node, select it, make it visible and return true
      if (nextIndexMatching >= 0) {

        // store found treepath
        cachedSearchKey = cachedSearchKey + search;
        setSelectedIndex(nextIndexMatching);
        return true;
      }
      cachedSearchKey = "";
      return true;
    }
    return super.processKeyBinding(ks, e, condition, pressed);
  }
    @Override
    public void keyPressed(KeyEvent e) {
      super.keyPressed(e);
      keyPressed.add(Key.getKey(e.getKeyCode()));

      char c = e.getKeyChar();
      if (Character.isDefined(c)) charPressed.add(e.getKeyChar());
    }
 public void type(KeyEvent ev) {
   setmods(ev);
   if (keygrab == null) {
     if (!root.type(ev.getKeyChar(), ev)) root.globtype(ev.getKeyChar(), ev);
   } else {
     keygrab.type(ev.getKeyChar(), ev);
   }
 }
Esempio n. 11
0
  private void campoValorKeyTyped(
      java.awt.event.KeyEvent evt) { // GEN-FIRST:event_campoValorKeyTyped
    if ((!numeros.contains(evt.getKeyChar() + "") && evt.getKeyChar() != '.')
        || campoValor.getText().length() >= maxCaracteresValor) {

      evt.consume();
    }
  } // GEN-LAST:event_campoValorKeyTyped
Esempio n. 12
0
 @Override
 public void keyTyped(KeyEvent ke) {
   if (ke.getKeyChar() == 'r') {
     setUpPlanets();
     repaint();
   } else if (ke.getKeyChar() == ' ') {
     applyBoost = true;
   }
 }
Esempio n. 13
0
public void keyPressed( KeyEvent e )
    {
      if (readonly)
	return;
      if (e.getKeyChar() == '\033')
	Abort ();
      else if (e.getKeyChar() == 'l')
	Layout (null);
    }
Esempio n. 14
0
 @Override
 protected void processKeyEvent(KeyEvent e) {
   if (e.getID() == KeyEvent.KEY_TYPED) {
     if (!Character.isDigit(e.getKeyChar()) && !(!positiveOnly && e.getKeyChar() == '-')) {
       e.consume();
     }
   }
   super.processKeyEvent(e);
 }
Esempio n. 15
0
  @Override
  public void keyTyped(KeyEvent e) {

    if (e.getKeyChar() == KeyEvent.VK_BACK_SPACE && TitleMenu.ip.length() > 0) {
      TitleMenu.ip = TitleMenu.ip.substring(0, TitleMenu.ip.length() - 1);
    } else {
      TitleMenu.ip += e.getKeyChar();
    }
  }
Esempio n. 16
0
 @Override
 public void keyTyped(KeyEvent e) {
   String s = "" + e.getKeyChar();
   if (s.matches("\\p{Graph}") || s.matches("\\p{Space}")) {
     position = getCursorPosition();
     controller.sendInsertRequest(
         currentDocID, position, "" + e.getKeyChar(), isBold, isItalic, isUnderline);
     updateDocToDataModel();
   }
 }
Esempio n. 17
0
 public void keyTyped(java.awt.event.KeyEvent e) {
   if (e.getKeyChar() != java.awt.event.KeyEvent.CHAR_UNDEFINED
       && !e.isActionKey()
       && (e.getModifiers() & getToolkit().getMenuShortcutKeyMask()) == 0) {
     org.nlogo.window.ButtonWidget button = findActionButton(e.getKeyChar());
     if (button != null) {
       button.keyTriggered();
     }
   }
 }
  @Override
  public void keyPressed(KeyEvent e) {
    // Do not edit neural web while user is selecting key bindings
    if (expandContractKey.isActive()
        || newNeuronKey.isActive()
        || newClusterKey.isActive()
        || deleteKey.isActive()) return;

    try {
      if (e.getKeyChar() == expandContractKey.getText().charAt(0)) {
        if (selectedCluster != null && selectedCluster.clusterNum != 0)
          selectedCluster.expanded = !selectedCluster.expanded;
        else if (selectedNeuron != null)
          selectedNeuron.cluster.expanded = !selectedNeuron.cluster.expanded;

        redraw = true;
      } else if (e.getKeyChar() == newNeuronKey.getText().charAt(0)) {
        Cluster cluster;

        if (selectedCluster != null) cluster = selectedCluster;
        else if (selectedNeuron != null) cluster = selectedNeuron.cluster;
        else if (clusters.size() > 2) {
          cluster = clusters.get(2);
        } else {
          WindowTools.informationWindow(
              "Error: You cannot add a neuron without a cluster, please select a Neuron or a Cluster.",
              "Error");
          return;
        }

        int x = Math.min(Main.canvasWidth - 11, Math.max(10, mouseX));
        int y = Math.min(Main.canvasHeight - 33, Math.max(33, mouseY));

        neurons.add(new Neuron(x, y, cluster));

        redraw = true;
      } else if (e.getKeyChar() == newClusterKey.getText().charAt(0)) {
        int x = Math.min(Main.canvasWidth - 11, Math.max(10, mouseX));
        int y = Math.min(Main.canvasHeight - 33, Math.max(33, mouseY));

        clusters.add(new Cluster(x, y));

        redraw = true;
      } else if (e.getKeyChar() == deleteKey.getText().charAt(0)) {
        if (selectedCluster != null) selectedCluster.delete();
        else if (selectedNeuron != null) selectedNeuron.delete();
        else if (selectedConnection != null) selectedConnection.delete();

        redraw = true;
      }
    } catch (StringIndexOutOfBoundsException sioobe) {
      WindowTools.informationWindow(
          "Invalid keybinding, please select a character for each action.", "Whoops!");
    }
  }
 @Override
 public void keyTyped(KeyEvent e) {
   // read input for new level name
   if (saveMenuVisible) {
     if (e.getKeyChar() == KeyEvent.VK_BACK_SPACE && saveLevelName.length() > 0) {
       saveLevelName = saveLevelName.substring(0, saveLevelName.length() - 1);
     } else {
       saveLevelName += e.getKeyChar();
     }
   }
 }
  public void process(KeyEvent e) {
    if (e.isConsumed() || !StringUtil.isEmptyOrSpaces(myPopup.getSpeedSearch().getFilter())) return;

    if (Character.isLetterOrDigit(e.getKeyChar())) {
      final String s = Character.toString(e.getKeyChar());
      final T toSelect = myChar2ValueMap.get(s);
      if (toSelect != null) {
        select(toSelect);
        e.consume();
      }
    }
  }
Esempio n. 21
0
 @Override
 public void keyPressed(KeyEvent e) {
   this.registerStandardExit(e);
   if (e.getKeyChar() == KeyEvent.VK_SPACE) {
     System.out.println("Switching...");
     flag += 1;
     flag = flag % 3;
   }
   if (e.getKeyChar() == 'p') {
     pause = !pause;
   }
 }
Esempio n. 22
0
 /**
  * @autor Misayo Metodo que permite presionar y convertir letras en mayusculas; no se permite
  *     presionar la tecla apostrofe
  * @param java.awt.event.KeyEvent evt evento de la tecla presionada
  */
 public static void presionarCaracteresEspacioMayusculas(java.awt.event.KeyEvent evt) {
   char key = evt.getKeyChar();
   if (key >= 'a' && key <= 'z'
       || (key == 'á' || key == 'é' || key == 'í' || key == 'ó' || key == 'ú'))
     evt.setKeyChar((char) (((int) evt.getKeyChar()) - 32));
   else if ((key == comillaSimple)
       && (key < 'A' || key > 'Z')
       && (key != 'Ñ')
       && (key != 'Á')
       && (key != 'É')
       && (key != 'Í')
       && (key != 'Ó')
       && (key != 'Ú')) evt.consume();
 }
Esempio n. 23
0
  @Override
  public synchronized void keyPressed(final KeyEvent key) {
    if (key.getKeyCode() == KeyEvent.VK_SPACE) {
      this.videoFrame.togglePause();
    } else if (key.getKeyChar() == 'c'
        && this.polygonListener.getPolygon().getVertices().size() > 2) {
      try {
        final Polygon p = this.polygonListener.getPolygon().clone();
        this.polygonListener.reset();
        this.modelImage =
            this.capture
                .getCurrentFrame()
                .process(new PolygonExtractionProcessor<Float[], MBFImage>(p, RGBColour.BLACK));

        if (this.matcher == null) {
          // configure the matcher
          final HomographyModel model = new HomographyModel();
          final RANSAC<Point2d, Point2d, HomographyModel> ransac =
              new RANSAC<Point2d, Point2d, HomographyModel>(
                  model,
                  new SingleImageTransferResidual2d<HomographyModel>(),
                  3.0,
                  1500,
                  new RANSAC.ProbabilisticMinInliersStoppingCondition(0.01),
                  true);
          this.matcher =
              new ConsistentLocalFeatureMatcher2d<Keypoint>(
                  new FastBasicKeypointMatcher<Keypoint>(8));
          this.matcher.setFittingModel(ransac);

          this.modelPanel.setPreferredSize(this.modelPanel.getSize());
        }

        this.modelFrame.setImage(ImageUtilities.createBufferedImageForDisplay(this.modelImage));

        final DoGColourSIFTEngine engine = new DoGColourSIFTEngine();
        engine.getOptions().setDoubleInitialImage(true);

        this.matcher.setModelFeatures(engine.findFeatures(this.modelImage));
      } catch (final Exception e) {
        e.printStackTrace();
      }
    } else if (key.getKeyChar() == '1') {
      this.renderMode = RenderMode.SQUARE;
    } else if (key.getKeyChar() == '2') {
      this.renderMode = RenderMode.PICTURE;
    } else if (key.getKeyChar() == '3') {
      this.renderMode = RenderMode.VIDEO;
    }
  }
  /**
   * Method declaration
   *
   * @param k
   */
  public void keyTyped(KeyEvent k) {

    if (k.getKeyChar() == '\n' && k.isControlDown()) {
      k.consume();
      execute();
    }
  }
Esempio n. 25
0
 private void reOrderKeyTyped(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_reOrderKeyTyped
   char c = evt.getKeyChar();
   if (!(Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))) {
     getToolkit().beep();
     evt.consume();
   }
 } // GEN-LAST:event_reOrderKeyTyped
  /** KeyListener method. */
  @Override
  public void keyPressed(KeyEvent ke) {
    animator.start();
    int DELTA_SIZE = 1;

    switch (ke.getKeyCode()) {
      case KeyEvent.VK_UP:
        gcodeRenderer.pan(0, DELTA_SIZE);
        // this.eye.y+=DELTA_SIZE;
        break;
      case KeyEvent.VK_DOWN:
        gcodeRenderer.pan(0, -DELTA_SIZE);
        break;
      case KeyEvent.VK_LEFT:
        gcodeRenderer.pan(-DELTA_SIZE, 0);
        break;
      case KeyEvent.VK_RIGHT:
        gcodeRenderer.pan(DELTA_SIZE, 0);
        break;
      case KeyEvent.VK_MINUS:
        if (ke.isControlDown()) gcodeRenderer.zoom(-1);
        break;
      case KeyEvent.VK_0:
      case KeyEvent.VK_ESCAPE:
        gcodeRenderer.resetView();
        break;
    }

    switch (ke.getKeyChar()) {
      case '+':
        if (ke.isControlDown()) gcodeRenderer.zoom(1);
        break;
    }
  }
  @Override
  public void keyPressed(final KeyEvent e) {
    if (!(e.isAltDown() || e.isMetaDown() || e.isControlDown() || myPanel.isNodePopupActive())) {
      if (!Character.isLetter(e.getKeyChar())) {
        return;
      }

      final IdeFocusManager focusManager = IdeFocusManager.getInstance(myPanel.getProject());
      final ActionCallback firstCharTyped = new ActionCallback();
      focusManager.typeAheadUntil(firstCharTyped);
      myPanel.moveDown();
      //noinspection SSBasedInspection
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              try {
                final Robot robot = new Robot();
                final boolean shiftOn = e.isShiftDown();
                final int code = e.getKeyCode();
                if (shiftOn) {
                  robot.keyPress(KeyEvent.VK_SHIFT);
                }
                robot.keyPress(code);
                robot.keyRelease(code);

                // don't release Shift
                firstCharTyped.setDone();
              } catch (AWTException ignored) {
              }
            }
          });
    }
  }
 private void txtCantKeyPressed(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_txtCantKeyPressed
   char tecla = evt.getKeyChar();
   if (Character.isLetter(tecla)) {
     JOptionPane.showMessageDialog(null, "No puede introducir letras...");
     txtCant.setText("");
   }
 } // GEN-LAST:event_txtCantKeyPressed
Esempio n. 29
0
File: Z.java Progetto: adamldavis/z
 @Override
 public void keyPressed(KeyEvent e) {
   if (!links.isEmpty()) return;
   switch (e.getKeyChar()) {
     case 's':
       // TODO: Search!!!!
       String name = display.showInputDialog("Search", "Z");
       ZTask activeTask = taskList.getActiveTask();
       for (ZNode node : getZNodes()) {
         if (node.getName().startsWith(name)) {
           log.info("found {}", node.getName());
           if (activeTask != null) {
             activeTask.add(node);
           }
         }
       }
       break;
     case 'm':
       if (selectedNode.getNodeType() == ZNodeType.CLASS) {
         addMethodLinks();
       }
       break;
     case 'p':
       // TODO: add polymorphic links
     case 'i':
     case 'r':
       // TODO: add import/require links
     case 'h':
     case 'f':
       addFieldLinks();
   }
 }
Esempio n. 30
0
  @Override
  /** met a jour les commandes en fonctions des touches appuyees */
  public void keyPressed(KeyEvent e) {

    switch (e.getKeyChar()) {
        // si on appuie sur 'q',commande joueur est gauche
      case 'q':
        this.commandeEnCours.gauche = true;
        break;
        // si on appuie sur 'd',commande joueur est droite
      case 'd':
        this.commandeEnCours.droite = true;
        break;
        // si on appuie sur 'z',commande joueur est haut
      case 'z':
        this.commandeEnCours.haut = true;
        break;
        // si on appuie sur 's',commande joueur est bas
      case 's':
        this.commandeEnCours.bas = true;
        break;
    }

    switch (e.getKeyCode()) {
      case KeyEvent.VK_SPACE:
        this.commandeEnCours.attaque = true;
    }
  }