private TextBox textBoxEditor(final RuleAttribute at, final boolean isReadOnly) {
    final TextBox box = new TextBox();
    box.setEnabled(!isReadOnly);
    box.setVisibleLength((at.getValue().length() < 3) ? 3 : at.getValue().length());
    box.setText(at.getValue());
    box.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            at.setValue(box.getText());
          }
        });

    if (at.getAttributeName().equals(DATE_EFFECTIVE_ATTR)
        || at.getAttributeName().equals(DATE_EXPIRES_ATTR)) {
      if (at.getValue() == null || "".equals(at.getValue())) {
        box.setText("");
      }

      box.setVisibleLength(10);
    }

    box.addKeyUpHandler(
        new KeyUpHandler() {
          public void onKeyUp(KeyUpEvent event) {
            int length = box.getText().length();
            box.setVisibleLength(length > 0 ? length : 1);
          }
        });
    return box;
  }
示例#2
0
  public PersonSearchPanel() {
    rootElement = uiBinder.createAndBindUi(this);
    searchBox.setVisibleLength(40);
    searchBox.addKeyPressHandler(
        new EnterKeyHandler(
            new HandlerAction() {
              public void actionPerformed() {
                personServiceAsync.getPersons(
                    new AsyncCallback<List<Person>>() {
                      public void onFailure(Throwable caught) {
                        Window.alert("What? An error has occured. Message: " + caught.getMessage());
                        caught.printStackTrace();
                      }

                      public void onSuccess(List<Person> result) {
                        populatePersonResult(result);
                        resultPanel.setVisible(true);
                      }
                    });
              }
            }));
    resultPanel.setVisible(false);
    resultPanel.add(new Label("Search Result:"));
    searchResult = new Grid(0, 2);
    resultPanel.add(searchResult);
  }
示例#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();
  }
 private static TextBox createTextBox(boolean isPassword) {
   TextBox tb;
   if (isPassword) {
     tb =
         new PasswordTextBox() {
           @Override
           public void onBrowserEvent(Event event) {
             super.onBrowserEvent(event);
             handlePaste(this, event);
           }
         };
   } else {
     tb =
         new TextBox() {
           @Override
           public void onBrowserEvent(Event event) {
             super.onBrowserEvent(event);
             handlePaste(this, event);
           }
         };
   }
   tb.addKeyPressHandler(
       new KeyPressHandler() {
         @Override
         public void onKeyPress(KeyPressEvent event) {
           event.stopPropagation();
         }
       });
   tb.sinkEvents(Event.ONPASTE);
   tb.setVisibleLength(40);
   return tb;
 }
示例#5
0
 public void createDeepLink() {
   if (tabContent instanceof IFrameTabPanel) {
     PromptDialogBox dialogBox =
         new PromptDialogBox(
             Messages.getString("deepLink"),
             Messages.getString("ok"),
             Messages.getString("cancel"),
             false, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
             true);
     String url =
         Window.Location.getProtocol()
             + "//"
             + Window.Location.getHostName()
             + ":"
             + Window.Location.getPort()
             + Window.Location.getPath() // $NON-NLS-1$ //$NON-NLS-2$
             + "?name="
             + textLabel.getText()
             + "&startup-url="; //$NON-NLS-1$ //$NON-NLS-2$
     String startup = ((IFrameTabPanel) tabContent).getUrl();
     TextBox urlbox = new TextBox();
     urlbox.setText(url + URL.encodeComponent(startup));
     urlbox.setVisibleLength(80);
     dialogBox.setContent(urlbox);
     dialogBox.center();
   }
 }
示例#6
0
  public Geocoder2Demo() {
    Panel panel = new FlowPanel();
    final FormPanel form = new FormPanel();
    form.setAction("#");
    Panel formElements = new FlowPanel();
    Label label = new Label("Search for an address:");
    formElements.add(label);
    final TextBox addressBox = new TextBox();
    addressBox.setVisibleLength(40);
    formElements.add(addressBox);
    Button submit = new Button("Search");
    submit.addClickListener(
        new ClickListener() {
          public void onClick(Widget sender) {
            form.submit();
          }
        });
    formElements.add(submit);
    form.add(formElements);
    form.addFormHandler(
        new FormHandler() {
          public void onSubmit(FormSubmitEvent event) {
            showAddress(addressBox.getText());
            event.setCancelled(true);
          }

          public void onSubmitComplete(FormSubmitCompleteEvent event) {}
        });
    panel.add(form);

    map = new MapWidget(LatLng.newInstance(34, 0), 1);
    map.setSize("100%", "480px");
    panel.add(map);

    Grid grid = new Grid((sampleAddresses.length / NUM_ADDRESS_COLUMNS) + 1, NUM_ADDRESS_COLUMNS);

    for (int i = 0; i < sampleAddresses.length; i++) {
      final String address = sampleAddresses[i];
      Button link = new Button(address);
      // Hyperlink link = new Hyperlink(address, true,
      // "Extracting Structured Address Information");
      link.addClickListener(
          new ClickListener() {
            public void onClick(Widget sender) {
              addressBox.setText(address);
              form.submit();
            }
          });
      grid.setWidget(i / NUM_ADDRESS_COLUMNS, i % NUM_ADDRESS_COLUMNS, link);
    }
    panel.add(grid);

    initWidget(panel);
    geocoder = new Geocoder();
  }
  /** Creates a new length property editor. */
  public YoungAndroidLengthPropertyEditor() {
    // The radio button group cannot be shared across all instances, so we append a unique id.
    int uniqueId = ++uniqueIdSeed;
    String radioButtonGroup = "LengthType-" + uniqueId;
    automaticRadioButton = new RadioButton(radioButtonGroup, MESSAGES.automaticCaption());
    fillParentRadioButton = new RadioButton(radioButtonGroup, MESSAGES.fillParentCaption());
    customLengthRadioButton = new RadioButton(radioButtonGroup);
    customLengthField = new TextBox();
    customLengthField.setVisibleLength(3);
    customLengthField.setMaxLength(3);

    Panel customRow = new HorizontalPanel();
    customRow.add(customLengthRadioButton);
    customRow.add(customLengthField);
    Label pixels = new Label(MESSAGES.pixelsCaption());
    pixels.setStylePrimaryName("ode-PixelsLabel");
    customRow.add(pixels);

    Panel panel = new VerticalPanel();
    panel.add(automaticRadioButton);
    panel.add(fillParentRadioButton);
    panel.add(customRow);

    automaticRadioButton.addValueChangeHandler(
        new ValueChangeHandler() {
          @Override
          public void onValueChange(ValueChangeEvent event) {
            // Clear the custom length field.
            customLengthField.setText("");
          }
        });
    fillParentRadioButton.addValueChangeHandler(
        new ValueChangeHandler() {
          @Override
          public void onValueChange(ValueChangeEvent event) {
            // Clear the custom length field.
            customLengthField.setText("");
          }
        });
    customLengthField.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            // If the user clicks on the custom length field, but the radio button for a custom
            // length
            // is not checked, check it.
            if (!customLengthRadioButton.isChecked()) {
              customLengthRadioButton.setChecked(true);
            }
          }
        });

    initAdditionalChoicePanel(panel);
  }
示例#8
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 TextBox textBoxEditor(final RuleMetadata rm, final boolean isReadOnly) {
    final TextBox box = new TextBox();
    box.setEnabled(!isReadOnly);
    box.setVisibleLength((rm.getValue().length() < 3) ? 3 : rm.getValue().length());
    box.setText(rm.getValue());
    box.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            rm.setValue(box.getText());
          }
        });

    box.addKeyUpHandler(
        new KeyUpHandler() {
          public void onKeyUp(KeyUpEvent event) {
            box.setVisibleLength(box.getText().length());
          }
        });
    return box;
  }
示例#10
0
  public NumberBoxItem(String name, String title, boolean allowNegativeNumber) {
    super(name, title);
    this.allowNegativeNumber = allowNegativeNumber;

    textBox = new TextBox();
    textBox.setName(name);
    textBox.setTitle(title);
    textBox.setTabIndex(0);

    textBox.addValueChangeHandler(
        new ValueChangeHandler<String>() {
          @Override
          public void onValueChange(ValueChangeEvent<String> event) {
            setModified(true);
            setUndefined(event.getValue().equals(""));
          }
        });

    textBox.setVisibleLength(6);

    wrapper = new InputElementWrapper(textBox, this);
  }
  private ToolStrip toolstripButtons() {

    final TextBox filter = new TextBox();
    filter.setMaxLength(30);
    filter.setVisibleLength(20);
    filter.getElement().setAttribute("style", "float:right; width:120px;");
    filter.addKeyUpHandler(
        keyUpEvent -> {
          String word = filter.getText();
          if (word != null && word.trim().length() > 0) {
            filter(word);
          } else {
            clearFilter();
          }
        });

    ToolStrip topLevelTools = new ToolStrip();

    final HTML label = new HTML(Console.CONSTANTS.commom_label_filter() + ":&nbsp;");
    label.getElement().setAttribute("style", "padding-top:8px;");
    topLevelTools.addToolWidget(label);
    topLevelTools.addToolWidget(filter);

    enableBtn =
        new ToolButton(Console.CONSTANTS.common_label_enable(), event -> presenter.enable());
    disableBtn =
        new ToolButton(Console.CONSTANTS.common_label_disable(), event -> presenter.disable());
    refreshBtn =
        new ToolButton(Console.CONSTANTS.common_label_refresh(), event -> presenter.loadChanges());

    topLevelTools.addToolButtonRight(enableBtn);
    topLevelTools.addToolButtonRight(disableBtn);
    topLevelTools.addToolButtonRight(refreshBtn);

    return topLevelTools;
  }
