Package com.google.gwt.user.client.ui

Examples of com.google.gwt.user.client.ui.TextBoxBase


  /** displays a popup to prompt the user for the URI or revert to default assignment
   * @param left
   * @param top
  */
  void promptUserUri(int left, int top) {
    final TextBoxBase textBox = new TextBox();
    final MyDialog popup = new MyDialog(textBox) {
      public boolean onKeyUpPreview(char key, int modifiers) {
        // avoid ENTER from closing the popup without proper reaction
        if ( key == KeyboardListener.KEY_ESCAPE ) {
          hide();      // only ESCAPE keystroke closes the popup
          return false;
        }
       
        if ( key == KeyboardListener.KEY_ENTER ) {
          String str = textBox.getText().trim();
          _processAccept(str, this);
        }
          return true;
        }
    };
    popup.setText("Specify the namespace root for the ontology URI");
   
    textBox.setWidth("300");
    if ( namespaceRoot != null ) {
      textBox.setText(namespaceRoot);
    }

    popup.getButtonsPanel().insert(
        new PushButton("OK", new ClickListener() {
          public void onClick(Widget sender) {
            String str = textBox.getText().trim();
            _processAccept(str, popup);
          }
        })
        , 0
    );

    if ( userGiven ) {
      popup.getButtonsPanel().insert(
          new PushButton("Revert to default", new ClickListener() {
            public void onClick(Widget sender) {
              userGiven = false;
              namespaceRoot = defaultNameSpace;
              update();
              popup.hide();
            }
          })
          , 0
      );
    }
   
    popup.setPopupPosition(left, top + 20);
    new Timer() { @Override
      public void run() {
        textBox.setFocus(true);
      }
    }.schedule(180);
   
    popup.show();

View Full Code Here


    }
  }
 
  private Widget _createWidgetForValue(final GuiInfo gui, String value) {
    int visLines = readOnly ? Math.min(gui.numLines, _countLines(value)) : gui.numLines;
    TextBoxBase tb;
    if ( visLines == 1 ) {
      tb = new TextBox();
    }
    else {
      TextArea ta = new TextArea();
      ta.setVisibleLines(visLines);
      tb = ta;
    }
    tb.setText(value);
    tb.setReadOnly(readOnly);
    tb.setWidth(gui.width);
   
    if ( ! readOnly ) {
      // capture changes in the field to update the corresponding metadata
      // property for the mapping:
      final TextBoxBase tbb = tb;
      tb.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
          String value = tbb.getText().trim();
          Map<String, String> md = mapping.getMetadata();
          if ( md == null ) {
            mapping.setMetadata(new HashMap<String, String>());
          }
          md = mapping.getMetadata();
          md.put(gui.uri, value);
        }
      });
     
      // workaround
      tb.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
          // TODO Auto-generated method stub
          tbb.setFocus(true);
        }
       
      });
    }
    return tb;
View Full Code Here

      return decPanel;
    }

    public static TextBoxBase createTextBoxBase(int nl, String width,
      ChangeListener cl) {
    final TextBoxBase tb;
    if ( nl <=1 ) {
      tb = new TextBox();
      tb.setWidth(width);
    }
    else {
      // avoid huge textareas (TODO max 20 line is arbitrary)
      if ( nl > 20 ) {
        nl = 20;
      }
      tb = new TextArea();
      // TODO 16 is just a rough scaling factor
      tb.setSize(width, "" +(nl *16));
    }
    if ( cl != null ) {
      tb.addChangeListener(cl);
    }
    return tb;
  }
