public void draw(Graphics2D g2) {

    g2.setColor(new Color(33, 104, 96));
    g2.fill(new Rectangle2D.Double(0, 0, Window.WIDTH, Window.HEIGHT));

    bigPkm(selected == 0, g2, character.currentPokemon()[0]);
    for (int i = 1; i < 6; i++) {
      smallPkm(selected == i, g2, character.currentPokemon()[i], i - 1);
    }
    if (hasCancel)
      cancelButton(
          selected == totalButtons - 1,
          g2,
          Window.WIDTH - WIDTH3 - 20,
          Window.HEIGHT - HEIGHT3 - 20);
    if (switching) switchingTxt.draw(g2);
    else txt.draw(g2);

    if (menu != null) {
      menu.draw(g2);
      if (menu.result() != null) {
        if (menu.result().equals("Switch")) {
          if (inBattle) {
            switchIndex = selected;
            over = true;
          } else {
            switchIndex = selected;
            switching = true;
          }
        }
        menu = null;
      }
    }
  }
Exemplo n.º 2
0
 private void initMessageUI() {
   messageBox = new TextBox();
   messageBox.setReadOnly(true);
   messageBox.setWidth(FieldCanvas.SIZE * game.getBoard().getDimension().x + "px");
   messageBox.setText("Click field to start game.");
   add(messageBox);
 }
Exemplo n.º 3
0
  private void initOutputLocation() {
    // currently, the save location is populated deterministically by the combination of
    // the users's input

    final RootPanel outputPanel = RootPanel.get("output");
    output = new TextBox();
    output.setVisibleLength(150);
    output.addChangeHandler(
        new ChangeHandler() {
          @Override
          public void onChange(final ChangeEvent event) {
            outputPathUserSpecified = true;
            updateOutputLocation();
          }
        });
    outputPanel.add(output);

    final RootPanel outputWarning = RootPanel.get("outputWarning");
    outputValidationPanel = new ValidationPanel(2);

    outputWarning.add(outputValidationPanel);

    connectOutputLocationAndFileTable();
    // Fire userChanged to get the output location updated
    userChanged();
    updateOutputLocation();
  }
Exemplo n.º 4
0
  public void testSubmitAndHideDialog() {
    System.out.println("testSubmitAndHideDialog");
    final FormPanel form = new FormPanel();
    form.setMethod(FormPanel.METHOD_GET);
    form.setEncoding(FormPanel.ENCODING_URLENCODED);
    form.setAction(GWT.getModuleBaseURL() + "formHandler");

    TextBox tb = new TextBox();
    form.add(tb);
    tb.setText("text");
    tb.setName("tb");

    final DialogBox dlg = new DialogBox();
    dlg.setWidget(form);
    dlg.show();

    delayTestFinish(TEST_DELAY);
    form.addSubmitCompleteHandler(
        new SubmitCompleteHandler() {
          public void onSubmitComplete(SubmitCompleteEvent event) {
            // Make sure we get our results back.
            assertTrue(event.getResults().equals("tb=text"));
            finishTest();

            // Hide the dialog on submit complete. This was causing problems at one
            // point because hiding the dialog detached the form and iframe.
            dlg.hide();
          }
        });

    form.submit();
  }
Exemplo n.º 5
0
  public DeletePopup(final CommandWithCommitMessage command) {
    super(CommonImages.INSTANCE.edit(), "Delete this item");

    checkInCommentTextBox.setTitle("Check in comment");
    checkInCommentTextBox.setWidth("200px");
    addAttribute("Check in comment:", checkInCommentTextBox);

    final HorizontalPanel hp = new HorizontalPanel();
    final Button create = new Button("Delete item");
    create.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {

            if (!Window.confirm("Are you sure you want to delete this asset?")) {
              return;
            }

            hide();
            command.execute(checkInCommentTextBox.getText());
          }
        });
    hp.add(create);

    Button cancel = new Button("Cancel");
    cancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {
            hide();
          }
        });
    hp.add(new HTML("&nbsp"));
    hp.add(cancel);
    addAttribute("", hp);
  }
