예제 #1
0
파일: DIPList.java 프로젝트: keeps/roda
  @Override
  protected void configureDisplay(CellTable<IndexedDIP> display) {

    dateCreated =
        new Column<IndexedDIP, Date>(
            new DateCell(DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM))) {
          @Override
          public Date getValue(IndexedDIP dip) {
            return dip != null ? dip.getDateCreated() : null;
          }
        };

    lastModified =
        new Column<IndexedDIP, Date>(
            new DateCell(DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM))) {
          @Override
          public Date getValue(IndexedDIP dip) {
            return dip != null ? dip.getLastModified() : null;
          }
        };

    titleColumn =
        new TextColumn<IndexedDIP>() {

          @Override
          public String getValue(IndexedDIP dip) {
            return dip != null ? dip.getTitle() : null;
          }
        };

    titleColumn.setSortable(true);
    dateCreated.setSortable(true);
    lastModified.setSortable(true);

    display.addColumn(titleColumn, messages.aipGenericTitle());
    display.addColumn(dateCreated, messages.dipCreatedDate());
    display.addColumn(lastModified, messages.dipLastModified());

    Label emptyInfo = new Label(messages.noItemsToDisplay());
    display.setEmptyTableWidget(emptyInfo);

    // define default sorting
    display.getColumnSortList().push(new ColumnSortInfo(titleColumn, true));

    // display.setColumnWidth(titleColumn, 7.0, Unit.EM);
    display.setColumnWidth(dateCreated, 13.0, Unit.EM);
    display.setColumnWidth(lastModified, 13.0, Unit.EM);

    dateCreated.setCellStyleNames("nowrap");
    lastModified.setCellStyleNames("nowrap");

    addStyleName("my-collections-table");
    emptyInfo.addStyleName("my-collections-empty-info");
  }
예제 #2
0
  private Column<FileSystemItem, ImageResource> addIconColumn(
      final FileTypeRegistry fileTypeRegistry) {
    Column<FileSystemItem, ImageResource> iconColumn =
        new Column<FileSystemItem, ImageResource>(new ImageResourceCell()) {

          @Override
          public ImageResource getValue(FileSystemItem object) {
            if (object == parentPath_) return FileIconResources.INSTANCE.iconUpFolder();
            else return fileTypeRegistry.getIconForFile(object);
          }
        };
    iconColumn.setSortable(true);
    filesDataGrid_.addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    filesDataGrid_.setColumnWidth(iconColumn, ICON_COLUMN_WIDTH_PIXELS, Unit.PX);

    sortHandler_.setComparator(
        iconColumn,
        new FilesListComparator() {
          @Override
          public int doCompare(FileSystemItem arg0, FileSystemItem arg1) {
            if (arg0.isDirectory() && !arg1.isDirectory()) return 1;
            else if (arg1.isDirectory() && !arg0.isDirectory()) return -1;
            else return arg0.getExtension().compareTo(arg1.getExtension());
          }
        });

    return iconColumn;
  }
  private Column<CMSContentSummary, ?> initNameColumn() {
    Column<CMSContentSummary, String> processNameColumn =
        new Column<CMSContentSummary, String>(new TextCell()) {
          @Override
          public String getValue(CMSContentSummary object) {
            return object.getName();
          }
        };
    processNameColumn.setSortable(true);

    return processNameColumn;
  }
  private Column column4Column() {
    Column<DataMockSummary, String> column4Column =
        new Column<DataMockSummary, String>(new TextCell()) {

          @Override
          public String getValue(DataMockSummary unit) {
            return unit.getColumn4();
          }
        };
    column4Column.setSortable(true);
    return column4Column;
  }
  private Column initInitiatorColumn() {
    Column<ProcessInstanceSummary, String> processInitiatorColumn =
        new Column<ProcessInstanceSummary, String>(new TextCell()) {
          @Override
          public String getValue(ProcessInstanceSummary object) {
            return object.getInitiator();
          }
        };
    processInitiatorColumn.setSortable(true);
    processInitiatorColumn.setDataStoreName("log.identity");

    return processInitiatorColumn;
  }
 private Column initDescriptionColumn() {
   // start time
   Column<ProcessInstanceSummary, String> descriptionColumn =
       new Column<ProcessInstanceSummary, String>(new TextCell()) {
         @Override
         public String getValue(ProcessInstanceSummary object) {
           return object.getProcessInstanceDescription();
         }
       };
   descriptionColumn.setSortable(true);
   descriptionColumn.setDataStoreName("log.processInstanceDescription");
   return descriptionColumn;
 }
 private Column initJobTypeColumn() {
   // Job type
   Column<RequestSummary, String> jobTypeColumn =
       new Column<RequestSummary, String>(new TextCell()) {
         @Override
         public String getValue(RequestSummary object) {
           return object.getCommandName();
         }
       };
   jobTypeColumn.setSortable(true);
   jobTypeColumn.setDataStoreName(COLUMN_COMMANDNAME);
   return jobTypeColumn;
 }
 private Column initJobNameColumn() {
   // Job name
   Column<RequestSummary, String> jobNameColumn =
       new Column<RequestSummary, String>(new TextCell()) {
         @Override
         public String getValue(RequestSummary object) {
           return object.getKey();
         }
       };
   jobNameColumn.setSortable(true);
   jobNameColumn.setDataStoreName(COLUMN_BUSINESSKEY);
   return jobNameColumn;
 }
 private Column initDueDateColumn() {
   // Time
   Column<RequestSummary, String> dueDateColumn =
       new Column<RequestSummary, String>(new TextCell()) {
         @Override
         public String getValue(RequestSummary object) {
           return DateUtils.getDateTimeStr(object.getTime());
         }
       };
   dueDateColumn.setSortable(true);
   dueDateColumn.setDataStoreName(COLUMN_TIMESTAMP);
   return dueDateColumn;
 }
  private Column initJobIdColumn() {
    // Id
    Column<RequestSummary, Number> jobIdColumn =
        new Column<RequestSummary, Number>(new NumberCell()) {
          @Override
          public Number getValue(RequestSummary object) {
            return object.getJobId();
          }
        };
    jobIdColumn.setSortable(true);
    jobIdColumn.setDataStoreName(COLUMN_ID);

    return jobIdColumn;
  }
  private Column initStatusColumn() {
    // Status
    Column<RequestSummary, String> statusColumn =
        new Column<RequestSummary, String>(new TextCell()) {
          @Override
          public String getValue(RequestSummary object) {
            return object.getStatus();
          }
        };
    statusColumn.setSortable(true);
    statusColumn.setDataStoreName(COLUMN_STATUS);

    return statusColumn;
  }
  private Column initProcessVersionColumn() {
    // Process Version.
    Column<ProcessInstanceSummary, String> processVersionColumn =
        new Column<ProcessInstanceSummary, String>(new TextCell()) {
          @Override
          public String getValue(ProcessInstanceSummary object) {
            return object.getProcessVersion();
          }
        };
    processVersionColumn.setSortable(true);
    processVersionColumn.setDataStoreName("log.processVersion");

    return processVersionColumn;
  }
  private Column initStartDateColumn() {
    // start time
    Column<ProcessInstanceSummary, String> startTimeColumn =
        new Column<ProcessInstanceSummary, String>(new TextCell()) {
          @Override
          public String getValue(ProcessInstanceSummary object) {
            Date startTime = object.getStartTime();
            if (startTime != null) {
              DateTimeFormat format = DateTimeFormat.getFormat("dd/MM/yyyy HH:mm");
              return format.format(startTime);
            }
            return "";
          }
        };
    startTimeColumn.setSortable(true);
    startTimeColumn.setDataStoreName("log.start");

    return startTimeColumn;
  }
