コード例 #1
0
 public void updateChanges(List<ModelNode> _changes) {
   dataProvider.setList(_changes);
   table.selectDefaultEntity();
   this.changes.clear();
   this.changes.addAll(_changes);
   detailsConfigurationChange.clearValue();
 }
コード例 #2
0
 public void setEnabled(final boolean enabled) {
   if (enabled) {
     enableBtn.setVisible(false);
     disableBtn.setVisible(true);
     refreshBtn.setEnabled(true);
   } else {
     enableBtn.setVisible(true);
     disableBtn.setVisible(false);
     refreshBtn.setEnabled(false);
     dataProvider.setList(Collections.emptyList());
   }
   detailsConfigurationChange.clearValue();
 }
コード例 #3
0
  @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();
  }