コード例 #1
0
 @Override
 public void render(Context context, RichGroup value, SafeHtmlBuilder sb) {
   if (value != null) {
     ImageResource resource = SmallIcons.INSTANCE.bulletWhiteIcon();
     if (value.isSyncEnabled()) {
       // FIXME - remove old way of determining sync state once values for new attribute are
       // generated.
       if ((value.getLastSynchronizationState() != null
               && value.getLastSynchronizationState().equals("OK"))
           || (value.getLastSynchronizationState() == null
               && value.getLastSuccessSynchronizationTimestamp() != null)) {
         resource = SmallIcons.INSTANCE.bulletGreenIcon();
         if (value.getAuthoritativeGroup() != null && value.getAuthoritativeGroup().equals("1")) {
           sb.append(renderer.render(resource, "Synchronized - OK / Authoritative sync"));
           sb.append(
               renderer.render(
                   SmallIcons.INSTANCE.bulletStarIcon(),
                   "Synchronized - OK / Authoritative sync"));
         } else {
           sb.append(renderer.render(resource, "Synchronized - OK"));
         }
       } else {
         resource = SmallIcons.INSTANCE.bulletRedIcon();
         if (value.getAuthoritativeGroup() != null && value.getAuthoritativeGroup().equals("1")) {
           sb.append(renderer.render(resource, "Synchronized - Error / Authoritative sync"));
           sb.append(
               renderer.render(
                   SmallIcons.INSTANCE.bulletStarIcon(),
                   "Synchronized - Error / Authoritative sync"));
         } else {
           sb.append(renderer.render(resource, "Synchronized - Error"));
         }
       }
     } else {
       if (value.getAuthoritativeGroup() != null && value.getAuthoritativeGroup().equals("1")) {
         sb.append(renderer.render(resource, "Not synchronized / Authoritative sync"));
       } else {
         sb.append(renderer.render(resource, "Not synchronized"));
       }
     }
   }
 }
コード例 #2
0
ファイル: LogoutButton.java プロジェクト: katarinaHrab/perun
  /** Creates a new button */
  public LogoutButton() {

    // construct the button with image
    button =
        new CustomButton(
            ButtonTranslation.INSTANCE.logoutButton(),
            ButtonTranslation.INSTANCE.logout(),
            SmallIcons.INSTANCE.doorOutIcon(),
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                logout();
              }
            });

    this.initWidget(button);
  }
