private ListStore<Model> newStore() {
   final ListStore<Model> store = new ListStore<Model>();
   store.add(new Model(PortalInheritableFlag.INHERIT));
   store.add(new Model(PortalInheritableFlag.ON));
   store.add(new Model(PortalInheritableFlag.OFF));
   return store;
 }
Ejemplo n.º 2
0
  public ListStore<ModelData> getGroupComboStore() {

    if (sourceGrid != null) return getGroupComboStore(sourceGrid);
    if (sourceStore != null) return getGroupComboStore(sourceStore);

    ListStore<ModelData> groupStore = new ListStore<ModelData>();

    ModelData model;

    model = new BaseModelData();
    model.set("value", "productCode");
    model.set("description", "Product");
    groupStore.add(model);

    model = new BaseModelData();
    model.set("value", "serviceCode");
    model.set("description", "Service");
    groupStore.add(model);

    model = new BaseModelData();
    model.set("value", "institution.institutionName");
    model.set("description", "Institution");
    groupStore.add(model);

    model = new BaseModelData();
    model.set("value", "institution.state");
    model.set("description", "State");
    groupStore.add(model);

    return groupStore;
  }
Ejemplo n.º 3
0
  @SuppressWarnings("unchecked")
  @Override
  protected void handleEvent(AppEvent event) {
    if (event.getType() == AppEvents.AuditEventEntryView) {

      searchCriteria = null;
      currentEntity = Registry.get(Constants.ENTITY_ATTRIBUTE_MODEL);

      initUI();

      if (Registry.get(Constants.AUDIT_EVENT_TYPE_CODES) != null) {
        List<AuditEventTypeWeb> auditEventTypes =
            (List<AuditEventTypeWeb>) Registry.get(Constants.AUDIT_EVENT_TYPE_CODES);
        /*
         * for (AuditEventTypeWeb type : auditEventTypes) { Info.display("Information", "Event Types: "+
         * type.getAuditEventTypeCd() + ", " + type.getAuditEventTypeName()); }
         */
        eventTypesStore.removeAll();
        eventTypesStore.add(auditEventTypes);
      }

    } else if (event.getType() == AppEvents.Logout) {

      Dispatcher.get().dispatch(AppEvents.Logout);

    } else if (event.getType() == AppEvents.AuditEventReceived) {

      // Info.display("Information", "EventReceived");
      store.removeAll();

      AuditEventEntryListWeb events = (AuditEventEntryListWeb) event.getData();
      if (events.getAuditEventEntries() != null) {
        store.add(events.getAuditEventEntries());
      }

      grid.getSelectionModel().select(0, true);
      grid.getSelectionModel().deselect(0);

      status.hide();
      searchButton.unmask();

    } else if (event.getType() == AppEvents.EntityByIdRequest) {

      RecordWeb record = (RecordWeb) event.getData();

      if (record != null) {
        identifierStore.removeAll();

        buildRefRecordInfoDialog();
        refRecordInfoDialog.show();

        displayEntityRecord(attributeFieldMap, record);
        displayEntityIdentifier(record);
      }

    } else if (event.getType() == AppEvents.Error) {
      String message = event.getData();
      MessageBox.alert("Information", "Failure: " + message, null);
    }
  }