예제 #14
0
  public TagCategoriesView() {
    super(PressGangCCMSUI.INSTANCE.PressGangCCMS(), PressGangCCMSUI.INSTANCE.TagCategories());

    getPossibleChildrenResults().addColumn(idColumn, PressGangCCMSUI.INSTANCE.CategoryID());
    getPossibleChildrenResults().addColumn(nameColumn, PressGangCCMSUI.INSTANCE.CategoryName());
    getPossibleChildrenResults().addColumn(buttonColumn, PressGangCCMSUI.INSTANCE.AddRemove());

    idColumn.setSortable(true);
    nameColumn.setSortable(true);
    buttonColumn.setSortable(true);

    /*
       Allow the table to be sorted.
    */
    @NotNull
    final ColumnSortEvent.AsyncHandler columnSortHandler =
        new ColumnSortEvent.AsyncHandler(getPossibleChildrenResults());
    getPossibleChildrenResults().addColumnSortHandler(columnSortHandler);

    getExistingChildrenResults().addColumn(tagIdColumn, PressGangCCMSUI.INSTANCE.TagID());
    getExistingChildrenResults().addColumn(tagNameColumn, PressGangCCMSUI.INSTANCE.TagName());
    getExistingChildrenResults().addColumn(tagUpButtonColumn, PressGangCCMSUI.INSTANCE.Up());
    getExistingChildrenResults().addColumn(tagDownButtonColumn, PressGangCCMSUI.INSTANCE.Down());
  }
  private Column initProcessStateColumn() {
    // Process State
    Column<ProcessInstanceSummary, String> processStateColumn =
        new Column<ProcessInstanceSummary, String>(new TextCell()) {
          @Override
          public String getValue(ProcessInstanceSummary object) {
            String statusStr = constants.Unknown();
            switch (object.getState()) {
              case ProcessInstance.STATE_ACTIVE:
                statusStr = constants.Active();
                break;
              case ProcessInstance.STATE_ABORTED:
                statusStr = constants.Aborted();
                break;
              case ProcessInstance.STATE_COMPLETED:
                statusStr = constants.Completed();
                break;
              case ProcessInstance.STATE_PENDING:
                statusStr = constants.Pending();
                break;
              case ProcessInstance.STATE_SUSPENDED:
                statusStr = constants.Suspended();
                break;

              default:
                break;
            }

            return statusStr;
          }
        };
    processStateColumn.setSortable(true);
    processStateColumn.setDataStoreName("log.status");

    return processStateColumn;
  }
예제 #16
0
  private void createDataGrid() {
    dataGrid = new DataGrid<InputItem>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER);
    selectionModel = new SingleSelectionModel<InputItem>(KEY_PROVIDER);
    dataGrid.setSelectionModel(selectionModel);

    recordStore = new ListDataProvider<InputItem>(KEY_PROVIDER);
    recordStore.addDataDisplay(dataGrid);

    sortHandler = new ColumnSortEvent.ListHandler<InputItem>(recordStore.getList());

    Column<InputItem, InputItem> colId = new IdentityColumn<InputItem>(ID_CELL);
    dataGrid.addColumn(colId, new ResizableHeader<InputItem>("#", dataGrid, colId));
    dataGrid.setColumnWidth(colId, 35, Style.Unit.PX);

    final EditTextCell cellName = new EditTextCell();
    Column<InputItem, String> colName =
        new Column<InputItem, String>(cellName) {
          @Override
          public String getValue(InputItem rec) {
            return rec.getName();
          }
        };
    colName.setFieldUpdater(
        new FieldUpdater<InputItem, String>() {
          @Override
          public void update(int index, InputItem rec, String value) {
            if (!value.equals(rec.getName())) {
              markChange(rec);
              rec.setName(value);
              cellName.clearViewData(rec.getId());
            }
          }
        });
    dataGrid.addColumn(colName, new ResizableHeader<InputItem>("Name", dataGrid, colName));
    dataGrid.setColumnWidth(colName, 128, Style.Unit.PX);

    colName.setSortable(true);
    sortHandler.setComparator(
        colName,
        new Comparator<InputItem>() {
          @Override
          public int compare(InputItem o1, InputItem o2) {
            return o1.getName().compareTo(o2.getName());
          }
        });

    //        final SelectCell<String,Integer> cellActive = new SelectCell<String,Integer>(
    //                ZicoWidgets.<String,Integer>map("NO",0,"YES",1));
    //        Column<InputItem,Integer> colActive = new Column<InputItem, Integer>(cellActive) {
    //            @Override
    //            public Integer getValue(InputItem rec) {
    //                return rec.getActive();
    //            }
    //        };
    //        colActive.setFieldUpdater(new FieldUpdater<InputItem, Integer>() {
    //            @Override
    //            public void update(int index, InputItem rec, Integer value) {
    //                if (rec.getActive() != value) {
    //                    markChange(rec);
    //                    rec.setActive(value);
    //                    cellActive.clearViewData(rec.getId());
    //                }
    //            }
    //        });
    //        dataGrid.addColumn(colActive, new ResizableHeader<InputItem>("Active", dataGrid,
    // colActive));
    //        dataGrid.setColumnWidth(colActive, 128, Style.Unit.PX);

    //        final DatePickerCell cellTstart = new DatePickerCell(ClientUtil.TSTAMP_FORMAT0);
    //        Column<InputItem,Date> colTstart = new Column<InputItem, Date>(cellTstart) {
    //            @Override
    //            public Date getValue(InputItem rec) {
    //                return ClientUtil.unix2date(rec.getTstart());
    //            }
    //        };
    //        colTstart.setFieldUpdater(new FieldUpdater<InputItem, Date>() {
    //            @Override
    //            public void update(int index, InputItem rec, Date value) {
    //                long t = ClientUtil.date2unix(value);
    //                if (t != rec.getTstart()) {
    //                    markChange(rec);
    //                    rec.setTstart(t);
    //                    cellTstart.clearViewData(rec.getId());
    //                }
    //            }
    //        });
    //        colTstart.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    //        dataGrid.addColumn(colTstart, new ResizableHeader<InputItem>("TStart", dataGrid,
    // colTstart));
    //        dataGrid.setColumnWidth(colTstart, 100, Style.Unit.PX);

    //        final DatePickerCell cellTstop = new DatePickerCell(ClientUtil.TSTAMP_FORMAT0);
    //        Column<InputItem,Date> colTstop = new Column<InputItem, Date>(cellTstop) {
    //            @Override
    //            public Date getValue(InputItem rec) {
    //                return ClientUtil.unix2date(rec.getTstop());
    //            }
    //        };
    //        colTstop.setFieldUpdater(new FieldUpdater<InputItem, Date>() {
    //            @Override
    //            public void update(int index, InputItem rec, Date value) {
    //                long t = ClientUtil.date2unix(value);
    //                if (t != rec.getTstop()) {
    //                    markChange(rec);
    //                    rec.setTstop(t);
    //                    cellTstop.clearViewData(rec.getId());
    //                }
    //            }
    //        });
    //        colTstop.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    //        dataGrid.addColumn(colTstop, new ResizableHeader<InputItem>("TStop", dataGrid,
    // colTstop));
    //        dataGrid.setColumnWidth(colTstop, 100, Style.Unit.PX);

    Column<InputItem, Integer> colInput =
        new Column<InputItem, Integer>(cellInput) {
          @Override
          public Integer getValue(InputItem iitem) {
            return iitem.getInputId();
          }
        };
    colInput.setFieldUpdater(
        new FieldUpdater<InputItem, Integer>() {
          @Override
          public void update(int index, InputItem rec, Integer value) {
            if (rec.getInputId() != value) {
              markChange(rec);
              rec.setInputId(value);
              cellInput.clearViewData(rec.getId());
            }
          }
        });
    dataGrid.addColumn(colInput, new ResizableHeader<InputItem>("Input", dataGrid, colInput));
    dataGrid.setColumnWidth(colInput, 128, Style.Unit.PX);

    Column<InputItem, Integer> colTxForm =
        new Column<InputItem, Integer>(cellTxForm) {
          @Override
          public Integer getValue(InputItem rec) {
            return rec.getTxFormid();
          }
        };
    colTxForm.setFieldUpdater(
        new FieldUpdater<InputItem, Integer>() {
          @Override
          public void update(int index, InputItem iitem, Integer value) {
            if (iitem.getTxFormid() != value) {
              markChange(iitem);
              iitem.setTxFormid(value);
              cellTxForm.clearViewData(iitem.getId());
            }
          }
        });
    dataGrid.addColumn(colTxForm, new ResizableHeader<InputItem>("TxForm", dataGrid, colTxForm));
    dataGrid.setColumnWidth(colTxForm, 128, Style.Unit.PX);

    final EditTextCell cellComment = new EditTextCell();
    Column<InputItem, String> colComment =
        new Column<InputItem, String>(cellComment) {
          @Override
          public String getValue(InputItem rec) {
            return rec.getComment();
          }
        };
    colComment.setFieldUpdater(
        new FieldUpdater<InputItem, String>() {
          @Override
          public void update(int index, InputItem rec, String value) {
            if (!value.equals(rec.getComment())) {
              markChange(rec);
              rec.setComment(value);
              cellComment.clearViewData(rec.getId());
            }
          }
        });
    dataGrid.addColumn(colComment, new ResizableHeader<InputItem>("Comment", dataGrid, colComment));

    colComment.setSortable(true);
    sortHandler.setComparator(
        colComment,
        new Comparator<InputItem>() {
          @Override
          public int compare(InputItem o1, InputItem o2) {
            return o1.getComment().compareTo(o2.getComment());
          }
        });

    dataGrid.addCellPreviewHandler(
        new CellPreviewEvent.Handler<InputItem>() {
          @Override
          public void onCellPreview(CellPreviewEvent<InputItem> event) {
            NativeEvent nev = event.getNativeEvent();
            String eventType = nev.getType();
            if (BrowserEvents.CONTEXTMENU.equals(eventType)) {
              selectionModel.setSelected(event.getValue(), true);
              if (event.getValue() != null) {
                contextMenu.setPopupPosition(
                    event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY());
                contextMenu.show();
              }
            }
          }
        });

    dataGrid.setKeyboardSelectionPolicy(
        HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED);
    dataGrid.addDomHandler(
        new DoubleClickHandler() {
          @Override
          public void onDoubleClick(DoubleClickEvent event) {
            event.preventDefault();
          }
        },
        DoubleClickEvent.getType());
    dataGrid.addDomHandler(
        new ContextMenuHandler() {
          @Override
          public void onContextMenu(ContextMenuEvent event) {
            event.preventDefault();
          }
        },
        ContextMenuEvent.getType());
  }