示例#12
0
  // Helper method to create the internals of the HTML Form (FormPanel)
  //  Submit form may be for new post, or for editing existing post
  private FormPanel makeSubmitPostForm(final PostData post) {
    final FormPanel submitFormPanel = new FormPanel();
    VerticalPanel postFormPanel = new VerticalPanel();
    postFormPanel.addStyleName("submitPostVertPanel");
    submitFormPanel.add(postFormPanel);

    // Name input
    HorizontalPanel nameRow = new HorizontalPanel();
    Label nameLabel = new Label("Name (First Last");
    final TextBox nameTextbox = new TextBox();
    nameRow.add(nameLabel);
    nameRow.add(nameTextbox);
    postFormPanel.add(nameRow);

    // Title input
    HorizontalPanel titleRow = new HorizontalPanel();
    Label titleLabel = new Label("Title (e.g. car, bike, etc)");
    final TextBox titleTextbox = new TextBox();
    titleRow.add(titleLabel);
    titleRow.add(titleTextbox);
    postFormPanel.add(titleRow);

    // Description input
    HorizontalPanel descrRow = new HorizontalPanel();
    Label descrLabel = new Label("Item Short description");
    final TextArea descrText = new TextArea();
    descrText.setCharacterWidth(40);
    descrText.setVisibleLines(10);
    descrRow.add(descrLabel);
    descrRow.add(descrText);
    postFormPanel.add(descrRow);

    // Price input
    HorizontalPanel priceRow = new HorizontalPanel();
    Label priceLabel = new Label("Price ($)");
    final TextBox priceTextbox = new TextBox();
    priceTextbox.setVisibleLength(6);
    priceRow.add(priceLabel);
    priceRow.add(priceTextbox);
    postFormPanel.add(priceRow);

    // Address input
    HorizontalPanel addressRow = new HorizontalPanel();
    Label addressLabel = new Label("Address");
    final TextArea addressText = new TextArea();
    addressText.setCharacterWidth(40);
    addressText.setVisibleLines(5);
    addressRow.add(addressLabel);
    addressRow.add(addressText);
    postFormPanel.add(addressRow);

    if (post != null) {
      nameTextbox.setText(post.getSellerName());
      titleTextbox.setText(post.getTitle());
      descrText.setText(post.getDescription());
      priceTextbox.setText("" + post.getPrice());
      addressText.setText(post.getAddress());
    }

    // New widget for file upload
    HorizontalPanel fileRow = new HorizontalPanel();
    final FileUpload upload = new FileUpload();
    if (post != null) {
      Anchor link = new Anchor("Stored File", post.getURL());
      link.setTarget("_blank");
      fileRow.add(link);
      upload.setTitle("Change Uploaded File");
    } else upload.setTitle("Upload a File for Post");
    fileRow.add(upload);
    postFormPanel.add(fileRow);

    // Submit button
    Button submitButton;
    if (post != null) {
      submitButton = new Button("Submit Changes");
      submitButton.setText("Submit Changes");
    } else {
      submitButton = new Button("Submit Ad");
      submitButton.setText("Submit Ad");
    }
    submitButton.setStyleName("sideBarButton");
    postFormPanel.add(submitButton);

    // The submitFormPanel, when submitted, will trigger an HTTP call to the
    // servlet.  The following parameters must be set
    submitFormPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
    submitFormPanel.setMethod(FormPanel.METHOD_POST);

    // Set Names for the text boxes so that they can be retrieved from the
    // HTTP call as parameters
    nameTextbox.setName("name");
    titleTextbox.setName("title");
    descrText.setName("description");
    priceTextbox.setName("price");
    addressText.setName("address");
    upload.setName("upload");

    // Upon clicking "Submit" control goes to Controller
    submitButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            if (post == null) control.handlePostFromSubmitForm(submitFormPanel);
            else control.handlePostEditFromSubmitForm(post, submitFormPanel);
          }
        });

    // This event handler is "fired" just before the Form causes a doPost
    //  message to server
    submitFormPanel.addSubmitHandler(
        new FormPanel.SubmitHandler() {
          public void onSubmit(SubmitEvent event) {
            // This event is fired just before the form is submitted.
            //  We can take this opportunity to perform validation.
            if (nameTextbox.getText().length() == 0) {
              Window.alert("The author is required.");
              event.cancel();
            }
            if (titleTextbox.getText().length() == 0) {
              Window.alert("The title is required.");
              event.cancel();
            }
            Double price = Double.parseDouble(priceTextbox.getText());
            if (priceTextbox.getText().length() == 0 || Double.isNaN(price)) {
              Window.alert("The price is required. It must be a valid number");
              event.cancel();
            }
            if (addressText.getText().length() == 0) {
              Window.alert("The address is required.");
              event.cancel();
            }
            if (upload.getFilename().length() == 0 && post == null) {
              Window.alert("The upload file is required.");
              event.cancel();
            }
          }
        });

    // The doPost message itself is sent from the Form and not intercepted
    //  by GWT.

    // This event handler is "fired" just after the Form causes a doPost
    //  message to server
    submitFormPanel.addSubmitCompleteHandler(
        new FormPanel.SubmitCompleteHandler() {
          public void onSubmitComplete(SubmitCompleteEvent event) {
            if (post == null) {
              submitFormPanel.reset();
              nameTextbox.setFocus(true);
            } else control.viewAdDataFromServer();
          }
        });
    return submitFormPanel;
  }
  public FunctionPlotterExample() {
    presets.put("id", new String[] {"-10", "10", "function(x) {\n  return x;\n}"});
    presets.put("sine", new String[] {"-10", "10", "function(x) {\n  return Math.sin(x);\n}"});
    presets.put(
        "taylor",
        new String[] {
          "-3", "3", "function(x) {\n  return [Math.cos(x), 1 - x*x/2 + x*x*x*x/24];\n}"
        });
    presets.put(
        "sawtooth",
        new String[] {
          "-10",
          "10",
          "function(x) {\n  var y = 0;\n  for (var i = 1; i < 20; i+=2) {\n    y += Math.sin(i * x)/i;\n  }\n  var final = 1 - 2*(Math.abs(Math.floor(x / Math.PI)) % 2);\n  return [4/Math.PI * y, final];\n}"
        });

    initWidget(panel);
    panel.add(new HTML("<p><b>Equation: </b><br>"));
    textArea.setVisibleLines(10);
    textArea.setCharacterWidth(80);
    textArea.setValue(
        "function(x) {\n"
            + "  return [0.1 * x, 0.1 * x + Math.sin(x), 0.1*x + Math.cos(x)];\n"
            + "}");
    panel.add(textArea);

    presetsDD.addItem("(custom)", "custom");
    presetsDD.addItem("Identity", "id");
    presetsDD.addItem("Sine Wave", "sine");
    presetsDD.addItem("Taylor series", "taylor");
    presetsDD.addItem("Sawtooth", "sawtooth");
    presetsDD.setSelectedIndex(0);
    presetsDD.getElement().getStyle().setDisplay(Style.Display.INLINE_BLOCK);

    presetsDD.addChangeHandler(
        (event) -> {
          String value = presetsDD.getSelectedValue();
          if (value.equalsIgnoreCase("custom")) {
            return;
          }

          String[] preset = presets.get(value);
          fromTb.setValue(preset[0]);
          toTb.setValue(preset[1]);
          textArea.setValue(preset[2]);
          plot();
        });

    HorizontalPanel presetContainer = new HorizontalPanel();
    presetContainer.add(new HTML("<b>Preset functions:</b>"));
    presetContainer.add(presetsDD);
    panel.add(presetContainer);
    panel.add(new HTML("<p></p>"));
    HorizontalPanel rangeContainer = new HorizontalPanel();
    rangeContainer.add(new HTML("<b>x range:</b>"));
    fromTb.setVisibleLength(5);
    fromTb.setValue("-10");

    toTb.setVisibleLength(5);
    toTb.setValue("10");
    rangeContainer.add(fromTb);
    rangeContainer.add(new InlineLabel("to"));
    rangeContainer.add(toTb);
    panel.add(rangeContainer);
    Button plotBtn = new Button("Plot");

    plotBtn.addClickHandler((ev) -> plot());

    panel.add(new HTML("<p></p>"));
    panel.add(plotBtn);
    plot();
  }
  public FilterBasicPopUp() {
    super(true);
    setAnimationEnabled(true);
    AllBoolean = false;
    filtro = new ArrayList<TypeClient>();
    VerticalPanel verticalPanel = new VerticalPanel();
    setWidget(verticalPanel);
    verticalPanel.setSize("100%", "100%");

    SimplePanel simplePanel = new SimplePanel();
    verticalPanel.add(simplePanel);
    simplePanel.setSize("100%", "100%");

    if (textBox == null) textBox = new TextBox();
    textBox.setVisibleLength(100);
    simplePanel.setWidget(textBox);
    textBox.setSize("98%", "100%");
    Lang = ActualState.getLanguage();

    horizontalPanel = new HorizontalPanel();
    verticalPanel.add(horizontalPanel);

    Button btnNewButton = new Button(Lang.getFilterButton());
    horizontalPanel.add(btnNewButton);
    horizontalPanel.setCellHorizontalAlignment(btnNewButton, HasHorizontalAlignment.ALIGN_CENTER);

    All = new Button(Lang.getSelect_All());
    All.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            AllBoolean = !AllBoolean;
            if (AllBoolean) {
              textBox.setEnabled(false);
              textBox.setReadOnly(true);
              textBox.setText(Lang.getAllSelected());

            } else {
              textBox.setEnabled(true);
              textBox.setReadOnly(false);
              textBox.setText("");
            }
          }
        });
    horizontalPanel.add(All);
    All.setSize("100%", "100%");
    All.setStyleName("gwt-ButtonCenter");
    All.addMouseOutHandler(
        new MouseOutHandler() {
          public void onMouseOut(MouseOutEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenter");
          }
        });
    All.addMouseOverHandler(
        new MouseOverHandler() {
          public void onMouseOver(MouseOverEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenterOver");
          }
        });
    All.addMouseDownHandler(
        new MouseDownHandler() {
          public void onMouseDown(MouseDownEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenterPush");
          }
        });

    Advance = new Button(Lang.getAdvance());
    Advance.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            Controlador.change2FilterAdvance();
          }
        });
    Advance.setSize("100%", "100%");
    Advance.setStyleName("gwt-ButtonCenter");
    Advance.addMouseOutHandler(
        new MouseOutHandler() {
          public void onMouseOut(MouseOutEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenter");
          }
        });
    Advance.addMouseOverHandler(
        new MouseOverHandler() {
          public void onMouseOver(MouseOverEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenterOver");
          }
        });
    Advance.addMouseDownHandler(
        new MouseDownHandler() {
          public void onMouseDown(MouseDownEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenterPush");
          }
        });
    horizontalPanel.add(Advance);

    btnNewButton.setSize("100%", "100%");
    btnNewButton.setStyleName("gwt-ButtonCenter");
    btnNewButton.addMouseOutHandler(
        new MouseOutHandler() {
          public void onMouseOut(MouseOutEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenter");
          }
        });
    btnNewButton.addMouseOverHandler(
        new MouseOverHandler() {
          public void onMouseOver(MouseOverEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenterOver");
          }
        });
    btnNewButton.addMouseDownHandler(
        new MouseDownHandler() {
          public void onMouseDown(MouseDownEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenterPush");
          }
        });
    btnNewButton.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            filtro = new ArrayList<TypeClient>();
            if (!AllBoolean) {
              String Token = textBox.getText();
              String[] Words = Token.split(",");
              if (Words.length > 0) {
                Types = MakeWords(Words);
                filtro = FindTypes(Types, ActualState.getReadingActivityCloseCatalog());
                ArrayList<UserClient> Usuarios =
                    FindUsers(Types, ActualState.getReadingactivity().getGroup());
                MainEntryPoint.setFiltro(filtro, Usuarios, Types, new ArrayList<Long>());
                Me.hide();
              }
            } else {
              MainEntryPoint.CleanFilter();
              Me.hide();
            }
          }

          private ArrayList<UserClient> FindUsers(ArrayList<String> types, GroupClient group) {
            ArrayList<UserClient> salida = new ArrayList<UserClient>();
            for (UserClient studentUnit : group.getParticipatingUsers()) {
              testUserIn(studentUnit, types, salida);
            }
            testUserIn(group.getProfessor(), types, salida);
            return salida;
          }

          private void testUserIn(
              UserClient studentUnit, ArrayList<String> types, ArrayList<UserClient> salida) {
            for (String typocandidato : types) {
              if (studentUnit.getFirstName().toUpperCase().contains(typocandidato.toUpperCase()))
                AddSalida(studentUnit, salida);
              if (studentUnit.getLastName().toUpperCase().contains(typocandidato.toUpperCase()))
                AddSalida(studentUnit, salida);
              if (studentUnit
                  .getId()
                  .toString()
                  .toUpperCase()
                  .contains(typocandidato.toUpperCase())) AddSalida(studentUnit, salida);
              if (studentUnit.getEmail().toUpperCase().contains(typocandidato.toUpperCase()))
                AddSalida(studentUnit, salida);
            }
          }

          private void AddSalida(UserClient studentUnit, ArrayList<UserClient> salida) {
            if (!salida.contains(studentUnit)) salida.add(studentUnit);
          }

          private ArrayList<TypeClient> FindTypes(
              ArrayList<String> types, CatalogoClient catalogo) {
            ArrayList<TypeClient> Salida = new ArrayList<TypeClient>();
            for (EntryClient entryUni : catalogo.getEntries()) {
              EvaluaEntry(entryUni, types, Salida);
            }
            return Salida;
          }

          private void EvaluaEntry(
              EntryClient entryUni, ArrayList<String> types, ArrayList<TypeClient> salida) {
            if (entryUni instanceof TypeClient) EvaluaType((TypeClient) entryUni, types, salida);
            else if (entryUni instanceof TypeCategoryClient)
              EvaluaTypeCategory((TypeCategoryClient) entryUni, types, salida);
          }

          private void EvaluaTypeCategory(
              TypeCategoryClient entryUni, ArrayList<String> types, ArrayList<TypeClient> salida) {
            if (existeEn(entryUni, types)) AddHijos(entryUni, salida);
          }

          private void AddHijos(TypeCategoryClient entryUni, ArrayList<TypeClient> salida) {
            for (EntryClient candidato : entryUni.getChildren()) {
              if (candidato instanceof TypeClient) AddASalida((TypeClient) candidato, salida);
              else if (candidato instanceof TypeCategoryClient)
                AddHijos((TypeCategoryClient) candidato, salida);
            }
          }

          private void EvaluaType(
              TypeClient entryUni, ArrayList<String> types, ArrayList<TypeClient> salida) {
            if (existeEn(entryUni, types)) AddASalida(entryUni, salida);
          }

          private void AddASalida(TypeClient entryUni, ArrayList<TypeClient> salida) {
            if (!salida.contains(entryUni)) salida.add(entryUni);
          }

          private boolean existeEn(EntryClient entryUni, ArrayList<String> types) {
            for (String candidato : types) {
              if (candidato.toUpperCase().contains(entryUni.getName().toUpperCase())) return true;
            }
            return false;
          }

          private ArrayList<String> MakeWords(String[] words) {
            ArrayList<String> Salida = new ArrayList<String>();
            for (String SS : words) {
              if (!SS.isEmpty()) Salida.add(SS);
            }
            return Salida;
          }
        });
  }