コード例 #3
0
  /**
   * Prepares the GUI
   *
   * @param entity PerunEntity GROUP or VO
   * @param applicationType INITIAL | EXTENSION
   */
  protected void prepareGui(PerunEntity entity, String applicationType) {

    // trigger email verification as first if present in URL

    if (Location.getParameterMap().keySet().contains("m")
        && Location.getParameterMap().keySet().contains("i")) {

      String verifyI = Location.getParameter("i");
      String verifyM = Location.getParameter("m");

      if (verifyI != null && !verifyI.isEmpty() && verifyM != null && !verifyM.isEmpty()) {

        final SimplePanel verifContent = new SimplePanel();
        leftMenu.addItem(
            ApplicationMessages.INSTANCE.emailValidationMenuItem(),
            SmallIcons.INSTANCE.documentSignatureIcon(),
            verifContent);

        ValidateEmail request =
            new ValidateEmail(
                verifyI,
                verifyM,
                new JsonCallbackEvents() {
                  @Override
                  public void onLoadingStart() {
                    verifContent.clear();
                    verifContent.add(new AjaxLoaderImage());
                  }

                  @Override
                  public void onFinished(JavaScriptObject jso) {

                    BasicOverlayType obj = jso.cast();
                    if (obj.getBoolean() == true) {

                      verifContent.clear();
                      FlexTable ft = new FlexTable();
                      ft.setSize("100%", "300px");
                      ft.setHTML(
                          0,
                          0,
                          new Image(LargeIcons.INSTANCE.acceptIcon())
                              + "<h2>"
                              + ApplicationMessages.INSTANCE.emailValidationSuccess()
                              + "</h2>");
                      ft.getFlexCellFormatter()
                          .setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
                      ft.getFlexCellFormatter()
                          .setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                      verifContent.add(ft);

                    } else {

                      verifContent.clear();
                      FlexTable ft = new FlexTable();
                      ft.setSize("100%", "300px");
                      ft.setHTML(
                          0,
                          0,
                          new Image(LargeIcons.INSTANCE.deleteIcon())
                              + "<h2>"
                              + ApplicationMessages.INSTANCE.emailValidationFail()
                              + "</h2>");
                      ft.getFlexCellFormatter()
                          .setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
                      ft.getFlexCellFormatter()
                          .setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                      verifContent.add(ft);
                    }
                  }

                  @Override
                  public void onError(PerunError error) {
                    ((AjaxLoaderImage) verifContent.getWidget()).loadingError(error);
                  }
                });
        request.retrieveData();

        leftMenu.addLogoutItem();

        return;
      }
    }

    // group and extension is not allowed
    if (group != null && applicationType.equalsIgnoreCase("EXTENSION")) {

      RootLayoutPanel panel = RootLayoutPanel.get();
      panel.clear();
      FlexTable ft = new FlexTable();
      ft.setSize("100%", "300px");
      ft.setHTML(
          0,
          0,
          new Image(LargeIcons.INSTANCE.errorIcon())
              + "<h2>Error: "
              + ApplicationMessages.INSTANCE.groupMembershipCantBeExtended(
                  group.getName(), vo.getName())
              + "</h2>");
      ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
      ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
      panel.add(ft);
      return;
    }

    // application form page
    ApplicationFormPage formPage = new ApplicationFormPage(vo, group, applicationType);
    // even user "not yet in perun" can have some applications sent (therefore display by session
    // info)
    UsersApplicationsPage appsPage = new UsersApplicationsPage();

    // if rt test
    if ("true".equals(Location.getParameter("rttest"))) {
      TestRtReportingTabItem tabItem = new TestRtReportingTabItem();
      Widget rtTab = tabItem.draw();
      leftMenu.addItem("RT test", SmallIcons.INSTANCE.settingToolsIcon(), rtTab);
    }

    // proper menu text
    String appMenuText = ApplicationMessages.INSTANCE.applicationFormForVo(vo.getName());
    if (group != null) {
      appMenuText = ApplicationMessages.INSTANCE.applicationFormForGroup(group.getName());
    }
    if (applicationType.equalsIgnoreCase("EXTENSION")) {
      appMenuText = ApplicationMessages.INSTANCE.membershipExtensionForVo(vo.getName());
      if (group != null) {
        appMenuText = ApplicationMessages.INSTANCE.membershipExtensionForGroup(group.getName());
      }
    }

    // load list of applications first if param in session
    if ("apps".equals(Location.getParameter("page"))) {
      Anchor a =
          leftMenu.addItem(
              ApplicationMessages.INSTANCE.applications(),
              SmallIcons.INSTANCE.applicationFromStorageIcon(),
              appsPage);
      leftMenu.addItem(appMenuText, SmallIcons.INSTANCE.applicationFormIcon(), formPage);
      a.fireEvent(new ClickEvent() {});
      // appsPage.menuClick(); // load list of apps
    } else {
      Anchor a = leftMenu.addItem(appMenuText, SmallIcons.INSTANCE.applicationFormIcon(), formPage);
      leftMenu.addItem(
          ApplicationMessages.INSTANCE.applications(),
          SmallIcons.INSTANCE.applicationFromStorageIcon(),
          appsPage);
      a.fireEvent(new ClickEvent() {});
      // formPage.menuClick(); // load application form
    }

    leftMenu.addLogoutItem();
  }
コード例 #4
0
 public ImageResource getIcon() {
   return SmallIcons.INSTANCE.worldIcon();
 }
