Ejemplo n.º 1
0
  private TableEmployee showOrganizationLabelsAndButtons(Long id) {
    panel.removeAllComponents();
    panel.addComponent(new ButtonCreateOrganization(treetable));
    treetable.setCollapsed(id, false);
    Organization org = AdminServiceProvider.get().findOrganizationById(id);
    Label nameLabel = new Label("Название: " + org.getName());
    nameLabel.setStyleName("h2");
    panel.addComponent(nameLabel);
    if (org.getCreator() != null) {
      Label creatorLabel = new Label("Создатель: " + org.getCreator().getLogin());
      panel.addComponent(creatorLabel);
    }

    Format formatter = new SimpleDateFormat("dd.MM.yyyy hh:mm");
    Label dateLabel = new Label("Дата создания: " + formatter.format(org.getDate()));
    panel.addComponent(dateLabel);
    panel.addComponent(groupLabel(id));
    HorizontalLayout layoutButton = new HorizontalLayout();
    layoutButton.addComponent(buttonEditOrganization(org, nameLabel));
    layoutButton.addComponent(buttonCreateOrganization(org));
    TableEmployee tableEmployee = new TableOrganizationEmployee(id);
    tableEmployee.setMargin(true, false, false, false);
    layoutButton.addComponent(buttonCreateEmployee(id));
    layoutButton.setMargin(true, false, false, false);
    layoutButton.addComponent(createGroupLabel(id));
    panel.addComponent(layoutButton);
    return tableEmployee;
  }
Ejemplo n.º 2
0
  public static void fillTable(TreeTable treetable) {
    Set<Organization> rootOrganizations = AdminServiceProvider.get().getRootOrganizations();
    for (Organization org : rootOrganizations) {
      treetable.addItem(new Object[] {org.getName()}, org.getId());
    }

    for (Organization org : rootOrganizations) {
      treetable.setChildrenAllowed(org.getId(), !(org.getOrganizations().isEmpty()));
    }
  }
Ejemplo n.º 3
0
  // TODO: учеть версионность!
  void createGroupEditor(final long id, final Set<String> names) {
    final Organization org = AdminServiceProvider.get().findOrganizationById(id);
    final Set<String> all = AdminServiceProvider.get().getOrgGroupNames();

    final VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);

    final TwinColSelect twin = new TwinColSelect();
    twin.setSizeFull();
    twin.setNullSelectionAllowed(true);
    twin.setLeftColumnCaption("Доступные");
    twin.setRightColumnCaption("Отобранные для " + org.getName());
    twin.setImmediate(true);
    for (final String name : all) {
      twin.addItem(name);
      if (names.contains(name)) {
        twin.select(name);
      }
    }
    layout.addComponent(twin);

    final HorizontalLayout h = new HorizontalLayout();
    h.setSpacing(true);
    Button cancel =
        new Button(
            "Отменить",
            new Button.ClickListener() {

              private static final long serialVersionUID = -2885182304929510066L;

              @Override
              public void buttonClick(Button.ClickEvent event) {
                showOrganization(id);
              }
            });
    cancel.setClickShortcut(KeyCode.ESCAPE, 0);

    Button ok =
        new Button(
            "Применить",
            new Button.ClickListener() {

              private static final long serialVersionUID = -3182280627040233669L;

              @Override
              public void buttonClick(Button.ClickEvent event) {
                AdminServiceProvider.get()
                    .setOrgGroupNames(
                        id, new TreeSet<String>((Collection<String>) twin.getValue()));
                showOrganization(id);
              }
            });
    ok.setClickShortcut(KeyCode.O, ModifierKey.CTRL);

    h.addComponent(ok);
    h.addComponent(cancel);

    layout.addComponent(h);
    layout.setSizeFull();
    panel.removeAllComponents();
    panel.addComponent(layout);
    twin.focus();
  }