示例#1
0
  public TagPopup(UIObject target, String spaceUname, String tagname) {
    super(target, true, true, true);
    this.spaceUname = spaceUname;
    this.tagname = tagname;

    VerticalPanel panel = new VerticalPanel();
    panel.add(message);
    panel.add(new HTML("<b>" + tagname + "</b>"));
    panel.add(new Hr());
    panel.add(pagesPanel);
    if (!AbstractEntryPoint.isOffline()) {
      // so far, have to block tag cloud in offline model as the macro render logic is on
      // MacroHandler side, it is not easy to do in
      // offline model.
      Hyperlink tagCloud =
          new Hyperlink(
              Msg.consts.goto_tagcloud(),
              GwtUtils.buildToken(
                  GwtUtils.getCPageToken(SharedConstants.CPAGE_TAG_CLOUD), spaceUname));
      tagCloud.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent event) {
              TagPopup.this.hide();
            }
          });
      panel.add(tagCloud);
      panel.setCellHorizontalAlignment(tagCloud, HasHorizontalAlignment.ALIGN_RIGHT);
    }
    panel.setSize("100%", "100%");
    this.setWidget(panel);
  }
  public Widget draw() {

    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.getElement().setAttribute("style", "padding-top: 5px;");
    vp.setSize("100%", "100%");

    FindAllPublicationSystems call = new FindAllPublicationSystems();
    call.setCheckable(false);
    CellTable<PublicationSystem> table = call.getTable();
    table.addStyleName("perun-table");

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

    vp.add(sp);

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

    this.contentWidget.setWidget(vp);

    return getWidget();
  }
示例#3
0
  // Helper method to make list of buttons on left side of View
  public void makeSideBar(HorizontalPanel hp) {
    VerticalPanel sidePanel = new VerticalPanel();
    hp.add(sidePanel);
    sidePanel.setSize("72px", "98px");

    Button postAdButton = new Button("Post Ad");
    postAdButton.setStyleName("sideBarButton");
    postAdButton.setText("Post Ad");
    // add a clickListener to the button
    postAdButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            viewPostAdForm();
          }
        });
    sidePanel.add(postAdButton);

    Button viewAdsButton = new Button("View Ads");
    viewAdsButton.setStyleName("sideBarButton");
    viewAdsButton.setText("View Ads");
    // add a clickListener to the button
    viewAdsButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            control.viewAdDataFromServer();
          }
        });
    sidePanel.add(viewAdsButton);

    Hyperlink adminHyperlink = new Hyperlink("Admin Page", false, "newHistoryToken");
    sidePanel.add(adminHyperlink);
  }
示例#4
0
  public Widget draw() {

    VerticalPanel vp = new VerticalPanel();
    vp.getElement().setAttribute("style", "padding-top: 5px;");
    vp.setSize("100%", "100%");

    FindAllAuthors callback = new FindAllAuthors();
    CellTable<Author> table =
        callback.getTable(
            new FieldUpdater<Author, String>() {
              public void update(int index, Author object, String value) {
                if (session.isPerunAdmin()) {
                  session.getTabManager().addTab(new UsersPublicationsTabItem(object.getId()));
                }
              }
            });

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

    vp.add(sp);

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

    this.contentWidget.setWidget(vp);

    return getWidget();
  }
    private void addFileUploadWidget() {
      final FileUpload upload = new FileUpload();
      upload.setWidth("200px");
      upload.setName(getUniqueId());
      uploadForms.add(upload);
      final HorizontalPanel hPanel = new HorizontalPanel();
      hPanel.setHeight("30px");
      hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
      // Don't display ability to remove form if expecting exactly 1 upload or if this is the first
      // upload element
      if (isMultiple() && uploadForms.size() > 1) {
        com.google.gwt.user.client.ui.Image crossImage = new com.google.gwt.user.client.ui.Image();
        crossImage.setUrl(Resources.CROSS);
        crossImage.addClickHandler(
            new com.google.gwt.event.dom.client.ClickHandler() {
              public void onClick(final com.google.gwt.event.dom.client.ClickEvent clickEvent) {
                panel.remove(hPanel);
                uploadForms.remove(hPanel.getWidget(1));
              }
            });
        hPanel.add(crossImage);
      } else {
        com.google.gwt.user.client.ui.VerticalPanel space =
            new com.google.gwt.user.client.ui.VerticalPanel();
        space.setSize("16px", "1px");
        hPanel.add(space);
      }

      hPanel.add(upload);
      panel.add(hPanel);
      if (get() != null) {
        get().markForRedraw();
      }
    }
示例#6
0
  private Widget createScreenshotPanel() {
    VerticalPanel panel = new VerticalPanel();
    panel.setSize("100%", "100%");

    // background
    Label label2 = new Label("Background");
    panel.add(label2);
    HorizontalPanel bgTypes = new HorizontalPanel();
    bgTypes.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    panel.add(bgTypes);
    screenshotTransparentBt = new RadioButton("scbgtype", "Transparent");
    screenshotTransparentBt.addValueChangeHandler(
        new ValueChangeHandler<Boolean>() {
          @Override
          public void onValueChange(ValueChangeEvent<Boolean> event) {
            updatePreviewCanvas();
          }
        });

    bgTypes.add(screenshotTransparentBt); // stop because not support so far

    screenshotColorBt = new RadioButton("scbgtype", "Color");
    bgTypes.add(screenshotColorBt);

    screenshotColorBox = new ColorBox();
    screenshotColorBox.setValue("#333333");
    bgTypes.add(screenshotColorBox);

    return panel;
  }
