private void buildTable(int pageSize) {
    CellTable.Resources resources = GWT.create(TableResources.class);

    cellTable = new CellTable<SearchResultRow>(pageSize, resources);
    cellTable.setWidth("100%", true);
    // Initialize columns
    for (int i = 0; i < this.fieldDescs.size(); i++) {
      SearchResultFieldDesc desc = this.fieldDescs.get(i);
      if (desc.getTableDisplay() != TableDisplay.MANDATORY) {
        continue;
      }
      final int index = i;
      TextColumn<SearchResultRow> col =
          new TextColumn<SearchResultRow>() {
            @Override
            public String getValue(SearchResultRow data) {
              if (data == null) {
                return "";
              } else {
                return data.getField(index);
              }
            }
          };
      col.setSortable(desc.getSortable());
      cellTable.addColumn(col, desc.getTitle());
      cellTable.setColumnWidth(col, desc.getWidth());
      tableColIdx.add(i);
    }

    cellTable.setSelectionModel(selectionModel);
  }
  @SuppressWarnings("unchecked")
  @Override
  protected void createColumns(
      DefaultCellTable<ArtifactReference> table, ListDataProvider<ArtifactReference> dataProvider) {
    final TextColumn<ArtifactReference> nameColumn =
        new TextColumn<ArtifactReference>() {
          @Override
          public String getValue(ArtifactReference reference) {
            return reference.getName();
          }
        };
    nameColumn.setSortable(true);

    final TextColumn<ArtifactReference> urlColumn =
        new TextColumn<ArtifactReference>() {
          @Override
          public String getValue(ArtifactReference reference) {
            return reference.getUrl();
          }
        };
    urlColumn.setSortable(true);

    ColumnSortEvent.ListHandler<ArtifactReference> sortHandler =
        new ColumnSortEvent.ListHandler<ArtifactReference>(dataProvider.getList());
    sortHandler.setComparator(nameColumn, createColumnCommparator(nameColumn));
    sortHandler.setComparator(urlColumn, createColumnCommparator(urlColumn));

    table.addColumn(nameColumn, "Name");
    table.addColumn(urlColumn, "URL");
    table.addColumnSortHandler(sortHandler);

    table.addColumnSortHandler(sortHandler);
    table.getColumnSortList().push(urlColumn);
    table.getColumnSortList().push(nameColumn);
  }
Esempio n. 3
0
  @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");
  }
Esempio n. 4
0
  private TextColumn<FileSystemItem> addModifiedColumn() {
    TextColumn<FileSystemItem> modColumn =
        new TextColumn<FileSystemItem>() {
          public String getValue(FileSystemItem file) {
            if (!file.isDirectory()) return StringUtil.formatDate(file.getLastModified());
            else return new String();
          }
        };
    modColumn.setSortable(true);
    filesDataGrid_.addColumn(modColumn, "Modified");
    filesDataGrid_.setColumnWidth(modColumn, MODIFIED_COLUMN_WIDTH_PIXELS, Unit.PX);

    sortHandler_.setComparator(
        modColumn,
        new FoldersOnBottomComparator() {
          @Override
          public int doItemCompare(FileSystemItem arg0, FileSystemItem arg1) {
            return arg0.getLastModified().compareTo(arg1.getLastModified());
          }
        });

    return modColumn;
  }
Esempio n. 5
0
  private TextColumn<FileSystemItem> addSizeColumn() {
    TextColumn<FileSystemItem> sizeColumn =
        new TextColumn<FileSystemItem>() {
          public String getValue(FileSystemItem file) {
            if (!file.isDirectory()) return StringUtil.formatFileSize(file.getLength());
            else return new String();
          }
        };
    sizeColumn.setSortable(true);
    filesDataGrid_.addColumn(sizeColumn, "Size");
    filesDataGrid_.setColumnWidth(sizeColumn, SIZE_COLUMN_WIDTH_PIXELS, Unit.PX);

    sortHandler_.setComparator(
        sizeColumn,
        new FoldersOnBottomComparator() {
          @Override
          public int doItemCompare(FileSystemItem arg0, FileSystemItem arg1) {
            return new Long(arg0.getLength()).compareTo(new Long(arg1.getLength()));
          }
        });

    return sizeColumn;
  }
  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());
  }
  @Override
  protected void createColumns(
      DefaultCellTable<Transformer> table, ListDataProvider<Transformer> dataProvider) {
    TextColumn<Transformer> fromColumn =
        new TextColumn<Transformer>() {
          @Override
          public String getValue(Transformer transform) {
            return transform.getFrom();
          }
        };
    fromColumn.setSortable(true);

    TextColumn<Transformer> toColumn =
        new TextColumn<Transformer>() {
          @Override
          public String getValue(Transformer transform) {
            return transform.getTo();
          }
        };
    toColumn.setSortable(true);

    TextColumn<Transformer> typeColumn =
        new TextColumn<Transformer>() {
          @Override
          public String getValue(Transformer transform) {
            return transform.getType();
          }
        };
    typeColumn.setSortable(true);

    ColumnSortEvent.ListHandler<Transformer> sortHandler =
        new ColumnSortEvent.ListHandler<Transformer>(dataProvider.getList());
    sortHandler.setComparator(fromColumn, createColumnCommparator(fromColumn));
    sortHandler.setComparator(toColumn, createColumnCommparator(toColumn));
    sortHandler.setComparator(typeColumn, createColumnCommparator(typeColumn));

    table.addColumn(fromColumn, "From");
    table.addColumn(toColumn, "To");
    table.addColumn(typeColumn, "Type");

    table.addColumnSortHandler(sortHandler);
    table.getColumnSortList().push(typeColumn);
    table.getColumnSortList().push(toColumn);
    table.getColumnSortList().push(fromColumn);

    table.setWidth("100%", false);
    table.setColumnWidth(fromColumn, 45, Style.Unit.PCT);
    table.setColumnWidth(toColumn, 45, Style.Unit.PCT);
    table.setColumnWidth(typeColumn, 10, Style.Unit.PCT);
  }
