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; }
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; }