Ejemplo n.º 4
0
  /** {@inheritDoc} */
  @Override
  protected Component getComponent(ValueResult valueResult, boolean enabled) {
    final boolean canAdd = enabled && userCanPerformChangeType(ValueEventChangeType.ADD);

    final ContentPanel component = new ContentPanel();
    component.setHeadingText(getLabel());

    // Setting up the report store
    final List<?> reports = valueResult.getValuesObject();

    final ListStore<ReportReference> store = new ListStore<ReportReference>();
    if (reports != null) store.add((List<ReportReference>) reports);

    // Creating the toolbar
    if (canAdd) {
      component.setTopComponent(createToolbar(store));
    }

    // Creating the grid
    final FlexibleGrid<ReportReference> reportGrid =
        new FlexibleGrid<ReportReference>(store, null, createColumnModel(enabled));
    reportGrid.setAutoExpandColumn("name");
    reportGrid.setVisibleElementsCount(5);

    component.add(reportGrid);

    return component;
  }
  private Widget createBillTypeField(BillTypeManager billTypeManager) {
    List<BillType> billTypes = billTypeManager.getBillTypes();

    Collections.sort(
        billTypes,
        new Comparator<BillType>() {
          @Override
          public int compare(BillType billType1, BillType billType2) {
            return billType1.getName().compareToIgnoreCase(billType2.getName());
          }
        });

    List<BillTypeModel> billTypeModels = new ArrayList<BillTypeModel>();

    for (BillType billType : billTypes) {
      BillTypeModel billTypeModel = new BillTypeModel(billType);
      billTypeModels.add(billTypeModel);
    }

    ListStore<BillTypeModel> billTypeListBox = new ListStore<BillTypeModel>();
    billTypeListBox.add(billTypeModels);

    billTypeComboBox = new ComboBox<BillTypeModel>();
    billTypeComboBox.setFieldLabel("Bill Type");
    billTypeComboBox.setDisplayField("name");
    billTypeComboBox.setTriggerAction(TriggerAction.ALL);
    billTypeComboBox.setStore(billTypeListBox);
    billTypeComboBox.setAllowBlank(false);
    billTypeComboBox.setForceSelection(true);

    return billTypeComboBox;
  }
Ejemplo n.º 6
0
  /**
   * Constructor.
   *
   * @param name The field's name.
   * @param title The field's title.
   * @param desc The field's description.
   * @param options The options that can be selected.
   */
  public CCComboBoxField(
      final String name, final String title, final String desc, final List<Option> options) {
    super(name);

    final ComboBox<BaseModelData> cb = new ComboBox<BaseModelData>();
    cb.setTriggerAction(TriggerAction.ALL);
    cb.setFieldLabel(createLabel(name, title));
    cb.setToolTip(createTooltip(name, title, desc));
    cb.setDisplayField("title");
    cb.setValueField("value");
    cb.setEditable(false);

    final ListStore<BaseModelData> store = new ListStore<BaseModelData>();
    for (final Option o : options) {
      final BaseModelData model = new BaseModelData();

      model.set("title", o.getTitle());
      model.set("value", o.getValue());
      store.add(model);
      if (o.isDefault().booleanValue()) {
        cb.setValue(model);
      }
    }
    cb.setStore(store);

    _combobox = cb;
  }
  private void loadTable(List<RiepilogoCostiDipendentiModel> result) {

    store.removeAll();
    store.setStoreSorter(new StoreSorter<RiepilogoCostiDipendentiModel>());
    store.setDefaultSort("nome", SortDir.ASC);
    store.add(result);
  }
 @Override
 public void refresh(RefreshableEvent event) {
   if (event.getEventType() == RefreshableEvent.Type.DISTRICT_SUMMARIES) {
     ListStore<DistrictComparisonSummary> store1 = grid.getStore();
     if (store1.getCount() > 0) {
       store1.removeAll();
     }
     List<DistrictComparisons> summaries =
         getSummaries((List<DistrictComparisons>) event.getData(), parentView.loggedUser);
     for (DistrictComparisons d : summaries) {
       final String district = d.getDistrict();
       final String subcounty = d.getSubcounty();
       final String boreholes = d.getBoreholes();
       final String shallowWells = d.getShallowWells();
       final String publicTaps = d.getPublicTaps();
       final String protectedSprings = d.getProtectedSprings();
       int total =
           Integer.parseInt(boreholes)
               + Integer.parseInt(shallowWells)
               + Integer.parseInt(publicTaps)
               + Integer.parseInt(protectedSprings);
       DistrictComparisonSummary summary =
           new DistrictComparisonSummary(
               district,
               subcounty,
               boreholes,
               shallowWells,
               publicTaps,
               protectedSprings,
               String.valueOf(total));
       store1.add(summary);
     }
   }
 }