예제 #17
0
  private void initializeTable() {
    typeColumn =
        new TextColumn<AnnotationInfo>() {
          @Override
          public String getValue(AnnotationInfo annotationInfo) {
            String annotationTypeString = annotationInfo.getType();
            if (annotationTypeString.equals("non_canonical_five_prime_splice_site")) {
              annotationTypeString = "NC 5' splice";
            } else if (annotationTypeString.equals("non_canonical_three_prime_splice_site")) {
              annotationTypeString = "NC 3' splice";
            }
            return annotationTypeString;
          }
        };
    typeColumn.setSortable(true);

    startColumn =
        new Column<AnnotationInfo, Number>(new NumberCell()) {
          @Override
          public Integer getValue(AnnotationInfo annotationInfo) {
            return getDisplayMin(annotationInfo.getMin());
          }
        };
    startColumn.setSortable(true);

    stopColumn =
        new Column<AnnotationInfo, Number>(new NumberCell()) {
          @Override
          public Integer getValue(AnnotationInfo annotationInfo) {
            return annotationInfo.getMax();
          }
        };
    stopColumn.setSortable(true);

    lengthColumn =
        new Column<AnnotationInfo, Number>(new NumberCell()) {
          @Override
          public Integer getValue(AnnotationInfo annotationInfo) {
            return annotationInfo.getLength();
          }
        };
    lengthColumn.setSortable(true);

    dataGrid.addColumn(typeColumn, "Type");
    dataGrid.addColumn(startColumn, "Start");
    //        dataGrid.addColumn(stopColumn, "Stop");
    dataGrid.addColumn(lengthColumn, "Length");

    ColumnSortEvent.ListHandler<AnnotationInfo> sortHandler =
        new ColumnSortEvent.ListHandler<AnnotationInfo>(annotationInfoList);
    dataGrid.addColumnSortHandler(sortHandler);

    sortHandler.setComparator(
        typeColumn,
        new Comparator<AnnotationInfo>() {
          @Override
          public int compare(AnnotationInfo o1, AnnotationInfo o2) {
            return o1.getType().compareTo(o2.getType());
          }
        });

    sortHandler.setComparator(
        startColumn,
        new Comparator<AnnotationInfo>() {
          @Override
          public int compare(AnnotationInfo o1, AnnotationInfo o2) {
            return o1.getMin() - o2.getMin();
          }
        });

    sortHandler.setComparator(
        stopColumn,
        new Comparator<AnnotationInfo>() {
          @Override
          public int compare(AnnotationInfo o1, AnnotationInfo o2) {
            return o1.getMax() - o2.getMax();
          }
        });

    sortHandler.setComparator(
        lengthColumn,
        new Comparator<AnnotationInfo>() {
          @Override
          public int compare(AnnotationInfo o1, AnnotationInfo o2) {
            return o1.getLength() - o2.getLength();
          }
        });
  }
  /**
   * Returns empty table widget with attributes
   *
   * @return table widget
   */
  public CellTable<Attribute> getEmptyTable() {

    // Table data provider.
    dataProvider = new ListDataProvider<Attribute>(list);

    // Cell table
    table = new PerunTable<Attribute>(list);
    table.removeRowCountChangeHandler(); // remove row count change handler

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    // Sorting
    ListHandler<Attribute> columnSortHandler = new ListHandler<Attribute>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<Attribute>createCheckboxManager());

    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);

    // because of tab index
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    // checkbox column
    if (checkable) {

      // checkbox column column
      Column<Attribute, Attribute> checkBoxColumn =
          new Column<Attribute, Attribute>(new PerunCheckboxCell<Attribute>(true, false, false)) {
            @Override
            public Attribute getValue(Attribute object) {
              // Get the value from the selection model.
              GeneralObject go = object.cast();
              go.setChecked(selectionModel.isSelected(object));
              return go.cast();
            }
          };

      // updates the columns size
      table.setColumnWidth(checkBoxColumn, 40.0, Unit.PX);

      // Add the columns

      // Checkbox column header
      CheckboxCell cb = new CheckboxCell();
      Header<Boolean> checkBoxHeader =
          new Header<Boolean>(cb) {
            public Boolean getValue() {
              return false; // return true to see a checked checkbox.
            }
          };
      checkBoxHeader.setUpdater(
          new ValueUpdater<Boolean>() {
            public void update(Boolean value) {
              // sets selected to all, if value = true, unselect otherwise
              for (Attribute obj : list) {
                if (obj.isWritable()) {
                  selectionModel.setSelected(obj, value);
                }
              }
            }
          });

      table.addColumn(checkBoxColumn, checkBoxHeader);
    }

    // Create ID column.
    table.addIdColumn("Attr ID", null, 90);

    // Name column
    Column<Attribute, Attribute> nameColumn = JsonUtils.addColumn(new PerunAttributeNameCell());

    // Value column
    Column<Attribute, Attribute> valueColumn = JsonUtils.addColumn(new PerunAttributeValueCell());
    valueColumn.setFieldUpdater(
        new FieldUpdater<Attribute, Attribute>() {
          public void update(int index, Attribute object, Attribute value) {
            object = value;
            selectionModel.setSelected(object, object.isAttributeValid());
          }
        });

    // Description column
    Column<Attribute, Attribute> descriptionColumn =
        JsonUtils.addColumn(new PerunAttributeDescriptionCell());

    // Sorting name column
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(
        nameColumn, new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_NAME));

    // Sorting description column
    descriptionColumn.setSortable(true);
    columnSortHandler.setComparator(
        descriptionColumn,
        new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_DESCRIPTION));

    // Add sorting
    this.table.addColumnSortHandler(columnSortHandler);

    // updates the columns size
    this.table.setColumnWidth(nameColumn, 200.0, Unit.PX);

    // Add the columns.
    this.table.addColumn(nameColumn, "Name");
    this.table.addColumn(valueColumn, "Value");
    this.table.addColumn(descriptionColumn, "Description");

    return this.table;
  }
  private void initCredentialsTable(CellTable.Resources res) {
    keys = new CellTable<>(15, res);
    Column<AuthConfig, String> serverAddressColumn =
        new Column<AuthConfig, String>(new TextCell()) {
          @Override
          public String getValue(AuthConfig object) {
            return object.getServeraddress();
          }

          @Override
          public void render(Cell.Context context, AuthConfig object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant(
                "<div id=\""
                    + UIObject.DEBUG_ID_PREFIX
                    + "preferences-docker-credentials-cellTable-serveraddress-"
                    + context.getIndex()
                    + "\">");
            super.render(context, object, sb);
          }
        };
    serverAddressColumn.setSortable(true);

    Column<AuthConfig, String> editColumn =
        new Column<AuthConfig, String>(new ButtonCell()) {
          @Override
          public String getValue(AuthConfig object) {
            return "Edit";
          }

          @Override
          public void render(Cell.Context context, AuthConfig object, SafeHtmlBuilder sb) {
            if (object != null) {
              sb.appendHtmlConstant(
                  "<div id=\""
                      + UIObject.DEBUG_ID_PREFIX
                      + "preferences-docker-credentials-cellTable-edit-"
                      + context.getIndex()
                      + "\">");
              super.render(context, object, sb);
            }
          }
        };
    // Creates handler on button clicked
    editColumn.setFieldUpdater(
        new FieldUpdater<AuthConfig, String>() {
          @Override
          public void update(int index, AuthConfig object, String value) {
            delegate.onEditClicked(object);
          }
        });

    Column<AuthConfig, String> deleteColumn =
        new Column<AuthConfig, String>(new ButtonCell()) {
          @Override
          public String getValue(AuthConfig object) {
            return "Delete";
          }

          @Override
          public void render(Cell.Context context, AuthConfig object, SafeHtmlBuilder sb) {
            if (object != null) {
              sb.appendHtmlConstant(
                  "<div id=\""
                      + UIObject.DEBUG_ID_PREFIX
                      + "preferences-docker-credentials-cellTable-delete-"
                      + context.getIndex()
                      + "\">");
              super.render(context, object, sb);
            }
          }
        };
    // Creates handler on button clicked
    deleteColumn.setFieldUpdater(
        new FieldUpdater<AuthConfig, String>() {
          @Override
          public void update(int index, AuthConfig object, String value) {
            delegate.onDeleteClicked(object);
          }
        });

    keys.addColumn(serverAddressColumn, "Server Address");
    keys.addColumn(editColumn, ""); // Do not show label for edit column
    keys.addColumn(deleteColumn, ""); // Do not show label for delete column
    keys.setColumnWidth(serverAddressColumn, 70, Style.Unit.PCT);
    keys.setColumnWidth(editColumn, 20, Style.Unit.PX);
    keys.setColumnWidth(deleteColumn, 20, Style.Unit.PX);

    // don't show loading indicator
    keys.setLoadingIndicator(null);
  }
  private void initTableColumns() {
    // addedBy
    Column<CommentSummary, String> addedByColumn =
        new Column<CommentSummary, String>(new TextCell()) {
          @Override
          public String getValue(CommentSummary c) {
            // for some reason the username comes in format [User:'******'], so parse just the
            // <name>
            int first = c.getAddedBy().indexOf('\'');
            int last = c.getAddedBy().lastIndexOf('\'');
            return c.getAddedBy().substring(first + 1, last);
          }
        };
    addedByColumn.setSortable(false);
    commentsListGrid.addColumn(addedByColumn, constants.Added_By());
    commentsListGrid.setColumnWidth(addedByColumn, "100px");

    // date
    Column<CommentSummary, String> addedAtColumn =
        new Column<CommentSummary, String>(new TextCell()) {
          @Override
          public String getValue(CommentSummary c) {
            DateTimeFormat format = DateTimeFormat.getFormat("dd/MM/yyyy HH:mm");
            return format.format(c.getAddedAt());
          }
        };
    addedAtColumn.setSortable(true);
    addedAtColumn.setDefaultSortAscending(true);
    commentsListGrid.addColumn(addedAtColumn, constants.At());
    sortHandler.setComparator(
        addedAtColumn,
        new Comparator<CommentSummary>() {
          @Override
          public int compare(CommentSummary o1, CommentSummary o2) {
            return o1.getAddedAt().compareTo(o2.getAddedAt());
          }
        });

    // comment text
    Column<CommentSummary, String> commentTextColumn =
        new Column<CommentSummary, String>(new TextCell()) {
          @Override
          public String getValue(CommentSummary object) {
            return object.getText();
          }
        };
    addedByColumn.setSortable(false);
    commentsListGrid.addColumn(commentTextColumn, constants.Comment());

    List<HasCell<CommentSummary, ?>> cells = new LinkedList<HasCell<CommentSummary, ?>>();

    cells.add(
        new DeleteCommentActionHasCell(
            constants.Delete(),
            new Delegate<CommentSummary>() {
              @Override
              public void execute(CommentSummary comment) {
                presenter.removeTaskComment(comment.getId());
              }
            }));

    CompositeCell<CommentSummary> cell = new CompositeCell<CommentSummary>(cells);
    Column<CommentSummary, CommentSummary> actionsColumn =
        new Column<CommentSummary, CommentSummary>(cell) {
          @Override
          public CommentSummary getValue(CommentSummary object) {
            return object;
          }
        };
    commentsListGrid.addColumn(actionsColumn, "");
  }