コード例 #5
0
ファイル: GetFormItems.java プロジェクト: Karm/perun
  /**
   * Prepares the widgets from the items as A FORM FOR SETTINGS
   *
   * @param items
   */
  public void prepareSettings(final ArrayList<ApplicationFormItem> items) {

    // refresh table events
    final JsonCallbackEvents refreshEvents =
        new JsonCallbackEvents() {
          public void onFinished(JavaScriptObject jso) {
            prepareSettings(items);
          }
        };

    FlexTable ft = new FlexTable();
    ft.addStyleName("borderTable");
    ft.setWidth("100%");
    ft.setCellPadding(8);
    FlexCellFormatter fcf = ft.getFlexCellFormatter();

    ft.setHTML(0, 0, "<strong>Short name</strong>");
    ft.setHTML(0, 1, "<strong>Type</strong>");
    ft.setHTML(0, 2, "<strong>Preview</strong>");
    ft.setHTML(0, 3, "<strong>Edit</strong>");

    fcf.setStyleName(0, 0, "GPBYFDEFD");
    fcf.setStyleName(0, 1, "GPBYFDEFD");
    fcf.setStyleName(0, 2, "GPBYFDEFD");
    fcf.setStyleName(0, 3, "GPBYFDEFD");

    String locale = "en";

    if (LocaleInfo.getCurrentLocale().getLocaleName().equals("default")
        || LocaleInfo.getCurrentLocale().getLocaleName().equals("en")) {
      locale = "en";
    } else {
      locale = "cs";
    }

    int i = 1;
    for (final ApplicationFormItem item : items) {

      final int index = i - 1;

      // not yet set locale on config page
      RegistrarFormItemGenerator gen = new RegistrarFormItemGenerator(item, locale);

      // 0 = label
      String label = "";
      if (gen.isLabelShown()) {
        label = item.getShortname();
      }
      if (item.isRequired() == true) {
        label += "*";
      }
      ft.setHTML(i, 0, label);

      // 1 = type
      ft.setHTML(i, 1, item.getType());

      // 2 = preview
      Widget w = gen.getWidget();
      ft.setWidget(i, 2, w);

      // 3 = EDIT
      FlexTable editTable = new FlexTable();
      editTable.setStyleName("noBorder");
      ft.setWidget(i, 3, editTable);

      // color for items with unsaved changes
      if (item.wasEdited() == true) {
        ft.getFlexCellFormatter().setStyleName(i, 0, "log-changed");
        ft.getFlexCellFormatter().setStyleName(i, 1, "log-changed");
        ft.getFlexCellFormatter().setStyleName(i, 2, "log-changed");
        ft.getFlexCellFormatter().setStyleName(i, 3, "log-changed");
      }

      // mark row for deletion
      if (item.isForDelete()) {

        ft.getFlexCellFormatter().setStyleName(i, 0, "log-error");
        ft.getFlexCellFormatter().setStyleName(i, 1, "log-error");
        ft.getFlexCellFormatter().setStyleName(i, 2, "log-error");
        ft.getFlexCellFormatter().setStyleName(i, 3, "log-error");

        // undelete button
        CustomButton undelete =
            new CustomButton(
                ButtonTranslation.INSTANCE.undeleteFormItemButton(),
                ButtonTranslation.INSTANCE.undeleteFormItem(),
                SmallIcons.INSTANCE.arrowLeftIcon(),
                new ClickHandler() {
                  public void onClick(ClickEvent event) {
                    items.get(index).setForDelete(false);
                    // refresh
                    prepareSettings(items);
                  }
                });

        FlexTable undelTable = new FlexTable();
        undelTable.setStyleName("noBorder");
        undelTable.setHTML(
            0, 0, "<strong><span style=\"color:red;\">MARKED FOR DELETION</span></strong>");
        undelTable.setWidget(0, 1, undelete);
        ft.setWidget(i, 3, undelTable);
      }

      // color for new items to be saved
      if (item.getId() == 0) {
        ft.getFlexCellFormatter().setStyleName(i, 0, "log-success");
        ft.getFlexCellFormatter().setStyleName(i, 1, "log-success");
        ft.getFlexCellFormatter().setStyleName(i, 2, "log-success");
        ft.getFlexCellFormatter().setStyleName(i, 3, "log-success");
      }

      // up
      PushButton upButton =
          new PushButton(
              new Image(SmallIcons.INSTANCE.arrowUpIcon()),
              new ClickHandler() {

                public void onClick(ClickEvent event) {

                  if (index - 1 < 0) return;

                  // move it
                  items.remove(index);
                  items.add(index - 1, item);
                  item.setOrdnum(item.getOrdnum() - 1);

                  item.setEdited(true);

                  // refresh
                  prepareSettings(items);
                }
              });
      editTable.setWidget(0, 0, upButton);
      upButton.setTitle(ButtonTranslation.INSTANCE.moveFormItemUp());

      // down
      PushButton downButton =
          new PushButton(
              new Image(SmallIcons.INSTANCE.arrowDownIcon()),
              new ClickHandler() {

                public void onClick(ClickEvent event) {

                  if (index + 1 >= items.size()) return;

                  // move it
                  items.remove(index);
                  items.add(index + 1, item);
                  item.setOrdnum(item.getOrdnum() + 1);

                  item.setEdited(true);

                  // refresh
                  prepareSettings(items);
                }
              });
      editTable.setWidget(0, 1, downButton);
      downButton.setTitle(ButtonTranslation.INSTANCE.moveFormItemDown());

      // edit
      CustomButton editButton =
          new CustomButton(
              ButtonTranslation.INSTANCE.editFormItemButton(),
              ButtonTranslation.INSTANCE.editFormItem(),
              SmallIcons.INSTANCE.applicationFormEditIcon());
      editButton.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent event) {
              session
                  .getTabManager()
                  .addTabToCurrentTab(new EditFormItemTabItem(item, refreshEvents));
            }
          });
      editTable.setWidget(0, 2, editButton);

      // remove
      CustomButton removeButton =
          new CustomButton(
              ButtonTranslation.INSTANCE.deleteButton(),
              ButtonTranslation.INSTANCE.deleteFormItem(),
              SmallIcons.INSTANCE.deleteIcon());
      removeButton.addClickHandler(
          new ClickHandler() {

            public void onClick(ClickEvent event) {
              HTML text =
                  new HTML(
                      "<p>Deleting of form items is <strong>NOT RECOMMENDED!</strong><p>You will loose access to data users submitted in older applications within this form item!<p>Do you want to continue?");
              Confirm c =
                  new Confirm(
                      "Delete confirm",
                      text,
                      new ClickHandler() {
                        public void onClick(ClickEvent event) {
                          // mark for deletion when save changes
                          items.get(index).setForDelete(true);
                          // remove if newly created
                          if (items.get(index).getId() == 0) {
                            items.remove(index);
                          }
                          // refresh
                          prepareSettings(items);
                        }
                      },
                      true);
              c.setNonScrollable(true);
              c.show();
            }
          });
      editTable.setWidget(0, 3, removeButton);

      // format
      fcf.setHeight(i, 0, "28px");
      fcf.setVerticalAlignment(i, 0, HasVerticalAlignment.ALIGN_MIDDLE);
      fcf.setVerticalAlignment(i, 1, HasVerticalAlignment.ALIGN_MIDDLE);
      fcf.setVerticalAlignment(i, 2, HasVerticalAlignment.ALIGN_MIDDLE);

      i++;
    }

    contents.setWidget(ft);
  }
