@Override public Widget asWidget() { VerticalPanel content = (VerticalPanel) super.asWidget(); DefaultPager pager = new DefaultPager(); pager.setDisplay(getCellTable()); content.add(pager); return content; }
@SuppressWarnings("unchecked") public Widget asWidget() { VerticalPanel panel = new VerticalPanel(); panel.addStyleName("fill-layout-width"); setupTable(); dataProvider = new ListDataProvider<>(); dataProvider.addDataDisplay(table); panel.add(setupTableButtons()); panel.add(table); DefaultPager pager = new DefaultPager(); pager.setDisplay(table); panel.add(pager); return panel; }
Widget asWidget() { VerticalPanel layout = new VerticalPanel(); layout.setStyleName("fill-layout-width"); tools = new ToolStrip(); tools.addToolButtonRight( new ToolButton( Console.CONSTANTS.common_label_add(), new ClickHandler() { @Override public void onClick(ClickEvent event) { // onAdd singleton we need to request the specific type to be added int i = 1; List<Property> addressTuple = currentAddress.asPropertyList(); final ModelNode addressPrefix = new ModelNode(); Property denominator = null; for (Property tuple : addressTuple) { if (i == addressTuple.size()) { denominator = tuple; break; } else { addressPrefix.add(tuple.getName(), tuple.getValue()); } i++; } final String denominatorType = denominator.getName(); if (childInformation.isSingleton(denominatorType)) { Set<String> allowedSubResources = childInformation.getSingletons().get(denominatorType) != null ? new HashSet<String>( childInformation.getSingletons().get(denominatorType)) : new HashSet<String>(); // filter existing resources for (ModelNode existing : dataProvider.getList()) { allowedSubResources.remove(existing.asString()); } if (allowedSubResources.size() > 0) { SingletonDialog dialog = new SingletonDialog( allowedSubResources, new SimpleCallback<String>() { @Override public void onSuccess(String result) { addressPrefix.add(denominatorType, result); presenter.onPrepareAddChildResource(addressPrefix, true); } }); dialog.setWidth(320); dialog.setHeight(240); dialog.center(); } else { Feedback.alert( Console.CONSTANTS.availableChildrenTypes(), Console.CONSTANTS.allSingletonsAlreadyAdded()); } } else { presenter.onPrepareAddChildResource(currentAddress, false); } } })); final ToolButton remove = new ToolButton( Console.CONSTANTS.common_label_delete(), new ClickHandler() { @Override public void onClick(ClickEvent event) { ModelNode selection = selectionModel.getSelectedObject(); if (selection != null) presenter.onRemoveChildResource(currentAddress, selection); } }); tools.addToolButtonRight(remove); remove.setEnabled(false); table = new ModelNodeCellTable(12); table.addColumn( new ModelNodeColumn( new ModelNodeColumn.ValueAdapter() { @Override public String getValue(ModelNode model) { return URL.decodePathSegment(model.asString()); } }), "Child Resource"); Column<ModelNode, ModelNode> option = new Column<ModelNode, ModelNode>( new ViewLinkCell<ModelNode>( Console.CONSTANTS.common_label_view(), new ActionCell.Delegate<ModelNode>() { @Override public void execute(ModelNode selection) { presenter.onViewChild(currentAddress, selection.asString()); } })) { @Override public ModelNode getValue(ModelNode model) { return model; } }; table.addColumn(option, "Option"); dataProvider = new ListDataProvider<ModelNode>(); dataProvider.addDataDisplay(table); selectionModel = new SingleSelectionModel<ModelNode>(); table.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler( new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { ModelNode selection = selectionModel.getSelectedObject(); remove.setEnabled(selection != null); } }); DefaultPager pager = new DefaultPager(); pager.setDisplay(table); // ----- header = new HTML(); layout.add(header); layout.add(tools); layout.add(table); layout.add(pager); return layout; }
@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; }
@SuppressWarnings("unchecked") public Widget asWidget() { ProvidesKey<ModelNode> providesKey = node -> node.get("operation-date").asString(); table = new DefaultCellTable<>(20, providesKey); dataProvider = new ListDataProvider<>(providesKey); dataProvider.addDataDisplay(table); // the date / time column table.addColumn( new TextColumn<ModelNode>() { @Override public String getValue(ModelNode item) { // the operation-date is 2016-07-08T22:39:50.783Z // there is some format to facilitate user experience // by replacing the T with a blank space String opTimestamp = item.get("operation-date").asString(); opTimestamp = opTimestamp.replaceFirst("T", " "); return opTimestamp; } }, "Date and time"); // access-mechanism column TextColumn<ModelNode> accessMechanismColumn = createColumn("access-mechanism"); accessMechanismColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); table.addColumn(accessMechanismColumn, "Access Mechanism"); // remote address column TextColumn<ModelNode> remoteAddressColumn = new TextColumn<ModelNode>() { @Override public String getValue(ModelNode item) { // the remote address is 10.10.10.10/10.10.10.10 // to facilitate user experience we cut at at first slash String clientAddress = item.get("remote-address").asString(); clientAddress = clientAddress.substring(0, clientAddress.indexOf("/")); return clientAddress; } }; remoteAddressColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); table.addColumn(remoteAddressColumn, "Remote address"); // the resource address TextColumn<ModelNode> resourceColumn = new TextColumn<ModelNode>() { @Override public String getValue(ModelNode item) { return StringUtils.shortenStringIfNecessary(extractResourceAddress(item), 63); } }; table.addColumn(resourceColumn, "Resource address"); table.setColumnWidth(resourceColumn, 50, Style.Unit.PCT); // operation column table.addColumn( new TextColumn<ModelNode>() { @Override public String getValue(ModelNode item) { return item.get(OPERATIONS).get(0).get(OP).asString(); } }, "Operation"); // result column table.addColumn(createColumn(OUTCOME), "Result"); table.setTableLayoutFixed(false); // the details panel selectionModel = new SingleSelectionModel<>(providesKey); selectionModel.addSelectionChangeHandler( event -> { ModelNode changeDetails = selectionModel.getSelectedObject(); if (changeDetails != null) { detailsConfigurationChange.setValue(changeDetails.toString()); } }); table.setSelectionModel(selectionModel); detailsConfigurationChange = new TextAreaItem("details", "Details 1", 20); detailsConfigurationChange.setEnabled(false); HorizontalPanel header = new HorizontalPanel(); header.addStyleName("fill-layout-width"); header.add(new HTML("<h3 class='metric-label-embedded'>Configuration change details</h3>")); VerticalPanel detailsPanel = new VerticalPanel(); detailsPanel.addStyleName("metric-container"); detailsPanel.add(header); detailsPanel.add(detailsConfigurationChange.asWidget()); // ====================== DefaultPager pager = new DefaultPager(); pager.setDisplay(table); VerticalPanel tableAndPager = new VerticalPanel(); tableAndPager.setStyleName("fill-layout-width"); tableAndPager.add(table); tableAndPager.add(pager); SimpleLayout layout = new SimpleLayout() .setPlain(true) .setHeadline("Configuration Changes") .setDescription( SafeHtmlUtils.fromString(Console.MESSAGES.configuration_changes_description())) .addContent("", toolstripButtons()) .addContent("", tableAndPager) .addContent("", detailsPanel); return layout.build(); }
@SuppressWarnings("unchecked") public Widget asWidget() { VerticalPanel panel = new VerticalPanel(); panel.addStyleName("fill-popupLayout-width"); // table table = new DefaultCellTable<>(5); dataProvider = new ListDataProvider<>(); dataProvider.addDataDisplay(table); table.setSelectionModel(selectionModel); // columns Column<ModelNode, String> matchRuleColumn = new TextColumn<ModelNode>() { @Override public String getValue(ModelNode node) { // as the match-rules attribute is a list of attributes // none of them is required, so there is not a unique colum to show, so all defined // attributes are // displayed, there is a "view" button that shows all attributes nicely formatted in a // ModelNodeForm StringBuilder content = new StringBuilder(); for (Property prop : node.asPropertyList()) { content .append(prop.getName()) .append(": ") .append(prop.getValue().asString()) .append(", "); } return StringUtils.shortenStringIfNecessary(content.toString(), 120); } }; Column<ModelNode, ModelNode> linkOpenDetailsColumn = new Column<ModelNode, ModelNode>( new ViewLinkCell<>( Console.CONSTANTS.common_label_view(), (ActionCell.Delegate<ModelNode>) selection -> showDetailModal(selection))) { @Override public ModelNode getValue(ModelNode node) { return node; } }; linkOpenDetailsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); table.addColumn(matchRuleColumn, ""); table.addColumn(linkOpenDetailsColumn, "Option"); table.setColumnWidth(linkOpenDetailsColumn, 8, Style.Unit.PCT); panel.add(mainTableTools()); panel.add(table); DefaultPager pager = new DefaultPager(); pager.setDisplay(table); panel.add(pager); // ===================== match-rule form popup popupLayout.setStyleName("window-content"); // read-only form to show details of match-rules attribute ModelNodeFormBuilder.FormAssets detailForm = new ModelNodeFormBuilder() .setResourceDescription(resourceDescription) .setCreateMode(false) .unsorted() .setCreateNameAttribute(false) .setSecurityContext(securityContext) .build(); matchRulesForm = detailForm.getForm(); popupDialogOptions.showCancel(false); Widget formWidget = detailForm.getForm().asWidget(); popupLayout.add(formWidget); return panel; }
public Widget asWidget() { if (null == cellTable.getSelectionModel()) cellTable.setSelectionModel(new SingleSelectionModel<T>()); cellTable .getSelectionModel() .addSelectionChangeHandler( new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent selectionChangeEvent) { T selection = ((SingleSelectionModel<T>) cellTable.getSelectionModel()).getSelectedObject(); String displayValue = renderer.render(selection); currentDisplayedValue.setText(displayValue); } }); final String panelId = "popup_" + HTMLPanel.createUniqueId(); popup = new PopupPanel(true, true) { @Override protected void onPreviewNativeEvent(Event.NativePreviewEvent event) { if (Event.ONKEYUP == event.getTypeInt()) { if (event.getNativeEvent().getKeyCode() == ESCAPE) { // Dismiss when escape is pressed popup.hide(); } } } public void onBrowserEvent(Event event) { super.onBrowserEvent(event); } }; popup.getElement().setId(panelId); popup.setStyleName("default-popup"); /*popup.addCloseHandler(new CloseHandler<PopupPanel>() { public void onClose(CloseEvent<PopupPanel> event) { } });*/ VerticalPanel layout = new VerticalPanel(); layout.setStyleName("fill-layout-width"); layout.addStyleName("tablepicker-popup"); if (description != null) layout.add(new Label(description)); layout.add(cellTable); DefaultPager pager = new DefaultPager(); pager.setDisplay(cellTable); layout.add(pager); popup.setWidget(layout); currentDisplayedValue = new HTML(" "); currentDisplayedValue.setStyleName("table-picker-value"); header = new HorizontalPanel(); header.setStyleName("table-picker"); header.add(currentDisplayedValue); Image img = new Image(ConsoleIcons.INSTANCE.tablePicker()); header.add(img); currentDisplayedValue.getElement().getParentElement().setAttribute("width", "100%"); img.getParent().getElement().setAttribute("width", "18"); header.getElement().setAttribute("width", "100%"); header.getElement().setAttribute("cellspacing", "0"); header.getElement().setAttribute("cellpadding", "0"); header.getElement().setAttribute("border", "0"); ClickHandler clickHandler = new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { openPanel(); } }; currentDisplayedValue.addClickHandler(clickHandler); img.addClickHandler(clickHandler); return header; }