示例#15
0
 public void setVisibleLength(int length) {
   textBox.setVisibleLength(length);
 }
  private Grid addWalrusEntry(int row, WalrusInfoWeb walrusInfo) {
    final ArrayList<String> properties = walrusInfo.getProperties();
    int numProperties = properties.size() / 4;
    Grid g = new Grid(1 + numProperties, 2);
    g.setStyleName("euca-table");
    g.setCellPadding(4);

    int i = 0; // row 1
    g.setWidget(i, 0, new Label("Walrus host:"));
    g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    HorizontalPanel p = new HorizontalPanel();
    p.setSpacing(0);
    g.setWidget(i, 1, p);
    final TextBox walrusHost_box = new TextBox();
    walrusHost_box.addChangeListener(new ChangeCallback(this, row));
    walrusHost_box.setVisibleLength(35);
    walrusHost_box.setText(walrusInfo.getHost());
    p.add(walrusHost_box);
    p.add(new EucaButton("Deregister", new DeleteCallback(this, row)));

    for (int propIdx = 0; propIdx < numProperties; ++propIdx) {
      i++; // next row
      if ("KEYVALUE".equals(properties.get(4 * propIdx))) {
        g.setWidget(i, 0, new Label(properties.get(4 * propIdx + 1) + ": "));
        g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
        final TextBox propTextBox = new TextBox();
        propTextBox.addChangeListener(new ChangeCallback(this, row));
        propTextBox.setVisibleLength(30);
        propTextBox.setText(properties.get(4 * propIdx + 2));
        propTextBox.addFocusListener(new FocusHandler(this.hint, this.warningMessage));
        g.setWidget(i, 1, propTextBox);
      } else if ("KEYVALUEHIDDEN".equals(properties.get(4 * propIdx))) {
        g.setWidget(i, 0, new Label(properties.get(4 * propIdx + 1) + ": "));
        g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
        final TextBox propTextBox = new PasswordTextBox();
        propTextBox.addChangeListener(new ChangeCallback(this, row));
        propTextBox.setVisibleLength(30);
        propTextBox.setText(properties.get(4 * propIdx + 2));
        propTextBox.addFocusListener(new FocusHandler(this.hint, this.warningMessage));
        g.setWidget(i, 1, propTextBox);
      } else if ("BOOLEAN".equals(properties.get(4 * propIdx))) {
        final int index = propIdx;
        final CheckBox propCheckbox = new CheckBox();
        g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
        g.setWidget(i, 0, propCheckbox);
        if (Boolean.parseBoolean(properties.get(4 * index + 2))) {
          propCheckbox.setChecked(true);
        } else {
          propCheckbox.setChecked(false);
        }
        propCheckbox.addClickListener(
            new ClickListener() {
              public void onClick(Widget sender) {
                if (((CheckBox) sender).isChecked()) {
                  properties.set(4 * index + 2, String.valueOf(true));
                } else {
                  properties.set(4 * index + 2, String.valueOf(false));
                }
              }
            });
        g.setWidget(i, 1, new Label(properties.get(propIdx * 4 + 1)));
      }
    }
    return g;
  }
