public SelectUserOrRoleDialog(
      ArrayList<String> existing, final IUserRoleSelectedCallback callback) {
    super(
        Messages.getString("selectUserOrRole"),
        Messages.getString("ok"),
        Messages.getString("cancel"),
        false,
        true,
        contentTable); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    usersListBox.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            rolesListBox.setSelectedIndex(-1);
            okButton.setEnabled(true);
          }
        });
    rolesListBox.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            usersListBox.setSelectedIndex(-1);
            okButton.setEnabled(true);
          }
        });

    setCallback(
        new IDialogCallback() {

          public void cancelPressed() {}

          public void okPressed() {
            if (getSelectedUser() != null) {
              callback.userSelected(getSelectedUser());
            } else {
              callback.roleSelected(getSelectedRole());
            }
          }
        });

    // Unique ids are important for test automation
    contentTable.getElement().setId("userOrRoleDialogContentTable");
    usersListBox.getElement().setId("userOrRoleDialogUsersList");
    rolesListBox.getElement().setId("userOrRoleDialogRolesList");
    okButton.getElement().setId("userOrRoleDialogOkButton");
    okButton.setEnabled(false);
    cancelButton.getElement().setId("userOrRoleDialogCancelButton");

    usersListBox.setVisibleItemCount(5);
    rolesListBox.setVisibleItemCount(5);
    rolesListBox.setWidth("100%"); // $NON-NLS-1$
    usersListBox.setWidth("100%"); // $NON-NLS-1$
    contentTable.clear();
    contentTable.setWidth("100%"); // $NON-NLS-1$
    contentTable.setWidget(0, 0, new Label(Messages.getString("users"))); // $NON-NLS-1$
    contentTable.setWidget(1, 0, usersListBox);
    contentTable.setWidget(2, 0, new Label(Messages.getString("roles"))); // $NON-NLS-1$
    contentTable.setWidget(3, 0, rolesListBox);
    fetchAllUsers(existing);
    fetchAllRoles(existing);
    setWidth("200px"); // $NON-NLS-1$
  }
Ejemplo n.º 2
0
  private void render(final FixtureList retList, final FlexTable outer, final Scenario sc) {
    outer.clear();
    outer.getCellFormatter().setStyleName(0, 0, "modeller-fact-TypeHeader");
    outer
        .getCellFormatter()
        .setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
    outer.setStyleName("modeller-fact-pattern-Widget");
    outer.setWidget(0, 0, new SmallLabel(Constants.INSTANCE.ActivateRuleFlowGroup()));
    outer.getFlexCellFormatter().setColSpan(0, 0, 2);

    int row = 1;
    for (Fixture fixture : retList) {
      final ActivateRuleFlowGroup acticateRuleFlowGroup = (ActivateRuleFlowGroup) fixture;
      outer.setWidget(row, 0, new SmallLabel(acticateRuleFlowGroup.getName()));
      Image del =
          new ImageButton(
              DroolsGuvnorImages.INSTANCE.itemImages().deleteItemSmall(),
              Constants.INSTANCE.RemoveThisRuleFlowActivation(),
              new ClickHandler() {
                public void onClick(ClickEvent w) {
                  retList.remove(acticateRuleFlowGroup);
                  sc.getFixtures().remove(acticateRuleFlowGroup);
                  render(retList, outer, sc);
                  parent.renderEditor();
                }
              });
      outer.setWidget(row, 1, del);

      row++;
    }
  }