예제 #21
0
  /**
   * Returns the table with member-Groups
   *
   * @return CellTable widget
   */
  public CellTable<Group> getTable() {

    // Retrieves data
    this.retrieveData();

    // Table data provider.
    dataProvider = new ListDataProvider<Group>(list);

    // Cell table
    table = new PerunTable<Group>(list);

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    // Sorting
    ListHandler<Group> columnSortHandler = new ListHandler<Group>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // Table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<Group>createCheckboxManager());

    // Set empty content & loader
    table.setEmptyTableWidget(loaderImage);

    if (entity.equals(PerunEntity.VIRTUAL_ORGANIZATION)) {
      loaderImage.setEmptyResultMessage(
          "VO has no groups of managers (try to switch to 'Users' view).");
    } else if (entity.equals(PerunEntity.GROUP)) {
      loaderImage.setEmptyResultMessage(
          "Group has no groups of managers (try to switch to 'Users' view).");
    } else if (entity.equals(PerunEntity.FACILITY)) {
      loaderImage.setEmptyResultMessage(
          "Facility has no groups of managers (try to switch to 'Users' view).");
    }

    // Checkbox column column
    table.addCheckBoxColumn();

    // Create Group ID column.
    Column<Group, String> groupIdColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<Group, String>() {
              public String getValue(Group object) {
                return String.valueOf(object.getId());
              }
            },
            this.tableFieldUpdater);

    groupIdColumn.setSortable(true);
    columnSortHandler.setComparator(
        groupIdColumn, new GeneralComparator<Group>(GeneralComparator.Column.ID));

    table.setColumnWidth(groupIdColumn, 110.0, Unit.PX);

    if (JsonUtils.isExtendedInfoVisible()) {
      table.addColumn(groupIdColumn, "Group ID");
    }

    table.addNameColumn(tableFieldUpdater);
    table.addDescriptionColumn(tableFieldUpdater);

    return table;
  }