Esempio n. 8
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");
  }
Esempio n. 9
0
  /**
   * The table that holds the basic friends list.
   *
   * @param result
   */
  private void setTable(GetLogResult result) {
    if (cellTable.getColumnCount() == 4) {
      dataList.clear();
      dataList = dataProvider.getList();
      for (GetLogType friend : result.getResults()) dataList.add(friend);
    } else {
      TextColumn<GetLogType> victimColumn =
          new TextColumn<GetLogType>() {
            @Override
            public String getValue(GetLogType log) {
              if (log.getFbVictimName() != null) return log.getFbVictimName();
              else return "";
            }
          };
      victimColumn.setSortable(true);

      TextColumn<GetLogType> commentPermalink =
          new TextColumn<GetLogType>() {
            @Override
            public String getValue(GetLogType log) {
              if (log.getFbCommentPermalink() != null) return log.getFbCommentPermalink();
              else return "";
            }
          };
      commentPermalink.setSortable(true);

      TextColumn<GetLogType> comment =
          new TextColumn<GetLogType>() {
            @Override
            public String getValue(GetLogType log) {
              if (log.getFbComment() != null) return log.getFbComment();
              else return "";
            }
          };
      comment.setSortable(true);

      TextColumn<GetLogType> date =
          new TextColumn<GetLogType>() {
            @Override
            public String getValue(GetLogType log) {
              if (log.getDate() != null) return log.getDate().toString();
              else return "";
            }
          };
      date.setSortable(true);

      cellTable.addColumn(victimColumn, "Name");
      cellTable.addColumn(commentPermalink, "Comment Link");
      cellTable.addColumn(comment, "Comment Text");
      cellTable.addColumn(date, "Time");

      // Fix column sizes for stupid facebook
      cellTable.setWidth("675px", true);
      cellTable.setColumnWidth(victimColumn, 10.0, Unit.PCT);
      cellTable.setColumnWidth(commentPermalink, 40.0, Unit.PCT);
      cellTable.setColumnWidth(comment, 40.0, Unit.PCT);
      cellTable.setColumnWidth(date, 10.0, Unit.PCT);

      // Attach provider
      dataProvider.addDataDisplay(cellTable);
      dataList = dataProvider.getList();
      for (GetLogType friend : result.getResults()) dataList.add(friend);

      // Set row count
      cellTable.setRowCount(dataList.size());
      cellTable.setPageSize(20);

      ListHandler<GetLogType> columnSortHandler = new ListHandler<GetLogType>(dataList);
      columnSortHandler.setComparator(
          victimColumn,
          new Comparator<GetLogType>() {

            @Override
            public int compare(GetLogType o1, GetLogType o2) {
              if (o1 == o2) {
                return 0;
              }

              // Compare the name columns.
              if (o1 != null) {
                return (o2 != null) ? o1.getFbVictimName().compareTo(o2.getFbVictimName()) : 1;
              }
              return -1;
            }
          });

      columnSortHandler.setComparator(
          commentPermalink,
          new Comparator<GetLogType>() {

            @Override
            public int compare(GetLogType o1, GetLogType o2) {
              if (o1 == o2) {
                return 0;
              }

              // Compare the role columns.
              if (o1 != null) {
                return (o2 != null)
                    ? o1.getFbCommentPermalink().compareTo(o2.getFbCommentPermalink())
                    : 1;
              }
              return -1;
            }
          });

      columnSortHandler.setComparator(
          comment,
          new Comparator<GetLogType>() {
            @Override
            public int compare(GetLogType o1, GetLogType o2) {
              if (o1 == o2) {
                return 0;
              }

              // Compare the role columns.
              if (o1 != null) {
                return (o2 != null) ? o1.getFbComment().compareTo(o2.getFbComment()) : 1;
              }
              return -1;
            }
          });

      columnSortHandler.setComparator(
          date,
          new Comparator<GetLogType>() {

            @Override
            public int compare(GetLogType o1, GetLogType o2) {
              if (o1 == o2) {
                return 0;
              }

              // Compare the role columns.
              if (o1 != null) {
                return (o2 != null) ? o1.getDate().compareTo(o2.getDate()) : 1;
              }
              return -1;
            }
          });

      cellTable.addColumnSortHandler(columnSortHandler);
      cellTable.getColumnSortList().push(date);
      cellTable.setPageSize(5000);
    }
  }
  /**
   * Returns table with publications
   *
   * @return table
   */
  public CellTable<Publication> getEmptyTable() {

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

    // Cell table
    table = new PerunTable<Publication>(list);
    table.removeRowCountChangeHandler();
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

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

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

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

    // set empty content & loader
    table.setEmptyTableWidget(
        loaderImage.prepareToSearch(
            "Please select external pub. system and year range to search for publications for import."));

    // show checkbox column
    if (this.checkable) {
      table.addCheckBoxColumn();
    }

    /*
    // CATEGORY COLUMN
    ArrayList<String> categories = new ArrayList<String>();
    categories.add("Bodované v RIVu");
    categories.add("Nebodované v RIVu");
    categories.add("Příspěvek do ročenky");
    categories.add("Výjimečné výsledky");
    categories.add("Jiné");

    Column<Publication, String> categoryColumn = new Column<Publication, String>(new SelectionCell(categories)){
    	@Override
    	public String getValue(Publication object) {
    		// category ID as string, 0 if not set
    		int id = object.getCategoryId();
    		if (id == 0) {
    			// set default == 21/Bodované v RIVu to object
    			object.setCategoryId(21);
    		}
    		if (id == 21) {
    			return "Bodované v RIVu";
    		} else if (id == 22) {
    			return "Nebodované v RIVu";
    		} else if (id == 23) {
    			return "Výjimečné výsledky";
    		} else if (id == 24) {
    			return "Příspěvek do ročenky";
    		} else if (id == 25) {
    			return "Jiné";
    		} else {
    			return String.valueOf(id); // return ID if no match
    		}
    	}
    };
    categoryColumn.setFieldUpdater(new FieldUpdater<Publication, String>() {
    	public void update(int index, Publication object, String value) {

    		int id = 0;
    		if (value.equalsIgnoreCase("Bodované v RIVu")) {
    			id = 21;
    		} else if (value.equalsIgnoreCase("Nebodované v RIVu")) {
    			id = 22;
    		} else if (value.equalsIgnoreCase("Příspěvek do ročenky")) {
    			id = 24;
    		} else if (value.equalsIgnoreCase("Výjimečné výsledky")) {
    			id = 23;
    		} else if (value.equalsIgnoreCase("Jiné")) {
    			id = 25;
    		}
    		object.setCategoryId(id);
    		selectionModel.setSelected(object, true);

    	}
    });
    table.addColumn(categoryColumn, "Category");

    // NOT USEFULL => DISABLED
    // EXTERNAL ID
    TextColumn<Publication> externalIdColumn = new TextColumn<Publication>() {
    	public String getValue(Publication object) {
    		return String.valueOf(object.getExternalId());
    	};
    };
    externalIdColumn.setSortable(true);
    columnSortHandler.setComparator(externalIdColumn, new PublicationComparator(PublicationComparator.Column.EXTERNAL_ID));
    table.addColumn(externalIdColumn, "External Id");
     */

    // TITLE COLUMN
    TextColumn<Publication> titleColumn =
        new TextColumn<Publication>() {
          public String getValue(Publication object) {
            return object.getTitle();
          };
        };
    titleColumn.setSortable(true);
    columnSortHandler.setComparator(
        titleColumn, new PublicationComparator(PublicationComparator.Column.TITLE));
    table.addColumn(titleColumn, "Title");

    // AUTHORS COLUMN
    TextColumn<Publication> authorColumn =
        new TextColumn<Publication>() {
          public String getValue(Publication object) {
            return object.getAuthorsFormatted();
          };
        };
    authorColumn.setSortable(true);
    columnSortHandler.setComparator(
        authorColumn, new PublicationComparator(PublicationComparator.Column.AUTHORS));
    table.addColumn(authorColumn, "Authors");

    // YEAR COLUMN
    TextColumn<Publication> yearColumn =
        new TextColumn<Publication>() {
          public String getValue(Publication object) {
            return String.valueOf(object.getYear());
          };
        };
    yearColumn.setSortable(true);
    columnSortHandler.setComparator(
        yearColumn, new PublicationComparator(PublicationComparator.Column.YEAR));
    table.addColumn(yearColumn, "Year");

    // ISBN COLUMN
    TextColumn<Publication> isbnColumn =
        new TextColumn<Publication>() {
          public String getValue(Publication object) {
            return object.getIsbn();
          };
        };
    isbnColumn.setSortable(true);
    columnSortHandler.setComparator(
        isbnColumn, new PublicationComparator(PublicationComparator.Column.ISBN));
    table.addColumn(isbnColumn, "ISBN");

    // CITE COLUMN
    Column<Publication, String> citaceColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<Publication, String>() {
              public String getValue(Publication object) {
                return "Cite";
              }
            },
            new FieldUpdater<Publication, String>() {
              public void update(int index, Publication object, String value) {
                SimplePanel sp = new SimplePanel();
                sp.add(new HTML(object.getMain()));
                Confirm cf = new Confirm("Cite publication", sp, true);
                cf.show();
              };
            });

    table.addColumn(citaceColumn, "Cite");

    return table;
  }