示例#7
0
  private void addImageAndTitle(HorizontalPanel hp, GWTAppProperties properties) {
    Image logo = new Image(properties.getHeaderLogo());
    logo.setStyleName("square-header-LogoImage");
    logo.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            // when you click on the image, go to the home page.
            History.newItem(ChooseCasePilot.generateNavigationId(ChooseCasePilot.PageId.home));
          }
        });

    logo.setPixelSize(50, 50);
    hp.add(logo);

    VerticalPanel titleVerticalPane = new VerticalPanel();
    titleVerticalPane.setSize("100%", "100%");
    Label title = new Label(properties.getHeaderTitle1());
    Label subTitle = new Label(properties.getHeaderTitle2());
    title.setStyleName("square-headerpane-title");
    subTitle.setStyleName("square-headerpane-tagline");

    titleVerticalPane.add(title);
    titleVerticalPane.add(subTitle);

    hp.add(titleVerticalPane);
  }
  public LoginViewImpl() {
    VerticalPanel vp = new VerticalPanel();
    this.initWidget(vp);
    vp.setSize("100%", "100%");
    FlexTable grid = new FlexTable();
    grid.setStyleName(Adicionais.RESOURCES.css().login());

    Label loginLabel = new Label("Login:"******"Senha:");
    this.passwordTextBox = new PasswordTextBox();
    this.accessButton = new Button("Acessar");
    this.accessButton.setWidth("5em");

    grid.setCellSpacing(6);
    grid.setWidget(0, 0, loginLabel);
    grid.setWidget(0, 1, this.loginTextBox);
    grid.setWidget(1, 0, passwordLabel);
    grid.setWidget(1, 1, this.passwordTextBox);
    grid.setWidget(2, 0, accessButton);
    grid.getFlexCellFormatter().setColSpan(2, 0, 2);
    grid.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    vp.add(grid);
    vp.setCellVerticalAlignment(grid, HasVerticalAlignment.ALIGN_MIDDLE);
    vp.setCellHorizontalAlignment(grid, HasHorizontalAlignment.ALIGN_CENTER);
    this.setSize("100%", "100%");
  }
示例#9
0
  public MetricsHome(String chartOption) {

    VerticalPanel vp = new VerticalPanel();
    vp.setSize("97%", "100%");

    vpMetricsChart.setSize("100%", "100%");
    vpMetricsChart.setSpacing(30);
    vpMetricsChart.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    vp.add(new MetricsOptions());

    vp.add(vpMetricsChart);

    openDocumentationOption(chartOption);

    this.add(vp);
  }
示例#10
0
 public static void init() {
   panel.setSize("300px", "80px");
   panel.add(label);
   panel.add(fileUpload);
   popup.setGlassEnabled(true);
   popup.setAutoHideEnabled(true);
   popup.center();
   popup.add(panel);
 }
示例#11
0
文件: Term.java 项目: scbd/vocbench
    public TermDetail(ConceptObject conceptObject, TermObject termObject) {
      String text = termObject.getLabel();
      if (text.length() > 100) text = text.substring(0, 70) + "...";
      this.setHTML(
          constants.conceptInformationFor()
              + " <i>"
              + text
              + " ("
              + termObject.getLang()
              + ")</i>&nbsp;["
              + (termObject.isMainLabel()
                  ? constants.conceptPreferredTerm()
                  : constants.conceptNonPreferredTerm())
              + "]");
      TermDetailTabPanel termDetail =
          new TermDetailTabPanel(permissionTable, initData, TermDetail.this);
      termDetail.setURI(termObject, conceptObject);

      VerticalPanel vp = new VerticalPanel();
      vp.setSize("100%", "100%");
      vp.add(termDetail);

      panel.add(vp);
      panel.setCellHeight(vp, "100%");
      panel.setCellWidth(vp, "100%");

      HorizontalPanel buttonPanel = new HorizontalPanel();
      buttonPanel.setSpacing(5);
      buttonPanel.add(cancel);

      HorizontalPanel hp = new HorizontalPanel();
      hp.setSpacing(0);
      hp.setWidth("100%");
      hp.setStyleName("bottombar");
      hp.add(buttonPanel);
      hp.setCellHorizontalAlignment(buttonPanel, HasHorizontalAlignment.ALIGN_RIGHT);

      panel.add(hp);
      cancel.addClickHandler(this);
      panel.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_RIGHT);
      panel.setSize("100%", "100%");
      setWidget(panel);
    }
  public ConfigurationDialog(OkCancelDialogCallback callback) {
    setText("Configuration");
    setModal(true);
    this.okCancelDialogCallback = callback;

    setHTML("New dialog");

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

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    verticalPanel.add(horizontalPanel);
    verticalPanel.setCellHeight(horizontalPanel, "100%");
    verticalPanel.setCellWidth(horizontalPanel, "100%");
    horizontalPanel.setSize("324px", "29px");

    Label lblBrokerUrl = new Label("Broker url: ");
    horizontalPanel.add(lblBrokerUrl);

    final TextBox txtBrokerUrl = new TextBox();
    horizontalPanel.add(txtBrokerUrl);

    HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
    verticalPanel.add(horizontalPanel_1);
    verticalPanel.setCellWidth(horizontalPanel_1, "100%");
    verticalPanel.setCellHorizontalAlignment(
        horizontalPanel_1, HasHorizontalAlignment.ALIGN_CENTER);

    Button btnAcept = new Button("Acept");
    btnAcept.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            okCancelDialogCallback.okButtonClick(txtBrokerUrl.getText());
            hide();
          }
        });
    horizontalPanel_1.add(btnAcept);
    horizontalPanel_1.setCellVerticalAlignment(btnAcept, HasVerticalAlignment.ALIGN_MIDDLE);

    Button btnCancel = new Button("Cancel");
    btnCancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            okCancelDialogCallback.cancelButtonClick();
            hide();
          }
        });
    horizontalPanel_1.add(btnCancel);
    horizontalPanel_1.setCellVerticalAlignment(btnCancel, HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel_1.setCellHorizontalAlignment(btnCancel, HasHorizontalAlignment.ALIGN_RIGHT);
  }