示例#17
0
  public DialogCarma(KarmaHome home, KarmaUser user) {
    super(false, true);
    this.homeParent = home;
    this.user = user;

    setHTML(CONSTANTS.this_html());

    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    setWidget(verticalPanel);
    verticalPanel.setWidth("100%");

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setSpacing(5);
    verticalPanel.add(horizontalPanel);
    horizontalPanel.setWidth("100%");

    VerticalPanel verticalPanel_2 = new VerticalPanel();
    horizontalPanel.add(verticalPanel_2);
    verticalPanel_2.setSize("260", "110");

    Grid grid_1 = new Grid(3, 2);
    verticalPanel_2.add(grid_1);
    grid_1.setSize("", "100");

    Label label_10 = new Label(CONSTANTS.label_10_text());
    grid_1.setWidget(0, 0, label_10);
    grid_1.getCellFormatter().setWidth(0, 0, "100");

    listTypes = new ListBox();
    grid_1.setWidget(0, 1, listTypes);
    grid_1.getCellFormatter().setWidth(0, 1, "150");
    listTypes.setWidth("100%");
    ClientUtils.fillTypes(listTypes);

    Label label_11 = new Label(CONSTANTS.label_11_text());
    grid_1.setWidget(1, 0, label_11);

    tbPlate = new TextBox();
    tbPlate.setVisibleLength(10);
    grid_1.setWidget(1, 1, tbPlate);
    tbPlate.setWidth("100%");

    cbxForeign = new CheckBox(CONSTANTS.cbxForeign_text());
    grid_1.setWidget(2, 0, cbxForeign);
    cbxForeign.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            showCountries();
          }
        });

    listCountry = new ListBox();
    grid_1.setWidget(2, 1, listCountry);
    listCountry.setWidth("100%");
    listCountry.setVisible(false);
    ClientUtils.fillCountries(listCountry);

    VerticalPanel verticalPanel_6 = new VerticalPanel();
    horizontalPanel.add(verticalPanel_6);
    verticalPanel_6.setSize("260", "110");

    Grid grid_2 = new Grid(3, 2);
    verticalPanel_6.add(grid_2);
    grid_2.setSize("", "100");

    Label label_15 = new Label(CONSTANTS.label_15_text());
    grid_2.setWidget(0, 0, label_15);
    grid_2.getCellFormatter().setWidth(0, 0, "50");

    date = new DateBox();
    date.setFormat(new DefaultFormat(DateTimeFormat.getFormat("yyyy-MM-dd HH:mm")));
    grid_2.setWidget(0, 1, date);
    grid_2.getCellFormatter().setWidth(0, 1, "200");
    date.setWidth("100%");
    date.addValueChangeHandler(
        new ValueChangeHandler<Date>() {
          @Override
          public void onValueChange(ValueChangeEvent<Date> event) {
            Date d = event.getValue();
            if (d.after(new Date())
                || d.before(new Date(System.currentTimeMillis() - 31536000000L))) {
              date.setValue(new Date());
              MsgMan.getInstance().showError(CONSTANTS.error_date1(), date);
            }
          }
        });

    Label label_16 = new Label(CONSTANTS.label_16_text());
    grid_2.setWidget(1, 0, label_16);

    taNotes = new TextArea();
    taNotes.addKeyPressHandler(
        new KeyPressHandler() {
          public void onKeyPress(KeyPressEvent event) {
            updateCounter();
          }
        });
    taNotes.setSize("100%", "50");
    grid_2.setWidget(1, 1, taNotes);

    lblCounter = new Label("New label");
    lblCounter.addStyleName("counter");
    grid_2.setWidget(2, 1, lblCounter);
    grid_2.getCellFormatter().setHorizontalAlignment(2, 1, HasHorizontalAlignment.ALIGN_RIGHT);

    HorizontalPanel horizontalPanel_3 = new HorizontalPanel();
    horizontalPanel_3.setSpacing(5);
    horizontalPanel_3.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    verticalPanel.add(horizontalPanel_3);
    verticalPanel.setCellHorizontalAlignment(
        horizontalPanel_3, HasHorizontalAlignment.ALIGN_CENTER);

    btnPuntuar = new Button("New button");
    horizontalPanel_3.add(btnPuntuar);
    btnPuntuar.setText(CONSTANTS.btnPuntuar_text());
    btnPuntuar.setWidth("100");

    Button btnCancel = new Button("New button");
    horizontalPanel_3.add(btnCancel);
    btnCancel.setText(CONSTANTS.btnCancel_text());
    btnCancel.setWidth("100");
    btnPuntuar.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            makeKarma();
          }
        });
    btnCancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            DialogCarma.this.hide();
          }
        });

    updateCounter();
  }
示例#18
0
  public void onModuleLoad() {
    RootPanel rootPanel = RootPanel.get();
    RootPanel RootMenu = RootPanel.get("Menu");

    MenuBar menuBar = new MenuBar(false);
    RootMenu.add(menuBar);

    MenuItem CloseBoton =
        new MenuItem(
            "Close",
            false,
            new Command() {
              public void execute() {
                if (ActualUser.getUser().getProfile().equals(Constants.PROFESSOR))
                  Controlador.change2Administrator();
                else if (ActualUser.getUser().getProfile().equals(Constants.STUDENT))
                  Controlador.change2MyActivities();
              }
            });
    menuBar.addItem(CloseBoton);

    SimplePanel simplePanel = new SimplePanel();
    rootPanel.add(simplePanel, 0, 25);
    simplePanel.setSize("100%", "100%");

    DockLayoutPanel dockLayoutPanel = new DockLayoutPanel(Unit.EM);
    simplePanel.setWidget(dockLayoutPanel);
    dockLayoutPanel.setSize("100%", "100%");

    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    dockLayoutPanel.addWest(verticalPanel, 32.2);
    verticalPanel.setSize("100%", "100%");

    HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
    horizontalPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.add(horizontalPanel_1);
    horizontalPanel_1.setWidth("100%");

    VerticalPanel PanelCampos = new VerticalPanel();
    PanelCampos.setSpacing(10);
    horizontalPanel_1.add(PanelCampos);
    PanelCampos.setWidth("100%");

    HorizontalPanel horizontalPanel_2 = new HorizontalPanel();
    horizontalPanel_2.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    PanelCampos.add(horizontalPanel_2);
    horizontalPanel_2.setWidth("100%");

    Label lblNewLabel = new Label("Nombre");
    horizontalPanel_2.add(lblNewLabel);

    NameText = new TextBox();
    NameText.setMaxLength(25);
    NameText.setVisibleLength(25);
    horizontalPanel_2.add(NameText);
    NameText.setWidth("90%");
    String Nombre = "";
    if ((ActualUser.getUser().getName() != null) && (!ActualUser.getUser().getName().isEmpty()))
      Nombre = ActualUser.getUser().getName();
    NameText.setText(Nombre);

    HorizontalPanel horizontalPanel_3 = new HorizontalPanel();
    horizontalPanel_3.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    PanelCampos.add(horizontalPanel_3);
    horizontalPanel_3.setWidth("100%");

    Label lblNewLabel_1 = new Label("Apellidos");
    horizontalPanel_3.add(lblNewLabel_1);

    ApellidosText = new TextBox();
    ApellidosText.setVisibleLength(25);
    ApellidosText.setMaxLength(120);
    horizontalPanel_3.add(ApellidosText);
    ApellidosText.setWidth("90%");
    String Apellido = "";
    if ((ActualUser.getUser().getLastName() != null)
        && (!ActualUser.getUser().getLastName().isEmpty()))
      Apellido = ActualUser.getUser().getLastName();
    ApellidosText.setText(Apellido);

    HorizontalPanel horizontalPanel_4 = new HorizontalPanel();
    horizontalPanel_4.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_4.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    PanelCampos.add(horizontalPanel_4);
    horizontalPanel_4.setWidth("100%");

    SimplePanel simplePanel_1 = new SimplePanel();
    horizontalPanel_4.add(simplePanel_1);

    Button btnNewButton = new Button("Save");
    simplePanel_1.setWidget(btnNewButton);
    btnNewButton.setSize("100%", "100%");
    btnNewButton.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenter");
          }
        });

    btnNewButton.addMouseDownHandler(
        new MouseDownHandler() {
          public void onMouseDown(MouseDownEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenterPush");
          }
        });

    btnNewButton.addMouseOutHandler(
        new MouseOutHandler() {
          public void onMouseOut(MouseOutEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenter");
          }
        });

    btnNewButton.addMouseOverHandler(
        new MouseOverHandler() {
          public void onMouseOver(MouseOverEvent event) {

            ((Button) event.getSource()).setStyleName("gwt-ButtonCenterOver");
          }
        });

    btnNewButton.setStyleName("gwt-ButtonCenter");
    btnNewButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            UserApp AU = ActualUser.getUser();
            AU.setName(NameText.getText());
            AU.setLastName(ApellidosText.getText());
            LoadingPanel.getInstance().center();
            LoadingPanel.getInstance().setLabelTexto("Updating...");
            bookReaderServiceHolder.saveUser(
                AU,
                new AsyncCallback<Boolean>() {

                  public void onSuccess(Boolean result) {
                    bookReaderServiceHolder.loadUserById(
                        ActualUser.getUser().getId(),
                        new AsyncCallback<UserApp>() {

                          public void onSuccess(UserApp result) {
                            ActualUser.setUser(result);
                            bookReaderServiceHolder.updateRenameOfUser(
                                result.getId(),
                                new AsyncCallback<Void>() {

                                  public void onSuccess(Void result) {

                                    LoadingPanel.getInstance().hide();
                                    if (ActualUser.getUser()
                                        .getProfile()
                                        .equals(Constants.PROFESSOR))
                                      Controlador.change2Administrator();
                                    else if (ActualUser.getUser()
                                        .getProfile()
                                        .equals(Constants.STUDENT))
                                      Controlador.change2MyActivities();
                                  }

                                  public void onFailure(Throwable caught) {
                                    LoadingPanel.getInstance().hide();
                                    Window.alert(
                                        "I can refresh the old anotations, please re-save your name to fix it");
                                  }
                                });
                          }

                          public void onFailure(Throwable caught) {
                            Window.alert(
                                "I can reload the update User, if you want to show the new userInformation please reload the page");
                            LoadingPanel.getInstance().hide();
                          }
                        });
                  }

                  public void onFailure(Throwable caught) {
                    Window.alert("Error updating User.");
                    LoadingPanel.getInstance().hide();
                  }
                });
          }
        });

    VerticalPanel verticalPanel_1 = new VerticalPanel();
    verticalPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    dockLayoutPanel.add(verticalPanel_1);
    verticalPanel_1.setSize("100%", "100%");

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel_1.add(horizontalPanel);

    Image image = new Image("Logo.jpg");
    horizontalPanel.add(image);
  }
 private DisclosurePanel createCommentPostPanel() {
   DisclosurePanel postCommentDisclosurePanel = new DisclosurePanel("Post Comment");
   postCommentDisclosurePanel.setWidth("100%");
   postCommentDisclosurePanel.setOpen(true);
   VerticalPanel postCommentPanel = new VerticalPanel();
   postCommentPanel.setWidth("100%");
   // create text area for comment
   final TextArea commentTextArea = new TextArea();
   commentTextArea.setVisibleLines(3);
   commentTextArea.setWidth("500px");
   // create textfield for email address (if not logged in)
   final TextBox emailTextField = new TextBox();
   emailTextField.setVisibleLength(60);
   // create button panel
   HorizontalPanel buttonPanelWrapper = new HorizontalPanel();
   buttonPanelWrapper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
   buttonPanelWrapper.setWidth("500px");
   HorizontalPanel buttonPanel = new HorizontalPanel();
   // create buttons
   final Button submitButton = new Button("Submit");
   submitButton.addClickHandler(
       new ClickHandler() {
         public void onClick(ClickEvent event) {
           String commentStr = commentTextArea.getText();
           if (commentStr == null || "".equals(commentStr.trim())) {
             return;
           }
           Comment comment = new Comment();
           comment.setGlobalRead(true);
           comment.setOwner(permissibleObject.getOwner());
           comment.setAuthor(AuthenticationHandler.getInstance().getUser());
           comment.setComment(commentStr);
           comment.setParent(permissibleObject);
           comment.setEmail(emailTextField.getText());
           submitButton.setEnabled(false);
           submitComment(comment);
         }
       });
   final Button clearButton = new Button("Clear");
   clearButton.addClickHandler(
       new ClickHandler() {
         public void onClick(ClickEvent event) {
           commentTextArea.setText("");
           submitButton.setEnabled(true);
         }
       });
   // add buttons
   buttonPanel.add(clearButton);
   buttonPanel.add(submitButton);
   buttonPanelWrapper.add(buttonPanel);
   // add panels
   if (AuthenticationHandler.getInstance().getUser() == null) {
     postCommentPanel.add(new Label("Email:"));
     postCommentPanel.add(emailTextField);
   }
   postCommentPanel.add(new Label("Comment:"));
   postCommentPanel.add(commentTextArea);
   postCommentPanel.add(buttonPanelWrapper);
   postCommentDisclosurePanel.setContent(postCommentPanel);
   return postCommentDisclosurePanel;
 }