Esempio n. 11
0
  public DataObjectBrowser() {
    initWidget(uiBinder.createAndBindUi(this));

    objectButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            selectCurrentObject(true);
          }
        });

    dataObjectPropertiesProvider.setList(new ArrayList<ObjectProperty>());

    // Init data objects table

    dataObjectPropertiesTable.setEmptyTableWidget(
        new Label(Constants.INSTANCE.objectBrowser_emptyTable()));

    // Init property name column

    final TextColumn<ObjectProperty> propertyNameColumn =
        new TextColumn<ObjectProperty>() {

          @Override
          public void render(Cell.Context context, ObjectProperty object, SafeHtmlBuilder sb) {
            SafeHtml startDiv =
                new SafeHtml() {
                  @Override
                  public String asString() {
                    return "<div style=\"cursor: pointer;\">";
                  }
                };
            SafeHtml endDiv =
                new SafeHtml() {
                  @Override
                  public String asString() {
                    return "</div>";
                  }
                };

            sb.append(startDiv);
            super.render(context, object, sb);
            sb.append(endDiv);
          }

          @Override
          public String getValue(final ObjectProperty objectProperty) {
            return objectProperty.getName();
          }
        };

    propertyNameColumn.setSortable(true);
    dataObjectPropertiesTable.addColumn(
        propertyNameColumn, Constants.INSTANCE.objectBrowser_columnName());
    // dataObjectPropertiesTable.setColumnWidth(propertyNameColumn, 100, Style.Unit.PX);
    dataObjectPropertiesTable.setColumnWidth(propertyNameColumn, 30, Style.Unit.PCT);

    ColumnSortEvent.ListHandler<ObjectProperty> propertyNameColHandler =
        new ColumnSortEvent.ListHandler<ObjectProperty>(dataObjectPropertiesProvider.getList());
    propertyNameColHandler.setComparator(propertyNameColumn, new ObjectPropertyComparator("name"));
    dataObjectPropertiesTable.addColumnSortHandler(propertyNameColHandler);

    // Init property Label column

    final TextColumn<ObjectProperty> propertyLabelColumn =
        new TextColumn<ObjectProperty>() {

          @Override
          public void render(Cell.Context context, ObjectProperty object, SafeHtmlBuilder sb) {
            SafeHtml startDiv =
                new SafeHtml() {
                  @Override
                  public String asString() {
                    return "<div style=\"cursor: pointer;\">";
                  }
                };
            SafeHtml endDiv =
                new SafeHtml() {
                  @Override
                  public String asString() {
                    return "</div>";
                  }
                };

            sb.append(startDiv);
            super.render(context, object, sb);
            sb.append(endDiv);
          }

          @Override
          public String getValue(final ObjectProperty objectProperty) {
            return AnnotationValueHandler.getStringValue(
                objectProperty,
                MainDomainAnnotations.LABEL_ANNOTATION,
                MainDomainAnnotations.VALUE_PARAM);
          }
        };

    propertyLabelColumn.setSortable(true);
    dataObjectPropertiesTable.addColumn(
        propertyLabelColumn, Constants.INSTANCE.objectBrowser_columnLabel());
    dataObjectPropertiesTable.setColumnWidth(propertyLabelColumn, 30, Style.Unit.PCT);

    ColumnSortEvent.ListHandler<ObjectProperty> propertyLabelColHandler =
        new ColumnSortEvent.ListHandler<ObjectProperty>(dataObjectPropertiesProvider.getList());
    propertyNameColHandler.setComparator(
        propertyLabelColumn, new ObjectPropertyComparator("label"));
    dataObjectPropertiesTable.addColumnSortHandler(propertyLabelColHandler);

    // Init property type browsing column
    ClickableImageResourceCell typeImageCell = new ClickableImageResourceCell(true, 25);
    //        final TooltipCellDecorator<ImageResource> typeImageDecorator = new
    // TooltipCellDecorator<ImageResource>( typeImageCell );
    //        typeImageDecorator.setText(
    // Constants.INSTANCE.objectBrowser_action_goToDataObjectDefinition() );

    final Column<ObjectProperty, ImageResource> typeImageColumn =
        new Column<ObjectProperty, ImageResource>(typeImageCell) {
          @Override
          public ImageResource getValue(final ObjectProperty property) {

            if (!property.isBaseType()
                && !getDataObject().getClassName().equals(property.getClassName())
                && !getDataModel().isExternal(property.getClassName())) {
              return ImagesResources.INSTANCE.BrowseObject();
            } else {
              return null;
            }
          }
        };

    typeImageColumn.setFieldUpdater(
        new FieldUpdater<ObjectProperty, ImageResource>() {
          public void update(
              final int index, final ObjectProperty property, final ImageResource value) {

            onTypeCellSelection(property);
          }
        });

    dataObjectPropertiesTable.addColumn(typeImageColumn);

    // Init property type column
    final TextColumn<ObjectProperty> propertyTypeColumn =
        new TextColumn<ObjectProperty>() {

          @Override
          public void render(Cell.Context context, ObjectProperty object, SafeHtmlBuilder sb) {
            SafeHtml startDiv =
                new SafeHtml() {
                  @Override
                  public String asString() {
                    return "<div style=\"cursor: pointer;\">";
                  }
                };
            SafeHtml endDiv =
                new SafeHtml() {
                  @Override
                  public String asString() {
                    return "</div>";
                  }
                };

            sb.append(startDiv);
            super.render(context, object, sb);
            sb.append(endDiv);
          }

          @Override
          public String getValue(final ObjectProperty objectProperty) {
            return propertyTypeDisplay(objectProperty);
          }
        };
    propertyTypeColumn.setSortable(true);
    dataObjectPropertiesTable.addColumn(
        propertyTypeColumn, Constants.INSTANCE.objectBrowser_columnType());
    dataObjectPropertiesTable.setColumnWidth(propertyTypeColumn, 40, Style.Unit.PCT);

    // Init delete column
    final Column<ObjectProperty, String> deletePropertyColumnImg =
        new Column<ObjectProperty, String>(deleteCell) {
          @Override
          public String getValue(final ObjectProperty global) {
            return "Remove";
          }
        };

    deletePropertyColumnImg.setFieldUpdater(
        new FieldUpdater<ObjectProperty, String>() {
          public void update(final int index, final ObjectProperty property, final String value) {
            if (!isReadonly()) {
              checkAndDeleteDataObjectProperty(property, index);
            }
          }
        });

    dataObjectPropertiesTable.addColumn(deletePropertyColumnImg);

    ColumnSortEvent.ListHandler<ObjectProperty> propertyTypeColHandler =
        new ColumnSortEvent.ListHandler<ObjectProperty>(dataObjectPropertiesProvider.getList());
    propertyTypeColHandler.setComparator(
        propertyTypeColumn, new ObjectPropertyComparator("className"));
    dataObjectPropertiesTable.addColumnSortHandler(propertyTypeColHandler);

    dataObjectPropertiesTable.getColumnSortList().push(propertyNameColumn);

    // Init the selection model
    SingleSelectionModel<ObjectProperty> selectionModel =
        new SingleSelectionModel<ObjectProperty>();
    dataObjectPropertiesTable.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(
        new SelectionChangeEvent.Handler() {

          @Override
          public void onSelectionChange(SelectionChangeEvent event) {
            ObjectProperty selectedProperty =
                ((SingleSelectionModel<ObjectProperty>)
                        dataObjectPropertiesTable.getSelectionModel())
                    .getSelectedObject();
            notifyFieldSelected(selectedProperty);
          }
        });

    dataObjectPropertiesTable.setKeyboardSelectionPolicy(
        HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.BOUND_TO_SELECTION);

    dataObjectPropertiesTable.addCellPreviewHandler(
        new CellPreviewEvent.Handler<ObjectProperty>() {

          @Override
          public void onCellPreview(CellPreviewEvent<ObjectProperty> event) {
            if (showingObject && "click".equals(event.getNativeEvent().getType())) {
              int selectedRow = dataObjectPropertiesTable.getKeyboardSelectedRow();
              if (lastSelectedRow >= 0 && lastSelectedRow == selectedRow) {
                ObjectProperty selectedProperty =
                    dataObjectPropertiesProvider.getList().get(selectedRow);
                ((SingleSelectionModel<ObjectProperty>)
                        dataObjectPropertiesTable.getSelectionModel())
                    .setSelected(selectedProperty, true);
              }
              showingObject = false;
            }
          }
        });

    dataObjectPropertiesProvider.addDataDisplay(dataObjectPropertiesTable);
    dataObjectPropertiesProvider.refresh();

    newPropertyButton.setIcon(IconType.PLUS);

    setReadonly(true);
  }