Ejemplo n.º 9
0
 private void refreshAvailableUsers(List<User> users) {
   for (User user : users) {
     if (!group.getUsers().contains(user)) {
       fromUserStore.add(new UserData(user));
     }
   }
 }
 private void init() {
   this.setComboBoxProperties();
   ListStore<LogicalOperator> operatorsStore = new ListStore<LogicalOperator>();
   operatorsStore.add(LogicalOperator.getOperatorsList());
   super.setStore(operatorsStore);
   //        super.setValue(super.store.getAt(0));
 }
Ejemplo n.º 11
0
 private void refreshAvailableGroups(List<Group> groups) {
   for (Group group : groups) {
     if (!user.getGroups().contains(group)) {
       fromGroupStore.add(new GroupData(group));
     }
   }
 }
Ejemplo n.º 12
0
  public ListStore<ModelData> getValueComboStore() {
    ListStore<ModelData> valueStore = new ListStore<ModelData>();

    ModelData model;

    model = new BaseModelData();
    model.set("value", "dollarValue");
    model.set("description", "Dollar Values");
    valueStore.add(model);

    model = new BaseModelData();
    model.set("value", "count");
    model.set("description", "Services");
    valueStore.add(model);

    return valueStore;
  }
Ejemplo n.º 13
0
 /**
  * Populates runs
  *
  * @param models
  * @param enabled : is combobox enabled
  */
 @Override
 public void setModels(List<RunModel> models, boolean enabled) {
   if (models.size() > 0) {
     storeName.add(models);
     cbName.setValue(storeName.getAt(0));
   }
   cbName.setEnabled(enabled);
 }
Ejemplo n.º 14
0
 private void displayEntityIdentifier(RecordWeb record) {
   if (record.getIdentifiers() == null) {
     return;
   }
   for (IdentifierWeb identifier : record.getIdentifiers()) {
     identifierStore.add(identifier);
   }
 }
Ejemplo n.º 15
0
  private void setFields() {
    nameTextBox.setValue(group.getName());
    for (User user : group.getUsers()) {
      toUserStore.add(new UserData(user));
    }

    loadAvailableUsers();
  }
Ejemplo n.º 16
0
  public void onValueChange(ValueChangeEvent<List<GrisuFileObject>> arg0) {

    for (GrisuFileObject file : arg0.getValue()) {

      if (!inputFileStore.contains(file)) {
        inputFileStore.add(file);
      }
    }
  }
Ejemplo n.º 17
0
  private ContentPanel createScreenPairList(GroupRef groupRef) {
    TouchPanelDefinition touchPanel = groupRef.getPanel().getTouchPanelDefinition();

    ContentPanel screenContainer = new ContentPanel();
    screenContainer.setHeaderVisible(false);
    screenContainer.setWidth(260);
    screenContainer.setHeight(150);
    screenContainer.setLayout(new FitLayout());
    // overflow-auto style is for IE hack.
    screenContainer.addStyleName("overflow-auto");

    screenPairListView = new CheckBoxListView<BeanModel>();
    ListStore<BeanModel> store = new ListStore<BeanModel>();

    List<BeanModel> otherModels = new ArrayList<BeanModel>();
    List<BeanModel> screenPairModels = BeanModelDataBase.screenTable.loadAll();
    List<BeanModel> selectedModels = new ArrayList<BeanModel>();
    for (ScreenPairRef screenRef : groupRef.getGroup().getScreenRefs()) {
      selectedModels.add(screenRef.getScreen().getBeanModel());
    }
    for (BeanModel screenPairModel : screenPairModels) {
      if (((ScreenPair) screenPairModel.getBean()).getTouchPanelDefinition().equals(touchPanel)) {
        store.add(screenPairModel);
        screenPairListView.getSelectionModel().select(screenPairModel, true);
      } else if (((ScreenPair) screenPairModel.getBean())
          .getTouchPanelDefinition()
          .getCanvas()
          .equals(touchPanel.getCanvas())) {
        otherModels.add(screenPairModel);
      }
    }

    store.add(otherModels);
    for (BeanModel selectedModel : selectedModels) {
      screenPairListView.setChecked(selectedModel, true);
    }
    screenPairListView.setStore(store);
    screenPairListView.setDisplayProperty("panelName");
    screenPairListView.setStyleAttribute("overflow", "auto");
    screenPairListView.setSelectStyle("screen-view-item-sel");
    screenContainer.add(screenPairListView);
    return screenContainer;
  }
