Example #1
0
 private void initContent(String aValue) {
   if (allowHtml) {
     myHtmlView = new HTML();
     myHtmlView.setStylePrimaryName("field_htmlview");
     if (aValue != null) {
       myHtmlView.setHTML(aValue);
     } else {
       myHtmlView.setText(constants.editValue());
       myHtmlView.addStyleName("empty_field");
     }
     myOuterPanel.add(myHtmlView);
   } else {
     myTextView = new Label();
     myTextView.setStylePrimaryName("field_view");
     if (aValue != null && aValue.length() > 0) {
       myTextView.setText(aValue);
     } else {
       myTextView.setText(constants.editValue());
       myTextView.addStyleName("empty_field");
     }
     myOuterPanel.add(myTextView);
   }
 }
Example #2
0
 private void initWidget() {
   // To conform with the standard stylesheet
   final HTML widget = new HTML();
   widget.setStylePrimaryName("dropzone");
   initWidget(widget);
 }
Example #3
0
 public void addInfoMessage(String message) {
   HTML title = new HTML(message);
   title.setStylePrimaryName(STYLE.resultsInfoMessage());
   results.add(title);
 }
  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();
              }
            }
          });
    }
  }
Example #5
0
 /**
  * Description block creation
  *
  * @param description
  * @return
  */
 protected Widget buildDescription() {
   HTML desc = new HTML(getWizardDescription());
   desc.setHeight("30px");
   desc.setStylePrimaryName("blockDescription");
   return desc;
 }
Example #6
0
    private DocTab(
        ImageResource icon,
        String docId,
        String title,
        String tooltip,
        TabCloseObserver closeHandler) {
      docId_ = docId;

      final HorizontalPanel layoutPanel = new HorizontalPanel();
      layoutPanel.setStylePrimaryName(styles_.tabLayout());
      layoutPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
      layoutPanel.getElement().setDraggable("true");
      layoutPanel.addDomHandler(
          new DragStartHandler() {
            @Override
            public void onDragStart(DragStartEvent evt) {
              evt.getDataTransfer()
                  .setData(
                      getDataTransferFormat(),
                      docId_ + "|" + SourceWindowManager.getSourceWindowId());
              JsObject dt = evt.getDataTransfer().cast();
              dt.setString("effectAllowed", "move");

              // figure out where the cursor is inside the element; because the
              // drag shows an image of the tab, knowing where the cursor is
              // inside that image is necessary for us to know the screen
              // location of the dragged image
              int evtX = evt.getNativeEvent().getClientX();
              ElementEx ele = getElement().cast();
              events_.fireEvent(
                  new DocTabDragInitiatedEvent(
                      docId_,
                      getElement().getClientWidth(),
                      evtX - ele.getBoundingClientRect().getLeft()));
            }
          },
          DragStartEvent.getType());

      HTML left = new HTML();
      left.setStylePrimaryName(styles_.tabLayoutLeft());
      layoutPanel.add(left);

      contentPanel_ = new HorizontalPanel();
      contentPanel_.setTitle(tooltip);
      contentPanel_.setStylePrimaryName(styles_.tabLayoutCenter());
      contentPanel_.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

      if (icon != null) contentPanel_.add(imageForIcon(icon));

      label_ = new Label(title, false);
      label_.addStyleName(styles_.docTabLabel());
      contentPanel_.add(label_);

      appendDirtyMarker();

      Image img = new Image(ThemeResources.INSTANCE.closeTab());
      img.setStylePrimaryName(styles_.closeTabButton());
      img.addStyleName(ThemeStyles.INSTANCE.handCursor());
      contentPanel_.add(img);

      layoutPanel.add(contentPanel_);

      HTML right = new HTML();
      right.setStylePrimaryName(styles_.tabLayoutRight());
      layoutPanel.add(right);

      initWidget(layoutPanel);

      this.sinkEvents(Event.ONCLICK);
      closeHandler_ = closeHandler;
      closeElement_ = img.getElement();
    }
Example #7
0
  /**
   * Build the widget
   *
   * @param user the logged in user
   * @return the {@link Widget}
   */
  protected Widget buildUserIdentityCard() {

    final FlowPanel theIDWidget = new FlowPanel();
    theIDWidget.setStylePrimaryName("bonita_identification");

    final FlowPanel theLeftAlignedBox = new FlowPanel();
    theLeftAlignedBox.setStylePrimaryName("bonita_identified-left");

    theIDWidget.add(theLeftAlignedBox);

    final Image theAvatar = new Image("images/avatar-default.gif");
    theAvatar.setStyleName("bonita_avatar");

    theLeftAlignedBox.add(theAvatar);

    final FlowPanel theRightAlignedBox = new FlowPanel();
    theRightAlignedBox.setStylePrimaryName("bonita_identified-right");

    theLeftAlignedBox.add(theRightAlignedBox);

    HTML theUserIdentity = null;
    if (user.isAnonymous()) {
      theUserIdentity = new HTML(FormsResourceBundle.getMessages().anonymousLabel());
    } else {
      theUserIdentity = new HTML(user.getUsername());
    }
    theUserIdentity.setStylePrimaryName("bonita_identif-1");

    theRightAlignedBox.add(theUserIdentity);

    Anchor theLogoutLink = null;
    if (user.isAnonymous()) {
      theLogoutLink = new Anchor(FormsResourceBundle.getMessages().loginButtonLabel());
    } else {
      theLogoutLink = new Anchor(FormsResourceBundle.getMessages().logoutButtonLabel());
    }
    theLogoutLink.setStylePrimaryName("bonita_identif-2");

    final URLUtils urlUtils = URLUtilsFactory.getInstance();
    final List<String> paramsToRemove = new ArrayList<String>();
    paramsToRemove.add(URLUtils.LOCALE_PARAM);
    final List<String> hashParamsToRemove = new ArrayList<String>();
    if (user.isAutoLogin()) {
      hashParamsToRemove.add(URLUtils.AUTO_LOGIN_PARAM);
    } else {
      hashParamsToRemove.add(URLUtils.USER_CREDENTIALS_PARAM);
    }
    if (!user.isAnonymous()) {
      for (final Entry<String, Object> hashParamEntry : context.entrySet()) {
        hashParamsToRemove.add(hashParamEntry.getKey());
      }
    }
    Map<String, String> hashParamsToAdd = new HashMap<String, String>();
    hashParamsToAdd.put(URLUtils.TODOLIST_PARAM, "true");
    hashParamsToAdd.put(URLUtils.VIEW_MODE_PARAM, "app");
    final String theRedirectURL =
        urlUtils.rebuildUrl(paramsToRemove, null, hashParamsToRemove, hashParamsToAdd);
    String theURL = "?" + URLUtils.REDIRECT_URL_PARAM + "=";
    try {
      theURL += URL.encodeQueryString(theRedirectURL);
    } catch (final Exception e) {
      Window.alert("Unable to redirect to login page: Invalid URL");
      theURL += GWT.getModuleBaseURL();
    }
    theLogoutLink.setHref(theURL);

    theRightAlignedBox.add(theLogoutLink);

    return theIDWidget;
  }