示例#13
0
  public WeeklyPanel(Schedule schedule) {
    myConstants = GWT.create(MyConstants.class);
    this.schedule = schedule;
    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setSpacing(2);
    verticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.setSize("290px", "43px");
    initWidget(verticalPanel);

    RepeatEveryNPanel repeatWeeksPanel =
        new RepeatEveryNPanel(myConstants.repeatTypeWeeks(), schedule);
    verticalPanel.add(repeatWeeksPanel);
    repeatWeeksPanel.setWidth("239px");

    createRepeatWeeklyPanel(verticalPanel);

    TimeListPanel timeListPanel = new TimeListPanel(schedule);
    verticalPanel.add(timeListPanel);
    timeListPanel.setWidth("286px");
  }
示例#14
0
  public void onModuleLoad() {

    Label lblHelloWorld = new Label("hello world");
    rootPanel.add(lblHelloWorld, 10, 10);

    Button btnNew = new Button("new");
    btnNew.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            AddOption();
          }
        });
    rootPanel.add(btnNew, 10, 33);
    btnNew.setSize("41px", "29px");

    rootPanel.add(verticalPanel, 10, 77);
    verticalPanel.setSize("100px", "100px");

    OptionBox optionBox = new OptionBox();
    verticalPanel.add(optionBox);
  }
示例#15
0
  public Category() {

    VerticalPanel verPanel = new VerticalPanel();
    initWidget(verPanel);
    verPanel.setSize("100%", "100%");

    FlexTable flexTable = new FlexTable();
    verPanel.add(flexTable);
    verPanel.setCellVerticalAlignment(flexTable, HasVerticalAlignment.ALIGN_MIDDLE);
    verPanel.setCellHorizontalAlignment(flexTable, HasHorizontalAlignment.ALIGN_CENTER);
    flexTable.setSize("20%", "20%");

    Label lblCategoryName = new Label("CategoryName");
    flexTable.setWidget(0, 0, lblCategoryName);

    TextBox txtCatgegoryName = new TextBox();
    flexTable.setWidget(0, 1, txtCatgegoryName);

    Label lblCategoryDescription = new Label("CategoryDescription");
    flexTable.setWidget(1, 0, lblCategoryDescription);

    TextBox txtCategoryDescription = new TextBox();
    flexTable.setWidget(1, 1, txtCategoryDescription);

    CheckBox isParentCategory = new CheckBox();
    isParentCategory.setName("isParentCategory");
    flexTable.setWidget(2, 1, isParentCategory);

    Label lblIsParentCategory = new Label("ParentCategory");
    flexTable.setWidget(2, 0, lblIsParentCategory);

    TextButton buttonCreateCategory = new TextButton("Create");
    flexTable.setWidget(3, 1, buttonCreateCategory);

    flexTable.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    flexTable.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    flexTable.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    flexTable.getCellFormatter().setHorizontalAlignment(3, 1, HasHorizontalAlignment.ALIGN_CENTER);
  }
  public Widget draw() {

    titleWidget.setText(
        Utils.getStrippedStringWithEllipsis(facility.getName())
            + " ("
            + facility.getType()
            + "): create resource");

    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");

    // form inputs
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    final TextBox descriptionTextBox = new TextBox();

    final ListBoxWithObjects<VirtualOrganization> vosDropDown =
        new ListBoxWithObjects<VirtualOrganization>();

    // send button
    final CustomButton createButton =
        TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createResource());

    // local events fills the listbox of Vos and Slds
    JsonCallbackEvents event =
        new JsonCallbackEvents() {
          @Override
          public void onFinished(JavaScriptObject jso) {
            // fill VOs listbox
            vosDropDown.clear();
            ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
            vos = new TableSorter<VirtualOrganization>().sortByName(vos);
            for (VirtualOrganization vo : vos) {
              vosDropDown.addItem(vo);
            }
            if (!vos.isEmpty()) createButton.setEnabled(true);
          }

          @Override
          public void onLoadingStart() {
            vosDropDown.clear();
            vosDropDown.addItem("Loading...");
            createButton.setEnabled(false);
          }

          @Override
          public void onError(PerunError error) {
            vosDropDown.clear();
            vosDropDown.addItem("Error while loading");
            createButton.setEnabled(false);
          }
        };
    // load available VOs
    final GetVos vos = new GetVos(event);
    vos.setForceAll(true);
    vos.retrieveData();

    // layout
    FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();

    // Add some standard form options
    layout.setHTML(0, 0, "Name:");
    layout.setWidget(0, 1, nameTextBox);
    layout.setHTML(1, 0, "Description:");
    layout.setWidget(1, 1, descriptionTextBox);
    layout.setHTML(2, 0, "VO:");
    layout.setWidget(2, 1, vosDropDown);
    layout.setHTML(3, 0, "Facility:");
    layout.setHTML(3, 1, facility.getName() + " (" + facility.getType() + ")");

    for (int i = 0; i < layout.getRowCount(); i++) {
      cellFormatter.addStyleName(i, 0, "itemName");
    }

    layout.setWidth("350px");

    TabMenu menu = new TabMenu();

    final ExtendedTextBox.TextBoxValidator validator =
        new ExtendedTextBox.TextBoxValidator() {
          @Override
          public boolean validateTextBox() {
            if (nameTextBox.getTextBox().getText().trim().isEmpty()) {
              nameTextBox.setError("Name can't be empty.");
              return false;
            }
            nameTextBox.setOk();
            return true;
          }
        };
    nameTextBox.setValidator(validator);

    createButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {

            // loads new tab when creating successful, also disable button
            JsonCallbackEvents localEvents =
                new JsonCallbackEvents() {
                  public void onLoadingStart() {
                    (JsonCallbackEvents.disableButtonEvents(createButton)).onLoadingStart();
                  }

                  public void onFinished(JavaScriptObject jso) {
                    (JsonCallbackEvents.disableButtonEvents(createButton)).onFinished(jso);
                    Resource res = (Resource) jso;
                    session
                        .getTabManager()
                        .addTabToCurrentTab(
                            new CreateFacilityResourceManageServicesTabItem(facility, res), true);
                  }

                  public void onError(PerunError error) {
                    (JsonCallbackEvents.disableButtonEvents(createButton)).onError(error);
                  }
                };
            if (validator.validateTextBox()) {
              // request
              CreateResource request = new CreateResource(localEvents);
              request.createResource(
                  nameTextBox.getTextBox().getText().trim(),
                  descriptionTextBox.getText().trim(),
                  facility.getId(),
                  vosDropDown.getSelectedObject().getId());
            }
          }
        });

    menu.addWidget(createButton);

    final TabItem tab = this;
    menu.addWidget(
        TabMenu.getPredefinedButton(
            ButtonType.CANCEL,
            "",
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent clickEvent) {
                session.getTabManager().closeTab(tab, false);
              }
            }));

    vp.add(layout);
    vp.add(menu);
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);

    this.contentWidget.setWidget(vp);

    return getWidget();
  }