Ejemplo n.º 18
0
 private void setFields() {
   usernameTextBox.setValue(user.getUsername());
   fullnameTextBox.setValue(user.getFullname());
   emailTextBox.setValue(user.getEmail());
   enabledCheckBox.setValue(user.isActiveFlag());
   for (Group group : user.getGroups()) {
     if (!group.getName().equals(Constants.EVERYONE_GROUP_NAME)) {
       toGroupStore.add(new GroupData(group));
     }
   }
   loadAvailableGroups();
 }
  private ComboBox<AttributeDetail> createNameAttributeCombo() {
    this.nameAttributeCombo = new ComboBox<AttributeDetail>();
    nameAttributeCombo.setEditable(false);
    nameAttributeCombo.setTypeAhead(true);
    nameAttributeCombo.setTriggerAction(ComboBox.TriggerAction.ALL);
    nameAttributeCombo.setWidth(110);

    this.nameAttributeCombo.addSelectionChangedListener(
        new SelectionChangedListener<AttributeDetail>() {

          @Override
          public void selectionChanged(SelectionChangedEvent<AttributeDetail> se) {
            if (clickHandlerRegistration != null) {
              clickHandlerRegistration.removeHandler();
            }
            AttributeDetail attributeDetail = se.getSelectedItem();
            if (attributeDetail == null) {
              operatorCombo.disable();
            } else {
              AttributeCustomFields customFields =
                  AttributeCustomFieldsMap.getAttributeCustomFields(attributeDetail.getType());
              operatorCombo.clear();
              operatorCombo.removeAll();
              for (OperatorType operatorType : customFields.getOperatorList()) {
                operatorCombo.add(operatorType.toString());
              }
              operatorCombo.enable();
              conditionAttributeField.clear();
              conditionAttributeField.setValidator(customFields.getValidator());
              conditionAttributeField.setToolTip("Datatype: " + attributeDetail.getType());
              if (attributeDetail.getType().equals("dateTime")) {
                conditionAttributeField.addHandler(
                    new ClickHandler() {

                      @Override
                      public void onClick(ClickEvent event) {
                        timeInputWidget.show();
                      }
                    },
                    ClickEvent.getType());
              }
            }
          }
        });
    ListStore nameAttributeStore = new ListStore<AttributeDetail>();
    nameAttributeStore.add(attributes);
    nameAttributeCombo.setStore(nameAttributeStore);
    nameAttributeCombo.setDisplayField(AttributeDetail.AttributeDetailKeyValue.NAME.name());
    //        nameAttributeCombo.setSimpleValue("XXX");

    return nameAttributeCombo;
  }
Ejemplo n.º 20
0
  public ListStore<ModelData> getGroupComboStore(Grid<BeanModel> sourceGrid) {

    if (sourceGrid.getColumnModel().getColumnCount() > 0) {
      ListStore<ModelData> groupStore = new ListStore<ModelData>();
      ModelData model;
      for (int i = 0; i < sourceGrid.getColumnModel().getColumnCount(); i++) {
        model = new BaseModelData();
        model.set("value", sourceGrid.getColumnModel().getColumn(i).getId());
        model.set("description", sourceGrid.getColumnModel().getColumn(i).getHeader());
        groupStore.add(model);
      }
      return groupStore;
    } else return getGroupComboStore();
  }
  private Widget createStoreField() {
    ListStore<StoreModel> storeNameListStore = new ListStore<StoreModel>();

    for (String store : stores) {
      storeNameListStore.add(new StoreModel(store));
    }

    storeComboBox = new ComboBox<StoreModel>();
    storeComboBox.setFieldLabel("Store");
    storeComboBox.setDisplayField("name");
    storeComboBox.setTriggerAction(TriggerAction.ALL);
    storeComboBox.setStore(storeNameListStore);
    storeComboBox.setAllowBlank(false);

    return storeComboBox;
  }