示例#20
0
  public void onModuleLoad() {
    RootPanel RootTXOriginal = RootPanel.get();
    RootPanel RootMenu = RootPanel.get("Menu");
    RootTXOriginal.setSize("100%", "100%");
    RootMenu.setStyleName("Root");
    RootTXOriginal.setStyleName("Root");

    YO = this;
    MenuBar menuBar = new MenuBar(false);
    RootMenu.add(menuBar);
    menuBar.setWidth("100%");

    MenuItem menuItem = new MenuItem("GroupAdministration", false, (Command) null);
    menuItem.setHTML("Users Administrator");
    menuItem.setEnabled(false);
    menuBar.addItem(menuItem);

    MenuItemSeparator separator = new MenuItemSeparator();
    menuBar.addSeparator(separator);

    MenuItem mntmBack =
        new MenuItem(
            "Back",
            false,
            new Command() {
              public void execute() {
                Controlador.change2Administrator();
              }
            });
    menuBar.addItem(mntmBack);

    MenuItem AddLots =
        new MenuItem(
            "Masive add",
            false,
            new Command() {
              public void execute() {
                PanelAddMasibo PAM = new PanelAddMasibo(YO);
                PAM.setVisible(true);
                PAM.center();
              }
            });
    AddLots.setHTML("Masive add");
    menuBar.addItem(AddLots);

    HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
    RootTXOriginal.add(horizontalSplitPanel, 0, 25);
    horizontalSplitPanel.setSize("100%", "100%");

    VerticalPanel verticalPanel = new VerticalPanel();
    horizontalSplitPanel.setLeftWidget(verticalPanel);
    verticalPanel.setSize("100%", "");

    SimplePanel simplePanel = new SimplePanel();
    verticalPanel.add(simplePanel);

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    simplePanel.setWidget(horizontalPanel);
    horizontalPanel.setSize("100%", "100%");

    textBox = new TextBox();
    textBox.setVisibleLength(50);
    horizontalPanel.add(textBox);
    textBox.setWidth("90%");

    Button btnNewButton = new Button("New button");
    btnNewButton.setText("+");
    btnNewButton.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenter");
          }
        });

    btnNewButton.addMouseDownHandler(
        new MouseDownHandler() {
          public void onMouseDown(MouseDownEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenterPush");
          }
        });

    btnNewButton.addMouseOutHandler(
        new MouseOutHandler() {
          public void onMouseOut(MouseOutEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonCenter");
          }
        });

    btnNewButton.addMouseOverHandler(
        new MouseOverHandler() {
          public void onMouseOver(MouseOverEvent event) {

            ((Button) event.getSource()).setStyleName("gwt-ButtonCenterOver");
          }
        });

    btnNewButton.setStyleName("gwt-ButtonCenter");
    btnNewButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            String S = ClearText(textBox.getText());
            if (isValidEmail(S)) addText(S);
            else Window.alert(ErrorConstants.ERROR_NO_EMAIL_VALIDO + S);
            textBox.setText("");
          }

          private native boolean isValidEmail(String email) /*-{
	        var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	        var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
	        	return !reg1.test(email) && reg2.test(email);
			}-*/;
        });

    horizontalPanel.add(btnNewButton);
    btnNewButton.setWidth("66px");
    btnNewButton.setHTML("+");

    verticalPanel_1 = new VerticalPanel();
    verticalPanel.add(verticalPanel_1);
    verticalPanel_1.setWidth("100%");

    SaveNewUsers = new Button("Save New Users");
    SaveNewUsers.setVisible(false);
    SaveNewUsers.addClickHandler(
        new ClickHandler() {
          private AsyncCallback<Boolean> callback;

          public void onClick(ClickEvent event) {
            Pilallamada = new Stack<UserApp>();
            int Elementos_a_salvar = verticalPanel_1.getWidgetCount();
            for (int i = 0; i < Elementos_a_salvar; i++) {
              Widget Uno = verticalPanel_1.getWidget(i);
              Button Dos = (Button) Uno;
              String Nombre = Dos.getText();
              Pilallamada.add(new UserApp(Nombre, Constants.STUDENT));
            }
            if (!Pilallamada.isEmpty()) {
              callback =
                  new AsyncCallback<Boolean>() {

                    public void onFailure(Throwable caught) {
                      Window.alert("The user could not be saved at this moment");
                      LoadingPanel.getInstance().hide();
                    }

                    public void onSuccess(Boolean result) {
                      LoadingPanel.getInstance().hide();
                      if (!result)
                        Window.alert(
                            "The user "
                                + Pilallamada.peek().getEmail()
                                + " already exists (if you do not see him/her it's because he may be administrator)");
                      Pilallamada.pop();
                      if (!Pilallamada.isEmpty()) {
                        LoadingPanel.getInstance().center();
                        LoadingPanel.getInstance().setLabelTexto("Saving...");
                        bookReaderServiceHolder.saveUser(Pilallamada.peek(), callback);

                      } else {
                        refreshPanel();
                      }
                    }
                  };
              LoadingPanel.getInstance().center();
              LoadingPanel.getInstance().setLabelTexto("Saving...");
              bookReaderServiceHolder.saveUser(Pilallamada.peek(), callback);
            }
            verticalPanel_1.clear();
            SaveNewUsers.setVisible(false);
          }
        });
    SaveNewUsers.addMouseDownHandler(
        new MouseDownHandler() {
          public void onMouseDown(MouseDownEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonBottonSavePush");
          }
        });
    SaveNewUsers.addMouseOutHandler(
        new MouseOutHandler() {
          public void onMouseOut(MouseOutEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonBottonSave");
          }
        });
    SaveNewUsers.addMouseOverHandler(
        new MouseOverHandler() {
          public void onMouseOver(MouseOverEvent event) {
            ((Button) event.getSource()).setStyleName("gwt-ButtonBottonSaveOver");
          }
        });
    SaveNewUsers.setStyleName("gwt-ButtonBottonSave");
    //	SaveNewUsers.setStyleName("gwt-MenuItemMio");
    verticalPanel.add(SaveNewUsers);
    SaveNewUsers.setSize("100%", "100%");

    ScrollPanel scrollPanel = new ScrollPanel();
    horizontalSplitPanel.setRightWidget(scrollPanel);
    scrollPanel.setSize("100%", "100%");

    stackPanel_1 = new StackPanelMio();
    scrollPanel.setWidget(stackPanel_1);
    // simplePanel.add(stackPanel_1);

    stackPanel_1.setBotonTipo(new BotonesStackPanelUsersMio("prototipo", new VerticalPanel()));
    stackPanel_1.setBotonClick(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            Long Nombre = ((BotonesStackPanelUsersMio) event.getSource()).getEntidad().getID();
            LoadingPanel.getInstance().center();
            LoadingPanel.getInstance().setLabelTexto("Loading...");
            bookReaderServiceHolder.loadUserById(
                Nombre,
                new AsyncCallback<UserApp>() {

                  public void onFailure(Throwable caught) {
                    LoadingPanel.getInstance().hide();
                  }

                  public void onSuccess(UserApp result) {
                    LoadingPanel.getInstance().hide();
                    if (result.getGroupIds() == null) result.setGroupIds(new ArrayList<Long>());
                    if (!result.getGroupIds().isEmpty())
                      if (Window.confirm(
                          InformationConstants.ARE_YOU_SURE_DELETE_USER
                              + result.getGroupIds().size()
                              + InformationConstants.ARE_YOU_SURE_DELETE_USER2))
                        remove(result.getId());
                      else {
                      }
                    else {
                      if (Window.confirm(
                          "Are you sure you want to delete this user?, he is not a member of any group"))
                        remove(result.getId());
                    }
                  }
                });
          }

          private void remove(Long userId) {

            LoadingPanel.getInstance().center();
            LoadingPanel.getInstance().setLabelTexto("Deleting...");
            bookReaderServiceHolder.deleteUserApp(
                userId,
                new AsyncCallback<Integer>() {

                  public void onFailure(Throwable caught) {
                    LoadingPanel.getInstance().hide();
                    Window.alert("Sorry but the user could not be removed, try again later");
                  }

                  public void onSuccess(Integer result) {
                    LoadingPanel.getInstance().hide();
                    refreshPanel();
                  }
                });
          }
        });

    LoadingPanel.getInstance().center();
    LoadingPanel.getInstance().setLabelTexto("Loading...");
    bookReaderServiceHolder.getUsersApp(
        new AsyncCallback<ArrayList<UserApp>>() {

          public void onFailure(Throwable caught) {
            LoadingPanel.getInstance().hide();
          }

          public void onSuccess(ArrayList<UserApp> result) {
            LoadingPanel.getInstance().hide();
            if (result.size() < 10) {
              for (UserApp User1 : result) {
                String Bienvenida;
                if ((User1.getName() != null) && (!User1.getName().isEmpty()))
                  Bienvenida = User1.getName();
                else Bienvenida = User1.getEmail();
                EntidadUser E = new EntidadUser(Bienvenida, User1.getId());
                stackPanel_1.addBotonLessTen(E);
              }

            } else {
              for (UserApp User1 : result) {
                String Bienvenida;
                if ((User1.getName() != null) && (!User1.getName().isEmpty()))
                  Bienvenida = User1.getName();
                else Bienvenida = User1.getEmail();
                EntidadUser E = new EntidadUser(Bienvenida, User1.getId());
                stackPanel_1.addBoton(E);
              }
            }
            stackPanel_1.setSize("100%", "100%");
            stackPanel_1.ClearEmpty();
          }
        });

    stackPanel_1.setSize("100%", "100%");
  }