Exemplo n.º 6
0
  private Panel createNewNameInput(final ScrollPanel contentPanel) {
    VerticalPanel form = new VerticalPanel();
    HorizontalPanel nameForm = new HorizontalPanel();
    nameForm.add(new Label("Name"));
    final TextBox nameTextBox = new TextBox();
    nameTextBox.setName("personName");
    nameForm.add(nameTextBox);
    form.add(nameForm);
    Button saveButton =
        new Button(
            "Store",
            new ClickListener() {
              public void onClick(Widget sender) {
                String name = nameTextBox.getText();
                RaffleServiceGwtRemoteAsync service = RaffleServiceGwtRemote.App.getInstance();
                AsyncCallback callback =
                    new AsyncCallback() {
                      public void onFailure(Throwable caught) {
                        GWT.log("Failure while creating a new name", caught);
                      }

                      public void onSuccess(Object result) {
                        contentPanel.setWidget(new Label("Name is stored"));
                      }
                    };
                service.storeName(name, callback);
              }
            });
    form.add(saveButton);
    return form;
  }
Exemplo n.º 7
0
  public void inquiryCompleted(int discType) {
    if (remote == null) {
      mDisplay.setCurrent(vorForm);
      // Wait until the canvas appears...
      // For Nokia it is not the same?
      while (mDisplay.getCurrent() != vorForm) ;
      messages.insert("No NXT Brick found", messages.size());
    } else {
      try {
        remoteName = remote.getFriendlyName(false);
        messages.insert("Connecting to " + remoteName + "\n", messages.size());
      } catch (IOException ioe) {
        System.out.println("error retrieving friendly name");
      }

      try {
        // int[] attrs = {0x100}; // default attribute set plus service name
        UUID[] uuids = new UUID[] {new UUID(SERIALID)}; // Serial port service
        // agent.searchServices(attrs, uuids, remote, this);
        agent.searchServices(null, uuids, remote, this);
      } catch (BluetoothStateException bse) {
        System.out.println("service search failed");
      }
    }
  }
  public void testUnknowParams() throws Exception {
    Window uispecDialog = createUISpecWindow(JOB_WITH_UNKNOWN_PARAMS);

    TextBox runTextBox = uispecDialog.getTextBox(ComponentMatchers.componentLabelFor("run"));
    assertTrue(runTextBox.textEquals("Unkown parameter"));
    assertTrue(runTextBox.iconEquals(GuiUtil.loadIcon("error.png")));

    assertFalse(uispecDialog.getButton("OK").isEnabled());
  }
Exemplo n.º 9
0
 public void startApp() {
   textBox = new TextBox("Ophone", "\n", 512, TextField.UNEDITABLE);
   OxportMIDlet.addtext("Listo para exportar servicios...");
   textBox.addCommand(exitCom);
   textBox.addCommand(playCom);
   textBox.addCommand(initCom);
   textBox.setCommandListener(this);
   display.setCurrent(textBox);
 }
  public void testUnsupportedParams() throws Exception {
    Window uispecDialog = createUISpecWindow(JOB_WITH_UNSUPPORTED_PARAMS);

    TextBox runTextBox = uispecDialog.getTextBox(ComponentMatchers.componentLabelFor("run"));
    assertTrue(runTextBox.textEquals("RunParameterDefinition is unsupported."));
    assertTrue(runTextBox.iconEquals(GuiUtil.loadIcon("error.png")));

    assertFalse(uispecDialog.getButton("OK").isEnabled());
  }