Ejemplo n.º 22
0
  private void createGestureTypeList() {
    ContentPanel gestureTypesContainer = new ContentPanel();
    gestureTypesContainer.setHeaderVisible(false);
    gestureTypesContainer.setLayout(new FitLayout());
    // overflow-auto style is for IE hack.
    gestureTypesContainer.addStyleName("overflow-auto");
    gestureTypesContainer.setBorders(false);
    gestureTypesContainer.setBodyBorder(false);

    ListStore<BeanModel> gestureStore = new ListStore<BeanModel>();
    GestureType[] gestureTypes = GestureType.values();
    existsGestureTypeModels = new ArrayList<BeanModel>();

    for (int i = 0; i < gestureTypes.length; i++) {
      Gesture gesture = new Gesture(gestureTypes[i]);
      gesture.setOid(IDUtil.nextID());
      gestureMaps.put(gestureTypes[i].toString(), gesture);
      BeanModel gestureBeanModel = gesture.getBeanModel();
      gestureStore.add(gestureBeanModel);
      for (Gesture existGesture : gestures) {
        if (gestureTypes[i].equals(existGesture.getType())) {
          gestureMaps.put(existGesture.getType().toString(), existGesture);
          existsGestureTypeModels.add(gestureBeanModel);
        }
      }
    }

    gestureTypeListView =
        new CheckBoxListViewExt<BeanModel>() {
          @Override
          protected void afterRender() {
            super.afterRender();
            for (BeanModel checkedModel : existsGestureTypeModels) {
              this.setChecked(checkedModel, true);
            }
          }
        };
    gestureTypeListView.setStore(gestureStore);
    gestureTypeListView.setDisplayProperty("type");
    gestureTypeListView.setStyleAttribute("overflow", "auto");
    gestureTypesContainer.add(gestureTypeListView);

    BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 150);
    westData.setMargins(new Margins(0, 5, 0, 0));
    add(gestureTypesContainer, westData);
  }
Ejemplo n.º 23
0
  public void onRender(Item gradebookItemModel) {

    refreshCategoryPickerStore(gradebookItemModel);

    List<ItemModel> gradeItems = (List<ItemModel>) getGradeItems(gradebookItemModel);
    itemStore.add(gradeItems);

    // GRBK-643
    // If we have an import file/GB that doesn't have categories, we hide the columns in the setup
    // grid
    CategoryType cateogryType = gradebookItemModel.getCategoryType();
    if (CategoryType.NO_CATEGORIES == cateogryType) {

      // Hide category related columns
      columnConfigCategory.setHidden(true);
      columnConfigPercentCategory.setHidden(true);
    }
  }
Ejemplo n.º 24
0
  public ListStore<ModelData> getGroupComboStore(ListStore<BeanModel> sourceStore) {

    if (sourceGrid != null && groupCombo != null) return groupCombo.getStore();

    if (sourceStore.getCount() > 0) {

      ListStore<ModelData> groupStore = new ListStore<ModelData>();
      ModelData model;

      SortedSet<String> properties = new TreeSet<String>();
      for (String property : sourceStore.getAt(0).getPropertyNames()) properties.add(property);

      for (String property : properties) {
        model = new BaseModelData();
        model.set("value", property);
        model.set("description", getPropertyHeader(property));
        groupStore.add(model);
      }

      return groupStore;

    } else return getGroupComboStore();
  }
