Exemplo n.º 1
0
  public void onClose() {
    String errorMessage = null;

    if (currentNode.getLevel() < TaxonLevel.SPECIES) {
      if (parentToChildList.size() < 1) {
        errorMessage =
            "You must create at least one new taxon to split "
                + currentNode.getFullName()
                + " into.";
      }
    } else {
      if (parentToChildList.size() < 2) {
        errorMessage =
            "You must create at least two new taxon to split "
                + currentNode.getFullName()
                + " into.";
      } else if (children.getItems().size() != 0) {
        errorMessage = "You must remove all children from " + currentNode.getFullName() + ".";
      }
    }

    if (errorMessage == null) {
      TaxomaticUtils.impl.performSplit(
          currentNode,
          parentToChildList,
          new GenericCallback<String>() {
            public void onFailure(Throwable arg0) {
              // Error message already displayed by default callback.
            }

            public void onSuccess(String arg0) {
              hide();
              if (currentNode.getLevel() < TaxonLevel.SPECIES) {
                WindowUtils.confirmAlert(
                    "Saved",
                    "The split was successful.  However, the status of "
                        + currentNode.getFullName()
                        + " was not modified.  Would you like to edit the status of "
                        + currentNode.getFullName()
                        + "?",
                    new WindowUtils.SimpleMessageBoxListener() {
                      @Override
                      public void onYes() {
                        TaxonBasicEditor editor = new TaxonBasicEditor();
                        editor.show();
                        editor.center();
                      }
                    },
                    "Yes, edit",
                    "No, all finished");
              } else {
                WindowUtils.infoAlert("Saved", "Changes saved.");
              }
            }
          });
    } else {
      WindowUtils.errorAlert("Error", errorMessage);
    }
  }
Exemplo n.º 2
0
  /** This widget can be used to display the actions that are considered relevant */
  public WidgetSpecialActions() {
    Listener<ComponentEvent> l =
        new Listener<ComponentEvent>() {
          public void handleEvent(ComponentEvent ce) {
            DataList l = (DataList) ce.component;
            ServiceVisualizerManager.displayService(l.getSelectedItem().getId());
          }
        };
    ContentPanel frame = new ContentPanel();
    frame.setFrame(true);
    frame.setCollapsible(true);
    frame.setAnimCollapse(false);
    frame.setHeading("Interesting actions");

    final DataList list = new DataList();
    list.setFlatStyle(true);

    list.addListener(Events.SelectionChange, l);

    DataListItem item = new DataListItem();
    item.setText("Get Twitter followers");
    item.setId("http://soa4all.eu/twitter/getFollowers");
    list.add(item);

    item = new DataListItem();
    item.setText("Watson Search");
    item.setId("http://soa4all.eu/watson/search");
    list.add(item);

    item = new DataListItem();
    item.setText("BT Scenario 1");
    item.setStyleAttribute("color", "#00FF00");
    item.setId("http://soa4all.eu/composed/BTscenario1");
    list.add(item);

    item = new DataListItem();
    item.setText("Get Twitter Follower (Semantic)");
    item.setId("http://soa4all.eu/twitter/getFollowersSemantic");
    list.add(item);

    item = new DataListItem();
    item.setText("Profile Details (Fake Service)");
    item.setId("http://soa4all.eu/twitter/getProfileDetails");
    list.add(item);

    frame.setLayout(new FitLayout());
    frame.add(list);

    initWidget(frame);
  }
Exemplo n.º 3
0
  public LayoutContainer getRightSide() {
    BorderLayout layout = new BorderLayout();

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

    container.add(getButtonBar(), new BorderLayoutData(LayoutRegion.SOUTH, .1F));

    selected = new DataList();
    selected.setContextMenu(getListMenu());

    LayoutContainer right = new LayoutContainer();
    right.setLayout(new FillLayout());
    right.add(selected);

    container.add(selected, new BorderLayoutData(LayoutRegion.CENTER, .8F));
    container.setHeight(PANEL_HEIGHT - 20);
    return container;
  }
Exemplo n.º 4
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;
  }
Exemplo n.º 5
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;
  }
Exemplo n.º 6
0
 public int getNumberInList() {
   return selected.getItemCount();
 }
Exemplo n.º 7
0
 public void addItem(String[] footPrint, TaxonNode node) {
   if (validate(footPrint, node)) {
     DataListItem li = new DataListItem(node.getFullName());
     selected.add(li);
   }
 }