示例#17
0
  /**
   * Returns thanks management widget for publication
   *
   * @return widget
   */
  private Widget loadThanksSubTab() {

    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.smallBusinessIcon()));
    header.setHTML(0, 1, "<h3>Acknowledgement</h3>");
    dp.setHeader(header);

    // menu
    TabMenu menu = new TabMenu();

    // callback
    final FindThanksByPublicationId thanksCall = new FindThanksByPublicationId(publicationId);
    thanksCall.setCheckable(false);

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

    CellTable<Thanks> table = thanksCall.getTable();

    menu.addWidget(
        TabMenu.getPredefinedButton(
            ButtonType.ADD,
            "Add acknowledgement to publication",
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                session
                    .getTabManager()
                    .addTabToCurrentTab(
                        new CreateThanksTabItem(
                            publication, JsonCallbackEvents.refreshTableEvents(thanksCall)),
                        true);
              }
            }));

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

    removeButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            final ArrayList<Thanks> list = thanksCall.getTableSelectedList();
            String text = "Following acknowledgements will be removed from publication.";
            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) {
                        DeleteThanks request =
                            new DeleteThanks(
                                JsonCallbackEvents.disableButtonEvents(
                                    removeButton,
                                    JsonCallbackEvents.refreshTableEvents(thanksCall)));
                        request.deleteThanks(list.get(i).getId());
                      } else {
                        DeleteThanks request =
                            new DeleteThanks(JsonCallbackEvents.disableButtonEvents(removeButton));
                        request.deleteThanks(list.get(i).getId());
                      }
                    }
                  }
                });
          }
        });

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

    vp.add(sp);

    return dp;
  }
    NewFormDialog(final YoungAndroidProjectNode projectRootNode) {
      super(false, true);

      setStylePrimaryName("ode-DialogBox");
      setText(MESSAGES.newFormTitle());
      VerticalPanel contentPanel = new VerticalPanel();

      final String prefix = "Screen";
      final int prefixLength = prefix.length();
      int highIndex = 0;
      // Collect the existing form names so we can prevent duplicate form names.
      otherFormNames = new HashSet<String>();

      for (ProjectNode source : projectRootNode.getAllSourceNodes()) {
        if (source instanceof YoungAndroidFormNode) {
          String formName = ((YoungAndroidFormNode) source).getFormName();
          otherFormNames.add(formName);

          if (formName.startsWith(prefix)) {
            try {
              highIndex = Math.max(highIndex, Integer.parseInt(formName.substring(prefixLength)));
            } catch (NumberFormatException e) {
              continue;
            }
          }
        }
      }

      String defaultFormName = prefix + (highIndex + 1);

      newNameTextBox = new LabeledTextBox(MESSAGES.formNameLabel());
      newNameTextBox.setText(defaultFormName);
      newNameTextBox
          .getTextBox()
          .addKeyUpHandler(
              new KeyUpHandler() {
                @Override
                public void onKeyUp(KeyUpEvent event) {
                  int keyCode = event.getNativeKeyCode();
                  if (keyCode == KeyCodes.KEY_ENTER) {
                    handleOkClick(projectRootNode);
                  } else if (keyCode == KeyCodes.KEY_ESCAPE) {
                    hide();
                    executionFailedOrCanceled();
                  }
                }
              });
      contentPanel.add(newNameTextBox);

      String cancelText = MESSAGES.cancelButton();
      String okText = MESSAGES.okButton();

      // Keeps track of the total number of screens.
      int formCount = otherFormNames.size() + 1;
      if (formCount > MAX_FORM_COUNT) {
        HorizontalPanel errorPanel = new HorizontalPanel();
        HTML tooManyScreensLabel = new HTML(MESSAGES.formCountErrorLabel());
        errorPanel.add(tooManyScreensLabel);
        errorPanel.setSize("100%", "24px");
        contentPanel.add(errorPanel);

        okText = MESSAGES.addScreenButton();
        cancelText = MESSAGES.cancelScreenButton();

        // okText = "Add";
        // cancelText = "Don't Add";
      }

      Button cancelButton = new Button(cancelText);
      cancelButton.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              hide();
              executionFailedOrCanceled();
            }
          });
      Button okButton = new Button(okText);
      okButton.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              handleOkClick(projectRootNode);
            }
          });
      HorizontalPanel buttonPanel = new HorizontalPanel();
      buttonPanel.add(cancelButton);
      buttonPanel.add(okButton);
      buttonPanel.setSize("100%", "24px");
      contentPanel.add(buttonPanel);
      contentPanel.setSize("320px", "100%");

      add(contentPanel);
    }
示例#19
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();
  }
