Ejemplo n.º 1
0
  public UpcomingEventsTab() {

    super("Upcoming Events");
    addEventHandlers();

    setLayout(new FitLayout());

    store = new GroupingStore<UpcomingEventModelData>();
    // store.add(TestData.getStocks());

    ColumnConfig country = new ColumnConfig("country", "Country", 30);
    ColumnConfig city = new ColumnConfig("city", "City", 20);
    ColumnConfig venueName = new ColumnConfig("venueName", "Venue Name", 20);
    ColumnConfig startDate = new ColumnConfig("startDate", "Start Date", 20);
    ColumnConfig street = new ColumnConfig("street", "Street", 20);
    startDate.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/y"));

    List<ColumnConfig> config = new ArrayList<ColumnConfig>();
    config.add(country);
    config.add(city);
    config.add(venueName);
    config.add(street);
    config.add(startDate);

    final ColumnModel cm = new ColumnModel(config);

    GroupingView view = new GroupingView();
    view.setShowGroupedColumn(false);
    view.setForceFit(true);
    view.setGroupRenderer(
        new GridGroupRenderer() {
          public String render(GroupColumnData data) {
            String f = cm.getColumnById(data.field).getHeader();
            String l = data.models.size() == 1 ? "Item" : "Items";
            return f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
          }
        });

    Grid<UpcomingEventModelData> grid = new Grid<UpcomingEventModelData>(store, cm);
    grid.setView(view);
    grid.setBorders(true);

    grid.addListener(
        Events.RowDoubleClick,
        new Listener<GridEvent<UpcomingEventModelData>>() {

          public void handleEvent(GridEvent<UpcomingEventModelData> be) {

            Window.open(be.getModel().getUrl(), "Events", "");
          }
        });
    grid.setStateful(true);
    grid.setAutoExpandColumn("city");
    grid.setLoadMask(true);
    // grid.setBorders(true);
    // grid.setStripeRows(true);
    add(grid);
  }
  public LatestVirtualReportItemsPanel() {
    setHeading("Virtual Level Monitoring");
    setLayout(new FitLayout());

    ToolBar toolBar = new ToolBar();
    Button reflesh = new Button("Refresh");
    reflesh.setIcon(IconHelper.createStyle("icon-email-add"));
    id = new TextField<String>();
    id.setFieldLabel("Virtual ID");
    id.setAllowBlank(false);
    toolBar.add(new LabelToolItem("Virtual ID: "));
    toolBar.add(id);
    toolBar.add(reflesh);
    setTopComponent(toolBar);
    reflesh.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            String virtualId = id.getValue();
            service = (MonitoringManagerWebServiceAsync) Registry.get("guiservice");
            service.getMonitoringResources(
                "virtual",
                virtualId,
                new AsyncCallback<List<MonitoringResource>>() {
                  public void onFailure(Throwable caught) {
                    Dispatcher.forwardEvent(MainEvents.Error, caught);
                  }

                  public void onSuccess(List<MonitoringResource> result) {
                    getVirtualStore().removeAll();
                    if (result.size() > 0) virtualStore.add(result);
                  }
                });
          }
        });

    virtualStore = new GroupingStore<MonitoringResource>();
    virtualStore.groupBy("resource_type");
    cm = new ColumnModel(OptimisResource.getColumnConfig());
    GroupingView view = new GroupingView();
    view.setShowGroupedColumn(true);
    view.setForceFit(true);
    view.setGroupRenderer(
        new GridGroupRenderer() {
          public String render(GroupColumnData data) {
            String f = cm.getColumnById(data.field).getHeader();
            String l = data.models.size() == 1 ? "Item" : "Items";
            return f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
          }
        });

    virtualGrid = new Grid<MonitoringResource>(virtualStore, cm);
    virtualGrid.setTitle(" Service Resources ");
    virtualGrid.setView(view);
    virtualGrid.setBorders(true);
    virtualGrid.getView().setForceFit(true);
    add(virtualGrid);
  }
