/** 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);
  }
  public EditClassContentView() {
    setWidget(uiBinder.createAndBindUi(this));
    setId();
    saveBtn.setEnabled(false);
    saveBtn.addStyleName(CssTokens.DISABLED);
    coursePanel.setVisible(false);
    errorLabel.setVisible(false);

    scoreTextBox.addBlurHandler(
        new BlurHandler() {

          @Override
          public void onBlur(BlurEvent event) {
            String score = scoreTextBox.getText();
            if (!scoreTextBox.isReadOnly()) {
              if (score.isEmpty()) {
                errorLabel.setText("Please enter the minimum score");
                errorLabel.getElement().getStyle().setColor("orange");
                errorLabel.setVisible(true);
                saveEnabled(false);
                saveBtn.addStyleName(CssTokens.DISABLED);
              } else if (score != null || score != "") {
                if (Integer.parseInt(score) > 100 || Integer.parseInt(score) < 0) {
                  errorLabel.setText(i18n.GL3425());
                  errorLabel.getElement().getStyle().setColor("orange");
                  errorLabel.setVisible(true);
                  saveEnabled(false);
                  saveBtn.addStyleName(CssTokens.DISABLED);
                } else {
                  miniScore = Integer.valueOf(score);
                  saveEnabled(true);
                  saveBtn.removeStyleName(CssTokens.DISABLED);
                  errorLabel.setVisible(false);
                }
              }
            }
          }
        });
    scoreTextBox.setMaxLength(3);
    scoreTextBox.getElement().setAttribute("maxlength", "3");
    scoreTextBox.addKeyPressHandler(new NumbersOnly());
    createCourseBtn.addClickHandler(new AddCourseHandler());
  }
  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;
  }
Esempio n. 4
0
  @Override
  public void onModuleLoad() {
    RootPanel root = RootPanel.get("centerDiv");
    root.clear();

    VerticalPanel parent = new VerticalPanel();
    parent.setSize("100%", "100%");
    root.add(parent);

    final FlexTable flexTable = new FlexTable();
    flexTable.setStyleName((String) null);
    flexTable.setText(0, 0, "monetId:");

    final TextBox monetIdTextBox = new TextBox();
    monetIdTextBox.setMaxLength(12);
    monetIdTextBox.setWidth("60px");
    flexTable.setWidget(0, 1, monetIdTextBox);

    flexTable.setText(0, 2, "reason:");

    final TextBox reasonTextBox = new TextBox();
    reasonTextBox.setWidth("100px");
    flexTable.setWidget(0, 3, reasonTextBox);

    flexTable.setText(0, 4, "expire date:");

    VerticalPanel verticalPanel = new VerticalPanel();
    flexTable.setWidget(0, 5, verticalPanel);

    final RadioButton radioButton = new RadioButton("expire", "never expires");
    verticalPanel.add(radioButton);
    radioButton.setValue(true);

    final RadioButton radioButton1 = new RadioButton("expire", "select date");
    verticalPanel.add(radioButton1);

    Button saveButton = new Button("save");
    flexTable.setWidget(0, 6, saveButton);

    parent.add(flexTable);

    final DatePicker datePicker = new DatePicker();
    datePicker.setValue(new Date());
    flexTable.setWidget(1, 0, datePicker);
    flexTable.getFlexCellFormatter().setColSpan(1, 0, 7);
    flexTable.getFlexCellFormatter().setVisible(1, 0, false);
    flexTable.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    radioButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            flexTable.getFlexCellFormatter().setVisible(1, 0, false);
          }
        });

    radioButton1.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            flexTable.getFlexCellFormatter().setVisible(1, 0, true);
          }
        });
    saveButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            int monetId = 0;
            try {
              monetId = Integer.parseInt(monetIdTextBox.getText());
            } catch (NumberFormatException e) {
              Window.alert("wrong monetid");
              return;
            }
            String reason = reasonTextBox.getText();
            Date expire = null;
            if (radioButton1.getValue()) {
              expire = datePicker.getValue();
            }
            if (expire != null && expire.getTime() <= System.currentTimeMillis()) {
              Window.alert("Wrong expire date");
              return;
            }

            JSONObject json = new JSONObject();
            json.put("monetId", new JSONNumber(monetId));
            json.put("reason", new JSONString(reason));
            String date = "";
            if (expire != null)
              date = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(expire);
            json.put("expire", new JSONString(date));

            service.add(
                json.toString(),
                new AsyncCallback<String>() {

                  @Override
                  public void onSuccess(String result) {
                    monetIdTextBox.setValue("");
                    reasonTextBox.setValue("");
                    flexTable.getFlexCellFormatter().setVisible(1, 0, false);
                    getList(page, size);
                    Window.alert("add blacklist success");
                  }

                  @Override
                  public void onFailure(Throwable caught) {
                    Window.alert("add black list failed");
                  }
                });
          }
        });

    Column<BlackListRowData, Number> monetColumn =
        new Column<BlackListRowData, Number>(new NumberCell()) {
          @Override
          public Number getValue(BlackListRowData object) {
            return object.getMonetId();
          }
        };
    cellTable.addColumn(monetColumn, "monetid");

    TextColumn<BlackListRowData> reasonColumn =
        new TextColumn<BlackListRowData>() {
          @Override
          public String getValue(BlackListRowData object) {
            return object.getReason();
          }
        };
    cellTable.addColumn(reasonColumn, "reason");

    Column<BlackListRowData, Date> expireColum =
        new Column<BlackListRowData, Date>(new DateCell()) {
          @Override
          public Date getValue(BlackListRowData object) {
            return object.getExpire();
          }
        };
    cellTable.addColumn(expireColum, "expire date");

    Column<BlackListRowData, String> opColumn =
        new Column<BlackListRowData, String>(new ButtonCell()) {
          @Override
          public String getValue(BlackListRowData object) {
            return "remove";
          }
        };
    cellTable.addColumn(opColumn, "");
    opColumn.setFieldUpdater(
        new FieldUpdater<BlackListRowData, String>() {
          @Override
          public void update(int index, BlackListRowData object, String value) {
            service.delete(
                object.getMonetId(),
                new AsyncCallback<String>() {

                  @Override
                  public void onFailure(Throwable caught) {
                    Window.alert("remove blacklist failed");
                  }

                  @Override
                  public void onSuccess(String result) {
                    getList(page, size);
                    Window.alert("remove blacklist success");
                  }
                });
          }
        });
    getList(page, size);
    parent.add(cellTable);
  }
  private void createComponent() {
    hlBack = new Anchor("<<back");
    hlBack.addClickHandler(this);
    vPanel.add(hlBack);
    ProjectItems projectItems = currentUser.getProjectItems();
    if (projectItems.getProjectItemCount() == 0) {
      vPanel.add(new HTML("You are not subscribed to any projects."));
    } else {
      vPanel.add(form);
      lbProjects = new ListBox(false);
      lbProjects.addChangeHandler(this);
      vPanel.setSize("1000px", "500px");
      table.setCellSpacing(5);
      table.setCellPadding(0);
      table.setWidth("100%");
      tbName.setWidth("300px");
      // tbDescription.setWidth("300px");
      txtFileNotes.setHeight("75px");
      upload.setName("uploadFormElement");
      // fileUpload.setName("fileuploadFormElement");
      tbName.setName("name");
      tbDescription.setName("description");
      txtFileNotes.setName("notes");
      lbProjects.setName("projectDetails");
      btnSubmit.addClickHandler(this);
      txtWarnings.setStylePrimaryName("warnings");
      txtWarningDesc.setStylePrimaryName("warnings");
      txtFileNotes.setCharacterWidth(50);
      tbName.setMaxLength(50);
      // tbDescription.setMaxLength(255);
      // tbDescription.setText("");
      txtLogin = new TextBox();
      txtLogin.setName("user");
      txtLogin.setVisible(false);

      txtProject = new TextBox();
      txtProject.setName("projectName");
      txtProject.setVisible(false);

      int projectId = currentUser.getPreferredProjectId();

      for (int i = 0; i < projectItems.getProjectItemCount(); i++) {
        ProjectItem item = projectItems.getProjectItem(i);
        lbProjects.addItem(item.getProjectName(), String.valueOf(item.getProjectId()));
        if (projectId > 0) {
          if (projectId == item.getProjectId()) {
            lbProjects.setItemSelected(i, true);
          }
        } else {
          lbProjects.setItemSelected(0, true);
        }
      }

      table.setText(0, 0, "");
      table.setWidget(0, 1, txtWarnings);
      table.setText(1, 0, "");
      table.setWidget(1, 1, txtWarningDesc);
      table.setWidget(2, 0, new HTML("<b>Name:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(2, 1, tbName);
      table.setWidget(3, 0, new HTML("<b>File:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(3, 1, upload);
      // table.setWidget(4, 0, new HTML("<b>Description:</b>&nbsp;&nbsp;&nbsp;"));
      // table.setWidget(4, 1, fileUpload);
      table.setWidget(5, 0, new HTML("<b>Project:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(5, 1, lbProjects);
      table.setWidget(6, 0, new HTML("<b>Notes:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(6, 1, txtFileNotes);
      table.setWidget(7, 1, btnSubmit);
      table.setWidget(7, 2, txtLogin);
      table.setWidget(7, 3, txtProject);

      table.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(3, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(4, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(5, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(5, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(6, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(6, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(7, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(7, 0, HasVerticalAlignment.ALIGN_TOP);

      table.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(2, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(2, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(3, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(3, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(4, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(4, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(5, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(5, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(6, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(6, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(7, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(7, 1, HasVerticalAlignment.ALIGN_TOP);

      form.add(table);

      form.setAction(UPLOAD_ACTION_URL);
      form.setEncoding(FormPanel.ENCODING_MULTIPART);
      form.setMethod(FormPanel.METHOD_POST);

      form.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.
              String fileName1 = upload.getFilename().trim();
              // String fileName2 = fileUpload.getFilename().trim();
              // System.out.println("File1: " + fileName1);
              if (fileName1.length() == 0 && tbName.getText().length() == 0) {
                txtWarnings.setHTML("*Please upload a file.");
                txtWarningDesc.setHTML("*Please enter the Job name.");
                event.cancel();
              }
              if ((fileName1.length() == 0) && tbName.getText().length() != 0) {
                txtWarnings.setText("");
                txtWarningDesc.setText("");
                txtWarnings.setHTML("*Please upload a file.");
                event.cancel();
              }
              if ((!(fileName1.length() == 0)) && tbName.getText().length() == 0) {
                txtWarnings.setText("");
                txtWarningDesc.setText("");
                txtWarnings.setHTML("*Please enter the Job name.");
                event.cancel();
              }
            }
          });

      form.addSubmitCompleteHandler(
          new FormPanel.SubmitCompleteHandler() {
            public void onSubmitComplete(SubmitCompleteEvent event) {
              txtFileNotes.setText("");
              txtWarningDesc.setText("");
              String sessionID = Cookies.getCookie("sid");
              if (sessionID != null) {
                String result = event.getResults();
                System.out.println("UploadJob Result: " + result);
                // Log.info("Result: " + result);
                String[] results = result.split("~");
                /*for(int i = 0; i < results.length; i++)
                {
                	 System.out.println(results[i]);
                	 try
                	 {
                		 jobId = Integer.parseInt(results[0]);
                	 }
                	 catch(NumberFormatException e)
                	 {
                		 e.printStackTrace();
                	 }
                }*/
                int jobId = -1;
                try {
                  jobId = Integer.parseInt(results[0]);
                } catch (NumberFormatException e) {
                  e.printStackTrace();
                }
                // Code modified
                if (jobId == 0) {
                  txtWarnings.setHTML(results[1]);
                }
                // Code modified
                // txtWarnings.setHTML(results[1]);

                else {
                  if (currentUser.getUsertype().equalsIgnoreCase("user")) {
                    History.newItem("userJobList");
                  } else {
                    if (tab == 0) {

                      History.newItem("adminJobList");
                    } else {
                      History.newItem("jobList");
                    }
                    // AdminPage adminPage = new AdminPage(tab);
                    // RootPanel.get("content").add(adminPage);
                  }
                }
              } else {
                Login login = new Login();
                login.displayLoginBox();
              }
            }
          });
    }
  }