Ejemplo n.º 3
0
  protected void layoutCalendar() {
    calendarGrid.clear();
    calendarGrid.setCellSpacing(0);
    for (int i = 0, row = -2, col = 0; i < simpleDatePickers.size(); i++) {
      if ((i % monthColumns) == 0) {
        col = 0;
        row += 2;
      } else if (i > 0) {
        calendarGrid.setHTML(row, col, "&nbsp;");
        calendarGrid.setHTML(row + 1, col, "&nbsp;");
        calendarGrid.getCellFormatter().addStyleName(row, col, StyleMonthSeparator);
        calendarGrid.getCellFormatter().addStyleName(row + 1, col, StyleMonthSeparator);
        col += 1;
      }

      if (monthSelectorHeader.getParent() == null || simpleDatePickers.size() > 1) {
        if (i == 0 || (i % monthColumns) == 0) {
          calendarGrid.getRowFormatter().addStyleName(row, StyleMonthLabels);
          calendarGrid.getRowFormatter().addStyleName(row + 1, StyleMonthCell);
        }
        Widget w = null;
        if (i == 0 && monthSelectorHeader.getElement().getParentElement() == null)
          w = monthSelectorHeader;
        // calendarGrid.setWidget(row, col, monthSelectorHeader);
        else w = monthHeaders.get(i);
        // calendarGrid.setWidget(row, col, monthHeaders.get(i));

        DockPanel p = null;
        if (leftButtons.iterator().hasNext() && leftButtons.getParent() == null && col == 0) {
          p = leftButtons;
          p.add(w, DockPanel.WEST);
          p.setCellWidth(w, "100%");
          w = p;
          if (simpleDatePickers.size() == 1) {
            Iterator<Widget> it = p.iterator();
            while (it.hasNext()) {
              p.add(it.next(), DockPanel.WEST);
            }
          }
        }
        if (rightButtons.iterator().hasNext()
            && rightButtons.getParent() == null
            && ((i + 1) % monthColumns) == 0) {
          p = rightButtons;
          p.add(w, DockPanel.WEST);
          p.setCellWidth(w, "100%");
          w = p;
        }
        calendarGrid.setWidget(row, col, w);
      }

      calendarGrid.setWidget(row + 1, col, simpleDatePickers.get(i));
      calendarGrid.getColumnFormatter().addStyleName(i, "Month-" + i);
      simpleDatePickers.get(i).addValueChangeHandler(onDaySelected);
      col++;
    }
  }
 /**
  * Displays a status message to the user.
  *
  * @param message The message to display.
  * @param isError Indicates whether the status is an error status.
  */
 private void showStatus(String message, boolean isError) {
   mainPanel.clear();
   mainPanel.insertRow(0);
   mainPanel.addCell(0);
   Label msg = new Label(message);
   if (isError) {
     msg.setStylePrimaryName("hm-error");
   }
   mainPanel.setWidget(0, 0, msg);
 }
 /**
  * Displays a set of Google Contacts group entries in a tabular fashion with the help of a GWT
  * FlexTable widget. The data fields Title and ID are displayed.
  *
  * @param entries The Google Contacts group entries to display.
  */
 private void showData(ContactGroupEntry[] entries) {
   mainPanel.clear();
   String[] labels = new String[] {"Title", "ID"};
   mainPanel.insertRow(0);
   for (int i = 0; i < labels.length; i++) {
     mainPanel.addCell(0);
     mainPanel.setWidget(0, i, new Label(labels[i]));
     mainPanel.getFlexCellFormatter().setStyleName(0, i, "hm-tableheader");
   }
   for (int i = 0; i < entries.length; i++) {
     ContactGroupEntry entry = entries[i];
     int row = mainPanel.insertRow(i + 1);
     mainPanel.addCell(row);
     mainPanel.setWidget(row, 0, new Label(entry.getTitle().getText()));
     mainPanel.addCell(row);
     mainPanel.setWidget(row, 1, new Label(entry.getId().getValue()));
   }
 }
Ejemplo n.º 6
0
  @Override
  public void redisplayJobIds(List<String> jobIds) {
    tab.clear();

    int row = 0;
    for (final String jobId : jobIds) {
      int col = 0;
      final int fRow = row;

      Button execButton =
          new Button(
              constants.execute(),
              new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                  fireAppJobRequested(jobId);
                }
              });

      execButton.addStyleName("execButton");

      execButton.addMouseOverHandler(
          new MouseOverHandler() {
            @Override
            public void onMouseOver(MouseOverEvent event) {
              tab.getRowFormatter().addStyleName(fRow, "hoveredOn");
            }
          });
      execButton.addMouseOutHandler(
          new MouseOutHandler() {
            @Override
            public void onMouseOut(MouseOutEvent event) {

              tab.getRowFormatter().removeStyleName(fRow, "hoveredOn");
            }
          });

      tab.setWidget(row, col++, new Label(jobId));
      tab.setWidget(row, col++, execButton);

      ++row;
    }
  }
 /**
  * Displays a set of Google Contacts contact entries in a tabular fashion with the help of a GWT
  * FlexTable widget. The data fields Title, Email and Updated are displayed.
  *
  * @param entries The Google Contacts contact entries to display.
  */
 private void showData(ContactEntry[] entries) {
   mainPanel.clear();
   String[] labels = new String[] {"Title", "Email", "Updated"};
   mainPanel.insertRow(0);
   for (int i = 0; i < labels.length; i++) {
     mainPanel.addCell(0);
     mainPanel.setWidget(0, i, new Label(labels[i]));
     mainPanel.getFlexCellFormatter().setStyleName(0, i, "hm-tableheader");
   }
   for (int i = 0; i < entries.length; i++) {
     ContactEntry entry = entries[i];
     int row = mainPanel.insertRow(i + 1);
     mainPanel.addCell(row);
     mainPanel.setWidget(row, 0, new Label(entry.getTitle().getText()));
     mainPanel.addCell(row);
     String email = "";
     if (entry.getEmailAddresses().length > 0) {
       email = entry.getEmailAddresses()[0].getAddress();
     }
     mainPanel.setWidget(row, 1, new Label(email));
     mainPanel.addCell(row);
     mainPanel.setWidget(row, 2, new Label(entry.getUpdated().getValue().getDate().toString()));
   }
 }
