void initTable() {
    getTable().enableColumnResizing();

    TextColumnWithTooltip<VM> nameColumn =
        new TextColumnWithTooltip<VM>() {
          @Override
          public String getValue(VM object) {
            return object.getName();
          }
        };
    nameColumn.makeSortable();
    getTable().addColumn(nameColumn, constants.nameVm(), "300px"); // $NON-NLS-1$
  }
Esempio n. 2
0
  void initTable(final ApplicationConstants constants) {
    getTable().enableColumnResizing();

    ImageResourceColumn<VM> pluggedColumn =
        new ImageResourceColumn<VM>() {
          @Override
          public ImageResource getValue(VM object) {
            boolean isDiskPlugged = getDetailModel().isDiskPluggedToVm(object);
            setTitle(isDiskPlugged ? constants.active() : constants.inactive());
            return isDiskPlugged
                ? getCommonResources().upImage()
                : getCommonResources().downImage();
          }
        };
    getTable().addColumn(pluggedColumn, constants.empty(), "30px"); // $NON-NLS-1$

    TextColumnWithTooltip<VM> nameColumn =
        new TextColumnWithTooltip<VM>() {
          @Override
          public String getValue(VM object) {
            return object.getName();
          }
        };
    nameColumn.makeSortable();
    getTable().addColumn(nameColumn, constants.nameVm(), "140px"); // $NON-NLS-1$

    getTable().addColumn(new VmTypeColumn(), constants.empty(), "30px"); // $NON-NLS-1$

    TextColumnWithTooltip<VM> clusterColumn =
        new TextColumnWithTooltip<VM>() {
          @Override
          public String getValue(VM object) {
            return object.getVdsGroupName();
          }
        };
    clusterColumn.makeSortable();
    getTable().addColumn(clusterColumn, constants.clusterVm(), "140px"); // $NON-NLS-1$

    TextColumnWithTooltip<VM> ipColumn =
        new TextColumnWithTooltip<VM>() {
          @Override
          public String getValue(VM object) {
            return object.getVmIp();
          }
        };
    ipColumn.makeSortable();
    getTable().addColumn(ipColumn, constants.ipVm(), "140px"); // $NON-NLS-1$

    TextColumnWithTooltip<VM> fqdnColumn =
        new TextColumnWithTooltip<VM>() {
          @Override
          public String getValue(VM object) {
            return object.getVmFQDN();
          }
        };
    fqdnColumn.makeSortable();
    getTable().addColumn(fqdnColumn, constants.fqdn(), "140px"); // $NON-NLS-1$

    PercentColumn<VM> memColumn =
        new PercentColumn<VM>() {
          @Override
          public Integer getProgressValue(VM object) {
            return object.getUsageMemPercent();
          }
        };
    getTable().addColumn(memColumn, constants.memoryVm(), "140px"); // $NON-NLS-1$

    PercentColumn<VM> cpuColumn =
        new PercentColumn<VM>() {
          @Override
          public Integer getProgressValue(VM object) {
            return object.getUsageCpuPercent();
          }
        };
    getTable().addColumn(cpuColumn, constants.cpuVm(), "140px"); // $NON-NLS-1$

    PercentColumn<VM> netColumn =
        new PercentColumn<VM>() {
          @Override
          public Integer getProgressValue(VM object) {
            return object.getUsageNetworkPercent();
          }
        };
    getTable().addColumn(netColumn, constants.networkVm(), "140px"); // $NON-NLS-1$

    TextColumnWithTooltip<VM> statusColumn =
        new EnumColumn<VM, VMStatus>() {
          @Override
          protected VMStatus getRawValue(VM object) {
            return object.getStatus();
          }
        };
    statusColumn.makeSortable();
    getTable().addColumn(statusColumn, constants.statusVm(), "140px"); // $NON-NLS-1$

    TextColumnWithTooltip<VM> hostColumn =
        new UptimeColumn<VM>() {
          @Override
          protected Double getRawValue(VM object) {
            return object.getRoundedElapsedTime();
          }
        };
    hostColumn.makeSortable();
    getTable().addColumn(hostColumn, constants.uptimeVm(), "140px"); // $NON-NLS-1$
  }
  void initVmTable() {
    getTable().enableColumnResizing();

    AbstractTextColumn<VM> nameColumn =
        new AbstractTextColumn<VM>() {
          @Override
          public String getValue(VM object) {
            return object.getName();
          }
        };
    nameColumn.makeSortable();
    getTable().addColumn(nameColumn, constants.nameVm(), "95px"); // $NON-NLS-1$

    AbstractTextColumn<VM> templateColumn =
        new AbstractTextColumn<VM>() {
          @Override
          public String getValue(VM object) {
            return vmTemplateNameRenderer.render(object);
          }
        };
    templateColumn.makeSortable();
    getTable().addColumn(templateColumn, constants.templateVm(), "95px"); // $NON-NLS-1$

    AbstractTextColumn<VM> originColumn =
        new AbstractEnumColumn<VM, OriginType>() {
          @Override
          protected OriginType getRawValue(VM object) {
            return object.getOrigin();
          }
        };
    originColumn.makeSortable();
    getTable().addColumn(originColumn, constants.originVm(), "95px"); // $NON-NLS-1$

    AbstractTextColumn<VM> memoryColumn =
        new AbstractTextColumn<VM>() {
          @Override
          public String getValue(VM object) {
            return String.valueOf(object.getVmMemSizeMb()) + " MB"; // $NON-NLS-1$
          }
        };
    memoryColumn.makeSortable();
    getTable().addColumn(memoryColumn, constants.memoryVm(), "95px"); // $NON-NLS-1$

    AbstractTextColumn<VM> cpuColumn =
        new AbstractTextColumn<VM>() {
          @Override
          public String getValue(VM object) {
            return String.valueOf(object.getNumOfCpus());
          }
        };
    cpuColumn.makeSortable();
    getTable().addColumn(cpuColumn, constants.cpusVm(), "95px"); // $NON-NLS-1$

    AbstractTextColumn<VM> archColumn =
        new AbstractTextColumn<VM>() {
          @Override
          public String getValue(VM object) {
            return String.valueOf(object.getClusterArch());
          }
        };
    archColumn.makeSortable();
    getTable().addColumn(archColumn, constants.architectureVm(), "95px"); // $NON-NLS-1$

    AbstractTextColumn<VM> diskColumn =
        new AbstractTextColumn<VM>() {
          @Override
          public String getValue(VM object) {
            return String.valueOf(object.getDiskMap().size());
          }
        };
    diskColumn.makeSortable();
    getTable().addColumn(diskColumn, constants.disksVm(), "95px"); // $NON-NLS-1$

    AbstractTextColumn<VM> creationDateColumn =
        new AbstractFullDateTimeColumn<VM>() {
          @Override
          protected Date getRawValue(VM object) {
            return object.getVmCreationDate();
          }
        };
    creationDateColumn.makeSortable(
        new Comparator<VM>() {
          @Override
          public int compare(VM vm1, VM vm2) {
            return vm1.getVmCreationDate().compareTo(vm2.getVmCreationDate());
          }
        });
    getTable().addColumn(creationDateColumn, constants.creationDateVm(), "95px"); // $NON-NLS-1$

    AbstractTextColumn<VM> exportDateColumn =
        new AbstractFullDateTimeColumn<VM>() {
          @Override
          protected Date getRawValue(VM object) {
            return object.getExportDate();
          }
        };
    exportDateColumn.makeSortable(
        new Comparator<VM>() {
          @Override
          public int compare(VM vm1, VM vm2) {
            return vm1.getExportDate().compareTo(vm2.getExportDate());
          }
        });
    getTable().addColumn(exportDateColumn, constants.exportDateVm(), "95px"); // $NON-NLS-1$

    getTable()
        .addActionButton(
            new WebAdminButtonDefinition<VM>(constants.restoreVm()) {
              @Override
              protected UICommand resolveCommand() {
                return getDetailModel().getRestoreCommand();
              }
            });

    getTable()
        .addActionButton(
            new WebAdminButtonDefinition<VM>(constants.removeVm()) {
              @Override
              protected UICommand resolveCommand() {
                return getDetailModel().getRemoveCommand();
              }
            });

    getTable().showRefreshButton();
  }