Exemplo n.º 11
0
 @UiHandler("uploadBundleUploadButton")
 void clickUploadBundleUploadButton(ClickEvent event) {
   uploadBundleUploadButton.setEnabled(false);
   if (checkBundleFormValid()) {
     uploadResultTextBox.setVisible(false);
     showUploadProgressForBundle(true);
     presenter.uploadBundle(
         uploadBundleNameTextBox.getText(), uploadBundleClassNameTextBox.getText());
   }
 }
  /** This is the entry point method. */
  public void onModuleLoad() {
    sendButton = new Button("Send");
    nameField = new TextBox();
    nameField.setText("GWT User");
    errorLabel = new Label();

    // We can add style names to widgets
    sendButton.addStyleName("sendButton");

    // Add the nameField and sendButton to the RootPanel
    // Use RootPanel.get() to get the entire body element
    RootPanel.get("nameFieldContainer").add(nameField);
    RootPanel.get("sendButtonContainer").add(sendButton);
    RootPanel.get("errorLabelContainer").add(errorLabel);

    // Focus the cursor on the name field when the app loads
    nameField.setFocus(true);
    nameField.selectAll();

    // Create the popup dialog box
    dialogBox = new DialogBox();
    dialogBox.setText("Remote Procedure Call");
    dialogBox.setAnimationEnabled(true);
    closeButton = new Button("Close");
    // We can set the id of a widget by accessing its Element
    closeButton.getElement().setId("closeButton");
    textToServerLabel = new Label();
    serverResponseLabel = new HTML();
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.addStyleName("dialogVPanel");
    dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
    dialogVPanel.add(textToServerLabel);
    dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
    dialogVPanel.add(serverResponseLabel);
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    dialogVPanel.add(closeButton);
    dialogBox.setWidget(dialogVPanel);

    // Add a handler to close the DialogBox
    final ClickHandler buttonClickHandler =
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            dialogBox.hide();
            sendButton.setEnabled(true);
            sendButton.setFocus(true);
          }
        };
    closeButton.addClickHandler(buttonClickHandler);

    // Add a handler to send the name to the server
    ChangeEventHandler handler = new ChangeEventHandler();
    sendButton.addClickHandler(handler);
    nameField.addKeyUpHandler(handler);
  }
Exemplo n.º 13
0
 private TextBox buildParameterTextBox(String text) {
   TextBox paramBox = new TextBox();
   paramBox.setText(text);
   paramBox.setWidth("135");
   paramBox.addChangeHandler(
       new ChangeHandler() {
         public void onChange(ChangeEvent event) {
           enableSaveButton();
         }
       });
   return paramBox;
 }
Exemplo n.º 14
0
  public NXTLocator(Display d) {
    mDisplay = d;
    messages = new TextBox("NXT Status", "Welcome!\n", 8192, TextField.ANY);
    mDisplay.setCurrent(messages);

    // retrieve the local Bluetooth device object
    try {
      local = LocalDevice.getLocalDevice();
      agent = local.getDiscoveryAgent();
    } catch (BluetoothStateException bse) {
      messages.insert("no device found\n", messages.size());
    }
  }
Exemplo n.º 15
0
 public void testReset() {
   System.out.println("testReset");
   FormPanel form = new FormPanel();
   RootPanel.get().add(form);
   TextBox textBox = new TextBox();
   textBox.setText("Hello World");
   form.setWidget(textBox);
   assertEquals("Hello World", textBox.getText());
   System.out.println("reset: normal");
   form.reset();
   assertEquals("", textBox.getText());
   RootPanel.get().remove(form);
 }
Exemplo n.º 16
0
  private void addStock() {
    final String symbol = newSymbolTextBox.getText().toUpperCase().trim();
    newSymbolTextBox.setFocus(true);

    // Stock code must be between 1 and 10 chars that are numbers, letters, or dots.
    if (!symbol.matches("^[0-9A-Z\\.]{1,10}$")) {
      Window.alert("'" + symbol + "' is not a valit symbol.");
      newSymbolTextBox.selectAll();
      return;
    }

    newSymbolTextBox.setText("");
  }
Exemplo n.º 17
0
 public void testResetNative() {
   System.out.println("testResetNative"); // this test makes only sense if an event is called
   FormPanel form = new FormPanel();
   RootPanel.get().add(form);
   TextBox textBox = new TextBox();
   textBox.setText("Hello World");
   form.setWidget(textBox);
   assertEquals("Hello World", textBox.getText());
   System.out.println("reset: native");
   nativeFormReset(form.getElement());
   assertEquals("", textBox.getText());
   RootPanel.get().remove(form);
 }
Exemplo n.º 18
0
 public void findNXT() {
   if (local != null) {
     // place the device in inquiry mode
     try {
       agent.startInquiry(DiscoveryAgent.GIAC, this);
       messages.insert("Searching for NXT Brick\n", messages.size());
     } catch (BluetoothStateException bse) {
       System.out.println("inquiry couldn't be started");
     }
   } else {
     messages.insert("Bluetooth is off or this device doesn't support JSR82\n", messages.size());
   }
 }
