@Override public Widget createWidget() { LayoutPanel layout = new LayoutPanel(); FakeTabPanel titleBar = new FakeTabPanel("Socket Binding Groups"); layout.add(titleBar); ToolStrip toolstrip = new ToolStrip(); toolstrip.addToolButtonRight( new ToolButton( "Add", new ClickHandler() { @Override public void onClick(ClickEvent event) { presenter.launchNewSocketDialogue(); } })); layout.add(toolstrip); // ----------- VerticalPanel panel = new VerticalPanel(); panel.setStyleName("rhs-content-panel"); ContentHeaderLabel nameLabel = new ContentHeaderLabel("Socket Binding Declarations"); HorizontalPanel horzPanel = new HorizontalPanel(); horzPanel.getElement().setAttribute("style", "width:100%;"); // Image image = new Image(Icons.INSTANCE.deployment()); // horzPanel.add(image); // image.getElement().getParentElement().setAttribute("width", "25"); horzPanel.add(nameLabel); panel.add(horzPanel); socketTable = new SocketTable(); HorizontalPanel tableOptions = new HorizontalPanel(); tableOptions.getElement().setAttribute("cellpadding", "2px"); groupFilter = new ComboBox(); groupFilter.addValueChangeHandler( new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { presenter.onFilterGroup(event.getValue()); } }); Widget groupFilterWidget = groupFilter.asWidget(); groupFilterWidget.getElement().setAttribute("style", "width:200px;"); tableOptions.add(new Label("Socket Binding Group:")); tableOptions.add(groupFilterWidget); tableOptions.getElement().setAttribute("style", "float:right;"); panel.add(tableOptions); DefaultCellTable socketTableWidget = socketTable.asWidget(); panel.add(socketTableWidget); DefaultPager pager = new DefaultPager(); pager.setPage(0); pager.setPageSize(6); pager.setDisplay(socketTableWidget); panel.add(pager); ScrollPanel scroll = new ScrollPanel(panel); layout.add(scroll); layout.setWidgetTopHeight(titleBar, 0, Style.Unit.PX, 26, Style.Unit.PX); layout.setWidgetTopHeight(toolstrip, 26, Style.Unit.PX, 30, Style.Unit.PX); layout.setWidgetTopHeight(scroll, 56, Style.Unit.PX, 100, Style.Unit.PCT); // ----------- ToolStrip detailToolStrip = new ToolStrip(); editBtn = new ToolButton(Console.CONSTANTS.common_label_edit()); ClickHandler editHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { SocketBinding editedEntity = form.getEditedEntity(); if (editBtn.getText().equals(Console.CONSTANTS.common_label_edit())) { presenter.editSocketBinding(editedEntity); } else { presenter.saveSocketBinding( editedEntity.getName(), editedEntity.getGroup(), form.getChangedValues()); } } }; editBtn.addClickHandler(editHandler); detailToolStrip.addToolButton(editBtn); ClickHandler clickHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { SocketBinding socket = form.getEditedEntity(); Feedback.confirm( "Delete Socket Binding", "Really delete this socket binding '" + socket.getName() + "' ?", new Feedback.ConfirmationHandler() { @Override public void onConfirmation(boolean isConfirmed) { if (isConfirmed) { presenter.onDelete(form.getEditedEntity()); } } }); } }; ToolButton deleteBtn = new ToolButton(Console.CONSTANTS.common_label_delete()); deleteBtn.addClickHandler(clickHandler); detailToolStrip.addToolButton(deleteBtn); panel.add(new ContentGroupLabel("Socket Binding")); panel.add(detailToolStrip); // --- form = new Form<SocketBinding>(SocketBinding.class); form.setNumColumns(2); TextItem nameItem = new TextItem("name", "Name"); TextItem interfaceItem = new TextItem("interface", "Interface"); NumberBoxItem portItem = new NumberBoxItem("port", "Port"); TextBoxItem multicastItem = new TextBoxItem("multiCastAddress", "Multicast Address"); NumberBoxItem multicastPortItem = new NumberBoxItem("multiCastPort", "Multicast Port"); form.setFields(nameItem, interfaceItem, portItem, multicastItem, multicastPortItem); form.bind(socketTable.getCellTable()); Widget formWidget = form.asWidget(); form.setEnabled(false); final FormHelpPanel helpPanel = new FormHelpPanel( new FormHelpPanel.AddressCallback() { @Override public ModelNode getAddress() { ModelNode address = new ModelNode(); address.add("socket-binding-group", form.getEditedEntity().getGroup()); address.add("socket-binding", "*"); return address; } }, form); panel.add(helpPanel.asWidget()); panel.add(formWidget); // ------------------------------------------ return layout; }
@Override public void setBindings(String groupName, List<SocketBinding> bindings) { socketTable.updateFrom(groupName, bindings); }