示例#20
0
  /** Main class */
  public void onModuleLoad() {

    // basic settings
    session.setUiElements(new UiElements(null));

    // Get web page's BODY
    RootLayoutPanel body = RootLayoutPanel.get();

    // check RPC url
    if (session.getRpcUrl().isEmpty()) {
      VerticalPanel bodyContents = new VerticalPanel();
      bodyContents.setSize("100%", "300px");
      bodyContents.add(
          new HTML(new Image(LargeIcons.INSTANCE.errorIcon()) + "<h2>RPC SERVER NOT FOUND!</h2>"));
      bodyContents.setCellHorizontalAlignment(
          bodyContents.getWidget(0), HasHorizontalAlignment.ALIGN_CENTER);
      bodyContents.setCellVerticalAlignment(
          bodyContents.getWidget(0), HasVerticalAlignment.ALIGN_BOTTOM);
      body.add(bodyContents);
      return;
    }

    // WEB PAGE SPLITTER
    body.add(bodySplitter);

    // left menu
    leftMenu = new ApplicationFormLeftMenu();

    // show loading box
    loadingBox = session.getUiElements().perunLoadingBox();
    loadingBox.show();

    // switch menu event
    JsonCallbackEvents events =
        new JsonCallbackEvents() {
          @Override
          public void onFinished(JavaScriptObject jso) {

            bodySplitter.clear();
            bodySplitter.addSouth(getFooter(), 23);
            ArrayList<Application> apps = JsonUtils.jsoAsList(jso);
            if (apps != null && !apps.isEmpty()) {
              // show menu
              bodySplitter.addWest(leftMenu, 280);
            }
            // else don't show menu
            // MAIN CONTENT
            contentPanel.setSize("100%", "100%");
            contentPanel.add(leftMenu.getContent());
            bodySplitter.add(contentPanel);

            // Append more GUI elements from UiElements class which are not part of splitted design
            // WE DON'T WANT TO CONFUSE USER WITH STATUS MESSAGES
            // bodySplitter.getElement().appendChild(session.getUiElements().getStatus().getElement()); // status

            // starts loading
            isUserMemberOfVo();

            // hides the loading box
            loadingBox.hide();
          }

          @Override
          public void onError(PerunError error) {
            // MAIN CONTENT

            bodySplitter.clear();
            bodySplitter.addSouth(getFooter(), 23);
            contentPanel.clear();
            contentPanel.setSize("100%", "100%");
            contentPanel.add(leftMenu.getContent());
            bodySplitter.add(contentPanel);

            // Append more GUI elements from UiElements class which are not part of splitted design
            // bodySplitter.getElement().appendChild(session.getUiElements().getStatus().getElement()); // status

            // starts loading
            isUserMemberOfVo();

            // hides the loading box
            loadingBox.hide();
          }
        };

    // load VO to check if exists
    loadVo(events);
  }
  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;
          }
        });
  }