Exemplo n.º 19
0
 private boolean checkBundleFormValid() {
   if (uploadBundleNameTextBox.getText().isEmpty()) {
     showUploadResult(UploadPresenter.MSG_NO_BUNDLE_NAME);
   } else if (!uploadDriverDone) {
     showUploadResult(UploadPresenter.MSG_NO_FILE_DRIVER);
   } else if (!uploadModuleDone) {
     showUploadResult(UploadPresenter.MSG_NO_FILE_MODULE);
   } else if (uploadBundleClassNameTextBox.getText().isEmpty()) {
     showUploadResult(UploadPresenter.MSG_NO_MCL_CLASS_FULL_NAME);
   } else {
     return true;
   }
   return false;
 }
Exemplo n.º 20
0
 private void initTitleEditor() {
   final RootPanel titlePanel = RootPanel.get("title");
   title.setVisibleLength(60);
   titlePanel.add(title);
   title.addKeyUpHandler(
       new KeyUpHandler() {
         @Override
         public void onKeyUp(final KeyUpEvent event) {
           userEditedTitle = true;
           updateOutputLocation();
         }
       });
   titleChangeListener = new TitleChangeListener();
   title.addChangeHandler(titleChangeListener);
 }
  private void checkClickOnHyperlink(String html, String link, String expectedTarget)
      throws Exception {
    JTextPane textPane = createTextPane(html);
    DummyHyperlinkListener listener = new DummyHyperlinkListener();
    textPane.addHyperlinkListener(listener);
    TextBox textComponent = new TextBox(textPane);
    textComponent.clickOnHyperlink(link);
    assertEquals(1, listener.getCallCount());
    assertEquals(expectedTarget, listener.getLastEvent().getDescription());

    listener.reset();
    textComponent.triggerClickOnHyperlink(link).run();
    assertEquals(1, listener.getCallCount());
    assertEquals(expectedTarget, listener.getLastEvent().getDescription());
  }
Exemplo n.º 22
0
 @UiHandler("clearSessionFiltersButton")
 void handleClearSessionFiltersButtonClick(ClickEvent e) {
   sessionsTo.setValue(null, true);
   sessionsFrom.setValue(null, true);
   sessionIdsTextBox.setText(null);
   stopTypingSessionIdsTimer.schedule(10);
 }
Exemplo n.º 23
0
  public void run(final RootPanel rp, final String nick) {

    if (Cookies.getCookie(nick) == null) Cookies.setCookie(nick, "" + 0);

    cl.setPageSize(500);

    final Button sendMessage =
        new Button(
            "sendMessage",
            new ClickHandler() {

              public void onClick(ClickEvent event) {

                if (!message.getText().equals("")) {
                  new Post().postJson(SERVERURL, nick.toString(), message.getText());
                  message.setText("");
                }
              }
            });

    rp.get("mainDiv2").setVisible(true);
    message.getElement().setAttribute("placeholder", "Introduce your message");
    message.getElement().setAttribute("id", "message");

    cl.getElement().setAttribute("id", "chatBox");

    sendMessage.getElement().setAttribute("id", "sendMessage");
    sendMessage.setText("Send");

    vp.getElement().setAttribute("id", "verticalPanel");
    hp.getElement().setAttribute("id", "horizontalPanel");

    panel.getElement().setAttribute("id", "scroller");

    hp.add(message);
    hp.add(sendMessage);
    panel.add(cl);
    vp.add(panel);

    vp.add(hp);
    rp.get("mainDiv2").add(vp);

    Timer t =
        new Timer() {
          @Override
          public void run() {
            getMessages();

            if (chatList != null && Integer.parseInt(Cookies.getCookie(nick)) < chatList.size()) {
              cl.setRowCount(chatList.size() + 1, true);
              cl.setRowData(
                  Integer.parseInt(Cookies.getCookie(nick)),
                  chatList.subList(Integer.parseInt(Cookies.getCookie(nick)), chatList.size()));
              panel.setVerticalScrollPosition(panel.getMaximumVerticalScrollPosition() - 1);
              Cookies.setCookie(nick, "" + chatList.size());
            }
          }
        };
    t.scheduleRepeating(1000);
  }