Esempio n. 6
0
  public Widget draw() {

    // show only part of title
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(publication.getTitle()));

    // MAIN PANEL
    ScrollPanel sp = new ScrollPanel();
    sp.addStyleName("perun-tableScrollPanel");

    VerticalPanel vp = new VerticalPanel();
    vp.addStyleName("perun-table");
    sp.add(vp);

    // resize perun table to correct size on screen
    session.getUiElements().resizePerunTable(sp, 350, this);

    // content
    final FlexTable ft = new FlexTable();
    ft.setStyleName("inputFormFlexTable");

    if (publication.getLocked() == false) {

      ft.setHTML(1, 0, "Id / Origin:");
      ft.setHTML(2, 0, "Title:");
      ft.setHTML(3, 0, "Year:");
      ft.setHTML(4, 0, "Category:");
      ft.setHTML(5, 0, "Rank:");
      ft.setHTML(6, 0, "ISBN / ISSN:");
      ft.setHTML(7, 0, "DOI:");
      ft.setHTML(8, 0, "Full cite:");
      ft.setHTML(9, 0, "Created by:");
      ft.setHTML(10, 0, "Created date:");

      for (int i = 0; i < ft.getRowCount(); i++) {
        ft.getFlexCellFormatter().setStyleName(i, 0, "itemName");
      }
      ft.getFlexCellFormatter().setWidth(1, 0, "100px");

      final ListBoxWithObjects<Category> listbox = new ListBoxWithObjects<Category>();
      // fill listbox
      JsonCallbackEvents events =
          new JsonCallbackEvents() {
            public void onFinished(JavaScriptObject jso) {
              for (Category cat : JsonUtils.<Category>jsoAsList(jso)) {
                listbox.addItem(cat);
                // if right, selected
                if (publication.getCategoryId() == cat.getId()) {
                  listbox.setSelected(cat, true);
                }
              }
            }
          };
      FindAllCategories categories = new FindAllCategories(events);
      categories.retrieveData();

      final TextBox rank = new TextBox();
      rank.setWidth("30px");
      rank.setMaxLength(4);
      rank.setText(String.valueOf(publication.getRank()));

      final TextBox title = new TextBox();
      title.setMaxLength(1024);
      title.setText(publication.getTitle());
      title.setWidth("500px");
      final TextBox year = new TextBox();
      year.setText(String.valueOf(publication.getYear()));
      year.setMaxLength(4);
      year.setWidth("30px");
      final TextBox isbn = new TextBox();
      isbn.setText(publication.getIsbn());
      isbn.setMaxLength(32);
      final TextBox doi = new TextBox();
      doi.setText(publication.getDoi());
      doi.setMaxLength(256);
      final TextArea main = new TextArea();
      main.setText(publication.getMain());
      main.setSize("500px", "70px");
      // set max length
      main.getElement().setAttribute("maxlength", "4000");

      ft.setHTML(
          1,
          1,
          publication.getId()
              + " / <Strong>Ext. Id: </strong>"
              + publication.getExternalId()
              + " <Strong>System: </strong>"
              + publication.getPublicationSystemName());
      ft.setWidget(2, 1, title);
      ft.setWidget(3, 1, year);
      ft.setWidget(4, 1, listbox);
      if (session.isPerunAdmin()) {
        // only perunadmin can change rank
        ft.setWidget(5, 1, rank);
      } else {
        ft.setHTML(5, 1, "" + publication.getRank());
      }
      ft.setWidget(6, 1, isbn);
      ft.setWidget(7, 1, doi);
      ft.setWidget(8, 1, main);
      ft.setHTML(9, 1, String.valueOf(publication.getCreatedBy()));
      ft.setHTML(
          10,
          1,
          DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM)
              .format(new Date((long) publication.getCreatedDate())));

      // update button

      final CustomButton change =
          TabMenu.getPredefinedButton(ButtonType.SAVE, "Save changes in publication details");
      change.addClickHandler(
          new ClickHandler() {

            public void onClick(ClickEvent event) {

              Publication pub = JsonUtils.clone(publication).cast();

              if (!JsonUtils.checkParseInt(year.getText())) {
                JsonUtils.cantParseIntConfirm("YEAR", year.getText());
              } else {
                pub.setYear(Integer.parseInt(year.getText()));
              }
              if (session.isPerunAdmin()) {
                pub.setRank(Double.parseDouble(rank.getText()));
              }
              pub.setCategoryId(listbox.getSelectedObject().getId());
              pub.setTitle(title.getText());
              pub.setMain(main.getText());
              pub.setIsbn(isbn.getText());
              pub.setDoi(doi.getText());

              UpdatePublication upCall =
                  new UpdatePublication(
                      JsonCallbackEvents.disableButtonEvents(
                          change,
                          new JsonCallbackEvents() {
                            public void onFinished(JavaScriptObject jso) {
                              // refresh page content
                              Publication p = jso.cast();
                              publication = p;
                              draw();
                            }
                          }));
              upCall.updatePublication(pub);
            }
          });

      ft.setWidget(0, 0, change);

    } else {

      ft.getFlexCellFormatter().setColSpan(0, 0, 2);
      ft.setWidget(
          0,
          0,
          new HTML(
              new Image(SmallIcons.INSTANCE.lockIcon())
                  + " <strong>Publication is locked. Ask administrator to perform any changes for you at [email protected].</strong>"));

      ft.setHTML(1, 0, "Id / Origin:");
      ft.setHTML(2, 0, "Title:");
      ft.setHTML(3, 0, "Year:");
      ft.setHTML(4, 0, "Category:");
      ft.setHTML(5, 0, "Rank:");
      ft.setHTML(6, 0, "ISBN / ISSN:");
      ft.setHTML(7, 0, "DOI:");
      ft.setHTML(8, 0, "Full cite:");
      ft.setHTML(9, 0, "Created by:");
      ft.setHTML(10, 0, "Created date:");

      for (int i = 0; i < ft.getRowCount(); i++) {
        ft.getFlexCellFormatter().setStyleName(i, 0, "itemName");
      }
      ft.getFlexCellFormatter().setWidth(1, 0, "100px");

      ft.setHTML(
          1,
          1,
          publication.getId()
              + " / <Strong>Ext. Id: </strong>"
              + publication.getExternalId()
              + " <Strong>System: </strong>"
              + publication.getPublicationSystemName());
      ft.setHTML(2, 1, publication.getTitle());
      ft.setHTML(3, 1, String.valueOf(publication.getYear()));
      ft.setHTML(4, 1, publication.getCategoryName());
      ft.setHTML(5, 1, String.valueOf(publication.getRank()) + " (default is 0)");
      ft.setHTML(6, 1, publication.getIsbn());
      ft.setHTML(7, 1, publication.getDoi());
      ft.setHTML(8, 1, publication.getMain());
      ft.setHTML(9, 1, String.valueOf(publication.getCreatedBy()));
      ft.setHTML(
          10,
          1,
          DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM)
              .format(new Date((long) publication.getCreatedDate())));
    }

    // LOCK / UNLOCK button for PerunAdmin

    if (session.isPerunAdmin()) {
      final CustomButton lock;
      if (publication.getLocked()) {
        lock =
            new CustomButton(
                "Unlock",
                "Allow editing of publication details (for users).",
                SmallIcons.INSTANCE.lockOpenIcon());
        ft.setWidget(0, 0, lock);
        ft.getFlexCellFormatter().setColSpan(0, 0, 1);
        ft.setWidget(
            0, 1, new HTML(new Image(SmallIcons.INSTANCE.lockIcon()) + " Publication is locked."));
      } else {
        lock =
            new CustomButton(
                "Lock",
                "Deny editing of publication details (for users).",
                SmallIcons.INSTANCE.lockIcon());
        ft.setWidget(0, 1, lock);
      }
      lock.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent event) {
              UpdatePublication upCall =
                  new UpdatePublication(
                      JsonCallbackEvents.disableButtonEvents(
                          lock,
                          new JsonCallbackEvents() {
                            public void onFinished(JavaScriptObject jso) {
                              // refresh page content
                              Publication p = jso.cast();
                              publication = p;
                              draw();
                            }
                          }));
              Publication p = JsonUtils.clone(publication).cast();
              p.setLocked(!publication.getLocked());
              upCall.updatePublication(p);
            }
          });
    }

    DisclosurePanel dp = new DisclosurePanel();
    dp.setWidth("100%");
    dp.setContent(ft);
    dp.setOpen(true);

    FlexTable detailsHeader = new FlexTable();
    detailsHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.bookIcon()));
    detailsHeader.setHTML(0, 1, "<h3>Details</h3>");
    dp.setHeader(detailsHeader);

    vp.add(dp);
    vp.add(loadAuthorsSubTab());
    vp.add(loadThanksSubTab());

    this.contentWidget.setWidget(sp);

    return getWidget();
  }
Esempio n. 7
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);
  }
Esempio n. 8
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);
  }