示例#22
0
  public Widget draw() {

    this.titleWidget.setText(
        Utils.getStrippedStringWithEllipsis(service.getName()) + ": exec services");

    final VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");

    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");

    final ListExecServices callback = new ListExecServices(serviceId);
    CellTable<ExecService> table =
        callback.getTable(
            new FieldUpdater<ExecService, String>() {
              public void update(int index, ExecService object, String value) {
                // manage details of exec services (dependency, status, update values?)
                session.getTabManager().addTab(new ViewExecServiceTabItem(object));
              }
            });

    // refresh event after deletion
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(callback);

    menu.addWidget(
        TabMenu.getPredefinedButton(
            ButtonType.CREATE,
            ButtonTranslation.INSTANCE.createExecService(),
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent clickEvent) {
                session.getTabManager().addTabToCurrentTab(new AddExecServiceTabItem(service));
              }
            }));

    final CustomButton deleteButton =
        TabMenu.getPredefinedButton(
            ButtonType.REMOVE, ButtonTranslation.INSTANCE.deleteSelectedExecServices());
    menu.addWidget(deleteButton);
    deleteButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            final ArrayList<ExecService> execToRemove = callback.getTableSelectedList();
            UiElements.showDeleteConfirm(
                execToRemove,
                new ClickHandler() {
                  @Override
                  public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                    for (int i = 0; i < execToRemove.size(); i++) {
                      if (i == execToRemove.size() - 1) {
                        DeleteExecService request =
                            new DeleteExecService(
                                JsonCallbackEvents.disableButtonEvents(deleteButton, events));
                        request.deleteExecService(execToRemove.get(i).getId());
                      } else {
                        DeleteExecService request =
                            new DeleteExecService(
                                JsonCallbackEvents.disableButtonEvents(deleteButton));
                        request.deleteExecService(execToRemove.get(i).getId());
                      }
                    }
                  }
                });
          }
        });

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

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

    final CustomButton enable =
        TabMenu.getPredefinedButton(ButtonType.ENABLE, "Enable selected exec service(s)");
    final CustomButton disable =
        TabMenu.getPredefinedButton(ButtonType.DISABLE, "Disable selected exec service(s)");

    menu.addWidget(enable);
    menu.addWidget(disable);

    enable.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {

            ArrayList<ExecService> list = callback.getTableSelectedList();
            for (int i = 0; i < list.size(); i++) {

              ExecService e = list.get(i);
              if (i < list.size() - 1) {
                // any call
                if (!e.isEnabled()) {
                  UpdateExecService request =
                      new UpdateExecService(JsonCallbackEvents.disableButtonEvents(enable));
                  e.setEnabled(true);
                  request.updateExecService(e);
                }
              } else {
                // last call
                if (!e.isEnabled()) {
                  UpdateExecService request =
                      new UpdateExecService(JsonCallbackEvents.disableButtonEvents(enable, events));
                  e.setEnabled(true);
                  request.updateExecService(e);
                }
              }
            }
          }
        });

    disable.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {

            ArrayList<ExecService> list = callback.getTableSelectedList();
            for (int i = 0; i < list.size(); i++) {

              ExecService e = list.get(i);
              if (i < list.size() - 1) {
                // any call
                if (e.isEnabled()) {
                  UpdateExecService request =
                      new UpdateExecService(JsonCallbackEvents.disableButtonEvents(disable));
                  e.setEnabled(false);
                  request.updateExecService(e);
                }
              } else {
                // last call
                if (e.isEnabled()) {
                  UpdateExecService request =
                      new UpdateExecService(
                          JsonCallbackEvents.disableButtonEvents(disable, events));
                  e.setEnabled(false);
                  request.updateExecService(e);
                }
              }
            }
          }
        });

    deleteButton.setEnabled(false);
    enable.setEnabled(false);
    disable.setEnabled(false);
    JsonUtils.addTableManagedButton(callback, table, deleteButton);
    JsonUtils.addTableManagedButton(callback, table, enable);
    JsonUtils.addTableManagedButton(callback, table, disable);

    vp.add(sp);
    vp.setCellHeight(sp, "100%");

    // add tabs to the main panel
    this.contentWidget.setWidget(vp);

    return getWidget();
  }
  public ItemDetailTouchScreenView() {

    // Handler Manager
    handlerManager = new HandlerManager(this);

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

    HeaderDeclarativeView headerView = new HeaderDeclarativeView();
    headerView.setSize("100%", "100%");
    verticalPanel.add(headerView);
    setHeaderDisplay(headerView);

    contentPanel = new VerticalPanel();
    contentPanel.setSpacing(0);
    verticalPanel.add(contentPanel);
    contentPanel.setWidth("100%");
    contentPanel.addStyleName("forFriendPanel");

    itemTitlePanel = new ItemDetailTitlePanel();
    contentPanel.add(itemTitlePanel);
    itemTitlePanel.setStyleName("itemDetail-Panel");
    itemTitlePanel.setWidth("100%");

    itemDetailTabPanel = new DecoratedTabPanel();
    contentPanel.add(itemDetailTabPanel);
    itemDetailTabPanel.setSize("100%", "100%");
    contentPanel.addStyleName("forFriendPanel");

    offersPanel = new VerticalPanel();
    tabOffers = new ItemDetailTabPanel();
    tabOffers.setTabImageUrl("images/172-pricetag-disabled.png");
    tabOffers.setTabDescriptionLabelText(MESSAGES.tabOffersText_text());
    itemDetailTabPanel.add(offersPanel, tabOffers);
    offersPanel.setSize("100%", "100%");
    offersPanel.setSpacing(0);

    placesPanel = new VerticalPanel();
    tabPlaces = new ItemDetailTabPanel();
    tabPlaces.setTabImageUrl("images/07-map-marker-disabled.png");
    tabPlaces.setTabDescriptionLabelText(MESSAGES.tabPlacesText_text());
    itemDetailTabPanel.add(placesPanel, tabPlaces);
    placesPanel.setSize("100%", "100%");
    placesPanel.setSpacing(0);

    friendsPanel = new VerticalPanel();
    tabFriends = new ItemDetailTabPanel();
    tabFriends.setTabImageUrl("images/111-user-disabled.png");
    tabFriends.setTabDescriptionLabelText(MESSAGES.tabFriendsText_text());
    itemDetailTabPanel.add(friendsPanel, tabFriends);
    friendsPanel.setSize("100%", "100%");
    friendsPanel.setSpacing(0);

    itemDetailTabPanel
        .getTabBar()
        .addSelectionHandler(
            new SelectionHandler<Integer>() {

              @Override
              public void onSelection(SelectionEvent<Integer> event) {
                int selTab = event.getSelectedItem();

                if (selTab == 0) {
                  tabOffers.setTabImageUrl("images/172-pricetag.png");
                  tabPlaces.setTabImageUrl("images/07-map-marker-disabled.png");
                  tabFriends.setTabImageUrl("images/111-user-disabled.png");
                } else if (selTab == 1) {
                  tabPlaces.setTabImageUrl("images/07-map-marker.png");
                  tabOffers.setTabImageUrl("images/172-pricetag-disabled.png");
                  tabFriends.setTabImageUrl("images/111-user-disabled.png");
                } else if (selTab == 2) {
                  tabFriends.setTabImageUrl("images/111-user.png");
                  tabOffers.setTabImageUrl("images/172-pricetag-disabled.png");
                  tabPlaces.setTabImageUrl("images/07-map-marker-disabled.png");
                }
                ;
              }
            });
  }