View Full Code Here

        ViewOnlyCell voCell = new ViewOnlyCell(nl, "600");
        widget = voCell;
      }
      else {
        int nl = attr.getNumberOfLines();
        TextBoxBase tb = OrrUtil.createTextBoxBase(nl, "600", cl);
        widget = tb;
      }
     
      if ( resourceTypeWidget != null && resourceTypeWidget.resourceTypeAttrDef == attr ) {
        // we handle this as a special case.
View Full Code Here

       
        m_panel = createMainPanel(isMultivalued, m_selectedItemsContainerId, m_suggestBoxContainerId);
        m_panel.addStyleName("spiffy-mvsb");
        m_panel.getElement().setId(HTMLPanel.createUniqueId());
       
        final TextBoxBase textfield = new TextBox();
//        if (isMultivalued) {
//            m_panel.addStyleName("textarearow");
////            textfield = new TextArea();
//        } else {
//            m_panel.addStyleName("textfieldrow");
////            textfield = new TextBox();
//        }

        //Create our own SuggestOracle that queries REST endpoint
        SuggestOracle oracle = new RestSuggestOracle();
        //initialize the SuggestBox
        m_field = new SuggestBox(oracle, textfield);
        m_feedback = new FormFeedback();
       
        if (isMultivalued) {
            m_panel.addStyleName("wideTextField");       
            m_panel.addStyleName("multivalue");
            //have to do this here b/c gwt suggest box wipes
            //style name if added in previous if
            textfield.addStyleName("multivalue");
           
            textfield.addKeyPressHandler(new KeyPressHandler()
            {
                @Override
                public void onKeyPress(KeyPressEvent event)
                {
                    adjustTextWidth();
                    m_lastCurPos = textfield.getCursorPos();
                }
            });
        } else {
            m_field.addStyleName("wideTextField");
        }
View Full Code Here

        m_feedback.setStatus(status);
        if (tooltip != null) {
            m_feedback.setTitle(tooltip);
        }

        TextBoxBase textBox = m_field.getTextBox();
        if (FormFeedback.LOADING == status) {
            textBox.setEnabled(false);
        } else {
            textBox.setEnabled(true);
            textBox.setFocus(false); //Blur then focus b/c of a strange problem with the cursor or selection highlights no longer visible within the textfield (this is a workaround)
            textBox.setFocus(true);
        }
    }
View Full Code Here

    }
  }

  protected void activateEditor() {
    if(editor instanceof TextBoxBase) {
      TextBoxBase textbox = (TextBoxBase)editor;
      textbox.setSelectionRange(0, textbox.getText().length());
    }
  }
View Full Code Here

                }, KeyPressEvent.getType());
                break;
            case KEY_UP:

                if (widget instanceof TextBoxBase) {
                    final TextBoxBase textBox = (TextBoxBase) widget;
                    textBox.addKeyUpHandler(new KeyUpHandler() {

                        @Override
                        public void onKeyUp(final KeyUpEvent event) {
                            final PTInstruction changeHandlerInstruction = new PTInstruction();
                            changeHandlerInstruction.setObjectID(addHandler.getObjectID());
                            changeHandlerInstruction.put(TYPE.KEY, TYPE.KEY_.EVENT);
                            changeHandlerInstruction.put(HANDLER.KEY, HANDLER.KEY_.STRING_VALUE_CHANGE_HANDLER);
                            changeHandlerInstruction.put(PROPERTY.VALUE, textBox.getText());

                            final PTInstruction eventInstruction = buildEventInstruction(addHandler, domHandlerType);
                            eventInstruction.put(PROPERTY.VALUE, event.getNativeEvent().getKeyCode());

                            if (addHandler.containsKey(PROPERTY.KEY_FILTER)) {
View Full Code Here

        super(new ItemSuggestOracle<T>(itemProvider, textBoxBase), textBoxBase, new ItemListSuggestionDisplay());
        this.itemProvider = itemProvider;
    }
   
    public Set<T> getItems() {
        TextBoxBase base = getTextBox();
        String [] lines = base.getText().split("\n");
        Set<T> items = new HashSet<T>();
        for(String line : lines) {
            final List<T> itemsMatchingExactly = itemProvider.getItemsMatchingExactly(line.trim());
            items.addAll(itemsMatchingExactly);
        }
View Full Code Here

    this.eventBus = eventBus;
  }

  @Override
  public void onKeyDown(KeyDownEvent event) {
    TextBoxBase source = (TextBoxBase) event.getSource();
    if (!isOldTextdefine) {
      oldText = source.getText();
      isOldTextdefine = true;
    }
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.user.client.ui.TextBoxBase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.