예제 #22
0
  /** Helper to createCellTable(). Adds columns to the table. */
  private void addColumns() {
    NumberFormat yearFormat = NumberFormat.getFormat("0000");

    // Address column
    TextColumn<HouseData> addrColumn =
        new TextColumn<HouseData>() {
          @Override
          public String getValue(HouseData house) {
            return house.getAddress();
          }
        };
    homesCellTable.addColumn(addrColumn, "Address");
    addrColumn.setSortable(true);
    columnName.add("Address");

    // Postal code column
    TextColumn<HouseData> postalColumn =
        new TextColumn<HouseData>() {
          @Override
          public String getValue(HouseData house) {
            return house.getPostalCode();
          }
        };
    homesCellTable.addColumn(postalColumn, "Postal Code");
    postalColumn.setSortable(true);
    columnName.add("Postal Code");

    // Current Land Value column
    Column<HouseData, Number> currlandValColumn =
        new Column<HouseData, Number>(new NumberCell()) {
          @Override
          public Number getValue(HouseData house) {
            return house.getCurrentLandValue();
          }
        };
    homesCellTable.addColumn(currlandValColumn, "Current Land Value");
    currlandValColumn.setSortable(true);
    columnName.add("Current Land Value");

    // Current Improvement Value column
    Column<HouseData, Number> currImprovValColumn =
        new Column<HouseData, Number>(new NumberCell()) {
          @Override
          public Number getValue(HouseData house) {
            return house.getCurrentImprovementValue();
          }
        };
    homesCellTable.addColumn(currImprovValColumn, "Current Improvement Value");
    currImprovValColumn.setSortable(true);
    columnName.add("Current Improvement Value");

    // Assessment Year column
    Column<HouseData, Number> assYearColumn =
        new Column<HouseData, Number>(new NumberCell(yearFormat)) {
          @Override
          public Number getValue(HouseData house) {
            return house.getAssessmentYear();
          }
        };
    homesCellTable.addColumn(assYearColumn, "Assessment Year");
    assYearColumn.setSortable(true);
    columnName.add("Assessment Year");

    // Previous Land Value column
    Column<HouseData, Number> prevlandValColumn =
        new Column<HouseData, Number>(new NumberCell()) {
          @Override
          public Number getValue(HouseData house) {
            return house.getPreviousLandValue();
          }
        };
    homesCellTable.addColumn(prevlandValColumn, "Previous Land Value");
    prevlandValColumn.setSortable(true);
    columnName.add("Previous Land Value");

    // Previous Improvement Value column
    Column<HouseData, Number> prevImprovValColumn =
        new Column<HouseData, Number>(new NumberCell()) {
          @Override
          public Number getValue(HouseData house) {
            return house.getPreviousImprovementValue();
          }
        };
    homesCellTable.addColumn(prevImprovValColumn, "Previous Improvement Value");
    prevImprovValColumn.setSortable(true);
    columnName.add("Previous Improvement Value");

    // Built Year column
    Column<HouseData, Number> yrBuiltColumn =
        new Column<HouseData, Number>(new NumberCell(yearFormat)) {
          @Override
          public Number getValue(HouseData house) {
            return house.getYearBuilt();
          }
        };
    homesCellTable.addColumn(yrBuiltColumn, "Year Built");
    yrBuiltColumn.setSortable(true);
    columnName.add("Year Built");

    // Big Improvement Year column
    Column<HouseData, Number> improvYearColumn =
        new Column<HouseData, Number>(new NumberCell(yearFormat)) {
          @Override
          public Number getValue(HouseData house) {
            return house.getBigImprovementYear();
          }
        };
    homesCellTable.addColumn(improvYearColumn, "Big Improvement Year");
    improvYearColumn.setSortable(true);
    columnName.add("Big Improvement Year");

    /* User specified column begins.
     * User specified columns are class variables because enableEdit() needs to
     * replace following columns with editable cells.
     */
    // Realtor column
    Column<HouseData, String> ownerColumn =
        new TextColumn<HouseData>() {
          @Override
          public String getValue(HouseData house) {
            return house.getOwner();
          }
        };
    homesCellTable.addColumn(ownerColumn, "Realtor");
    ownerColumn.setSortable(true);
    columnName.add("Realtor");

    // Price column
    Column<HouseData, Number> priceColumn =
        new Column<HouseData, Number>(new NumberCell()) {
          @Override
          public Number getValue(HouseData house) {
            return house.getPrice();
          }
        };
    homesCellTable.addColumn(priceColumn, "Price");
    priceColumn.setSortable(true);
    columnName.add("Price");

    // For Sale column
    Column<HouseData, String> isSellingColumn =
        new TextColumn<HouseData>() {
          @Override
          public String getValue(HouseData house) {
            if (house.getIsSelling()) return "For Sale";
            return "";
          }
        };
    homesCellTable.addColumn(isSellingColumn, "Sale");
    isSellingColumn.setSortable(true);
    columnName.add("Sale");
  }