コード例 #6
0
 public ImageResource getIcon() {
   return SmallIcons.INSTANCE.userRedIcon();
 }
コード例 #7
0
 public ImageResource getIcon() {
   return SmallIcons.INSTANCE.settingToolsIcon();
 }
コード例 #8
0
 public ImageResource getIcon() {
   return SmallIcons.INSTANCE.trafficLightsIcon();
 }
コード例 #9
0
 public ImageResource getIcon() {
   return SmallIcons.INSTANCE.attributesDisplayIcon();
 }
コード例 #10
0
  public Widget draw() {

    titleWidget.setText("Add manager");

    final CustomButton searchButton =
        new CustomButton(
            "Search", ButtonTranslation.INSTANCE.searchUsers(), SmallIcons.INSTANCE.findIcon());

    this.users =
        new FindCompleteRichUsers(
            "",
            null,
            JsonCallbackEvents.disableButtonEvents(
                searchButton,
                new JsonCallbackEvents() {
                  @Override
                  public void onFinished(JavaScriptObject jso) {
                    // if found 1 item, select
                    ArrayList<User> list = JsonUtils.jsoAsList(jso);
                    if (list != null && list.size() == 1) {
                      users.getSelectionModel().setSelected(list.get(0), true);
                    }
                  }
                }));

    // MAIN TAB PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");

    // HORIZONTAL MENU
    TabMenu tabMenu = new TabMenu();

    // get the table
    final CellTable<User> table;
    if (session.isPerunAdmin()) {
      table =
          users.getTable(
              new FieldUpdater<User, String>() {
                public void update(int i, User user, String s) {
                  session.getTabManager().addTab(new UserDetailTabItem(user));
                }
              });
    } else {
      table = users.getTable();
    }

    rebuildAlreadyAddedWidget();

    final CustomButton addButton =
        TabMenu.getPredefinedButton(
            ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersToVo());
    final TabItem tab = this;

    // search textbox
    final ExtendedTextBox searchBox =
        tabMenu.addSearchWidget(
            new PerunSearchEvent() {
              @Override
              public void searchFor(String text) {
                startSearching(text);
                searchString = text;
              }
            },
            searchButton);

    tabMenu.addWidget(addButton);

    tabMenu.addWidget(
        TabMenu.getPredefinedButton(
            ButtonType.CLOSE,
            "",
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent clickEvent) {
                session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
              }
            }));

    addButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            final ArrayList<User> list = users.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
              for (int i = 0; i < list.size(); i++) {
                // FIXME - Should have only one callback to core
                final int n = i;
                AddAdmin request =
                    new AddAdmin(
                        JsonCallbackEvents.disableButtonEvents(
                            addButton,
                            new JsonCallbackEvents() {
                              @Override
                              public void onFinished(JavaScriptObject jso) {
                                // put names to already added
                                alreadyAddedList.add(list.get(n));
                                rebuildAlreadyAddedWidget();
                                // unselect added person
                                users.getSelectionModel().setSelected(list.get(n), false);
                                // clear search
                                searchBox.getTextBox().setText("");
                              }
                            }));
                request.addVoAdmin(vo, list.get(i));
              }
            }
          }
        });

    // if some text has been searched before
    if (!searchString.equals("")) {
      searchBox.getTextBox().setText(searchString);
      startSearching(searchString);
    }

    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(users, table, addButton);

    // add a class to the table and wrap it into scroll panel
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");

    // add menu and the table to the main panel
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    firstTabPanel.add(alreadyAdded);
    firstTabPanel.add(sp);

    session.getUiElements().resizePerunTable(sp, 350, this);

    this.contentWidget.setWidget(firstTabPanel);

    return getWidget();
  }