Ejemplo n.º 25
0
 public ProfileView(Controller controller) {
   super(controller);
   states.add(InputFormData.getStates());
   countries.add(InputFormData.getCountry());
 }
  public static Menu getLayerContextMenu() {
    if (layerContextMenu == null) {
      layerContextMenu = new Menu();
      // add zoom to max extent
      MenuItem zoomToMaxExtend = new MenuItem();
      zoomToMaxExtend.setText("Zoom to layer extend");
      zoomToMaxExtend.setIcon(LayerResources.ICONS.zoomToMaxExtend());
      zoomToMaxExtend.addSelectionListener(new ZoomToLayerExtentAction(treePanel));
      layerContextMenu.add(zoomToMaxExtend);

      MenuItem exportMenuItem = new MenuItem();
      exportMenuItem.setText("Export");
      exportMenuItem.setSubMenu(new GPExportMenu(treePanel));
      layerContextMenu.add(exportMenuItem);

      MenuItem cqlFilterMenuItem = new MenuItem();
      cqlFilterMenuItem.setText("CQL Filter");
      cqlFilterMenuItem.setSubMenu(new GPCQLFilterMenu(treePanel));
      layerContextMenu.add(cqlFilterMenuItem);

      MenuItem timeFilterMenuItem = new MenuItem();
      timeFilterMenuItem.setText("TIME Filter");
      timeFilterMenuItem.setSubMenu(new GPTimeFilterMenu(treePanel));
      layerContextMenu.add(timeFilterMenuItem);

      MenuItem layerProperties = new MenuItem();
      layerProperties.setText("Layer Properties");
      layerProperties.setIcon(LayerResources.ICONS.layerProperties());
      layerProperties.addSelectionListener(new ShowLayerPropertiesAction(treePanel));

      MenuItem copyMenuItem = new MenuItem("Copy Layer");
      copyMenuItem.setIcon(LayerResources.ICONS.copy());
      copyMenuItem.addSelectionListener(new CopyLayerAction(treePanel, pasteAction, pasteMenuItem));

      layerContextMenu.add(copyMenuItem);

      MenuItem createViewportLayerMenu = new MenuItem();
      createViewportLayerMenu.setText("Create Viewport");
      createViewportLayerMenu.setIcon(BasicWidgetResources.ICONS.viewport());
      createViewportLayerMenu.addSelectionListener(new CreateLayerViewportAction(treePanel));
      layerContextMenu.add(createViewportLayerMenu);

      // TODO ADD EditWFS dynamically
      EditWFSAction editFeatureAction = new EditWFSAction(treePanel);
      MenuItem editFeature = new MenuItem();
      editFeature.setText(editFeatureAction.getTitle());
      editFeature.setIcon(editFeatureAction.getImage());
      editFeature.addSelectionListener(editFeatureAction);
      layerContextMenu.add(editFeature);

      refreshTimeComboBox =
          new ComboBox() {
            @Override
            protected void onSelect(ModelData model, int index) {
              super.onSelect(model, index);
              refreshTimeComboBox.clearSelections();
              layerContextMenu.hide();
            }
          };
      refreshTimeComboBox.setEmptyText("Refresh Time");
      ListStore<LayerRefreshTimeValue> store = new ListStore<LayerRefreshTimeValue>();
      store.add(LayerRefreshTimeValue.getLayerRefreshTimeList());
      refreshTimeComboBox.setStore(store);
      refreshTimeComboBox.setEditable(Boolean.FALSE);
      refreshTimeComboBox.setForceSelection(Boolean.TRUE);
      refreshTimeComboBox.setTypeAhead(Boolean.FALSE);
      refreshTimeComboBox.setUseQueryCache(Boolean.FALSE);
      refreshTimeComboBox.setDisplayField(LayerRefreshTimeValue.REFRESH_TIME_KEY);
      //        refreshMenuItem.setIcon(LayerResources.ICONS.layerRefresh());
      refreshTimeComboBox.addSelectionChangedListener(new RefreshLayerAction(treePanel));
      layerContextMenu.add(refreshTimeComboBox);

      layerContextMenu.add(layerProperties);
    }
    return layerContextMenu;
  }
 public void setStore(List<ColumnInformationWeb> columnInformationStore) {
   store.removeAll();
   store.add(columnInformationStore);
 }
  private void createGrid(boolean widget) {
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

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

    column = new ColumnConfig();
    column.setId("symbol");
    column.setHeader("Symbol");
    column.setWidth(100);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("last");
    column.setHeader("Last");
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setWidth(75);
    column.setRenderer(gridNumber);
    configs.add(column);

    column = new ColumnConfig("change", "Change", 100);
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setRenderer(change);
    configs.add(column);

    column = new ColumnConfig("date", 125);
    if (widget) {
      Button btn = new Button("Updated");
      btn.addListener(
          Events.OnClick,
          new Listener<ButtonEvent>() {
            public void handleEvent(ButtonEvent be) {
              // stop column from getting click and causing sort
              be.cancelBubble();
            }
          });
      btn.setStyleAttribute("float", "left");
      column.setWidget(btn, "Last Updated");
    } else {
      column.setAlignment(HorizontalAlignment.RIGHT);
      column.setHeader("Last Updated");
    }

    column.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/yyyy"));
    configs.add(column);

    ListStore<Stock> store = new ListStore<Stock>();
    store.add(TestData.getStocks());

    ColumnModel cm = new ColumnModel(configs);

    cm.addHeaderGroup(0, 0, new HeaderGroupConfig("Header Grouping Example", 1, 5));
    cm.addHeaderGroup(1, 2, new HeaderGroupConfig("Stock Performance", 1, 2));

    if (widget) {
      Slider s = new Slider();
      s.setWidth(100);

      // ugly, but centers slider
      FlexTable tbl = new FlexTable();
      tbl.setWidth("100%");
      tbl.setHTML(0, 0, "&nbsp;");
      tbl.setHTML(
          0, 1, "<span style='white-space: nowrap;font-size: 11px'>Slide Me: &nbsp;</span>");
      tbl.setWidget(0, 2, s);
      tbl.setHTML(0, 3, "&nbsp;");
      tbl.getCellFormatter().setWidth(0, 0, "50%");
      tbl.getCellFormatter().setWidth(0, 3, "50%");
      cm.addHeaderGroup(1, 0, new HeaderGroupConfig(tbl, 1, 2));
    } else {
      cm.addHeaderGroup(1, 0, new HeaderGroupConfig("Stock Information", 1, 2));
    }

    ContentPanel cp = new ContentPanel();
    cp.setBodyBorder(false);
    cp.setIcon(Resources.ICONS.table());
    cp.setHeading(widget ? "Column Grouping with Widget" : "Column Grouping");
    cp.setButtonAlign(HorizontalAlignment.CENTER);
    cp.setLayout(new FitLayout());
    cp.setSize(600, 300);

    Grid<Stock> grid = new Grid<Stock>(store, cm);
    grid.setStyleAttribute("borderTop", "none");
    grid.getView().setForceFit(true);
    grid.setBorders(true);
    cp.add(grid);

    vp.add(cp);
  }