Esempio n. 12
0
  /**
   * Returns empty table
   *
   * @return table widget
   */
  public CellTable<Destination> getEmptyTable() {

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

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

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

    if (showFac) {
      loaderImage.setEmptyResultMessage("Service has no destination.");
    } else {
      loaderImage.setEmptyResultMessage(
          "Facility has no services destinations. Service configuration can't be propagated.");
    }

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

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

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

    if (this.checkable) {
      table.addCheckBoxColumn();
    }

    // add id column
    table.addIdColumn("Destination ID", null);

    // DESTINATION COLUMN
    TextColumn<Destination> destinationColumn =
        new TextColumn<Destination>() {
          public String getValue(Destination object) {
            return object.getDestination();
          }
        };

    // TYPE COLUMN
    TextColumn<Destination> typeColumn =
        new TextColumn<Destination>() {
          public String getValue(Destination object) {
            return object.getType().toUpperCase();
          }
        };

    // SERVICE COLUMN
    TextColumn<Destination> serviceColumn =
        new TextColumn<Destination>() {
          public String getValue(Destination object) {
            return object.getService().getName();
          }
        };

    // FACILITY COLUMN
    TextColumn<Destination> facilityColumn =
        new TextColumn<Destination>() {
          public String getValue(Destination object) {
            return object.getFacility().getName();
          }
        };

    destinationColumn.setSortable(true);
    columnSortHandler.setComparator(
        destinationColumn,
        new Comparator<Destination>() {
          public int compare(Destination o1, Destination o2) {
            return o1.getDestination().compareToIgnoreCase(o2.getDestination());
          }
        });

    typeColumn.setSortable(true);
    columnSortHandler.setComparator(
        typeColumn,
        new Comparator<Destination>() {
          public int compare(Destination o1, Destination o2) {
            return o1.getType().compareToIgnoreCase(o2.getType());
          }
        });

    serviceColumn.setSortable(true);
    columnSortHandler.setComparator(
        serviceColumn,
        new Comparator<Destination>() {
          public int compare(Destination o1, Destination o2) {
            return o1.getService().getName().compareToIgnoreCase(o2.getService().getName());
          }
        });

    facilityColumn.setSortable(true);
    columnSortHandler.setComparator(
        facilityColumn,
        new Comparator<Destination>() {
          public int compare(Destination o1, Destination o2) {
            return o1.getFacility().getName().compareToIgnoreCase(o2.getFacility().getName());
          }
        });

    // updates the columns size
    table.setColumnWidth(serviceColumn, 250.0, Unit.PX);
    table.setColumnWidth(facilityColumn, 250.0, Unit.PX);

    // Add the columns.

    if (showServ) {
      table.addColumn(serviceColumn, "Service");
    }
    if (showFac) {
      table.addColumn(facilityColumn, "Facility");
    }

    table.addColumn(destinationColumn, "Destination");
    table.addColumn(typeColumn, "Type");

    return table;
  }