Ejemplo n.º 8
0
 /** Clear all menu content (discard all widgets) !! */
 public void clear() {
   menu.clear();
 }
Ejemplo n.º 9
0
  @SuppressWarnings("unchecked")
  public void populateFilesList(
      SolutionBrowserPerspective perspective, SolutionTree solutionTree, TreeItem item) {
    filesList.clear();
    ArrayList<Element> files = (ArrayList<Element>) item.getUserObject();
    // let's sort this list based on localized name
    Collections.sort(
        files,
        new Comparator<Element>() {
          public int compare(Element o1, Element o2) {
            String name1 = o1.getAttribute("localized-name"); // $NON-NLS-1$
            String name2 = o2.getAttribute("localized-name"); // $NON-NLS-1$
            return name1.compareTo(name2);
          }
        });
    if (files != null) {
      int rowCounter = 0;
      for (int i = 0; i < files.size(); i++) {
        Element fileElement = files.get(i);
        if ("false".equals(fileElement.getAttribute("isDirectory"))) { // $NON-NLS-1$ //$NON-NLS-2$
          String name = fileElement.getAttribute("name"); // $NON-NLS-1$
          String solution = solutionTree.getSolution();
          String path = solutionTree.getPath();
          String lastModifiedDateStr = fileElement.getAttribute("lastModifiedDate"); // $NON-NLS-1$
          String url = fileElement.getAttribute("url"); // $NON-NLS-1$
          ContentTypePlugin plugin = PluginOptionsHelper.getContentTypePlugin(name);
          String icon = null;
          if (plugin != null) {
            icon = plugin.getFileIcon();
          }
          String localizedName = fileElement.getAttribute("localized-name");
          String description = fileElement.getAttribute("description");
          String tooltip = localizedName;
          if (solutionTree.isUseDescriptionsForTooltip() && !StringUtils.isEmpty(description)) {
            tooltip = description;
          }
          final FileItem fileLabel =
              new FileItem(
                  name,
                  localizedName,
                  tooltip,
                  solution,
                  path, //$NON-NLS-1$
                  lastModifiedDateStr,
                  url,
                  this,
                  PluginOptionsHelper.getEnabledOptions(name),
                  toolbar.getSupportsACLs(),
                  icon);
          // BISERVER-2317: Request for more IDs for Mantle UI elements
          // set element id as the filename
          fileLabel.getElement().setId("file-" + name); // $NON-NLS-1$
          fileLabel.addFileSelectionChangedListener(toolbar);
          fileLabel.setWidth("100%"); // $NON-NLS-1$
          try {
            perspective.getDragController().makeDraggable(fileLabel);
          } catch (Exception e) {
            Throwable throwable = e;
            String text = "Uncaught exception: ";
            while (throwable != null) {
              StackTraceElement[] stackTraceElements = throwable.getStackTrace();
              text += throwable.toString() + "\n";
              for (int ii = 0; ii < stackTraceElements.length; ii++) {
                text += "    at " + stackTraceElements[ii] + "\n";
              }
              throwable = throwable.getCause();
              if (throwable != null) {
                text += "Caused by: ";
              }
            }
            DialogBox dialogBox = new DialogBox(true);
            DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF");
            System.err.print(text);
            text = text.replaceAll(" ", "&nbsp;");
            dialogBox.setHTML("<pre>" + text + "</pre>");
            dialogBox.center();
          }
          filesList.setWidget(rowCounter++, 0, fileLabel);

          if (selectedFileItem != null
              && selectedFileItem.getFullPath().equals(fileLabel.getFullPath())) {
            fileLabel.setStyleName("fileLabelSelected"); // $NON-NLS-1$
            selectedFileItem = fileLabel;
          } else {
            fileLabel.setStyleName("fileLabel"); // $NON-NLS-1$
          }
        }
      }
    }
  }
Ejemplo n.º 10
0
 public void beforeFetchSolutionDocument() {
   filesList.clear();
 }
Ejemplo n.º 11
0
 /**
  * Removes all rows. Must be when the structure of the calendar has been changed (display mode)
  */
 private void clear() {
   final FlexTable grid = (FlexTable) getWidget();
   grid.clear();
   grid.removeAllRows();
 }