Exemplo n.º 1
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 public void select(int s, int e) {
   xtext.select(s, e);
   // Fixed 5100806
   // We must take care that Swing components repainted correctly
   xtext.repaint();
 }
Exemplo n.º 2
0
 /** Deselects the highlighted text. */
 public void deselect() {
   int selStart = xtext.getSelectionStart();
   int selEnd = xtext.getSelectionEnd();
   if (selStart != selEnd) {
     xtext.select(selStart, selStart);
   }
 }
Exemplo n.º 3
0
 @Override
 public void setBounds(int x, int y, int width, int height, int op) {
   super.setBounds(x, y, width, height, op);
   if (xtext != null) {
     /*
      * Fixed 6277332, 6198290:
      * the coordinates is coming (to peer): relatively to closest HW parent
      * the coordinates is setting (to textField): relatively to closest ANY parent
      * the parent of peer is target.getParent()
      * the parent of textField is the same
      * see 6277332, 6198290 for more information
      */
     int childX = x;
     int childY = y;
     Component parent = target.getParent();
     // we up to heavyweight parent in order to be sure
     // that the coordinates of the text pane is relatively to closest parent
     while (parent.isLightweight()) {
       childX -= parent.getX();
       childY -= parent.getY();
       parent = parent.getParent();
     }
     xtext.setBounds(childX, childY, width, height);
     xtext.validate();
   }
 }
Exemplo n.º 4
0
 @Override
 public Dimension getMinimumSize(int cols) {
   Font f = xtext.getFont();
   FontMetrics fm = xtext.getFontMetrics(f);
   return new Dimension(
       fm.charWidth('0') * cols + 10, fm.getMaxDescent() + fm.getMaxAscent() + PADDING);
 }
Exemplo n.º 5
0
  XTextFieldPeer(TextField target) {
    super(target);
    text = target.getText();
    xtext = new XAWTTextField(text, this, target.getParent());
    xtext.getDocument().addDocumentListener(xtext);
    xtext.setCursor(target.getCursor());
    XToolkit.specialPeerMap.put(xtext, this);

    initTextField();
    setText(target.getText());
    if (target.echoCharIsSet()) {
      setEchoChar(target.getEchoChar());
    } else setEchoChar((char) 0);

    int start = target.getSelectionStart();
    int end = target.getSelectionEnd();
    // Fix for 5100200
    // Restoring Motif behaviour
    // Since the end position of the selected text can be greater than the length of the text,
    // so we should set caret to max position of the text
    setCaretPosition(Math.min(end, text.length()));
    if (end > start) {
      // Should be called after setText() and setCaretPosition()
      select(start, end);
    }

    setEditable(target.isEditable());

    // After this line we should not change the component's text
    firstChangeSkipped = true;
    AWTAccessor.getComponentAccessor().setPeer(xtext, this);
  }
Exemplo n.º 6
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 public void setEditable(boolean editable) {
   if (xtext != null) {
     xtext.setEditable(editable);
     xtext.repaint();
   }
 }
Exemplo n.º 7
0
 /** @see java.awt.peer.ComponentPeer */
 @Override
 public void setEnabled(boolean enabled) {
   super.setEnabled(enabled);
   if (xtext != null) {
     xtext.setEnabled(enabled);
     xtext.repaint();
   }
 }
Exemplo n.º 8
0
 /** @see java.awt.peer.TextFieldPeer */
 @Override
 public void setEchoChar(char c) {
   if (xtext != null) {
     xtext.setEchoChar(c);
     xtext.putClientProperty(
         "JPasswordField.cutCopyAllowed", xtext.echoCharIsSet() ? Boolean.FALSE : Boolean.TRUE);
   }
 }
Exemplo n.º 9
0
 @Override
 public void setFont(Font f) {
   synchronized (getStateLock()) {
     font = f;
     if (xtext != null && xtext.getFont() != f) {
       xtext.setFont(font);
     }
   }
   xtext.validate();
 }
Exemplo n.º 10
0
 @Override
 public void handleJavaMouseEvent(MouseEvent mouseEvent) {
   super.handleJavaMouseEvent(mouseEvent);
   if (xtext != null) {
     mouseEvent.setSource(xtext);
     int id = mouseEvent.getID();
     if (id == MouseEvent.MOUSE_DRAGGED || id == MouseEvent.MOUSE_MOVED)
       xtext.processMouseMotionEventImpl(mouseEvent);
     else xtext.processMouseEventImpl(mouseEvent);
   }
 }