Ejemplo n.º 3
0
  public void draw(DoneDrawingCallback callback) {
    removeAll();

    final List<ColumnConfig> cols = getColumns();

    final Map<String, RowData> group = getGroupsForRows();
    final Map<String, String> groupIDToName = new HashMap<String, String>();
    final GroupingStore<BaseModelData> store = new GroupingStore<BaseModelData>();
    for (RowData row : getRows()) {
      final BaseModelData model = new BaseModelData();
      model.set("id", row.getField("id"));
      model.set("lockid", row.getField("lockid"));
      for (ColumnConfig col : cols) model.set(col.getId(), row.getField(col.getId()));
      RowData gID = group.get(row.getField("id"));
      if (gID == null) {
        model.set("groupid", "none");
        model.set("groupidentifier", null);
        groupIDToName.put("none", "No Group Defined");
      } else {
        model.set("groupid", gID.get("groupid"));
        model.set("groupidentifier", gID.get("id"));
        groupIDToName.put(gID.get("groupid"), "Working Set: " + gID.get("groupname"));
      }

      store.add(model);
    }
    store.groupBy("groupid");

    final GroupingView view = new GroupingView();
    view.setShowGroupedColumn(false);
    view.setGroupRenderer(
        new GridGroupRenderer() {
          public String render(GroupColumnData data) {
            return groupIDToName.get(data.group);
          }
        });

    final GridSelectionModel<BaseModelData> sel = new GridSelectionModel<BaseModelData>();
    sel.setSelectionMode(SelectionMode.SINGLE);

    grid = new Grid<BaseModelData>(store, new ColumnModel(cols));
    grid.setSelectionModel(sel);
    grid.setView(view);
    grid.addListener(
        Events.RowClick,
        new Listener<GridEvent>() {
          public void handleEvent(GridEvent be) {
            if (groupButton != null && be != null && be.getModel() != null)
              groupButton.setEnabled(be.getModel().get("groupidentifier") != null);
          }
        });
    // grid.setWidth(680);

    int size = 25;

    final LayoutContainer wrapper = new LayoutContainer();
    wrapper.setLayout(new FillLayout());
    // wrapper.setScrollMode(Scroll.ALWAYS);
    wrapper.add(grid);

    final LayoutContainer container = new LayoutContainer(new BorderLayout());
    container.setBorders(false);
    container.add(getToolBar(), new BorderLayoutData(LayoutRegion.SOUTH, size, size, size));
    container.add(wrapper, new BorderLayoutData(LayoutRegion.CENTER));

    add(container);

    callback.isDrawn();
  }
Ejemplo n.º 4
0
  @Override
  public Grid<ModelData> initGrid(ListStore<ModelData> store) {
    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    columns.add(configColumn(AdminUserBeanDesc.login, 380));
    ColumnConfig roleColumn = configColumn(AdminUserBeanDesc.role, 400);
    roleColumn.setRenderer(
        new GridCellRenderer<ModelData>() {

          public Object render(
              ModelData model,
              String property,
              com.extjs.gxt.ui.client.widget.grid.ColumnData config,
              int rowIndex,
              int colIndex,
              ListStore<ModelData> store,
              Grid<ModelData> grid) {
            Object obj = model.get(AdminUserBeanDesc.role.getName());

            String label = "";

            try {
              label = (String) ((BeanModel) obj).get("label");
            } catch (Exception e) {
              log.log(
                  java.util.logging.Level.INFO,
                  "can't cast obj:"
                      + obj
                      + "|class:"
                      + (null != obj ? obj.getClass() : "null")
                      + "|to RoleBean");
            }

            return getSortedGroupLabel(label);
          }
        });
    columns.add(roleColumn);
    columns.add(configColumn(AdminUserBeanDesc.lastName, 110));
    columns.add(configColumn(AdminUserBeanDesc.firstName, 110));

    ColumnConfig typeColumn = configColumn(AdminUserBeanDesc.userType, 60);
    typeColumn.setAlignment(HorizontalAlignment.CENTER);
    typeColumn.setRenderer(
        new GridCellRenderer<ModelData>() {

          public Object render(
              ModelData model,
              String property,
              ColumnData config,
              int rowIndex,
              int colIndex,
              ListStore<ModelData> store,
              Grid<ModelData> grid) {
            Type type = Type.valueOf((String) model.get(property));
            return TypeDecorator.decorate(type);
          }
        });
    columns.add(typeColumn);
    ColumnConfig activeColumn = configColumn(AdminUserBeanDesc.active, 100);
    activeColumn.setAlignment(HorizontalAlignment.CENTER);
    CheckBoxImageRender.getInstance().render(activeColumn);
    columns.add(activeColumn);
    // columns.add(configCheckColumn(AdminUserBeanDesc.active, 55));
    ColumnConfig creationDateColumn = configColumn(AdminUserBeanDesc.creationDate, 120);
    creationDateColumn.setRenderer(
        new GridCellRenderer<ModelData>() {

          public Object render(
              ModelData model,
              String property,
              com.extjs.gxt.ui.client.widget.grid.ColumnData config,
              int rowIndex,
              int colIndex,
              ListStore<ModelData> store,
              Grid<ModelData> grid) {
            return DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss")
                .format((Date) model.get(AdminUserBeanDesc.creationDate.getName()));
          }
        });
    columns.add(creationDateColumn);
    columns.add(configColumn(AdminUserBeanDesc.authenticationLogin, 100));

    final ColumnModel cm = new ColumnModel(columns);

    GroupingView gridview = new GroupingView() { // for RoleBean grouping

          @Override
          protected String getGroup(
              Object value, ModelData m, int rowIndex, int colIndex, ListStore<ModelData> ds) {
            if (value instanceof RoleBean) {
              // return ((RoleBean) value).getLabel();
              return getSortedGroupLabel(((RoleBean) value).getLabel());
            } else {
              return value == null ? "" : value.toString();
            }
          }
        };
    gridview.setShowGroupedColumn(false);
    gridview.setForceFit(true);
    gridview.setGroupRenderer(
        new GridGroupRenderer() {

          public String render(GroupColumnData data) {
            String f = cm.getColumnById(data.field).getHeader();
            String l =
                data.models.size() == 1
                    ? I18nUtils.getMessages().user_groupTextTpl_member()
                    : I18nUtils.getMessages().user_groupTextTpl_members();

            String label = "";
            if (null != data && null != data.gvalue) {
              label = data.gvalue.toString();
            }

            return f
                + ": "
                + getSortedGroupLabel(label)
                + " ("
                + data.models.size()
                + " "
                + l
                + ")";
          }
        });

    Grid<ModelData> grid = new Grid<ModelData>(store, cm);
    grid.setView(gridview);
    grid.setAutoExpandColumn(AdminUserBeanDesc.login.getName());
    grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

    return grid;
  }