示例#21
0
  public void addBadge(
      String badge, boolean requireForSignup, String applyToRole, int numSlots, int earlySignup) {
    if (badge.equals(SELECT_A_BADGE)) {
      return;
    }

    final int rows = badgeft.getRowCount() - 1;

    badgeft.setText(rows + 1, 0, badge);

    final CheckBox cb = new CheckBox();
    cb.setValue(requireForSignup);
    badgeft.setWidget(rows + 1, 1, cb);

    final ListBox roles = new ListBox();
    roles.setVisibleItemCount(1);

    roles.addItem(ALL_ROLES);

    int sel_index = 0;

    for (int i = 0; i < roleft.getRowCount() - 2; ++i) {
      String role = roleft.getText(i + 1, 0);
      roles.addItem(role);
      if (applyToRole != null && role.equals(applyToRole)) {
        sel_index = roles.getItemCount() - 1;
      }
    }

    roles.setSelectedIndex(sel_index);
    badgeft.setWidget(rows + 1, 2, roles);

    final TextBox slots = new TextBox();
    slots.setVisibleLength(2);
    if (requireForSignup && applyToRole != null) {
      slots.setText("" + numSlots);
    } else {
      slots.setEnabled(false);
      slots.setText("0");
    }
    badgeft.setWidget(rows + 1, 3, slots);
    slots.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            try {
              int num = Integer.parseInt(slots.getText());
              if (num < 0) {
                slots.setText("0");
              }
            } catch (NumberFormatException e) {
              slots.setText("0");
            }
          }
        });

    cb.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            if (cb.getValue() && roles.getSelectedIndex() > 0) {
              slots.setEnabled(true);
            } else {
              slots.setEnabled(false);
              slots.setText("0");
            }
          }
        });

    roles.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            if (cb.getValue() && roles.getSelectedIndex() > 0) {
              slots.setEnabled(true);
            } else {
              slots.setEnabled(false);
              slots.setText("0");
            }
          }
        });

    final TextBox early = new TextBox();
    early.setVisibleLength(2);
    early.setText("" + earlySignup);
    badgeft.setWidget(rows + 1, 4, early);
    early.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            try {
              int num = Integer.parseInt(early.getText());
              if (num < 0) {
                early.setText("0");
              }
            } catch (NumberFormatException e) {
              early.setText("0");
            }
          }
        });

    badgeft.setWidget(
        rows + 1,
        5,
        new Button(
            "Remove",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                final Object sender = event.getSource();
                final int rows = badgeft.getRowCount() - 1;
                for (int i = 0; i < rows; ++i) {
                  if (badgeft.getWidget(i + 1, 5) == sender) {
                    badgeft.removeRow(i + 1);
                    break;
                  }
                }
              }
            }));
  }
示例#22
0
  public void addRole(String role, int min_value, int max_value) {
    if (role.equals(SELECT_A_ROLE)) {
      return;
    }

    final int rows = roleft.getRowCount() - 2;

    // check role doesn't already exist
    for (int row = 0; row < rows; ++row) {
      if (roleft.getText(row + 1, 0).equals(role)) {
        return;
      }
    }

    roleft.insertRow(rows + 1);
    roleft.setText(rows + 1, 0, role);

    final TextBox min = new TextBox();
    final TextBox max = new TextBox();

    min.setText("" + min_value);
    max.setText("" + max_value);

    min.setVisibleLength(2);
    max.setVisibleLength(2);

    ChangeHandler minmax =
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            final Object sender = event.getSource();
            try {
              Integer minv = Integer.parseInt(min.getText());
              Integer maxv = Integer.parseInt(max.getText());

              if (sender == min) {
                if (minv > maxv) {
                  max.setText(min.getText());
                }
              } else if (sender == max) {
                if (maxv < minv) {
                  min.setText(max.getText());
                }
              }
            } catch (NumberFormatException e) {
              if (sender == min) {
                min.setText("0");
              } else if (sender == max) {
                max.setText("0");
              }
            }

            updateRoleTotals();
          }
        };

    min.addChangeHandler(minmax);
    max.addChangeHandler(minmax);

    roleft.setWidget(rows + 1, 1, min);
    roleft.setWidget(rows + 1, 2, max);
    roleft.setWidget(
        rows + 1,
        3,
        new Button(
            "Remove",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                final Object sender = event.getSource();
                final int rows = roleft.getRowCount() - 2;
                for (int i = 0; i < rows; ++i) {
                  if (roleft.getWidget(i + 1, 3) == sender) {
                    roleft.removeRow(i + 1);
                    updateBadgeRoles();
                    break;
                  }
                }
              }
            }));

    updateRoleTotals();
  }