Exemplo n.º 11
0
 @Override
 public void setForeground(Color c) {
   foreground = c;
   if (xtext != null) {
     if (xtext.getForeground() != c) {
       xtext.setForeground(foreground);
     }
     xtext.setSelectionColor(foreground);
     xtext.setCaretColor(foreground);
   }
   repaintText();
 }
Exemplo n.º 12
0
 @Override
 public void setBackground(Color c) {
   if (log.isLoggable(PlatformLogger.Level.FINE)) {
     log.fine("target=" + target + ", old=" + background + ", new=" + c);
   }
   background = c;
   if (xtext != null) {
     if (xtext.getBackground() != c) {
       xtext.setBackground(c);
     }
     xtext.setSelectedTextColor(c);
   }
   repaintText();
 }
Exemplo n.º 13
0
 private void setXAWTTextField(String txt) {
   text = txt;
   if (xtext != null) {
     // JTextField.setText() posts two different events (remove & insert).
     // Since we make no differences between text events,
     // the document listener has to be disabled while
     // JTextField.setText() is called.
     xtext.getDocument().removeDocumentListener(xtext);
     xtext.setText(txt);
     if (firstChangeSkipped) {
       postEvent(new TextEvent(target, TextEvent.TEXT_VALUE_CHANGED));
     }
     xtext.getDocument().addDocumentListener(xtext);
     xtext.setCaretPosition(0);
   }
 }
Exemplo n.º 14
0
 @Override
 public void dispose() {
   XToolkit.specialPeerMap.remove(xtext);
   // visible caret has a timer thread which must be stopped
   xtext.getCaret().setVisible(false);
   super.dispose();
 }
Exemplo n.º 15
0
 /**
  * to be implemented.
  *
  * @see java.awt.peer.TextComponentPeer
  */
 @Override
 public int getCaretPosition() {
   return xtext.getCaretPosition();
 }
Exemplo n.º 16
0
 @Override
 void handleJavaInputMethodEvent(InputMethodEvent e) {
   if (xtext != null) xtext.processInputMethodEventImpl(e);
 }
Exemplo n.º 17
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 public InputMethodRequests getInputMethodRequests() {
   if (xtext != null) return xtext.getInputMethodRequests();
   else return null;
 }
Exemplo n.º 18
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 public int getSelectionStart() {
   return xtext.getSelectionStart();
 }
Exemplo n.º 19
0
 @Override
 public void setVisible(boolean b) {
   super.setVisible(b);
   if (xtext != null) xtext.setVisible(b);
 }
Exemplo n.º 20
0
 @Override
 public void focusLost(FocusEvent e) {
   super.focusLost(e);
   xtext.forwardFocusLost(e);
 }
Exemplo n.º 21
0
 @Override
 public void focusGained(FocusEvent e) {
   super.focusGained(e);
   xtext.forwardFocusGained(e);
 }
Exemplo n.º 22
0
 @Override
 void paintPeer(final Graphics g) {
   if (xtext != null) xtext.paint(g);
 }
Exemplo n.º 23
0
 @Override
 public void print(Graphics g) {
   if (xtext != null) {
     xtext.print(g);
   }
 }
Exemplo n.º 24
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 public int getSelectionEnd() {
   return xtext.getSelectionEnd();
 }
Exemplo n.º 25
0
 @Override
 public void repaint() {
   if (xtext != null) xtext.repaint();
 }
Exemplo n.º 26
0
 @Override
 public Dimension getPreferredSize() {
   return xtext.getPreferredSize();
 }
Exemplo n.º 27
0
 @Override
 public Dimension getMinimumSize() {
   return xtext.getMinimumSize();
 }
Exemplo n.º 28
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 @SuppressWarnings("deprecation")
 public String getText() {
   return xtext.getText();
 }
Exemplo n.º 29
0
 /**
  * to be implemented.
  *
  * @see java.awt.peer.TextComponentPeer
  */
 @Override
 public void setCaretPosition(int position) {
   if (xtext != null) xtext.setCaretPosition(position);
 }
Exemplo n.º 30
0
 void repaintText() {
   xtext.repaintNow();
 }