Exemplo n.º 24
0
 public void loadInputBoxConfig(XmlElementBean eleInputboxBean) {
   super.loadInputBoxConfig(eleInputboxBean);
   this.setTypePromptBean(null);
   if (eleInputboxBean != null) {
     String dateformat = eleInputboxBean.attributeValue("dateformat");
     if (dateformat != null) this.dateformat = dateformat.trim();
   }
 }
Exemplo n.º 25
0
 public ComputeKappa(CyNetwork network, JFrame frame) {
   wgs = new WeightGraphStructure(network);
   menuUtils = new ModelMenuUtils(wgs, frame);
   menuUtils.srcDialog = new ArrayList<Integer>();
   menuUtils.tgtDialog = new ArrayList<Integer>();
   if (!wgs.initWeights()) {
     JOptionPane.showMessageDialog(frame, menuUtils.errorWeigth, title, JOptionPane.ERROR_MESSAGE);
     return;
   }
   wgs.reach = menuUtils.getReach();
   if (wgs.reach == 0.0) return;
   threshold = menuUtils.getThreshold();
   if (threshold == Double.MAX_VALUE) return;
   txt = new TextBox(frame, title + " " + wgs.getName(), 0.5, 1.0);
   txt.setVisible(true);
   txt.append(params());
 }
Exemplo n.º 26
0
 private void setOutputPathChangeEnabled(final boolean enabled) {
   if (output != null && enabled != outputPathChangeEnabled) {
     outputPathChangeEnabled = enabled;
     if (!outputPathChangeEnabled) {
       outputPathUserSpecified = false;
     }
     output.setReadOnly(!enabled);
     // Update the output location, when changes are disabled, the field gets filled automatically
     updateOutputLocation();
   }
 }
Exemplo n.º 27
0
  public void commandAction(Command c, Displayable s) {
    if (c == exitCom) {
      destroyApp(true);
      notifyDestroyed();

    } else if (c == initCom) {
      if (ox == null) {
        textBox.insert("Exportando...\n", textBox.size());
        ox = new Oxport();
        ox.start();
      }
    } else if (c == playCom) {
      if ((ox == null) || (ox.getOServer() == null)) addtext("Playground need a OServer running");
      else {
        if (playground == null) playground = new PlayGround(this);
        display.setCurrent(playground);
      }
    } else {
    }
  }
Exemplo n.º 28
0
  private void filterSessions(Set<SessionDataDto> sessionDataDtoSet) {
    if (sessionDataDtoSet == null || sessionDataDtoSet.isEmpty()) {
      sessionIdsTextBox.setText(null);
      stopTypingSessionIdsTimer.schedule(10);

      return;
    }

    final StringBuilder builder = new StringBuilder();
    boolean first = true;
    for (SessionDataDto sessionDataDto : sessionDataDtoSet) {
      if (!first) {
        builder.append("/");
      }
      builder.append(sessionDataDto.getSessionId());
      first = false;
    }
    sessionIdsTextBox.setText(builder.toString());
    stopTypingSessionIdsTimer.schedule(10);
  }
Exemplo n.º 29
0
  /** Ask the user for the URL. */
  private void getUrl() {
    try {
      if (urlTextBox == null) {
        urlTextBox =
            new TextBox(
                Resource.getString(ResourceConstants.AMS_DISC_APP_WEBSITE_INSTALL),
                defaultInstallListUrl,
                1024,
                TextField.ANY);
        urlTextBox.addCommand(endCmd);
        urlTextBox.addCommand(saveCmd);
        urlTextBox.addCommand(discoverCmd);
        urlTextBox.setCommandListener(this);
      }

      display.setCurrent(urlTextBox);
    } catch (Exception ex) {
      displayException(Resource.getString(ResourceConstants.EXCEPTION), ex.toString());
    }
  }
 @Override
 public void addMedidaTextHandler(TextBoxHandler handler) {
   tbMedida.addKeyPressHandler(handler);
   tbMedida.addKeyDownHandler(handler);
   tbMedida.addKeyUpHandler(handler);
   tbMedida.addFocusHandler(handler);
   tbMedida.addClickHandler(handler);
   tbMedida.addValueChangeHandler(handler);
   tbMedida.addChangeHandler(handler);
 }