Ejemplo n.º 29
0
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setStyleAttribute("margin", "10px");

    final FormPanel panel = new FormPanel();
    panel.setHeading("File Upload Example");
    panel.setFrame(true);
    panel.setAction("myurl");
    panel.setEncoding(Encoding.MULTIPART);
    panel.setMethod(Method.POST);
    panel.setButtonAlign(HorizontalAlignment.CENTER);
    panel.setWidth(350);

    TextField<String> name = new TextField<String>();
    name.setFieldLabel("Name");
    panel.add(name);

    FileUploadField file = new FileUploadField();
    file.setAllowBlank(false);
    file.setName("uploadedfile");
    file.setFieldLabel("File");
    panel.add(file);

    List<Stock> list = TestData.getStocks();
    final ListStore<Stock> store = new ListStore<Stock>();
    store.add(list);

    final ComboBox<Stock> combo = new ComboBox<Stock>();
    combo.setFieldLabel("Company");
    combo.setDisplayField("name");
    combo.setName("name");
    combo.setValueField("symbol");
    combo.setForceSelection(true);
    combo.setStore(store);
    combo.setTriggerAction(TriggerAction.ALL);
    panel.add(combo);

    Button btn = new Button("Reset");
    btn.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            panel.reset();
          }
        });
    panel.addButton(btn);

    btn = new Button("Submit");
    btn.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            if (!panel.isValid()) {
              return;
            }
            // normally would submit the form but for example no server set up to
            // handle the post
            // panel.submit();
            MessageBox.info("Action", "You file was uploaded", null);
          }
        });
    panel.addButton(btn);

    add(panel);
  }
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FlowLayout(10));

    GridCellRenderer<Stock> buttonRenderer =
        new GridCellRenderer<Stock>() {

          private boolean init;

          public Object render(
              final Stock model,
              String property,
              ColumnData config,
              final int rowIndex,
              final int colIndex,
              ListStore<Stock> store,
              Grid<Stock> grid) {
            if (!init) {
              init = true;
              grid.addListener(
                  Events.ColumnResize,
                  new Listener<GridEvent<Stock>>() {

                    public void handleEvent(GridEvent<Stock> be) {
                      for (int i = 0; i < be.getGrid().getStore().getCount(); i++) {
                        if (be.getGrid().getView().getWidget(i, be.getColIndex()) != null
                            && be.getGrid().getView().getWidget(i, be.getColIndex())
                                instanceof BoxComponent) {
                          ((BoxComponent) be.getGrid().getView().getWidget(i, be.getColIndex()))
                              .setWidth(be.getWidth() - 10);
                        }
                      }
                    }
                  });
            }

            Button b =
                new Button(
                    (String) model.get(property),
                    new SelectionListener<ButtonEvent>() {
                      @Override
                      public void componentSelected(ButtonEvent ce) {
                        Info.display(
                            model.getName(), "<ul><li>" + model.getSymbol() + "</li></ul>");
                      }
                    });
            b.setWidth(grid.getColumnModel().getColumnWidth(colIndex) - 10);
            b.setToolTip("Click for more information");

            return b;
          }
        };

    final NumberFormat currency = NumberFormat.getCurrencyFormat();
    final NumberFormat number = NumberFormat.getFormat("0.00");

    GridCellRenderer<Stock> change =
        new GridCellRenderer<Stock>() {
          public String render(
              Stock model,
              String property,
              ColumnData config,
              int rowIndex,
              int colIndex,
              ListStore<Stock> store,
              Grid<Stock> grid) {
            double val = (Double) model.get(property);
            String style = val < 0 ? "red" : "green";
            return "<span style='color:" + style + "'>" + number.format(val) + "</span>";
          }
        };

    GridCellRenderer<Stock> gridNumber =
        new GridCellRenderer<Stock>() {
          public String render(
              Stock model,
              String property,
              ColumnData config,
              int rowIndex,
              int colIndex,
              ListStore<Stock> stor,
              Grid<Stock> grid) {
            Number value = model.<Number>get(property);
            return value == null ? null : currency.format(model.<Number>get(property));
          }
        };

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

    ColumnConfig column = new ColumnConfig();
    column.setId("name");
    column.setHeaderHtml("Company");
    column.setWidth(200);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("symbol");
    column.setHeaderHtml("Symbol");
    column.setWidth(100);
    column.setRenderer(buttonRenderer);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("last");
    column.setHeaderHtml("Last");
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setWidth(75);
    column.setRenderer(gridNumber);
    configs.add(column);

    column = new ColumnConfig("change", "Change", 100);
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setRenderer(change);
    configs.add(column);

    column = new ColumnConfig("date", "Last Updated", 100);
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/yyyy"));
    configs.add(column);

    final ListStore<Stock> store = new ListStore<Stock>();
    store.add(Stock.getStocks());

    ColumnModel cm = new ColumnModel(configs);

    ContentPanel cp = new ContentPanel();
    cp.setBodyBorder(false);
    //    cp.setIconStyle("icon-printer");
    cp.setIcon(
        AbstractImagePrototype.create(
            new ImageResource() {
              public int getHeight() {
                return 0;
              }

              public int getLeft() {
                return 0;
              }

              public SafeUri getSafeUri() {
                return null;
              }

              public int getTop() {
                return 0;
              }

              public String getURL() {
                return "resources/images/fam/printer.png";
              }

              public int getWidth() {
                return 0;
              }

              public boolean isAnimated() {
                return false;
              }

              public String getName() {
                return null;
              }
            }));
    //    cp.setIcon(Resources.ICONS.table());
    cp.setHeadingHtml("Widget Renderer Grid");
    cp.setButtonAlign(HorizontalAlignment.CENTER);
    cp.setLayout(new FitLayout());
    cp.setSize(600, 300);

    Grid<Stock> grid = new Grid<Stock>(store, cm);
    grid.setStyleAttribute("borderTop", "none");
    grid.setAutoExpandColumn("name");
    grid.setBorders(true);
    cp.add(grid);

    add(cp);
  }