Beispiel #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();
 }
Beispiel #2
0
 /** Deselects the highlighted text. */
 public void deselect() {
   int selStart = xtext.getSelectionStart();
   int selEnd = xtext.getSelectionEnd();
   if (selStart != selEnd) {
     xtext.select(selStart, selStart);
   }
 }
Beispiel #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();
   }
 }
Beispiel #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);
 }
Beispiel #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);
  }
Beispiel #6
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 public void setEditable(boolean editable) {
   if (xtext != null) {
     xtext.setEditable(editable);
     xtext.repaint();
   }
 }
Beispiel #7
0
 /** @see java.awt.peer.ComponentPeer */
 @Override
 public void setEnabled(boolean enabled) {
   super.setEnabled(enabled);
   if (xtext != null) {
     xtext.setEnabled(enabled);
     xtext.repaint();
   }
 }
Beispiel #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);
   }
 }
Beispiel #9
0
 @Override
 public void setFont(Font f) {
   synchronized (getStateLock()) {
     font = f;
     if (xtext != null && xtext.getFont() != f) {
       xtext.setFont(font);
     }
   }
   xtext.validate();
 }
Beispiel #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);
   }
 }
Beispiel #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();
 }
Beispiel #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();
 }
Beispiel #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);
   }
 }
Beispiel #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();
 }
Beispiel #15
0
 /**
  * to be implemented.
  *
  * @see java.awt.peer.TextComponentPeer
  */
 @Override
 public int getCaretPosition() {
   return xtext.getCaretPosition();
 }
Beispiel #16
0
 @Override
 void handleJavaInputMethodEvent(InputMethodEvent e) {
   if (xtext != null) xtext.processInputMethodEventImpl(e);
 }
Beispiel #17
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 public InputMethodRequests getInputMethodRequests() {
   if (xtext != null) return xtext.getInputMethodRequests();
   else return null;
 }
Beispiel #18
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 public int getSelectionStart() {
   return xtext.getSelectionStart();
 }
Beispiel #19
0
 @Override
 public void setVisible(boolean b) {
   super.setVisible(b);
   if (xtext != null) xtext.setVisible(b);
 }
Beispiel #20
0
 @Override
 public void focusLost(FocusEvent e) {
   super.focusLost(e);
   xtext.forwardFocusLost(e);
 }
Beispiel #21
0
 @Override
 public void focusGained(FocusEvent e) {
   super.focusGained(e);
   xtext.forwardFocusGained(e);
 }
Beispiel #22
0
 @Override
 void paintPeer(final Graphics g) {
   if (xtext != null) xtext.paint(g);
 }
Beispiel #23
0
 @Override
 public void print(Graphics g) {
   if (xtext != null) {
     xtext.print(g);
   }
 }
Beispiel #24
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 public int getSelectionEnd() {
   return xtext.getSelectionEnd();
 }
Beispiel #25
0
 @Override
 public void repaint() {
   if (xtext != null) xtext.repaint();
 }
Beispiel #26
0
 @Override
 public Dimension getPreferredSize() {
   return xtext.getPreferredSize();
 }
Beispiel #27
0
 @Override
 public Dimension getMinimumSize() {
   return xtext.getMinimumSize();
 }
Beispiel #28
0
 /** @see java.awt.peer.TextComponentPeer */
 @Override
 @SuppressWarnings("deprecation")
 public String getText() {
   return xtext.getText();
 }
Beispiel #29
0
 /**
  * to be implemented.
  *
  * @see java.awt.peer.TextComponentPeer
  */
 @Override
 public void setCaretPosition(int position) {
   if (xtext != null) xtext.setCaretPosition(position);
 }
Beispiel #30
0
 void repaintText() {
   xtext.repaintNow();
 }