コード例 #11
0
  /**
   * Returns widget with authors management for publication
   *
   * @return widget
   */
  private Widget loadAuthorsSubTab() {

    DisclosurePanel dp = new DisclosurePanel();
    dp.setWidth("100%");
    dp.setOpen(true);
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    dp.setContent(vp);

    FlexTable header = new FlexTable();
    header.setWidget(0, 0, new Image(LargeIcons.INSTANCE.userGreenIcon()));
    header.setHTML(0, 1, "<h3>Authors / Reported by</h3>");
    dp.setHeader(header);

    // menu
    TabMenu menu = new TabMenu();

    // callback
    final FindAuthorsByPublicationId call = new FindAuthorsByPublicationId(publication.getId());
    call.setCheckable(false);

    if (!publication.getLocked()) {
      // editable if not locked
      vp.add(menu);
      vp.setCellHeight(menu, "30px");
      call.setCheckable(true);
    }

    final CustomButton addButton =
        new CustomButton(
            "Add myself", "Add you as author of publication", SmallIcons.INSTANCE.addIcon());
    addButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(call);
            CreateAuthorship request =
                new CreateAuthorship(JsonCallbackEvents.disableButtonEvents(addButton, events));
            request.createAuthorship(publicationId, session.getActiveUser().getId());
          }
        });
    menu.addWidget(addButton);

    CustomButton addOthersButton =
        new CustomButton("Add others", "Add more authors", SmallIcons.INSTANCE.addIcon());
    addOthersButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            session
                .getTabManager()
                .addTabToCurrentTab(
                    new AddAuthorTabItem(publication, JsonCallbackEvents.refreshTableEvents(call)),
                    true);
          }
        });
    menu.addWidget(addOthersButton);

    // fill table
    CellTable<Author> table = call.getEmptyTable();
    call.retrieveData();

    final CustomButton removeButton =
        TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove select author(s) from publication");
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(call, table, removeButton);
    menu.addWidget(removeButton);

    removeButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            final ArrayList<Author> list = call.getTableSelectedList();
            String text =
                "Following users will be removed from publication's authors. They will lose any benefit granted by publication's rank.";
            UiElements.showDeleteConfirm(
                list,
                text,
                new ClickHandler() {
                  @Override
                  public void onClick(ClickEvent event) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                    for (int i = 0; i < list.size(); i++) {
                      // calls the request
                      if (i == list.size() - 1) {
                        DeleteAuthorship request =
                            new DeleteAuthorship(
                                JsonCallbackEvents.disableButtonEvents(
                                    removeButton, JsonCallbackEvents.refreshTableEvents(call)));
                        request.deleteAuthorship(publicationId, list.get(i).getId());
                      } else {
                        DeleteAuthorship request = new DeleteAuthorship();
                        request.deleteAuthorship(publicationId, list.get(i).getId());
                      }
                    }
                  }
                });
          }
        });

    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    table.addStyleName("perun-table");
    sp.addStyleName("perun-tableScrollPanel");

    vp.add(sp);

    return dp;
  }
