Пример #1
0
  public void load() {

    BorderLayout layout = new BorderLayout();
    // layout.setMargin(2);

    LayoutContainer full = new LayoutContainer();
    full.setLayout(layout);
    full.setLayoutOnChange(true);

    full.add(getInstructions(), new BorderLayoutData(LayoutRegion.NORTH, HEADER_HEIGHT));
    full.add(getLeftSide(), new BorderLayoutData(LayoutRegion.WEST, PANEL_WIDTH / 2 - 5));
    full.add(getRightSide(), new BorderLayoutData(LayoutRegion.CENTER, PANEL_WIDTH / 2 - 5));
    // full.setSize(PANEL_WIDTH + 10, PANEL_HEIGHT + 5);
    add(full);
  }
Пример #2
0
  private LayoutContainer getLeftSide() {
    // BorderLayout layout = new BorderLayout();
    RowLayout layout = new RowLayout(Orientation.VERTICAL);
    // layout.setMargin(0);
    // layout.setSpacing(0);

    LayoutContainer container = new LayoutContainer();
    container.setLayout(layout);
    container.setLayoutOnChange(true);
    container.setSize(PANEL_WIDTH / 2, PANEL_HEIGHT);

    children = new DataList();
    children.setSelectionMode(SelectionMode.MULTI);

    TaxonomyCache.impl.getTaxonChildren(
        currentNode.getId() + "",
        new GenericCallback<List<Taxon>>() {
          public void onFailure(Throwable caught) {
            WindowUtils.errorAlert("Error", "Could not fetch children, please try again later.");
          }

          public void onSuccess(List<Taxon> result) {
            for (Taxon taxon : result) {
              DataListItem li = new DataListItem(taxon.getFullName());
              li.setData("nodeID", "" + taxon.getId());
              li.setData("node", taxon);
              children.add(li);
            }
          }
        });

    container.add(
        new HTML("Children currently in " + currentNode.getFullName() + ":"), new RowData(1d, 25));
    container.add(children, new RowData(1d, 1d));

    return container;
  }
Пример #3
0
  public void load() {

    currentNode = TaxonomyCache.impl.getCurrentNode();

    BorderLayout layout = new BorderLayout();
    // layout.setMargin(5);
    // layout.setSpacing(5);

    LayoutContainer full = new LayoutContainer();
    full.setLayout(layout);
    full.setLayoutOnChange(true);

    TaxonomyBrowserPanel tp = getTaxonomyBrowserPanel();

    if (currentNode != null) {
      tp.update(currentNode.getId() + "");
    } else {
      tp.update();
    }

    int size = PANEL_WIDTH / 2;

    LayoutContainer left = new LayoutContainer();
    left.setLayout(new FillLayout());
    left.setSize(size, PANEL_HEIGHT);
    left.add(tp);

    full.add(
        new HTML("<b> Instructions:</b> " + getDescription()),
        new BorderLayoutData(LayoutRegion.NORTH, HEADER_HEIGHT));
    full.add(left, new BorderLayoutData(LayoutRegion.WEST, size));
    full.add(getRightSide(), new BorderLayoutData(LayoutRegion.CENTER, size));

    full.setSize(PANEL_WIDTH, PANEL_HEIGHT);

    add(full);
  }