Esempio n. 13
0
  // ------------------------------------------------------------------------
  //  CREATION OF ANNOTATIONS OF VARIOUS KIND
  // ------------------------------------------------------------------------
  public ComponentsPanel(IDomeo domeo, PluginsViewerPanel parent) {
    _domeo = domeo;
    _parent = parent;
    // _resources = resources;
    // _listPanel = new LogListPanel(_application);

    // Create layout
    initWidget(binder.createAndBindUi(this));
    this.setWidth((Window.getClientWidth() - 140) + "px");

    // Create a CellTable.
    final CellTable<PluginCard> table = new CellTable<PluginCard>();

    // Create name column.
    TextColumn<PluginCard> nameColumn =
        new TextColumn<PluginCard>() {
          @Override
          public String getValue(PluginCard pluginCard) {
            return pluginCard.name;
          }
        };

    // Make the name column sortable.
    nameColumn.setSortable(true);

    // Create type column.
    TextColumn<PluginCard> typeColumn =
        new TextColumn<PluginCard>() {
          @Override
          public String getValue(PluginCard pluginCard) {
            return pluginCard.type;
          }
        };
    typeColumn.setSortable(true);

    // Create sub type column.
    TextColumn<PluginCard> subTypeColumn =
        new TextColumn<PluginCard>() {
          @Override
          public String getValue(PluginCard pluginCard) {
            return pluginCard.subType;
          }
        };

    // Create sub type column.
    TextColumn<PluginCard> versionColumn =
        new TextColumn<PluginCard>() {
          @Override
          public String getValue(PluginCard pluginCard) {
            return pluginCard.version;
          }
        };

    // Add the columns.
    table.addColumn(typeColumn, "Type");
    table.addColumn(subTypeColumn, "Sub Type");
    table.addColumn(nameColumn, "Name");
    table.addColumn(versionColumn, "Version");

    // Create a data provider.
    ListDataProvider<PluginCard> dataProvider = new ListDataProvider<PluginCard>();

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

    // Add the data to the data provider, which automatically pushes it to the
    // widget.
    List<PluginCard> list = dataProvider.getList();
    for (APlugin plugin : _domeo.getPluginsManager().getPluginsList()) {
      if (plugin.getMandatory()) {
        PluginCard pluginCard =
            new PluginCard(
                plugin.getPluginName(),
                plugin.getType(),
                plugin.getSubType(),
                plugin.getVersion(),
                true,
                true);
        list.add(pluginCard);
      }
    }

    ListHandler<PluginCard> nameColumnSortHandler = new ListHandler<PluginCard>(list);
    nameColumnSortHandler.setComparator(
        nameColumn,
        new Comparator<PluginCard>() {
          public int compare(PluginCard o1, PluginCard o2) {
            if (o1 == o2) {
              return 0;
            }

            // Compare the name columns.
            if (o1 != null) {
              return (o2 != null) ? o1.name.compareTo(o2.name) : 1;
            }
            return -1;
          }
        });
    table.addColumnSortHandler(nameColumnSortHandler);

    ListHandler<PluginCard> typeColumnSortHandler = new ListHandler<PluginCard>(list);
    typeColumnSortHandler.setComparator(
        typeColumn,
        new Comparator<PluginCard>() {
          public int compare(PluginCard o1, PluginCard o2) {
            if (o1 == o2) {
              return 0;
            }

            // Compare the name columns.
            if (o1 != null) {
              return (o2 != null) ? o1.type.compareTo(o2.type) : 1;
            }
            return -1;
          }
        });
    table.addColumnSortHandler(typeColumnSortHandler);

    componentsPanel.add(table);
  }