예제 #23
0
  @Override
  protected void configureDisplay(CellTable<Notification> display) {
    fromUser =
        new TextColumn<Notification>() {

          @Override
          public String getValue(Notification notification) {
            return notification != null ? notification.getFromUser() : null;
          }
        };

    sentOn =
        new Column<Notification, Date>(
            new DateCell(DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM))) {
          @Override
          public Date getValue(Notification notification) {
            return notification != null ? notification.getSentOn() : null;
          }
        };

    subject =
        new TextColumn<Notification>() {

          @Override
          public String getValue(Notification notification) {
            return notification != null ? notification.getSubject() : null;
          }
        };

    acknowledged =
        new Column<Notification, SafeHtml>(new SafeHtmlCell()) {
          @Override
          public SafeHtml getValue(Notification notification) {
            SafeHtml ret = null;
            if (notification != null) {
              if (notification.isAcknowledged()) {
                ret =
                    SafeHtmlUtils.fromSafeConstant(
                        "<span class='label-success'>"
                            + messages.showMessageAcknowledged()
                            + "</span>");
              } else {
                ret =
                    SafeHtmlUtils.fromSafeConstant(
                        "<span class='label-danger'>"
                            + messages.showMessageNotAcknowledged()
                            + "</span>");
              }
            }

            return ret;
          }
        };

    state =
        new Column<Notification, SafeHtml>(new SafeHtmlCell()) {
          @Override
          public SafeHtml getValue(Notification notification) {
            SafeHtml ret = null;
            if (notification != null) {
              ret = HtmlSnippetUtils.getNotificationStateHTML(notification.getState());
            }
            return ret;
          }
        };

    fromUser.setSortable(true);
    sentOn.setSortable(true);
    subject.setSortable(true);
    acknowledged.setSortable(true);
    state.setSortable(true);
    // TODO externalize strings into constants

    addColumn(fromUser, messages.notificationFrom(), true, false);
    addColumn(sentOn, messages.notificationSentOn(), true, false, 13);
    addColumn(subject, messages.notificationSubject(), true, false);
    addColumn(state, messages.notificationState(), true, false, 7);
    addColumn(acknowledged, messages.notificationAck(), true, false, 7);

    // default sorting
    display.getColumnSortList().push(new ColumnSortInfo(sentOn, false));

    addStyleName("my-collections-table");
  }
  private void initTableColumns(final SelectionModel<ProcessSummary> selectionModel) {
    // Checkbox column. This table will uses a checkbox column for selection.
    // Alternatively, you can call dataGrid.setSelectionEnabled(true) to enable
    // mouse selection.

    Column<ProcessSummary, Boolean> checkColumn =
        new Column<ProcessSummary, Boolean>(new CheckboxCell(true, false)) {
          @Override
          public Boolean getValue(ProcessSummary object) {
            // Get the value from the selection model.
            return selectionModel.isSelected(object);
          }
        };

    processdefListGrid.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    processdefListGrid.setColumnWidth(checkColumn, "40px");

    // Id.
    Column<ProcessSummary, String> processIdColumn =
        new Column<ProcessSummary, String>(new EditTextCell()) {
          @Override
          public String getValue(ProcessSummary object) {
            return object.getId();
          }
        };
    processIdColumn.setSortable(true);
    sortHandler.setComparator(
        processIdColumn,
        new Comparator<ProcessSummary>() {
          public int compare(ProcessSummary o1, ProcessSummary o2) {
            return Long.valueOf(o1.getId()).compareTo(Long.valueOf(o2.getId()));
          }
        });
    processdefListGrid.addColumn(
        processIdColumn, new ResizableHeader(constants.Id(), processdefListGrid, processIdColumn));

    // Process Id String.
    Column<ProcessSummary, String> processNameColumn =
        new Column<ProcessSummary, String>(new EditTextCell()) {
          @Override
          public String getValue(ProcessSummary object) {
            return object.getName();
          }
        };
    processNameColumn.setSortable(true);
    sortHandler.setComparator(
        processNameColumn,
        new Comparator<ProcessSummary>() {
          public int compare(ProcessSummary o1, ProcessSummary o2) {
            return o1.getName().compareTo(o2.getName());
          }
        });
    processdefListGrid.addColumn(
        processNameColumn,
        new ResizableHeader(constants.Name(), processdefListGrid, processNameColumn));

    // Process PKG.
    Column<ProcessSummary, String> processPkgColumn =
        new Column<ProcessSummary, String>(new EditTextCell()) {
          @Override
          public String getValue(ProcessSummary object) {
            return object.getPackageName();
          }
        };
    processPkgColumn.setSortable(true);
    sortHandler.setComparator(
        processPkgColumn,
        new Comparator<ProcessSummary>() {
          public int compare(ProcessSummary o1, ProcessSummary o2) {
            return o1.getPackageName().compareTo(o2.getPackageName());
          }
        });
    processdefListGrid.addColumn(
        processPkgColumn,
        new ResizableHeader(constants.Package(), processdefListGrid, processPkgColumn));

    // Process Session Id.
    Column<ProcessSummary, Number> processSessionIdColumn =
        new Column<ProcessSummary, Number>(new NumberCell()) {
          @Override
          public Number getValue(ProcessSummary object) {
            return object.getSessionId();
          }
        };
    processSessionIdColumn.setSortable(true);
    sortHandler.setComparator(
        processSessionIdColumn,
        new Comparator<ProcessSummary>() {
          public int compare(ProcessSummary o1, ProcessSummary o2) {
            return (o1.getSessionId() == o2.getSessionId()) ? 0 : 1;
          }
        });
    processdefListGrid.addColumn(
        processSessionIdColumn,
        new ResizableHeader("Session Id", processdefListGrid, processSessionIdColumn));
    processdefListGrid.setColumnWidth(processSessionIdColumn, "90px");

    // Version Type
    Column<ProcessSummary, String> versionColumn =
        new Column<ProcessSummary, String>(new EditTextCell()) {
          @Override
          public String getValue(ProcessSummary object) {
            return object.getVersion();
          }
        };
    versionColumn.setSortable(true);
    sortHandler.setComparator(
        versionColumn,
        new Comparator<ProcessSummary>() {
          public int compare(ProcessSummary o1, ProcessSummary o2) {
            return o1.getVersion().compareTo(o2.getVersion());
          }
        });
    processdefListGrid.addColumn(
        versionColumn, new ResizableHeader(constants.Version(), processdefListGrid, versionColumn));
    processdefListGrid.setColumnWidth(versionColumn, "90px");

    // actions (icons)
    List<HasCell<ProcessSummary, ?>> cells = new LinkedList<HasCell<ProcessSummary, ?>>();

    cells.add(
        new StartActionHasCell(
            "Start process",
            new Delegate<ProcessSummary>() {
              @Override
              public void execute(ProcessSummary process) {
                PlaceRequest placeRequestImpl = new DefaultPlaceRequest("Form Display");
                System.out.println("Opening form for process id = " + process.getId());
                placeRequestImpl.addParameter("processId", process.getId());
                placeRequestImpl.addParameter("sessionId", String.valueOf(process.getSessionId()));
                placeManager.goTo(placeRequestImpl);
              }
            }));

    cells.add(
        new DetailsActionHasCell(
            "Details",
            new Delegate<ProcessSummary>() {
              @Override
              public void execute(ProcessSummary process) {

                PlaceRequest placeRequestImpl =
                    new DefaultPlaceRequest(constants.Process_Definition_Details());
                placeRequestImpl.addParameter("processId", process.getId());
                placeRequestImpl.addParameter(
                    "sessionId", Integer.toString(process.getSessionId()));
                placeManager.goTo(placeRequestImpl);
              }
            }));

    CompositeCell<ProcessSummary> cell = new CompositeCell<ProcessSummary>(cells);
    Column<ProcessSummary, ProcessSummary> actionsColumn =
        new Column<ProcessSummary, ProcessSummary>(cell) {
          @Override
          public ProcessSummary getValue(ProcessSummary object) {
            return object;
          }
        };
    processdefListGrid.addColumn(actionsColumn, "Actions");
    processdefListGrid.setColumnWidth(actionsColumn, "70px");
  }
  public Widget draw() {

    // contentWidget.setSize("100%", "100%");

    DockLayoutPanel ft = new DockLayoutPanel(Style.Unit.PX);
    contentWidget.setWidget(ft);

    final DataGrid gridTable = new DataGrid();
    gridTable.setSize("100%", "100%");

    final ArrayList<Attribute> vosList = new ArrayList<Attribute>();
    final GetAttributesV2 getVos =
        new GetAttributesV2(
            new JsonCallbackEvents() {
              public void onFinished(JavaScriptObject jso) {
                vosList.addAll(
                    new TableSorter<Attribute>()
                        .sortByAttrNameTranslation(JsonUtils.<Attribute>jsoAsList(jso)));
                gridTable.setRowData(vosList);
                gridTable.redraw();
              }
            });
    getVos.getUserAttributes(3411);
    getVos.retrieveData();

    gridTable.setSelectionModel(
        new MultiSelectionModel<Attribute>(new GeneralKeyProvider<Attribute>()));
    final SelectionModel<Attribute> selectionModel = gridTable.getSelectionModel();
    gridTable.setKeyboardSelectionPolicy(
        HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED);

    Column<Attribute, Boolean> checkBoxColumn =
        new Column<Attribute, Boolean>(new CheckboxCell(true, true)) {
          @Override
          public Boolean getValue(Attribute object) {
            // Get the value from the selection model.
            return selectionModel.isSelected(object);
          }
        };
    checkBoxColumn.setFieldUpdater(
        new FieldUpdater<Attribute, Boolean>() {
          @Override
          public void update(int i, Attribute Attribute, Boolean aBoolean) {
            selectionModel.setSelected(Attribute, aBoolean);
          }
        });

    // Checkbox column header
    CheckboxCell cb = new CheckboxCell();
    Header<Boolean> checkBoxHeader =
        new Header<Boolean>(cb) {
          public Boolean getValue() {
            return false; // return true to see a checked checkbox.
          }
        };
    checkBoxHeader.setUpdater(
        new ValueUpdater<Boolean>() {
          public void update(Boolean value) {
            // sets selected to all, if value = true, unselect otherwise
            for (Attribute obj : vosList) {
              selectionModel.setSelected(obj, value);
            }
          }
        });

    gridTable.addColumn(checkBoxColumn, checkBoxHeader, checkBoxHeader);
    gridTable.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);

    TextColumn<Attribute> idColumn =
        new TextColumn<Attribute>() {
          @Override
          public String getValue(Attribute object) {
            return String.valueOf(object.getId());
          }
        };

    if (JsonUtils.isExtendedInfoVisible()) {
      gridTable.addColumn(idColumn, "Id", "Id");
      gridTable.setColumnWidth(idColumn, "90px");
    }

    // Name column
    Column<Attribute, Attribute> nameColumn = JsonUtils.addColumn(new PerunAttributeNameCell());

    // Description column
    Column<Attribute, Attribute> descriptionColumn =
        JsonUtils.addColumn(new PerunAttributeDescriptionCell());

    // Value column
    Column<Attribute, Attribute> valueColumn =
        JsonUtils.addColumn(
            new PerunAttributeValueCell(),
            new FieldUpdater<Attribute, Attribute>() {
              public void update(int index, Attribute object, Attribute value) {
                object = value;
                selectionModel.setSelected(object, object.isAttributeValid());
              }
            });

    ColumnSortEvent.ListHandler<Attribute> columnSortHandler =
        new ColumnSortEvent.ListHandler<Attribute>(vosList);
    gridTable.addColumnSortHandler(columnSortHandler);

    // Sorting name column
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(
        nameColumn, new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_NAME));

    // Sorting description column
    descriptionColumn.setSortable(true);
    columnSortHandler.setComparator(
        descriptionColumn,
        new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_DESCRIPTION));

    // Add sorting
    gridTable.addColumnSortHandler(columnSortHandler);

    // updates the columns size
    gridTable.setColumnWidth(nameColumn, 200.0, Style.Unit.PX);
    gridTable.setColumnWidth(valueColumn, 420.0, Style.Unit.PX);

    gridTable.addColumn(nameColumn, "Name");
    gridTable.addColumn(valueColumn, "Value");
    gridTable.addColumn(descriptionColumn, "Description");

    TabMenu tabMenu = new TabMenu();

    tabMenu.addWidget(
        TabMenu.getPredefinedButton(
            ButtonType.ADD,
            "",
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent clickEvent) {
                session.getTabManager().addTabToCurrentTab(new TestDataGridTabItem(), true);
              }
            }));

    ft.addNorth(tabMenu, 50);
    ft.add(gridTable);

    return getWidget();
  }