Пример #4
0
  public LayoutContainer getRightSide() {
    RowLayout layout = new RowLayout();
    // layout.setMargin(0);
    // layout.setSpacing(0);

    ButtonBar south = new ButtonBar();
    south.setAlignment(HorizontalAlignment.RIGHT);
    final Button complete =
        new Button(
            "Complete Split",
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent ce) {
                onClose();
              }
            });
    south.add(complete);
    complete.setEnabled(false);

    LayoutContainer container = new LayoutContainer();
    container.setLayout(layout);
    container.setLayoutOnChange(true);

    final DataList moveList = new DataList();
    final ListBox listBox = new ListBox();
    listBox.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            moveList.removeAll();
            ArrayList<String> list =
                parentToChildList.get(listBox.getValue(listBox.getSelectedIndex()));
            if (list == null) return;
            Iterator<String> iterator = list.listIterator();
            while (iterator.hasNext()) {
              // FIXME: look at this, i just fix this and dont know if it's right. CS
              String nodeID = iterator.next();
              Taxon cur = TaxonomyCache.impl.getTaxon(nodeID);
              DataListItem li = new DataListItem(cur.getFullName());
              li.setData("nodeID", nodeID);
              li.setData("node", cur);
              moveList.add(li);
            }
            layout();
          }
        });

    Menu m = new Menu();
    MenuItem item = new MenuItem();
    item.setText("Remove");
    item.addSelectionListener(
        new SelectionListener<MenuEvent>() {
          @Override
          public void componentSelected(MenuEvent ce) {
            DataListItem item = (DataListItem) ce.getSource();
            ArrayList<String> list =
                parentToChildList.get(listBox.getValue(listBox.getSelectedIndex()));
            if (list != null) list.remove(item.getData("nodeID"));

            moveList.remove(item);
            children.add(item);
            layout();
          }
        });
    m.add(item);
    moveList.setContextMenu(m);

    VerticalPanel table = new VerticalPanel();
    table.add(new HTML("Current Taxonomic Group: "));
    table.add(listBox);
    listBox.setWidth("100%");
    listBox.setEnabled(false);

    final ButtonBar bar = new ButtonBar();
    bar.setAlignment(HorizontalAlignment.RIGHT);
    final Button addChild =
        new Button(
            "Add Child",
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent ce) {
                List<DataListItem> sel = children.getSelectedItems();
                if (sel == null) return;
                ArrayList<String> list =
                    parentToChildList.get(listBox.getValue(listBox.getSelectedIndex()));
                for (DataListItem selected : sel) {
                  children.remove(selected);
                  String nodeID = selected.getData("nodeID");
                  if (!list.contains(nodeID)) {
                    list.add(nodeID);
                    DataListItem item = new DataListItem(selected.getText());
                    item.setData("nodeID", nodeID);
                    item.setData("node", selected.getData("node"));
                    moveList.add(item);
                  }
                }
                layout();
              }
            });
    addChild.setEnabled(false);
    bar.add(addChild);
    bar.add(
        new Button(
            "Create New Taxon",
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent ce) {
                TaxonomyCache.impl.fetchTaxon(
                    currentNode.getParentId(),
                    false,
                    new GenericCallback<Taxon>() {
                      public void onFailure(Throwable caught) {
                        WindowUtils.errorAlert(
                            "Error",
                            "Could not " + "find parent level to attach new taxonomic concept to.");
                      }

                      public void onSuccess(Taxon result) {
                        complete.setEnabled(true);

                        final CreateNewTaxonPanel panel = new CreateNewTaxonPanel(result);
                        panel.addListener(
                            Events.StateChange,
                            new Listener<BaseEvent>() {
                              public void handleEvent(BaseEvent be) {
                                Taxon newNode = (Taxon) be.getSource();
                                parentToChildList.put(
                                    newNode.getId() + "", new ArrayList<String>());
                                listBox.addItem(newNode.getFullName(), newNode.getId() + "");
                                listBox.setSelectedIndex(listBox.getItemCount() - 1);
                                listBox.setEnabled(true);
                                moveList.removeAll();
                                addChild.setEnabled(true);
                              }
                            });
                        panel.show();
                      }
                    });
              }
            }));

    container.add(table, new RowData(1d, 25));
    container.add(bar, new RowData(1d, 25));
    container.add(new HTML("Children to add to new taxon:"), new RowData(1d, 25));
    container.add(moveList, new RowData(1d, 1d));
    container.add(south, new RowData(1d, 25));

    return container;
  }
Пример #5
0
  @Override
  protected void onRender(Element target, int index) {
    super.onRender(target, index);

    layout.setPadding(new Padding(2, 17, 1, 10)); // DIM
    layout.setHBoxLayoutAlign(HBoxLayout.HBoxLayoutAlign.MIDDLE);
    c.setLayout(layout);
    c.setLayoutOnChange(true);
    c.setAutoHeight(false);
    c.setAutoWidth(false);

    left.setIcon(AbstractImagePrototype.create(AzzeroCO2Resources.INSTANCE.left()));
    left.setIconAlign(Style.IconAlign.LEFT);
    left.setSize(32, 32);
    left.setText("");
    left.setToolTip("");
    left.setTitle("");
    left.setEnabled(false);
    left.setVisible(false);

    left.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            Dispatcher.forwardEvent(new AppEvent(UnAnnoDiAttivitaEvents.Previous, ce));
          }
        });
    c.add(left, new HBoxLayoutData(new Margins(0, 0, 0, 0)));

    flex.setFlex(1);
    c.add(leftText, flex);

    leftText.setSize(200, 15);
    rigthText.setSize(250, 15);
    rigthText.setStyleAttribute("text-align", "right");
    rigthText.setStyleAttribute("font-family", "arial");
    leftText.setStyleAttribute("font-family", "arial");
    leftText.setStyleAttribute("font-size", "14px");
    rigthText.setStyleAttribute("font-size", "14px");

    c.add(rigthText, new HBoxLayoutData(new Margins(0, 5, 0, 0)));

    right.setIconAlign(Style.IconAlign.RIGHT);
    //  right.setText("Energia");
    right.setIcon(AbstractImagePrototype.create(AzzeroCO2Resources.INSTANCE.rigth()));
    right.setSize(32, 32);
    right.setTitle("");
    right.setText("");
    right.setToolTip("");

    c.add(right, new HBoxLayoutData(new Margins(0, 0, 0, 0)));
    right.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            if (rigthText.getText().equalsIgnoreCase("torna alla home")) {
              Dispatcher.forwardEvent(CentralEvents.ShowPanel, Eventi.MAIN);
            } else {
              Dispatcher.forwardEvent(new AppEvent(UnAnnoDiAttivitaEvents.Next, ce));
            }
          }
        });
    add(c);
  }