コード例 #12
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();
  }
コード例 #13
0
 public ImageResource getIcon() {
   return SmallIcons.INSTANCE.booksIcon();
 }
コード例 #14
0
  public Widget draw() {

    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()));

    // main widget panel
    final VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");

    AbsolutePanel dp = new AbsolutePanel();
    final FlexTable menu = new FlexTable();
    menu.setCellSpacing(5);

    // Add facility information
    menu.setWidget(0, 0, new Image(LargeIcons.INSTANCE.databaseServerIcon()));
    Label facilityName = new Label();
    facilityName.setText(Utils.getStrippedStringWithEllipsis(facility.getName(), 40));
    facilityName.setStyleName("now-managing");
    facilityName.setTitle(facility.getName());
    menu.setWidget(0, 1, facilityName);

    menu.setHTML(0, 2, "&nbsp;");
    menu.getFlexCellFormatter().setWidth(0, 2, "25px");

    int column = 3;

    final JsonCallbackEvents events =
        new JsonCallbackEvents() {
          public void onFinished(JavaScriptObject jso) {
            new GetEntityById(
                    PerunEntity.FACILITY,
                    facilityId,
                    new JsonCallbackEvents() {
                      public void onFinished(JavaScriptObject jso) {
                        facility = jso.cast();
                        open();
                        draw();
                      }
                    })
                .retrieveData();
          }
        };

    CustomButton change =
        new CustomButton(
            "",
            ButtonTranslation.INSTANCE.editFacilityDetails(),
            SmallIcons.INSTANCE.applicationFormEditIcon());
    change.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            // prepare confirm content
            session
                .getTabManager()
                .addTabToCurrentTab(new EditFacilityDetailsTabItem(facility, events));
          }
        });
    menu.setWidget(0, column, change);

    column++;

    menu.setHTML(0, column, "&nbsp;");
    menu.getFlexCellFormatter().setWidth(0, column, "25px");
    column++;

    if (JsonUtils.isExtendedInfoVisible()) {
      menu.setHTML(
          0,
          column,
          "<strong>ID:</strong><br/><span class=\"inputFormInlineComment\">"
              + facility.getId()
              + "</span>");
      column++;
      menu.setHTML(0, column, "&nbsp;");
      menu.getFlexCellFormatter().setWidth(0, column, "25px");
      column++;
    }

    menu.setHTML(
        0,
        column,
        "<strong>Description:</strong><br/><span class=\"inputFormInlineComment\">"
            + facility.getDescription()
            + "&nbsp;</span>");

    dp.add(menu);
    vp.add(dp);
    vp.setCellHeight(dp, "30px");

    // TAB PANEL

    tabPanel.clear();
    tabPanel.add(new FacilityResourcesTabItem(facility), "Resources");
    tabPanel.add(new FacilityAllowedGroupsTabItem(facility), "Allowed Groups");
    tabPanel.add(new FacilityStatusTabItem(facility), "Services status");
    tabPanel.add(new FacilitySettingsTabItem(facility), "Services settings");
    tabPanel.add(new FacilityDestinationsTabItem(facility), "Services destinations");
    tabPanel.add(new FacilityHostsTabItem(facility), "Hosts");
    tabPanel.add(new FacilityManagersTabItem(facility), "Managers");
    tabPanel.add(new FacilitySecurityTeamsTabItem(facility), "Security teams");
    tabPanel.add(new FacilityBlacklistTabItem(facility), "Blacklist");
    tabPanel.add(new FacilityOwnersTabItem(facility), "Owners");

    // Resize must be called after page fully displays
    Scheduler.get()
        .scheduleDeferred(
            new Command() {
              @Override
              public void execute() {
                tabPanel.finishAdding();
              }
            });

    vp.add(tabPanel);

    this.contentWidget.setWidget(vp);
    return getWidget();
  }
コード例 #15
0
 public ImageResource getIcon() {
   return SmallIcons.INSTANCE.databaseServerIcon();
 }