예제 #26
0
  public OrganismPanel() {
    initWidget(ourUiBinder.createAndBindUi(this));
    loadingDialog = new LoadingDialog("Processing ...", null, false);

    TextColumn<OrganismInfo> organismNameColumn =
        new TextColumn<OrganismInfo>() {
          @Override
          public String getValue(OrganismInfo organism) {
            return organism.getName();
          }
        };
    Column<OrganismInfo, Number> annotationsNameColumn =
        new Column<OrganismInfo, Number>(new NumberCell()) {
          @Override
          public Integer getValue(OrganismInfo object) {
            return object.getNumFeatures();
          }
        };
    Column<OrganismInfo, Number> sequenceColumn =
        new Column<OrganismInfo, Number>(new NumberCell()) {
          @Override
          public Integer getValue(OrganismInfo object) {
            return object.getNumSequences();
          }
        };

    sequenceColumn.setSortable(true);
    organismNameColumn.setSortable(true);
    annotationsNameColumn.setSortable(true);

    Annotator.eventBus.addHandler(
        OrganismChangeEvent.TYPE,
        new OrganismChangeEventHandler() {
          @Override
          public void onOrganismChanged(OrganismChangeEvent organismChangeEvent) {
            organismInfoList.clear();
            organismInfoList.addAll(MainPanel.getInstance().getOrganismInfoList());
          }
        });

    dataGrid.setLoadingIndicator(new HTML("Calculating Annotations ... "));
    dataGrid.addColumn(organismNameColumn, "Name");
    dataGrid.addColumn(annotationsNameColumn, "Annotations");
    dataGrid.addColumn(sequenceColumn, "Ref Sequences");
    dataGrid.setEmptyTableWidget(
        new Label("No organisms available. Add new organisms using the form field."));

    singleSelectionModel.addSelectionChangeHandler(
        new SelectionChangeEvent.Handler() {
          @Override
          public void onSelectionChange(SelectionChangeEvent event) {
            if (!creatingNewOrganism) {
              loadOrganismInfo();
              changeButtonSelection();
            } else {
              creatingNewOrganism = false;
            }
          }
        });
    dataGrid.setSelectionModel(singleSelectionModel);

    dataProvider.addDataDisplay(dataGrid);

    dataGrid.addDomHandler(
        new DoubleClickHandler() {
          @Override
          public void onDoubleClick(DoubleClickEvent event) {
            if (singleSelectionModel.getSelectedObject() != null) {
              String orgId = singleSelectionModel.getSelectedObject().getId();
              if (!MainPanel.getInstance().getCurrentOrganism().getId().equals(orgId)) {
                OrganismRestService.switchOrganismById(orgId);
              }
            }
          }
        },
        DoubleClickEvent.getType());

    List<OrganismInfo> trackInfoList = dataProvider.getList();

    ColumnSortEvent.ListHandler<OrganismInfo> sortHandler =
        new ColumnSortEvent.ListHandler<OrganismInfo>(trackInfoList);
    dataGrid.addColumnSortHandler(sortHandler);
    sortHandler.setComparator(
        organismNameColumn,
        new Comparator<OrganismInfo>() {
          @Override
          public int compare(OrganismInfo o1, OrganismInfo o2) {
            return o1.getName().compareTo(o2.getName());
          }
        });
    sortHandler.setComparator(
        annotationsNameColumn,
        new Comparator<OrganismInfo>() {
          @Override
          public int compare(OrganismInfo o1, OrganismInfo o2) {
            return o1.getNumFeatures() - o2.getNumFeatures();
          }
        });
    sortHandler.setComparator(
        sequenceColumn,
        new Comparator<OrganismInfo>() {
          @Override
          public int compare(OrganismInfo o1, OrganismInfo o2) {
            return o1.getNumSequences() - o2.getNumSequences();
          }
        });
  }
예제 #27
0
  private void initTableColumns(
      SelectionModel<Supply> selectionModel, ListHandler<Supply> sortHandler) {

    // НОМЕР
    Column<Supply, String> supplyIdColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return Integer.toString(object.getSupplyId());
          }
        };
    supplyIdColumn.setSortable(true);
    sortHandler.setComparator(
        supplyIdColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            if (o1.getSupplyId() == o2.getSupplyId()) return 0;
            else if (o1.getSupplyId() > o2.getSupplyId()) return 1;
            else return -1;
          }
        });
    dataGrid.addColumn(supplyIdColumn, "Номер");
    dataGrid.setColumnWidth(supplyIdColumn, 30, Unit.PX);

    // ТИП
    Column<Supply, String> typeColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            if ("1".equals(object.getDeliveryDirection())) return "В филиал";
            else if ("0".equals(object.getDeliveryDirection())) return "На склад";
            else return "Ошибка!";
          }
        };
    typeColumn.setSortable(true);
    sortHandler.setComparator(
        typeColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getDeliveryDirection().compareTo(o2.getDeliveryDirection());
          }
        });
    dataGrid.addColumn(typeColumn, "Направление");
    dataGrid.setColumnWidth(typeColumn, 50, Unit.PX);

    // ДАТА ПОСТАВКИ
    // если сроки нарушены, то показывается актуальная дата!
    Column<Supply, String> dateColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            DateTimeFormat dateFormat = DateTimeFormat.getFormat("yyyy-MM-dd");
            if (object.getDateFact() != null) return dateFormat.format(object.getDateFact());
            else return dateFormat.format(object.getDateOk());
          }
        };
    dateColumn.setSortable(true);
    sortHandler.setComparator(
        dateColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getDateOk().compareTo(o2.getDateOk());
          }
        });
    dataGrid.addColumn(dateColumn, "Дата доставки");
    dataGrid.setColumnWidth(dateColumn, 70, Unit.PX);

    // СТАТУС
    Column<Supply, String> statusColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return StatusDict.getType(object.getStatus().getStatusCode());
          }
        };
    statusColumn.setSortable(true);
    sortHandler.setComparator(
        statusColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            if (o1.getStatus().getStatusCode() == o2.getStatus().getStatusCode()) return 0;
            else if (o1.getStatus().getStatusCode() == o2.getStatus().getStatusCode()) return -1;
            return 1;
          }
        });
    dataGrid.addColumn(statusColumn, "Статус доставки");
    dataGrid.setColumnWidth(statusColumn, 70, Unit.PX);

    // НОМЕР НАКЛАДНОЙ
    Column<Supply, String> nakladNumColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return object.getNakladNum();
          }
        };
    nakladNumColumn.setSortable(true);
    sortHandler.setComparator(
        nakladNumColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getNakladNum().compareTo(o2.getNakladNum());
          }
        });
    dataGrid.addColumn(nakladNumColumn, "Накладная");
    dataGrid.setColumnWidth(nakladNumColumn, 50, Unit.PX);

    // АДРЕС
    Column<Supply, String> addressColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return object.getAddress();
          }
        };
    addressColumn.setSortable(true);
    sortHandler.setComparator(
        addressColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getAddress().compareTo(o2.getAddress());
          }
        });
    dataGrid.addColumn(addressColumn, "Адрес");
    // если направление - со склада к филиалу, то Адрес кликабелен
    dataGrid.setColumnWidth(addressColumn, 70, Unit.PX);

    // КОНТРАГЕНТЫ
    Column<Supply, String> kontrName =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return object.getKont().getName();
          }
        };
    kontrName.setSortable(true);
    sortHandler.setComparator(
        kontrName,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getKont().getName().compareTo(o2.getKont().getName());
          }
        });
    dataGrid.addColumn(kontrName, "Контрагент");
    // TODO: при нажании на название компании-контрагента - окошко с
    // информацией о т.к.
    dataGrid.setColumnWidth(kontrName, 50, Unit.PX);

    // ТРАНСПОРТНЫЕ КОМПАНИИ
    Column<Supply, String> transCompName =
        new Column<Supply, String>(new ClickableTextCell()) {
          @Override
          public String getValue(Supply object) {
            return object.getTk().getName();
          }
        };
    transCompName.setSortable(true);
    sortHandler.setComparator(
        transCompName,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getTk().getName().compareTo(o2.getTk().getName());
          }
        });
    transCompName.setFieldUpdater(
        new FieldUpdater<Supply, String>() {

          @Override
          public void update(int index, Supply object, String value) {
            final DialogBox dialogBox = new DialogBox();
            TKDetailed tkDetailed = new TKDetailed(object.getTk());

            tkDetailed
                .getCancel()
                .addClickHandler(
                    new ClickHandler() {
                      public void onClick(ClickEvent event) {
                        dialogBox.hide();
                      }
                    });

            dialogBox.setAnimationEnabled(true);
            dialogBox.setWidget(tkDetailed);

            dialogBox.center();
          }
        });
    dataGrid.addColumn(transCompName, "Транспортная компания");
    // TODO: при нажании на название ТК - окошко с информацией о ТК
    dataGrid.setColumnWidth(transCompName, 70, Unit.PX);

    // Кнопка редактиварония
    Column<Supply, String> buttonColumn =
        new Column<Supply, String>(new ButtonCell()) {
          @Override
          public String getValue(Supply object) {
            return " ... ";
          }
        };
    buttonColumn.setFieldUpdater(
        new FieldUpdater<Supply, String>() {

          @Override
          public void update(int index, Supply object, String value) {
            final DialogBox dialogBox = new DialogBox();
            FlowPanel flowPanel = new FlowPanel();
            flowPanel.setHeight("100px");
            flowPanel.setWidth("100px");
            flowPanel.add(new HTML("Id = " + object.getSupplyId()));
            final Button closeButton = new Button("Закрыть");
            flowPanel.add(closeButton);
            dialogBox.setAnimationEnabled(true);
            dialogBox.setWidget(flowPanel);

            // Add a handler to close the DialogBox
            closeButton.addClickHandler(
                new ClickHandler() {
                  public void onClick(ClickEvent event) {
                    dialogBox.hide();
                  }
                });
            dialogBox.center();
          }
        });
    dataGrid.addColumn(buttonColumn, "");
    dataGrid.setColumnWidth(buttonColumn, 50, Unit.PX);
  }