示例#23
0
  public EventEditor(final Admin admin, JSEventTemplate et) {
    this.admin = admin;
    this.et = et;

    vpanel.setWidth("100%");
    vpanel.setHeight("100%");

    final Label errmsg = new Label();
    errmsg.addStyleName(errmsg.getStylePrimaryName() + "-error");
    errmsg.addStyleName(errmsg.getStylePrimaryName() + "-bottom");

    FlexTable grid = new FlexTable();
    grid.setWidth("100%");

    CellFormatter cf = grid.getCellFormatter();
    // right align field labels
    cf.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    cf.setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    cf.setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    cf.setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    cf.setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    cf.setHorizontalAlignment(5, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    cf.setHorizontalAlignment(7, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    grid.setText(0, 0, "Event Name:");
    grid.setText(1, 0, "Raid Size:");
    grid.setText(2, 0, "Minimum Level:");
    grid.setText(3, 0, "Instance:");
    grid.setText(4, 0, "Bosses:");
    grid.setText(5, 0, "Roles:");
    grid.setText(7, 0, "Badges:");

    size.setVisibleLength(2);
    minlevel.setVisibleLength(2);

    size.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            try {
              int sizen = Integer.parseInt(size.getText());
              if (sizen < 0) {
                size.setText("0");
              }
            } catch (NumberFormatException e) {
              size.setText("25");
            }

            updateRoleTotals();
          }
        });

    minlevel.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            try {
              int minleveln = Integer.parseInt(minlevel.getText());
              if (minleveln < 0) {
                size.setText("0");
              }
            } catch (NumberFormatException e) {
              size.setText(MAX_LEVEL);
            }
          }
        });

    instances.setWidth("100%");
    instances.setVisibleItemCount(1);

    roles.setWidth("100%");
    roles.setVisibleItemCount(1);

    badges.setWidth("100%");
    badges.setVisibleItemCount(1);

    grid.setWidget(0, 1, name);
    grid.setWidget(1, 1, size);
    grid.setWidget(2, 1, minlevel);

    grid.setWidget(3, 1, instances);

    GoteFarm.goteService.getInstances(
        admin.current_guild.key,
        new AsyncCallback<List<JSInstance>>() {
          public void onSuccess(List<JSInstance> results) {
            int sel = 0;

            for (JSInstance i : results) {
              instances.addItem(i.name, i.key);
              if (EventEditor.this.et != null && i.key.equals(EventEditor.this.et.instance_key)) {
                sel = instances.getItemCount() - 1;
              }
            }

            instances.setSelectedIndex(sel);

            updateBosses();
          }

          public void onFailure(Throwable caught) {}
        });

    instances.addChangeHandler(this);
    roles.addChangeHandler(this);
    badges.addChangeHandler(this);

    grid.setWidget(3, 2, newinst);

    newinst.setText(NEW_INSTANCE);

    newinst.addKeyPressHandler(
        new KeyPressHandler() {
          public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
              final String inst = newinst.getText();

              boolean found = false;

              for (int i = 0; i < instances.getItemCount(); ++i) {
                if (instances.getItemText(i).equals(inst)) {
                  instances.setSelectedIndex(i);
                  focusBoss();
                  found = true;
                  break;
                }
              }

              if (!found) {
                GoteFarm.goteService.addInstance(
                    admin.current_guild.key,
                    inst,
                    new AsyncCallback<JSInstance>() {
                      public void onSuccess(JSInstance result) {
                        instances.addItem(result.name, result.key);
                        instances.setSelectedIndex(instances.getItemCount() - 1);
                        bosses.clear();

                        focusBoss();
                      }

                      public void onFailure(Throwable caught) {
                        errmsg.setText(caught.getMessage());
                      }
                    });
              }
            }
          }
        });

    grid.setWidget(4, 1, bosses);
    grid.setWidget(4, 2, newboss);

    bosses.setWidth("100%");
    bosses.setVisibleItemCount(10);

    newboss.setText(NEW_BOSS);

    newboss.addKeyPressHandler(
        new KeyPressHandler() {
          public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
              int selinst = instances.getSelectedIndex();
              if (selinst == -1) {
                errmsg.setText("You need to select and instance to " + "add a boss.");
                return;
              }

              final String boss = newboss.getText();

              boolean found = false;

              for (int i = 0; i < bosses.getItemCount(); ++i) {
                if (bosses.getItemText(i).equals(boss)) {
                  bosses.setItemSelected(i, true);
                  focusBoss();
                  found = true;
                  break;
                }
              }

              if (!found) {
                GoteFarm.goteService.addBoss(
                    instances.getValue(selinst),
                    boss,
                    new AsyncCallback<JSBoss>() {

                      public void onSuccess(JSBoss result) {
                        bosses.addItem(result.name, result.key);
                        bosses.setItemSelected(bosses.getItemCount() - 1, true);

                        focusBoss();
                      }

                      public void onFailure(Throwable caught) {
                        errmsg.setText(caught.getMessage());
                      }
                    });
              }
            }
          }
        });

    grid.setWidget(5, 1, roles);

    roles.addItem(SELECT_A_ROLE);

    GoteFarm.goteService.getRoles(
        admin.current_guild.key,
        new AsyncCallback<List<JSRole>>() {
          public void onSuccess(List<JSRole> results) {
            for (JSRole i : results) {
              roles.addItem(i.name, i.key);
            }
          }

          public void onFailure(Throwable caught) {}
        });

    grid.setWidget(5, 2, newrole);

    newrole.setText(NEW_ROLE);

    newrole.addKeyPressHandler(
        new KeyPressHandler() {
          private void focusRole() {
            newrole.setFocus(true);
            newrole.setText(NEW_ROLE);
            newrole.setSelectionRange(0, NEW_ROLE.length());
          }

          public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
              final String role = newrole.getText();

              boolean found = false;

              for (int i = 0; i < roles.getItemCount(); ++i) {
                if (roles.getItemText(i).equals(role)) {
                  roles.setSelectedIndex(i);
                  addRole(role);
                  focusRole();
                  found = true;
                  break;
                }
              }

              if (!found) {
                GoteFarm.goteService.addRole(
                    admin.current_guild.key,
                    role,
                    true,
                    new AsyncCallback<JSRole>() {
                      public void onSuccess(JSRole result) {
                        roles.addItem(role, result.key);
                        roles.setSelectedIndex(roles.getItemCount() - 1);

                        addRole(role);
                        focusRole();
                      }

                      public void onFailure(Throwable caught) {
                        errmsg.setText(caught.getMessage());
                      }
                    });
              }
            }
          }
        });

    roleft.setWidth("100%");
    roleft.setCellSpacing(0);
    roleft.setCellPadding(5);
    roleft.setText(0, 0, "Role");
    roleft.setText(0, 1, "Min");
    roleft.setText(0, 2, "Max");
    roleft.setText(1, 0, "Totals");

    FlexTable.FlexCellFormatter rcf = roleft.getFlexCellFormatter();
    rcf.addStyleName(0, 0, "header");
    rcf.addStyleName(0, 1, "header");
    rcf.addStyleName(0, 2, "header");
    rcf.addStyleName(0, 3, "header");
    rcf.addStyleName(1, 0, "footer");
    rcf.addStyleName(1, 1, "footer");
    rcf.addStyleName(1, 2, "footer");
    rcf.addStyleName(1, 3, "footer");

    FlexTable.FlexCellFormatter gcf = grid.getFlexCellFormatter();

    grid.setWidget(6, 0, roleft);
    gcf.setColSpan(6, 0, 3);

    grid.setWidget(7, 1, badges);

    badges.addItem(SELECT_A_BADGE);

    GoteFarm.goteService.getBadges(
        admin.current_guild.key,
        new AsyncCallback<List<JSBadge>>() {
          public void onSuccess(List<JSBadge> results) {
            for (JSBadge badge : results) {
              badges.addItem(badge.name, badge.key);
            }
          }

          public void onFailure(Throwable caught) {}
        });

    grid.setWidget(7, 2, newbadge);

    newbadge.setText(NEW_BADGE);

    newbadge.addKeyPressHandler(
        new KeyPressHandler() {
          private void focusBadge() {
            newbadge.setFocus(true);
            newbadge.setText(NEW_BADGE);
            newbadge.setSelectionRange(0, NEW_BADGE.length());
          }

          public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
              final String badge = newbadge.getText();

              boolean found = false;

              for (int i = 0; i < badges.getItemCount(); ++i) {
                if (badges.getItemText(i).equals(badge)) {
                  addBadge(badge);
                  focusBadge();
                  found = true;
                  break;
                }
              }

              if (!found) {
                GoteFarm.goteService.addBadge(
                    admin.current_guild.key,
                    badge,
                    0,
                    new AsyncCallback<JSBadge>() {
                      public void onSuccess(JSBadge result) {
                        badges.addItem(badge, result.key);
                        badges.setSelectedIndex(badges.getItemCount() - 1);

                        addBadge(badge);
                        focusBadge();
                      }

                      public void onFailure(Throwable caught) {
                        errmsg.setText(caught.getMessage());
                      }
                    });
              }
            }
          }
        });

    badgeft.setWidth("100%");
    badgeft.setCellSpacing(0);
    badgeft.setCellPadding(5);
    badgeft.setText(0, 0, "Badge");
    badgeft.setText(0, 1, "Require For Sign Up");
    badgeft.setText(0, 2, "Apply To Role");
    badgeft.setText(0, 3, "Num Role Slots");
    badgeft.setText(0, 4, "Early Signup (Hours)");

    FlexTable.FlexCellFormatter bcf = badgeft.getFlexCellFormatter();
    bcf.addStyleName(0, 0, "header");
    bcf.addStyleName(0, 1, "header");
    bcf.addStyleName(0, 2, "header");
    bcf.addStyleName(0, 3, "header");
    bcf.addStyleName(0, 4, "header");
    bcf.addStyleName(0, 5, "header");

    grid.setWidget(8, 0, badgeft);
    gcf.setColSpan(8, 0, 3);

    vpanel.add(grid);

    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.setWidth("100%");

    final CheckBox modify = new CheckBox("Modify published events (can change signups)");
    modify.setValue(true);
    modify.addStyleName(modify.getStylePrimaryName() + "-bottom");
    modify.addStyleName(modify.getStylePrimaryName() + "-left");

    Button save =
        new Button(
            "Save",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                // clear error message
                errmsg.setText("");

                final JSEventTemplate t = new JSEventTemplate();

                if (EventEditor.this.et != null) {
                  t.key = EventEditor.this.et.key;
                } else {
                  t.key = null;
                }

                t.name = name.getText();
                t.size = getRaidSize();
                t.minimumLevel = Integer.parseInt(minlevel.getText());
                int index = instances.getSelectedIndex();
                if (index < 0) {
                  errmsg.setText("Please select an instance for this event.");
                  return;
                }
                t.instance_key = instances.getValue(index);

                t.boss_keys = new ArrayList<String>();
                for (int i = 0; i < bosses.getItemCount(); ++i) {
                  if (bosses.isItemSelected(i)) {
                    t.boss_keys.add(bosses.getValue(i));
                  }
                }

                t.roles = new ArrayList<JSEventRole>();
                for (int i = 0; i < roleft.getRowCount() - 2; ++i) {
                  JSEventRole er = new JSEventRole();
                  er.name = roleft.getText(i + 1, 0);
                  er.role_key = getRoleKey(er.name);
                  TextBox minmax;
                  minmax = (TextBox) roleft.getWidget(i + 1, 1);
                  er.min = Integer.parseInt(minmax.getText());
                  minmax = (TextBox) roleft.getWidget(i + 1, 2);
                  er.max = Integer.parseInt(minmax.getText());
                  t.roles.add(er);
                }

                t.badges = new ArrayList<JSEventBadge>();
                for (int i = 0; i < badgeft.getRowCount() - 1; ++i) {
                  JSEventBadge eb = new JSEventBadge();
                  eb.name = badgeft.getText(i + 1, 0);
                  eb.badge_key = getBadgeKey(eb.name);
                  CheckBox cb = (CheckBox) badgeft.getWidget(i + 1, 1);
                  eb.requireForSignup = cb.getValue();
                  ListBox lb = (ListBox) badgeft.getWidget(i + 1, 2);
                  String role = lb.getItemText(lb.getSelectedIndex());
                  if (!role.equals(ALL_ROLES)) {
                    eb.applyToRole = role;
                  }
                  TextBox tb;
                  tb = (TextBox) badgeft.getWidget(i + 1, 3);
                  eb.numSlots = Integer.parseInt(tb.getText());
                  tb = (TextBox) badgeft.getWidget(i + 1, 4);
                  eb.earlySignup = Integer.parseInt(tb.getText());
                  t.badges.add(eb);
                }

                t.modifyEvents = modify.getValue();

                GoteFarm.goteService.saveEventTemplate(
                    admin.current_guild.key,
                    t,
                    new AsyncCallback<JSEventTemplate>() {
                      public void onSuccess(JSEventTemplate result) {
                        EventEditor.this.admin.eventAdded();
                        EventEditor.this.admin.setCenterWidget(null);
                        if (t.key != null && t.modifyEvents) {
                          admin.fireAdminChange(AdminChange.getEventsChanged());
                        }
                      }

                      public void onFailure(Throwable caught) {
                        errmsg.setText(caught.getMessage());
                      }
                    });
              }
            });

    save.addStyleName(save.getStylePrimaryName() + "-bottom");
    save.addStyleName(save.getStylePrimaryName() + "-left");

    Button cancel =
        new Button(
            "Cancel",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                EventEditor.this.admin.setCenterWidget(null);
              }
            });

    cancel.addStyleName(cancel.getStylePrimaryName() + "-bottom");
    cancel.addStyleName(cancel.getStylePrimaryName() + "-right");

    hpanel.add(save);
    // Editing an existing event?
    if (EventEditor.this.et != null) {
      hpanel.add(modify);
    }
    hpanel.add(errmsg);
    hpanel.add(cancel);

    vpanel.add(hpanel);

    if (et != null) {
      for (JSEventRole ev : et.roles) {
        addRole(ev.name, ev.min, ev.max);
      }

      for (JSEventBadge eb : et.badges) {
        addBadge(eb.name, eb.requireForSignup, eb.applyToRole, eb.numSlots, eb.earlySignup);
      }
    }

    if (et == null) {
      name.setText(NEW_EVENT);

      DeferredCommand.addCommand(
          new Command() {
            public void execute() {
              name.setFocus(true);
              name.setSelectionRange(0, NEW_EVENT.length());
            }
          });

      size.setText("25");
      minlevel.setText(MAX_LEVEL);
    } else {
      name.setText(et.name);
      size.setText("" + et.size);
      minlevel.setText("" + et.minimumLevel);
    }

    updateRoleTotals();

    initWidget(vpanel);

    setStyleName("Admin-EventEditor");
  }