示例#24
0
  private void initLayout() {

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

    HTML conceptLab = new HTML(constants.exportConcept());
    HTML exportLab = new HTML(constants.exportFormat());
    HTML schemeLab = new HTML(constants.exportScheme());
    HTML dateLab = new HTML(constants.exportDate());
    HTML termCodeLab = new HTML(constants.exportTermCode());

    conceptLab.setWordWrap(false);
    exportLab.setWordWrap(false);
    schemeLab.setWordWrap(false);
    dateLab.setWordWrap(false);
    termCodeLab.setWordWrap(false);

    table.setWidget(0, 0, schemeLab);
    table.setWidget(0, 1, getScheme());
    table.setWidget(1, 0, conceptLab);
    table.setWidget(1, 1, getConcept());
    table.setWidget(2, 0, exportLab);
    table.setWidget(2, 1, getExportFormat());
    // table.setWidget(3, 0, termCodeLab);
    // table.setWidget(3, 1, getTermCode());
    // table.setWidget(4, 0, dateLab);
    // table.setWidget(4, 1, getDatePanel());

    table.getColumnFormatter().setWidth(0, "15%");
    table.getColumnFormatter().setWidth(1, "75%");

    final VerticalPanel exportOption = new VerticalPanel();
    exportOption.setSize("100%", "100%");
    exportOption.add(GridStyle.setTableRowStyle(table, "#F4F4F4", "#E8E8E8", 3));

    final Button export = new Button(constants.exportButton());
    final CheckBox chkZip = new CheckBox(constants.exportUseZip());

    HorizontalPanel bottombar = new HorizontalPanel();
    bottombar.setSpacing(5);
    bottombar.add(chkZip);
    bottombar.add(export);
    bottombar.setSize("100%", "100%");
    bottombar.setStyleName("bottombar");
    bottombar.setCellHorizontalAlignment(chkZip, HasHorizontalAlignment.ALIGN_LEFT);
    bottombar.setCellHorizontalAlignment(export, HasHorizontalAlignment.ALIGN_RIGHT);
    bottombar.setCellVerticalAlignment(export, HasVerticalAlignment.ALIGN_MIDDLE);

    // ButtonbarWidget bottomBarPanel = new ButtonbarWidget(null, bottombar);

    /*ld.setSize("100%", "100%");
    spacer.setSize("100%", "100%");
    spacer.setCellHorizontalAlignment(ld, HasHorizontalAlignment.ALIGN_CENTER);
    spacer.setCellVerticalAlignment(ld, HasVerticalAlignment.ALIGN_MIDDLE);

     Window.addResizeHandler(new ResizeHandler()
        {
        	public void onResize(ResizeEvent event) {
        		spacer.setSize("100%", "100%");
    		}
    	});*/

    VerticalPanel optionPanel = new VerticalPanel();
    optionPanel.setSize("100%", "100%");
    optionPanel.setStyleName("borderbar");
    optionPanel.add(exportOption);
    // optionPanel.add(spacer);
    optionPanel.add(bottombar);
    // optionPanel.setCellHeight(spacer, "100%");
    optionPanel.setCellVerticalAlignment(exportOption, HasVerticalAlignment.ALIGN_TOP);
    optionPanel.setCellVerticalAlignment(bottombar, HasVerticalAlignment.ALIGN_BOTTOM);

    HorizontalPanel langPanel = new HorizontalPanel();
    /*Image img = new Image("images/map-grey.gif");
    final Label lang = new Label(constants.exportSelectLang());
    lang.setSize("150", "100%");
    lang.setStyleName("displayexportLang");
    lang.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    lang.addClickHandler(new ClickHandler() {
    	public void onClick(ClickEvent event) {
    		if(selectLanguage == null || !selectLanguage.isLoaded)
    			selectLanguage = new SelectLanguage();
    		selectLanguage.show();
    	}
    });

    langPanel.setSize("10%", "100%");
    langPanel.add(img);
    langPanel.add(new HTML("&nbsp;"));
    langPanel.add(lang);
    langPanel.add(new HTML("&nbsp;"));
    langPanel.add(new HTML("&nbsp;"));
    langPanel.setCellWidth(lang, "100%");
    langPanel.setCellHeight(lang, "100%");
    langPanel.setCellVerticalAlignment(img, HasVerticalAlignment.ALIGN_MIDDLE);
    langPanel.setCellVerticalAlignment(lang, HasVerticalAlignment.ALIGN_MIDDLE);
    langPanel.setCellHorizontalAlignment(lang, HasHorizontalAlignment.ALIGN_RIGHT);
    langPanel.setSpacing(1);*/

    VerticalPanel tempmainPanel = new VerticalPanel();
    tempmainPanel.setSpacing(10);
    tempmainPanel.add(optionPanel);

    BodyPanel mainPanel = new BodyPanel(constants.exportTitle(), tempmainPanel, langPanel);

    mainBodypanel.setSize("100%", "100%");
    mainBodypanel.add(mainPanel);
    mainBodypanel.setCellHorizontalAlignment(mainPanel, HasHorizontalAlignment.ALIGN_CENTER);
    mainBodypanel.setCellVerticalAlignment(mainPanel, HasVerticalAlignment.ALIGN_TOP);
    mainBodypanel.setCellWidth(mainPanel, "100%");
    mainBodypanel.setCellHeight(mainPanel, "100%");

    panel.clear();
    panel.setSize("100%", "100%");
    panel.add(mainBodypanel);
    panel.add(loadingDialog);
    panel.setCellHorizontalAlignment(mainPanel, HasHorizontalAlignment.ALIGN_CENTER);
    panel.setCellVerticalAlignment(mainPanel, HasVerticalAlignment.ALIGN_TOP);
    showLoading(false);

    // =================

    export.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            if (!format.getValue((format.getSelectedIndex())).equals("")
                && !format.getValue(format.getSelectedIndex()).equals("--None--")) {
              exp.setFormat(format.getValue(format.getSelectedIndex()));
            } else {
              exp.setFormat(null);
            }
            String expformat = exp.getFormat();
            if (expformat == null || expformat.equals("")) {
              Window.alert(constants.exportSelectFormat());
            } else if (exp.getStartDate() != null || exp.getEndDate() != null) {
              if (exp.getStartDate() == null || exp.getEndDate() == null) {
                Window.alert(constants.exportSelectDateRange());
              }
            } else {
              showLoading(true);
              exp.setExpLanguage(userSelectedLanguage);
              exp.setTermCode(termCodeBox.getValue().equals("") ? null : termCodeBox.getValue());

              AsyncCallback<String> callback =
                  new AsyncCallback<String>() {
                    public void onSuccess(String key) {
                      String formattype = format.getValue(format.getSelectedIndex());

                      String filename =
                          "export_"
                              + formattype.toLowerCase()
                              + "_"
                              + DateTimeFormat.getFormat("ddMMyyyyhhmmss").format(new Date());

                      if (formattype.equals(ExportFormat.SKOS)
                          || formattype.equals(ExportFormat.SKOSXL)) filename += ".rdf";
                      else if (formattype.equals(ExportFormat.TBX)) filename += ".tbx";
                      else if (formattype.equals(ExportFormat.OWL_SIMPLE_FORMAT))
                        filename += ".owl";
                      else if (formattype.equals(ExportFormat.OWL_COMPLETE_FORMAT))
                        filename += ".owl";
                      else if (formattype.equals(ExportFormat.RDBMS_SQL_FORMAT)) filename += ".sql";

                      Window.open(
                          GWT.getHostPageBaseURL()
                              + "downloadExportData?filename="
                              + filename
                              + "&key="
                              + key
                              + "&size="
                              + ConfigConstants.ZIPSIZE
                              + "&forcezip="
                              + chkZip.getValue(),
                          "_download",
                          "");
                      showLoading(false);
                    }

                    public void onFailure(Throwable caught) {
                      showLoading(false);
                      ExceptionManager.showException(caught, constants.exportDataFail());
                    }
                  };
              Service.exportService.export(exp, MainApp.userId, 74, MainApp.userOntology, callback);
            }
          }
        });
  }
  private void configure() {
    // Configure parentPanel
    parentPanel.setBorderWidth(50);
    parentPanel.setSize("100%", "100%");
    parentPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    parentPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    // Initialize Labels, Boxes, and Buttons
    Label header;
    if (!isEdit) {
      header = new Label("Create an Event");
    } else {
      header = new Label("Edit Event");
    }
    header.setStyleName("subHeaderText");
    Label nameLabel = new Label("Event Name ");
    Label locLabel = new Label("Location");
    Label dateLabel = new Label("Date");
    Label startTimeLabel = new Label("Start Time");
    Label endTimeLabel = new Label("End Time");
    Label descLabel = new Label("Description");
    Label chosenUsersLabel = new Label("Attendees");
    Label chooseUsersLabel = new Label("Add Attendees\t");
    configureInputFields();

    // Add style and text
    header.setStyleName("header");

    // Everything goes into a FlexTable
    FlexTable flexTable = new FlexTable();
    flexTable.setCellPadding(100);
    flexTable.setCellSpacing(100);

    flexTable.setWidget(0, 0, nameLabel);
    flexTable.setWidget(1, 0, locLabel);
    flexTable.setWidget(2, 0, dateLabel);
    flexTable.setWidget(3, 0, startTimeLabel);
    flexTable.setWidget(4, 0, endTimeLabel);
    flexTable.setWidget(5, 0, descLabel);
    flexTable.setWidget(6, 0, chosenUsersLabel);
    flexTable.setWidget(7, 0, chooseUsersLabel);

    flexTable.setWidget(0, 1, boxes.get(0));
    flexTable.setWidget(1, 1, boxes.get(1));
    flexTable.setWidget(2, 1, boxes.get(2));
    flexTable.setWidget(3, 1, boxes.get(3));
    flexTable.setWidget(4, 1, boxes.get(4));
    flexTable.setWidget(5, 1, areas.get(0));
    flexTable.setWidget(6, 1, areas.get(1));
    flexTable.setWidget(7, 1, userCellList);

    if (createButton != null) {
      flexTable.setWidget(8, 3, cancelButton);
      flexTable.setWidget(8, 4, createButton);
    } else {
      flexTable.setWidget(8, 3, saveButton);
      flexTable.setWidget(8, 4, cancelButton);
      flexTable.setWidget(8, 5, deleteButton);
    }

    // Add the FlexTable to the ParentPanel
    parentPanel.add(header);
    parentPanel.add(flexTable);
    Constants.logger.severe("CREATEEVENTVIEW.JAVA: END OF CONFIGURE().");
  }