예제 #28
0
  @Override
  public void initTableColumns(DataGrid<T> dataGrid, ListHandler<T> sortHandler) {

    // ------------------------- Last Name ----------------------------------
    final Column<T, String> lastNameColumn =
        new Column<T, String>(new TextCell()) {

          @Override
          public String getValue(T object) {
            return ((UserInfoGwt) object).getLastName();
          }
        };
    lastNameColumn.setSortable(true);
    sortHandler.setComparator(
        lastNameColumn,
        new Comparator<T>() {

          @Override
          public int compare(T o1, T o2) {
            return ((UserInfoGwt) o1).getLastName().compareTo(((UserInfoGwt) o2).getLastName());
          }
        });
    dataGrid.addColumn(lastNameColumn, "Last Name");
    dataGrid.setColumnWidth(lastNameColumn, "50px");

    // ------------------------- First Name ---------------------------------
    final Column<T, String> firstNameColumn =
        new Column<T, String>(new TextCell()) {

          @Override
          public String getValue(T object) {
            return ((UserInfoGwt) object).getFirstName();
          }
        };
    firstNameColumn.setSortable(true);
    sortHandler.setComparator(
        firstNameColumn,
        new Comparator<T>() {

          @Override
          public int compare(T o1, T o2) {
            return ((UserInfoGwt) o1).getFirstName().compareTo(((UserInfoGwt) o2).getFirstName());
          }
        });
    dataGrid.addColumn(firstNameColumn, "First Name");
    dataGrid.setColumnWidth(firstNameColumn, "50px");

    // --------------------------- User ID ----------------------------------
    final Column<T, String> userIdColumn =
        new Column<T, String>(new TextCell()) {

          @Override
          public String getValue(T object) {
            return ((UserInfoGwt) object).getUserName();
          }
        };
    userIdColumn.setSortable(true);
    sortHandler.setComparator(
        userIdColumn,
        new Comparator<T>() {

          @Override
          public int compare(T o1, T o2) {
            return ((UserInfoGwt) o1).getUserName().compareTo(((UserInfoGwt) o2).getUserName());
          }
        });
    dataGrid.addColumn(userIdColumn, "User ID");
    dataGrid.setColumnWidth(userIdColumn, "50px");
  }
예제 #29
0
  /**
   * Returns the table with member-users
   *
   * @return CellTable widget
   */
  public CellTable<User> getTable() {

    // Retrieves data
    this.retrieveData();

    // Table data provider.
    dataProvider = new ListDataProvider<User>(list);

    // Cell table
    table = new PerunTable<User>(list);

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    if (entity.equals(PerunEntity.VIRTUAL_ORGANIZATION)) {
      loaderImage.setEmptyResultMessage("VO has no managers (try to switch to 'Groups' view).");
    } else if (entity.equals(PerunEntity.GROUP)) {
      loaderImage.setEmptyResultMessage("Group has no managers (try to switch to 'Groups' view).");
    } else if (entity.equals(PerunEntity.FACILITY)) {
      loaderImage.setEmptyResultMessage(
          "Facility has no managers (try to switch to 'Groups' view).");
    } else if (entity.equals(PerunEntity.SECURITY_TEAM)) {
      loaderImage.setEmptyResultMessage(
          "SecurityTeam has no members (try to switch to 'Groups' view).");
    }

    // Sorting
    ListHandler<User> columnSortHandler = new ListHandler<User>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // Table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<User>createCheckboxManager());

    // Set empty content & loader
    table.setEmptyTableWidget(loaderImage);

    // Checkbox column column
    if (checkable) {
      table.addCheckBoxColumn();
    }

    // Create User ID column.
    Column<User, String> userIdColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<User, String>() {
              public String getValue(User object) {
                return String.valueOf(object.getId());
              }
            },
            this.tableFieldUpdater);

    userIdColumn.setSortable(true);
    columnSortHandler.setComparator(
        userIdColumn, new GeneralComparator<User>(GeneralComparator.Column.ID));

    table.setColumnWidth(userIdColumn, 110.0, Unit.PX);

    if (JsonUtils.isExtendedInfoVisible()) {
      table.addColumn(userIdColumn, "User ID");
    }

    table.setHyperlinksAllowed(false);
    table.addNameColumn(tableFieldUpdater);

    // Create organization column.
    Column<User, String> organizationColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<User, String>() {
              public String getValue(User object) {
                Attribute at = object.getAttribute("urn:perun:user:attribute-def:def:organization");
                if (at != null
                    && at.getValue() != null
                    && !"null".equalsIgnoreCase(at.getValue())) {
                  return at.getValue();
                }
                return "";
              }
            },
            this.tableFieldUpdater);

    // Create e-mail column.
    Column<User, String> emailColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<User, String>() {
              public String getValue(User object) {
                Attribute at =
                    object.getAttribute("urn:perun:user:attribute-def:def:preferredMail");
                if (at != null
                    && at.getValue() != null
                    && !"null".equalsIgnoreCase(at.getValue())) {
                  return at.getValue().replace(",", " ");
                }
                return "";
              }
            },
            this.tableFieldUpdater);

    // Create name column.
    Column<User, String> loginsColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<User, String>() {
              public String getValue(User object) {
                return object.getLogins();
              }
            },
            this.tableFieldUpdater);

    organizationColumn.setSortable(true);
    columnSortHandler.setComparator(
        organizationColumn, new RichUserComparator(RichUserComparator.Column.ORGANIZATION));

    emailColumn.setSortable(true);
    columnSortHandler.setComparator(
        emailColumn, new RichUserComparator(RichUserComparator.Column.EMAIL));

    // Add the other columns.
    table.addColumn(organizationColumn, "Organization");
    table.addColumn(emailColumn, "E-mail");
    table.addColumn(loginsColumn, "Logins");

    return table;
  }