Example #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;
  }
Example #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()));
    }
  }
Example #3
0
 private Component groupLabel(Long id) {
   final Set<String> names = AdminServiceProvider.get().getOrgGroupNames(id);
   final HorizontalLayout layout = new HorizontalLayout();
   String s = "Группы: ";
   if (!names.isEmpty()) {
     s += Joiner.on(", ").join(names);
   } else {
     s += "не состоит ни в одной";
   }
   layout.addComponent(new Label(s));
   return layout;
 }
Example #4
0
  Component createGroupLabel(final long id) {
    final Set<String> names = AdminServiceProvider.get().getOrgGroupNames(id);
    final Button button =
        new Button(
            names.isEmpty() ? "Добавить группы" : "Изменить группы",
            new Button.ClickListener() {
              private static final long serialVersionUID = 6657371896778851327L;

              @Override
              public void buttonClick(Button.ClickEvent event) {
                createGroupEditor(id, names);
              }
            });
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);
    layout.setMargin(false, true, false, false);
    layout.addComponent(button);
    return layout;
  }
Example #5
0
 @Override
 public List<Item> loadItems(final int start, final int count) {
   final List<InfoSystemService> systems =
       AdminServiceProvider.get().queryInfoSystemServices(ids, asc, start, count);
   final List<Item> items = Lists.newArrayListWithExpectedSize(systems.size());
   for (final InfoSystemService s : systems) {
     final PropertysetItem item = new PropertysetItem();
     InfoSystem infoSystem = s.getInfoSystem();
     item.addItemProperty("id", new ObjectProperty<String>(s.getId().toString()));
     item.addItemProperty(
         "infosys", new ObjectProperty<String>(infoSystem == null ? "" : infoSystem.getCode()));
     item.addItemProperty("address", new ObjectProperty<String>(s.getAddress()));
     item.addItemProperty("revision", new ObjectProperty<String>(s.getRevision()));
     item.addItemProperty("sname", new ObjectProperty<String>(s.getSname()));
     item.addItemProperty("sversion", new ObjectProperty<String>(s.getSversion()));
     item.addItemProperty("name", new ObjectProperty<String>(s.getName()));
     item.addItemProperty("available", new ObjectProperty<Boolean>(s.isAvailable()));
     items.add(item);
   }
   return items;
 }
Example #6
0
 @Override
 public int size() {
   return AdminServiceProvider.get().countInfoSystemServices();
 }
Example #7
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();
  }