示例#26
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);
  }
示例#27
0
  public Widget draw() {

    this.titleWidget.setText(
        Utils.getStrippedStringWithEllipsis(group.getName()) + ": " + "ext sources");

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

    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));

    // get VO resources
    final GetGroupExtSources extSources = new GetGroupExtSources(groupId);

    // refresh table event
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(extSources);

    // create ext source button
    CustomButton addButton =
        TabMenu.getPredefinedButton(
            ButtonType.ADD,
            true,
            ButtonTranslation.INSTANCE.addExtSource(),
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                session
                    .getTabManager()
                    .addTabToCurrentTab(new AddGroupExtSourceTabItem(groupId), true);
              }
            });
    if (session.isVoAdmin(voId)) {
      menu.addWidget(addButton);
    }

    final CustomButton removeButton =
        TabMenu.getPredefinedButton(
            ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeExtSource());
    removeButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            final ArrayList<ExtSource> extSourcesToRemove = extSources.getTableSelectedList();
            String text =
                "Following external sources will be removed from Group. You won't be able to import members from them anymore.";
            UiElements.showDeleteConfirm(
                extSourcesToRemove,
                text,
                new ClickHandler() {
                  @Override
                  public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < extSourcesToRemove.size(); i++) {
                      RemoveExtSource request;
                      if (i == extSourcesToRemove.size() - 1) {
                        request =
                            new RemoveExtSource(
                                JsonCallbackEvents.disableButtonEvents(removeButton, events));
                      } else {
                        request =
                            new RemoveExtSource(
                                JsonCallbackEvents.disableButtonEvents(removeButton));
                      }
                      request.removeGroupExtSource(groupId, extSourcesToRemove.get(i).getId());
                    }
                  }
                });
          }
        });
    if (session.isVoAdmin(voId)) {
      menu.addWidget(removeButton);
    }

    // authorization - enable buttons for vo admin only.
    if (!session.isVoAdmin(voId)) {
      addButton.setEnabled(false);
      removeButton.setEnabled(false);
      extSources.setCheckable(false);
    }

    menu.addFilterWidget(
        new ExtendedSuggestBox(extSources.getOracle()),
        new PerunSearchEvent() {
          @Override
          public void searchFor(String text) {
            extSources.filterTable(text);
          }
        },
        "Filter external sources by name or type");

    // add menu to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");

    CellTable<ExtSource> table = extSources.getTable();

    if (session.isVoAdmin(voId)) {
      removeButton.setEnabled(false);
      JsonUtils.addTableManagedButton(extSources, table, removeButton);
    }

    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");

    vp.add(sp);

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

    this.contentWidget.setWidget(vp);

    return getWidget();
  }
示例#28
0
 public void clearLoading() {
   tbPanel.clear();
   tbPanel.setSize("100%", "100%");
 }
  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();
              }
            }
          });
    }
  }
示例#30
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%");
  }