示例#24
0
  public RowLayoutPortlet() {
    LayoutPanel panel = new LayoutPanel();
    initWidget(panel);

    final CheckBox column = new CheckBox("Column");
    column.addValueChangeHandler(
        new ValueChangeHandler<Boolean>() {
          public void onValueChange(ValueChangeEvent<Boolean> event) {
            getTargetLayout().setColumn(column.getValue());
            target.layout();
          }
        });

    final TextBox spacing = new TextBox();
    spacing.setVisibleLength(4);
    spacing.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            try {
              getTargetLayout().setSpacing(Integer.parseInt(spacing.getText()));
            } catch (NumberFormatException e) {
              // ignore
            }
            target.layout();
          }
        });

    final Label bounds = new Label();
    target.addLayoutHandler(
        new LayoutHandler() {
          public void onLayoutUpdated(LayoutEvent layoutEvent) {
            bounds.setText(LDOM.getBounds(target).toString());
            column.setValue(getTargetLayout().isColumn());
            spacing.setText(Integer.toString(getTargetLayout().getSpacing()));
          }
        });

    demoList.addItem("Buttons & Body");
    demoList.addItem("Sidebar & Margin");
    demoList.addItem("Border Layout");
    demoList.setSelectedIndex(0);

    Button add =
        new CssButton(
            "Add Widget",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                target.add(new Thing("Widget-" + (target.getWidgetCount() + 1)));
                target.layout();
              }
            },
            "Add a new widget to the layout");

    final Button go =
        new CssButton(
            "Go",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                go();
              }
            },
            "Reset the layout to the selected state");

    demoList.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            go.click();
          }
        });

    FormBuilder b = new FormBuilder();
    b.add(add)
        .label("Spacing")
        .field(spacing)
        .field(column)
        .add("")
        .field(bounds)
        .wrap()
        .width("100%")
        .add(demoList)
        .add(go)
        .endRow();

    panel.add(b.getForm(), 22);
    panel.add(target, LayoutConstraints.HIDDEN);

    go();
  }
示例#25
0
  public ColorPicker() {
    // UI Drawing
    // ------------------

    hue = 0;
    saturation = 100;
    brightness = 100;
    red = 255;
    green = 0;
    blue = 0;

    HorizontalPanel panel = new HorizontalPanel();
    FlexTable table = new FlexTable();

    // Add the large slider map
    slidermap = new SliderMap(this);
    panel.add(slidermap);
    panel.setCellWidth(slidermap, "258px");
    panel.setCellHeight(slidermap, "258px");

    // Add the small slider bar
    sliderbar = new SliderBar(this);
    panel.add(sliderbar);
    panel.setCellWidth(sliderbar, "40px");
    panel.setCellHeight(sliderbar, "258px");

    // Define the Flextable's content
    // Color preview at the top
    colorpreview = new HTML("");
    colorpreview.setWidth("50px");
    colorpreview.setHeight("50px");
    DOM.setStyleAttribute(colorpreview.getElement(), "border", "1px solid black");

    // Radio buttons
    rbHue = new RadioButton("color", "H:");
    rbHue.addClickHandler(this);
    rbSaturation = new RadioButton("color", "S:");
    rbSaturation.addClickHandler(this);
    rbBrightness = new RadioButton("color", "V:");
    rbBrightness.addClickHandler(this);
    rbRed = new RadioButton("color", "R:");
    rbRed.addClickHandler(this);
    rbGreen = new RadioButton("color", "G:");
    rbGreen.addClickHandler(this);
    rbBlue = new RadioButton("color", "B:");
    rbBlue.addClickHandler(this);

    // Textboxes
    tbHue = new TextBox();
    tbHue.setText(new Integer(hue).toString());
    tbHue.setMaxLength(3);
    tbHue.setVisibleLength(4);
    tbHue.addKeyPressHandler(this);
    tbHue.addChangeHandler(this);
    tbSaturation = new TextBox();
    tbSaturation.setText(new Integer(saturation).toString());
    tbSaturation.setMaxLength(3);
    tbSaturation.setVisibleLength(4);
    tbSaturation.addKeyPressHandler(this);
    tbSaturation.addChangeHandler(this);
    tbBrightness = new TextBox();
    tbBrightness.setText(new Integer(brightness).toString());
    tbBrightness.setMaxLength(3);
    tbBrightness.setVisibleLength(4);
    tbBrightness.addKeyPressHandler(this);
    tbBrightness.addChangeHandler(this);
    tbRed = new TextBox();
    tbRed.setText(new Integer(red).toString());
    tbRed.setMaxLength(3);
    tbRed.setVisibleLength(4);
    tbRed.addKeyPressHandler(this);
    tbRed.addChangeHandler(this);
    tbGreen = new TextBox();
    tbGreen.setText(new Integer(green).toString());
    tbGreen.setMaxLength(3);
    tbGreen.setVisibleLength(4);
    tbGreen.addKeyPressHandler(this);
    tbGreen.addChangeHandler(this);
    tbBlue = new TextBox();
    tbBlue.setText(new Integer(blue).toString());
    tbBlue.setMaxLength(3);
    tbBlue.setVisibleLength(4);
    tbBlue.addKeyPressHandler(this);
    tbBlue.addChangeHandler(this);
    tbHexColor = new TextBox();
    tbHexColor.setText("ff0000");
    tbHexColor.setMaxLength(6);
    tbHexColor.setVisibleLength(6);
    tbHexColor.addKeyPressHandler(this);
    tbHexColor.addChangeHandler(this);

    // Put together the FlexTable
    table.setWidget(0, 0, colorpreview);
    table.getFlexCellFormatter().setColSpan(0, 0, 3);
    table.setWidget(1, 0, rbHue);
    table.setWidget(1, 1, tbHue);
    table.setWidget(1, 2, new HTML("&deg;"));
    table.setWidget(2, 0, rbSaturation);
    table.setWidget(2, 1, tbSaturation);
    table.setText(2, 2, "%");
    table.setWidget(3, 0, rbBrightness);
    table.setWidget(3, 1, tbBrightness);
    table.setText(3, 2, "%");
    table.setWidget(4, 0, rbRed);
    table.setWidget(4, 1, tbRed);
    table.setWidget(5, 0, rbGreen);
    table.setWidget(5, 1, tbGreen);
    table.setWidget(6, 0, rbBlue);
    table.setWidget(6, 1, tbBlue);
    table.setText(7, 0, "#:");
    table.setWidget(7, 1, tbHexColor);
    table.getFlexCellFormatter().setColSpan(7, 1, 2);

    // Final setup
    panel.add(table);
    rbSaturation.setValue(true);
    setPreview("ff0000");
    DOM.setStyleAttribute(colorpreview.getElement(), "cursor", "default");

    // First event
    onClick(rbSaturation);

    initWidget(panel);
  }