Ejemplo n.º 5
0
  private Window createGridWindow() {
    Window w = new Window();
    w.setIcon(IconHelper.createStyle("icon-grid"));
    w.setMinimizable(true);
    w.setMaximizable(true);
    w.setHeading("Messages Window");
    w.setSize(500, 400);
    w.setLayout(new FitLayout());

    GroupingStore<Employee> employeeList = new GroupingStore<Employee>();
    employeeList.add(TestData.getEmployees());
    employeeList.groupBy("department");

    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

    ColumnConfig column = new ColumnConfig();
    column.setId("name");
    column.setHeader("Sender Name");
    column.setWidth(200);
    configs.add(column);

    column = new ColumnConfig("department", "User group", 150);
    column.setAlignment(HorizontalAlignment.LEFT);
    configs.add(column);

    column = new ColumnConfig("designation", "Taggs", 150);
    column.setAlignment(HorizontalAlignment.LEFT);
    configs.add(column);

    column = new ColumnConfig("salary", "Length", 100);
    column.setAlignment(HorizontalAlignment.RIGHT);
    final NumberFormat number = NumberFormat.getFormat("0.00");
    GridCellRenderer<Employee> checkSalary =
        new GridCellRenderer<Employee>() {
          public String render(
              Employee model,
              String property,
              ColumnData config,
              int rowIndex,
              int colIndex,
              ListStore<Employee> employeeList,
              Grid<Employee> grid) {
            double val = (Double) model.get(property);
            String style = val < 70000 ? "red" : "green";
            return "<span style='color:" + style + "'>" + number.format(val) + "</span>";
          }
        };
    column.setRenderer(checkSalary);
    configs.add(column);

    column = new ColumnConfig("joiningdate", "Date", 100);
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setDateTimeFormat(DateTimeFormat.getShortDateFormat());
    configs.add(column);

    final ColumnModel cm = new ColumnModel(configs);

    GroupingView view = new GroupingView();
    view.setForceFit(true);
    view.setGroupRenderer(
        new GridGroupRenderer() {
          public String render(GroupColumnData data) {
            String f = cm.getColumnById(data.field).getHeader();
            String l = data.models.size() == 1 ? "Item" : "Items";
            return f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
          }
        });

    Grid<Employee> grid = new Grid<Employee>(employeeList, cm);
    grid.setView(view);
    grid.setBorders(true);

    ContentPanel cp = new ContentPanel();
    cp.setBodyBorder(false);
    cp.setHeading("Friends List");
    cp.setButtonAlign(HorizontalAlignment.CENTER);
    cp.setLayout(new FitLayout());
    cp.setSize(700, 420);
    cp.add(grid);
    w.add(cp);

    return w;
  }