Esempio n. 14
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");
  }
  /**
   * Return table definition
   *
   * @return table widget
   */
  public CellTable<TaskResult> getEmptyTable() {

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

    // Cell table
    table = new PerunTable<TaskResult>(list);
    table.removeRowCountChangeHandler();

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

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

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

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

    table.addIdColumn("Result Id", null, 85);

    // destination column
    TextColumn<TaskResult> destinationColumn =
        new TextColumn<TaskResult>() {
          @Override
          public String getValue(TaskResult object) {
            return String.valueOf(object.getDestination().getDestination());
          }
        };

    destinationColumn.setSortable(true);
    columnSortHandler.setComparator(
        destinationColumn,
        new Comparator<TaskResult>() {
          public int compare(TaskResult o1, TaskResult o2) {
            return o1.getDestination()
                .getDestination()
                .compareToIgnoreCase((o2.getDestination().getDestination()));
          }
        });

    // Type column
    TextColumn<TaskResult> typeColumn =
        new TextColumn<TaskResult>() {
          @Override
          public String getValue(TaskResult object) {
            return String.valueOf(object.getDestination().getType());
          }
        };

    typeColumn.setSortable(true);
    columnSortHandler.setComparator(
        typeColumn,
        new Comparator<TaskResult>() {
          public int compare(TaskResult o1, TaskResult o2) {
            return o1.getDestination().getType().compareToIgnoreCase(o2.getDestination().getType());
          }
        });

    TextColumn<TaskResult> servColumn =
        new TextColumn<TaskResult>() {
          @Override
          public String getValue(TaskResult taskResult) {
            return taskResult.getService().getName();
          }
        };
    servColumn.setSortable(true);
    columnSortHandler.setComparator(
        servColumn,
        new Comparator<TaskResult>() {
          public int compare(TaskResult o1, TaskResult o2) {
            return o1.getService().getName().compareToIgnoreCase(o2.getService().getName());
          }
        });

    // status column
    TextColumn<TaskResult> statusColumn =
        new TextColumn<TaskResult>() {
          @Override
          public String getValue(TaskResult object) {
            return String.valueOf(object.getStatus());
          }
        };

    statusColumn.setSortable(true);
    columnSortHandler.setComparator(
        statusColumn,
        new Comparator<TaskResult>() {
          public int compare(TaskResult o1, TaskResult o2) {
            return o1.getStatus().compareToIgnoreCase(o2.getStatus());
          }
        });

    // time column
    TextColumn<TaskResult> timeColumn =
        new TextColumn<TaskResult>() {
          @Override
          public String getValue(TaskResult object) {
            return object.getTimestamp();
          }
        };

    timeColumn.setSortable(true);
    columnSortHandler.setComparator(
        timeColumn,
        new Comparator<TaskResult>() {
          public int compare(TaskResult o1, TaskResult o2) {
            return o1.getTimestamp().compareToIgnoreCase(o2.getTimestamp());
          }
        });

    // returnCode column
    TextColumn<TaskResult> returnCodeColumn =
        new TextColumn<TaskResult>() {
          @Override
          public String getValue(TaskResult object) {
            return String.valueOf(object.getReturnCode());
          }
        };

    // standardMessageCode column
    TextColumn<TaskResult> standardMessageColumn =
        new TextColumn<TaskResult>() {
          @Override
          public void render(Context context, TaskResult object, SafeHtmlBuilder sb) {
            if (object != null) {
              sb.appendEscapedLines(object.getStandardMessage());
            }
          }

          @Override
          public String getValue(TaskResult object) {
            return String.valueOf(object.getStandardMessage());
          }
        };

    // errorMessageCode column
    TextColumn<TaskResult> errorMessageColumn =
        new TextColumn<TaskResult>() {
          @Override
          public void render(Context context, TaskResult object, SafeHtmlBuilder sb) {
            if (object != null) {
              sb.appendEscapedLines(object.getErrorMessage());
            }
          }

          @Override
          public String getValue(TaskResult object) {
            return String.valueOf(object.getErrorMessage());
          }
        };

    // Add the other columns.
    table.addColumn(destinationColumn, "Destination");
    table.addColumn(typeColumn, "Type");
    table.addColumn(servColumn, "Service");
    table.addColumn(statusColumn, "Status");
    table.addColumn(timeColumn, "Time");
    table.addColumn(returnCodeColumn, "Return code");
    table.addColumn(standardMessageColumn, "Standard Message");
    table.addColumn(errorMessageColumn, "Error Message");

    // set row styles based on task state
    table.setRowStyles(
        new RowStyles<TaskResult>() {
          public String getStyleNames(TaskResult row, int rowIndex) {

            if (row.getStatus().equalsIgnoreCase("DONE")) {
              return "rowgreen";
            } else if (row.getStatus().equalsIgnoreCase("DENIED")) {
              return "rowyellow";
            } else if (row.getStatus().equalsIgnoreCase("FATAL_ERROR")) {
              return "rowred";
            } else if (row.getStatus().equalsIgnoreCase("ERROR")) {
              return "roworange";
            }
            return "";
          }
        });

    return table;
  }
  public DialogListaPontoEncontro(
      final InfoCaronaServerAsync controller, final String idSessao, final String idCarona) {
    novosPontos = "";
    listaNovosPontosEncontros = new ArrayList<InfoPontoEncontro>();
    this.idCarona = idCarona;
    this.controller = controller;

    setText("Pontos de Encontro - ID: " + idCarona);
    setAnimationEnabled(true);
    setGlassEnabled(true);
    center();

    VerticalPanel panelListaPontoEncontro = new VerticalPanel();
    tabelaPontoEncontro = new CellTable<InfoPontoEncontro>();
    tabelaPontoEncontro.setWidth("400px");
    dataProvider = new ListDataProvider<InfoPontoEncontro>();

    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    SimplePager pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    pager.setDisplay(tabelaPontoEncontro);
    pager.setPageSize(5);

    TextColumn<InfoPontoEncontro> colunaIdPontoEncontro =
        new TextColumn<InfoPontoEncontro>() {
          @Override
          public String getValue(InfoPontoEncontro pontoEncontro) {
            return pontoEncontro.getIdPontoEncontro();
          }
        };

    TextColumn<InfoPontoEncontro> colunaPontosEncontro =
        new TextColumn<InfoPontoEncontro>() {
          @Override
          public String getValue(InfoPontoEncontro pontoEncontro) {
            return pontoEncontro.getPontoEncontro();
          }
        };

    tabelaPontoEncontro.addColumn(colunaPontosEncontro, "Pontos de Encontro");
    listaPontoEncontros = new ArrayList<InfoPontoEncontro>();
    populaTabela();

    HorizontalPanel hPanel01 = new HorizontalPanel();
    final TextBox boxNovoPontoEncontro = new TextBox();
    boxNovoPontoEncontro.setWidth("200px");
    boxNovoPontoEncontro.setStyleName("boxModificada");

    Button buttonAdicionarOutroPontoEncontro = new Button();
    buttonAdicionarOutroPontoEncontro.setStyleName("botaoModificado");
    buttonAdicionarOutroPontoEncontro.setTitle("Adicionar Sugestão");
    buttonAdicionarOutroPontoEncontro.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            if (boxNovoPontoEncontro.getText().trim().equals("")) {
              DialogMensagemUsuario dialogErro =
                  new DialogMensagemUsuario("Falhou", "Ponto de Encontro Inválido");
              dialogErro.show();
            } else {
              novosPontos += boxNovoPontoEncontro.getText().trim() + ";";
              InfoPontoEncontro novoPontoEncontro =
                  new InfoPontoEncontro("00", boxNovoPontoEncontro.getText().trim());
              boxNovoPontoEncontro.setText("");

              listaNovosPontosEncontros.add(novoPontoEncontro);
              listaPontoEncontros = new ArrayList<InfoPontoEncontro>();

              for (InfoPontoEncontro novoPonto : listaNovosPontosEncontros) {
                listaPontoEncontros.add(novoPonto);
              }

              populaTabela();
            }
          }
        });

    Image imageFiltro = new Image("imagens/adicionar.png");
    imageFiltro.setSize("15px", "15px");
    buttonAdicionarOutroPontoEncontro.getElement().appendChild(imageFiltro.getElement());

    Button buttonSalvarNovosPontos = new Button("Salvar");
    buttonSalvarNovosPontos.setStyleName("botaoModificado");
    buttonSalvarNovosPontos.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            controller.cadastrarNovosPontosEncontro(
                idSessao,
                idCarona,
                novosPontos,
                new AsyncCallback<String>() {

                  @Override
                  public void onFailure(Throwable caught) {
                    DialogMensagemUsuario dialogSucess =
                        new DialogMensagemUsuario("Erro", caught.getMessage());
                    dialogSucess.show();
                  }

                  @Override
                  public void onSuccess(String result) {
                    DialogMensagemUsuario dialogSucess =
                        new DialogMensagemUsuario(
                            "ID: " + result, "Pontos de Encontro Cadastrados com Sucesso!");
                    dialogSucess.show();
                    hide();
                  }
                });
          }
        });

    Button buttonFechar = new Button("Fechar");
    buttonFechar.setStyleName("botaoModificado");

    buttonFechar.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            hide();
          }
        });

    colunaPontosEncontro.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);

    hPanel01.setCellVerticalAlignment(boxNovoPontoEncontro, HasVerticalAlignment.ALIGN_BOTTOM);
    hPanel01.setCellVerticalAlignment(buttonSalvarNovosPontos, HasVerticalAlignment.ALIGN_TOP);
    hPanel01.setCellVerticalAlignment(
        buttonAdicionarOutroPontoEncontro, HasVerticalAlignment.ALIGN_TOP);
    hPanel01.setCellVerticalAlignment(buttonFechar, HasVerticalAlignment.ALIGN_TOP);
    hPanel01.setCellHorizontalAlignment(boxNovoPontoEncontro, HasHorizontalAlignment.ALIGN_CENTER);
    hPanel01.setCellHorizontalAlignment(
        buttonSalvarNovosPontos, HasHorizontalAlignment.ALIGN_CENTER);
    hPanel01.setCellHorizontalAlignment(
        buttonAdicionarOutroPontoEncontro, HasHorizontalAlignment.ALIGN_CENTER);
    hPanel01.setCellHorizontalAlignment(buttonFechar, HasHorizontalAlignment.ALIGN_CENTER);
    hPanel01.setWidth("100%");
    hPanel01.setSpacing(6);

    hPanel01.add(boxNovoPontoEncontro);
    hPanel01.add(buttonAdicionarOutroPontoEncontro);
    hPanel01.add(buttonSalvarNovosPontos);
    hPanel01.add(buttonFechar);

    panelListaPontoEncontro.add(tabelaPontoEncontro);
    panelListaPontoEncontro.add(pager);
    panelListaPontoEncontro.add(hPanel01);

    panelListaPontoEncontro.setCellVerticalAlignment(
        tabelaPontoEncontro, HasVerticalAlignment.ALIGN_MIDDLE);
    panelListaPontoEncontro.setCellVerticalAlignment(pager, HasVerticalAlignment.ALIGN_MIDDLE);

    panelListaPontoEncontro.setCellHorizontalAlignment(
        tabelaPontoEncontro, HasHorizontalAlignment.ALIGN_CENTER);
    panelListaPontoEncontro.setCellHorizontalAlignment(pager, HasHorizontalAlignment.ALIGN_CENTER);
    panelListaPontoEncontro.setSpacing(8);

    setWidget(panelListaPontoEncontro);
  }
Esempio n. 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();
          }
        });
  }
  @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();
  }
Esempio n. 19
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();
          }
        });
  }