Ejemplo n.º 1
0
  private Window createStatisticWindow() {

    Window w = new Window();
    w.setIcon(IconHelper.createStyle("bogus"));
    w.setMinimizable(true);
    w.setMaximizable(true);
    w.setHeading("Statistics ");
    w.setSize(400, 400);

    w.setLayout(new AccordionLayout());

    ContentPanel cp = new ContentPanel();
    cp.setHeading("Most contacted friends this month");
    cp.setFrame(false);
    cp.setSize(300, 300);

    Frame frame = new Frame();
    frame.setUrl("chart.html");
    frame.setLayoutData(new FitLayout());
    cp.setLayout(new FitLayout());
    cp.add(frame);

    w.add(cp);

    cp = new ContentPanel();
    cp.setHeading("Most contacted friends in total");
    cp.setFrame(false);
    cp.setSize(300, 300);

    frame = new Frame();
    frame.setUrl(
        "https://chart.googleapis.com/chart?cht=p3&chs=350x200&chd=t:70,30,10&&chl=Hollie|Emerson|Christinal");
    frame.setLayoutData(new FitLayout());
    cp.setLayout(new FitLayout());
    cp.add(frame);

    w.add(cp);

    cp = new ContentPanel();
    cp.setHeading("Average sms per day last two weeks");
    cp.setFrame(false);
    cp.setSize(300, 300);

    frame = new Frame();
    frame.setUrl(
        "https://chart.googleapis.com/chart?cht=lc&chs=350x200&chd=t:25,50,70,90,25,44,56,34,23,56,0,0,34,5,5,103,3,2,6,13&&chl=1|2|3|4|5|6|7|8|9|10|11|12|13|14&chxt=x,y");
    frame.setLayoutData(new FitLayout());
    cp.setLayout(new FitLayout());
    cp.add(frame);

    w.add(cp);

    return w;
  }
Ejemplo n.º 2
0
 private ContentPanel getApplicationPanel() {
   if (applicationPanel == null) {
     applicationPanel = new ContentPanel();
     applicationPanel.setSize("221px", "85px");
     applicationPanel.setHeading("Application");
     applicationPanel.setLayout(new FitLayout());
     applicationPanel.add(getLayoutContainer_1(), new FitData(10, 30, 10, 10));
   }
   return applicationPanel;
 }
Ejemplo n.º 3
0
 private ContentPanel getCpusPanel() {
   if (cpusPanel == null) {
     cpusPanel = new ContentPanel();
     cpusPanel.setSize("106px", "84px");
     cpusPanel.setHideCollapseTool(true);
     cpusPanel.setHeading("CPUs");
     cpusPanel.setLayout(new FitLayout());
     cpusPanel.add(getLayoutContainer(), new FitData(10));
   }
   return cpusPanel;
 }
Ejemplo n.º 4
0
 private ContentPanel getCommandLinePanel() {
   if (commandLinePanel == null) {
     commandLinePanel = new ContentPanel();
     commandLinePanel.setHideCollapseTool(true);
     commandLinePanel.setSize("413px", "196px");
     commandLinePanel.setLayout(new FitLayout());
     commandLinePanel.setHeading("Commandline");
     commandLinePanel.setCollapsible(true);
     commandLinePanel.add(getTextAreaContainer(), new FitData(10));
   }
   return commandLinePanel;
 }
Ejemplo n.º 5
0
 private ContentPanel getStageFileList() {
   if (stageFileList == null) {
     stageFileList = new ContentPanel();
     stageFileList.setBodyBorder(false);
     stageFileList.setBorders(true);
     stageFileList.setSize("177px", "195px");
     stageFileList.setHideCollapseTool(true);
     stageFileList.setLayout(new FitLayout());
     stageFileList.add(getListView(), new FitData(10));
     stageFileList.setHeading("Job directory");
     stageFileList.setCollapsible(true);
     stageFileList.addButton(getRemoveFileButton());
     stageFileList.addButton(getAddFileButton());
   }
   return stageFileList;
 }
Ejemplo n.º 6
0
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    ContentPanel cp = new ContentPanel();
    cp.setHeading("Charts Gallery");
    cp.setFrame(true);
    cp.setSize(700, 350);
    cp.setLayout(new BorderLayout());

    BorderLayoutData eastData = new BorderLayoutData(LayoutRegion.EAST, 370);

    BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
    centerData.setMargins(new Margins(0, 5, 0, 0));

    cp.add(getChart(), centerData);
    cp.add(getDetails(), eastData);

    add(cp, new MarginData(20));
  }
  @Override
  protected void onRender(Element parent, int index) {

    super.onRender(parent, index);

    setLayout(new CenterLayout());

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

    configs.add(sm.getColumn());

    ColumnConfig column = new ColumnConfig();
    column.setId("ragioneSociale");
    column.setHeader("Ragione Sociale");
    column.setWidth(120);

    TextField<String> text = new TextField<String>();
    // text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("cognome");
    column.setHeader("Cognome");
    column.setWidth(120);

    text = new TextField<String>();
    // text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("nome");
    column.setHeader("Nome");
    column.setWidth(120);

    text = new TextField<String>();
    // text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("cf");
    column.setHeader("Codice Fiscale");
    column.setWidth(120);

    text = new TextField<String>();
    // text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("piva");
    column.setHeader("Partita IVA");
    column.setWidth(120);

    text = new TextField<String>();
    text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("denominazione");
    column.setHeader("Denominazione");
    column.setWidth(120);

    text = new TextField<String>();
    text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    caricaDati();

    ColumnModel cm = new ColumnModel(configs);

    ContentPanel cp = new ContentPanel();
    cp.setHeading("Anagrafica aziende");
    cp.setFrame(true);
    // cp.setIcon(Resources.ICONS.table());
    cp.setSize(Consts.LarghezzaFinestra, Consts.AltezzaFinestra);
    cp.setLayout(new FitLayout());

    final EditorGrid<BeanModel> grid = new EditorGrid<BeanModel>(store, cm);
    grid.setSelectionModel(sm);
    grid.setAutoExpandColumn("nome");
    grid.setBorders(true);
    grid.setClicksToEdit(EditorGrid.ClicksToEdit.TWO);
    cp.add(grid);

    ToolBar toolBar = new ToolBar();
    Button addButton = new Button("Aggiungi azienda");
    addButton.setIcon(
        IconHelper.create(
            "/resources/grafica/x16/add2.png", Consts.ICON_WIDTH_SMALL, Consts.ICON_HEIGHT_SMALL));
    addButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            BeanModelFactory factory = BeanModelLookup.get().getFactory(Azienda.class);
            Azienda azienda =
                new Azienda(
                    "NuovoNome",
                    "NuovoCognome",
                    "nuovaRS",
                    "nuovoCF",
                    "nuovaPIVA",
                    "NuovaDenominazione");
            BeanModel model = factory.createModel(azienda);

            grid.stopEditing();
            aziende.add(azienda);
            store.insert(model, 0);
            grid.startEditing(store.indexOf(model), 0);
          }
        });
    toolBar.add(addButton);
    toolBar.add(new SeparatorToolItem());

    Button remove = new Button("Rimuovi selezionati");
    remove.setIcon(
        IconHelper.create(
            "/resources/grafica/x16/delete2.png",
            Consts.ICON_WIDTH_SMALL,
            Consts.ICON_HEIGHT_SMALL));
    remove.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            if (!(sm.getSelectedItems()).isEmpty()) {
              MessageBox.confirm(
                  "Confirm",
                  "Sei sicuro di voler eliminare gli elemtni selezionati?",
                  cancellazione);
            } else {
              MessageBox.alert("Errore", "Selezionare uno o più elementi", cancellazione);
            }
          }
          // conferma per l'eliminazione
          final Listener<MessageBoxEvent> cancellazione =
              new Listener<MessageBoxEvent>() {

                @Override
                public void handleEvent(MessageBoxEvent ce) {
                  Button btn = ce.getButtonClicked();
                  if (btn.getText().equals("Yes")) {
                    List<BeanModel> modelsDaRimuovere = sm.getSelectedItems();
                    ArrayList<Azienda> aziendeDaRimuovere = new ArrayList();
                    if (modelsDaRimuovere != null) {
                      Iterator it = modelsDaRimuovere.iterator();
                      while (it.hasNext()) {
                        Object model = it.next();
                        store.remove((BeanModel) model);
                        Azienda azienda = ((BeanModel) model).getBean();
                        aziendeDaRimuovere.add(azienda);
                        aziende.remove(azienda);
                      }
                      cancellaDati(aziendeDaRimuovere);
                    }
                  }
                }
              };
        });
    toolBar.add(remove);
    cp.setTopComponent(toolBar);

    ToolBar statusBar = new ToolBar();
    status.setWidth(350);
    statusBar.add(status);
    cp.setBottomComponent(statusBar);
    cp.setButtonAlign(HorizontalAlignment.CENTER);

    Button resetButton =
        new Button(
            "Reset",
            new SelectionListener<ButtonEvent>() {

              @Override
              public void componentSelected(ButtonEvent ce) {
                store.rejectChanges();
              }
            });
    resetButton.setIcon(
        IconHelper.create(
            "/resources/grafica/x16/undo.png", Consts.ICON_WIDTH_SMALL, Consts.ICON_HEIGHT_SMALL));
    cp.addButton(resetButton);

    Button saveButton =
        new Button(
            "Save",
            new SelectionListener<ButtonEvent>() {

              @Override
              public void componentSelected(ButtonEvent ce) {
                store.commitChanges();
                salvaDati(aziende);
              }
            });
    saveButton.setIcon(
        IconHelper.create(
            "/resources/grafica/x16/save.png", Consts.ICON_WIDTH_SMALL, Consts.ICON_HEIGHT_SMALL));
    cp.addButton(saveButton);

    add(cp);
  }
Ejemplo n.º 8
0
  private void initUI() {
    long time = new java.util.Date().getTime();
    GWT.log("Initializing the UI ", null);

    container = new LayoutContainer();
    container.setLayout(new CenterLayout());

    // Rpc Proxy setup
    pagingToolBar = setupRpcProxy();

    // Audit event grid setup
    grid = setupGrid();

    // Panel
    ContentPanel cp = new ContentPanel();
    cp.setHeading("Entity Event Viewer");
    cp.setFrame(true);
    cp.setIcon(IconHelper.create("images/search_icon_16x16.png"));
    cp.setLayout(new FormLayout());
    cp.setSize(1100, 630);

    // Search Container
    ContentPanel searchContainer = new ContentPanel();
    searchContainer.setHeaderVisible(false);
    FormLayout searchFormLayout = new FormLayout();
    searchFormLayout.setLabelWidth(130);
    searchFormLayout.setDefaultWidth(770);

    searchContainer.setLayout(searchFormLayout);

    selectedEvenyTypes = new TextField<String>();
    selectedEvenyTypes.setFieldLabel("Selected Event Types");
    selectedEvenyTypes.setReadOnly(true);

    evenyTypes = new ListView<AuditEventTypeWeb>();
    evenyTypes.setDisplayProperty("auditEventTypeName");
    evenyTypes.setWidth(220);
    evenyTypes.setHeight(110);
    evenyTypes.setStore(eventTypesStore);
    evenyTypes
        .getSelectionModel()
        .addListener(
            Events.SelectionChange,
            new Listener<SelectionChangedEvent<AuditEventTypeWeb>>() {

              public void handleEvent(SelectionChangedEvent<AuditEventTypeWeb> be) {
                List<AuditEventTypeWeb> selections = be.getSelection();
                String selectedTypes = "";
                for (AuditEventTypeWeb type : selections) {
                  if (selectedTypes.isEmpty()) {
                    selectedTypes = type.getAuditEventTypeName();
                  } else {
                    selectedTypes = selectedTypes + ", " + type.getAuditEventTypeName();
                  }
                }
                selectedEvenyTypes.setValue(selectedTypes);

                if (selectedTypes.isEmpty()) {
                  searchButton.disable();
                } else {
                  searchButton.enable();
                }
              }
            });

    DateTimePropertyEditor dateFormat = new DateTimePropertyEditor("yyyy-MM-dd HH:mm");
    startDate = new DateField();
    startDate.setFieldLabel("Start Date Time");
    startDate.setToolTip("yyyy-MM-dd HH:mm");
    startDate.setPropertyEditor(dateFormat);

    endDate = new DateField();
    endDate.setFieldLabel("End Date Time");
    endDate.setToolTip("yyyy-MM-dd HH:mm");
    endDate.setPropertyEditor(dateFormat);

    LayoutContainer main = new LayoutContainer();
    main.setLayout(new ColumnLayout());

    LayoutContainer left = new LayoutContainer();
    left.setStyleAttribute("paddingRight", "10px");
    FormLayout layout = new FormLayout();
    layout.setLabelWidth(130);
    layout.setDefaultWidth(220);
    // layout.setLabelAlign(LabelAlign.TOP);
    left.setLayout(layout);
    left.add(startDate);

    LayoutContainer right = new LayoutContainer();
    right.setStyleAttribute("paddingLeft", "10px");
    layout = new FormLayout();
    // layout.setLabelAlign(LabelAlign.TOP);
    layout.setLabelWidth(130);
    layout.setDefaultWidth(220);
    right.setLayout(layout);
    right.add(endDate);

    main.add(left, new ColumnData(.5));
    main.add(right, new ColumnData(.5));

    HBoxLayoutData dataSelectedTypes = new HBoxLayoutData(new Margins(5, 0, 0, 0));
    searchContainer.add(selectedEvenyTypes, dataSelectedTypes);
    HBoxLayoutData dataTypes = new HBoxLayoutData(new Margins(5, 0, 5, 135));
    searchContainer.add(evenyTypes, dataTypes);

    searchContainer.add(main);
    HBoxLayoutData dataButtons = new HBoxLayoutData(new Margins(0, 0, 5, 0));
    searchContainer.add(setupButtonPanel(3), dataButtons);

    cp.add(searchContainer);
    cp.add(grid);
    cp.setBottomComponent(pagingToolBar);

    container.add(cp);

    LayoutContainer wrapper = (LayoutContainer) Registry.get(Constants.CENTER_PANEL);
    wrapper.removeAll();
    wrapper.add(container);
    wrapper.layout();
    GWT.log("Done Initializing the UI in " + (new java.util.Date().getTime() - time), null);
  }
Ejemplo n.º 9
0
  // 分支机构
  public ContentPanel createCcodebranchorgaddPanel() {
    ContentPanel panel = new ContentPanel();
    panel.setSize(400, 400);
    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();

    ColumnConfig ccode = new ColumnConfig("ccode", "ccode", 100);
    columns.add(ccode);

    ColumnConfig column = new ColumnConfig("orgname", "分支机构名称", 100);
    TextField<String> text = new TextField<String>();
    column.setEditor(new CellEditor(text));
    columns.add(column);
    ColumnConfig gname = new ColumnConfig("addr", "街道", 100);
    TextField<String> gnametext = new TextField<String>();
    gname.setEditor(new CellEditor(gnametext));
    columns.add(gname);

    ColumnConfig ncode = new ColumnConfig("ncode", "国别地区", 100);
    TextField<String> ncodetext = new TextField<String>();
    gname.setEditor(new CellEditor(ncodetext));
    columns.add(ncode);

    ColumnConfig fax = new ColumnConfig("fax", "传真", 100);
    TextField<String> faxtext = new TextField<String>();
    gname.setEditor(new CellEditor(faxtext));
    columns.add(fax);
    ColumnConfig telephone = new ColumnConfig("telephone", "电话", 100);
    TextField<String> telephonetext = new TextField<String>();
    gname.setEditor(new CellEditor(telephonetext));
    columns.add(telephone);
    ColumnConfig mobil = new ColumnConfig("mobil", "电话", 100);
    TextField<String> mobiltext = new TextField<String>();
    gname.setEditor(new CellEditor(mobiltext));
    columns.add(mobil);
    ColumnConfig postcode = new ColumnConfig("postcode", "邮编", 100);
    TextField<String> postcodetext = new TextField<String>();
    gname.setEditor(new CellEditor(postcodetext));
    columns.add(postcode);
    ColumnModel cm = new ColumnModel(columns);

    ModelType type = new ModelType();
    type.setRoot("records");
    type.setRecordName("record");
    type.setTotalName("totle");
    type.addField("ccode", "ccode");
    type.addField("orgname");

    type.addField("addr");
    type.addField("ncode");
    type.addField("idx");
    type.addField("fax");
    type.addField("telephone");
    type.addField("mobil");
    type.addField("postcode");
    StoreInfo info = new StoreInfo();

    info.setTablename("ccodebranchorgadd");
    info.setSql("select * from ccodebranchorgadd");
    info.setParent(store);
    info.setAutoinccolumn("idx");
    info.setLinkparentcolumns(new String[] {"ccode"});
    info.setKeyname(new String[] {"ccode", "idx"});

    BaseStore<JDBCModelData> branchorgadd = new BaseStore<JDBCModelData>(type, info);
    branchorgadd.setName("ccodebranchorgadd");
    BaseGrid branchorgaddstore = new BaseGrid(branchorgadd, cm);
    // officegrid.setAutoExpandColumn("ccode");
    // panel.setLayout(new BorderLayout());
    panel.setLayout(new FitLayout());
    BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
    centerData.setMargins(new Margins(0));
    panel.add(branchorgaddstore);
    registerStore(branchorgadd);
    return panel;
  }
Ejemplo n.º 10
0
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);

    criteria.addCondition(new Condition(IGoods.DELETED, Condition.EQUALS, "true"));
    BasePagingLoader loader = new PagingListService().getLoader(ModelNames.GOODS, criteria);
    loader.load(0, 10);
    final ListStore<BeanObject> store = new ListStore<BeanObject>(loader);

    toolBar = new PagingToolBar(10);
    toolBar.bind(loader);

    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    final CheckBoxSelectionModel<BeanObject> smRowSelection =
        new CheckBoxSelectionModel<BeanObject>();
    columns.add(smRowSelection.getColumn());
    columns.add(new ColumnConfig(IGoods.ID, "ID", 50));
    ColumnConfig col = new ColumnConfig(IGoods.NAME, Resources.constants.Goods_name(), 100);
    columns.add(col);
    col = new ColumnConfig(IGoods.SN, Resources.constants.Goods_SN(), 100);
    columns.add(col);

    col = new ColumnConfig(IGoods.SHOPPRICE, Resources.constants.Goods_shopPrice(), 80);
    col.setAlignment(HorizontalAlignment.RIGHT);
    col.setNumberFormat(NumberFormat.getCurrencyFormat());
    columns.add(col);

    ColumnConfig actcol = new ColumnConfig("Action", Resources.constants.GoodsList_action(), 100);
    //		columns.add(actcol);

    ColumnModel cm = new ColumnModel(columns);

    Grid<BeanObject> grid = new EditorGrid<BeanObject>(store, cm);
    grid.setLoadMask(true);
    grid.setBorders(true);
    grid.setSelectionModel(smRowSelection);
    //      grid.setAutoExpandColumn("forum");

    ActionCellRenderer render = new ActionCellRenderer(grid);
    ActionCellRenderer.ActionInfo act = new ActionCellRenderer.ActionInfo();
    act.setImage("icon_edit.gif");
    act.setAction("editGoods($id)");
    act.setTooltip(Resources.constants.GoodsList_action_edit());
    render.addAction(act);
    act = new ActionCellRenderer.ActionInfo();
    act.setImage("icon_trash.gif");
    act.setAction("deleteGoods($id)");
    act.setTooltip(Resources.constants.GoodsList_action_delete());
    render.addAction(act);

    actcol.setRenderer(render);

    HorizontalPanel header = new HorizontalPanel();
    header.add(Resources.images.icon_search().createImage());
    header.add(new Label("  " + Resources.constants.GoodsList_keyword()));
    header.add(txtKeyword);
    header.add(btnFind);
    add(header);

    btnFind.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          public void componentSelected(ButtonEvent ce) {
            search();
          }
        });

    ContentPanel panel = new ContentPanel();
    panel.setFrame(true);
    panel.setCollapsible(true);
    panel.setAnimCollapse(false);
    panel.setButtonAlign(HorizontalAlignment.CENTER);
    panel.setIconStyle("icon-table");
    //        panel.setHeading("Paging Grid");
    panel.setLayout(new FitLayout());
    panel.add(grid);
    panel.setSize(880, 350);
    panel.setBottomComponent(toolBar);

    panel.setButtonAlign(HorizontalAlignment.CENTER);
    panel.addButton(
        new Button(
            "彻底删除",
            new SelectionListener<ButtonEvent>() {
              public void componentSelected(ButtonEvent ce) {
                List<BeanObject> items = smRowSelection.getSelectedItems();
                purgeGoods(items);
              }
            }));

    panel.addButton(
        new Button(
            "恢复",
            new SelectionListener<ButtonEvent>() {
              public void componentSelected(ButtonEvent ce) {
                List<BeanObject> items = smRowSelection.getSelectedItems();
                restoreGoods(items);
              }
            }));

    add(panel);
  }
Ejemplo n.º 11
0
  public TaskGrid() {
    setLayout(new FlowLayout(10));
    getAriaSupport().setPresentation(true);

    final NumberFormat currency = NumberFormat.getCurrencyFormat();
    final NumberFormat number = NumberFormat.getFormat("0.00");
    // final NumberCellRenderer<Grid<Stock>> numberRenderer = new NumberCellRenderer<Grid<Stock>>(
    //		currency);

    /*
    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) {
    		Object o = model.get(property);

    		String v = "(not set)";
    		if(o == null) {
    			double val = (Double)o;
    			String style = val < 0 ? "red"
    					: GXT.isHighContrastMode ? "#00ff5a" : "green";
    			v = number.format(val);

    		}

    		return "<span qtitle='"
    				+ cm.getColumnById(property).getHeader() + "' qtip='"
    				+ v + "' style='font-weight: bold;color:" + style
    				+ "'>" + v + "</span>";
    	}
    };*/

    /*
    GridCellRenderer<Stock> gridNumber = new GridCellRenderer<Stock>() {
    	public String render(Stock model, String property,
    			ColumnData config, int rowIndex, int colIndex,
    			ListStore<Stock> store, Grid<Stock> grid) {
    		return numberRenderer.render(null, property,
    				model.get(property));
    	}
    };*/

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

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

    column = new ColumnConfig();
    column.setId("direction");
    column.setHeader("Direction");
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setWidth(100);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("sampled");
    column.setHeader("Sampled");
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setWidth(100);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("sampleSize");
    column.setHeader("Sample size");
    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", "Finished", 100);
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/yyyy"));
    configs.add(column);

    // ListStore<TaskDescription> store = new ListStore<TaskDescription>();
    // store.add(getStocks());

    // store.add(TaskData.getStocks());

    // store.add(getStocks());

    cm = new ColumnModel(configs);

    ContentPanel cp = new ContentPanel();
    cp.setBodyBorder(true);
    // cp.setIcon(Resources.ICONS.table());
    cp.setHeading("Available Linksets");
    cp.setButtonAlign(HorizontalAlignment.CENTER);
    cp.setLayout(new FitLayout());
    cp.getHeader().setIconAltText("Grid Icon");
    cp.setSize(600, 300);

    // final Grid<TaskDescription>
    grid = new Grid<TaskDescription>(getStocks(), cm);
    grid.setStyleAttribute("borderTop", "none");
    grid.setAutoExpandColumn("name");
    grid.setBorders(false);
    grid.setStripeRows(true);
    grid.setColumnLines(true);
    grid.setColumnReordering(true);
    grid.getAriaSupport().setLabelledBy(cp.getHeader().getId() + "-label");
    cp.add(grid);

    ToolBar toolBar = new ToolBar();
    toolBar.getAriaSupport().setLabel("Grid Options");

    toolBar.add(new LabelToolItem("Selection Mode: "));
    final SimpleComboBox<String> type = new SimpleComboBox<String>();
    type.getAriaSupport().setLabelledBy(toolBar.getItem(0).getId());
    type.setTriggerAction(TriggerAction.ALL);
    type.setEditable(false);
    type.setFireChangeEventOnSetValue(true);
    type.setWidth(100);
    type.add("Row");
    type.add("Cell");
    type.setSimpleValue("Row");
    type.addListener(
        Events.Change,
        new Listener<FieldEvent>() {
          public void handleEvent(FieldEvent be) {
            boolean cell = type.getSimpleValue().equals("Cell");
            grid.getSelectionModel().deselectAll();
            if (cell) {
              grid.setSelectionModel(new CellSelectionModel<TaskDescription>());
            } else {
              grid.setSelectionModel(new GridSelectionModel<TaskDescription>());
            }
          }
        });
    toolBar.add(type);

    cp.setTopComponent(toolBar);

    add(cp);

    // needed to enable quicktips (qtitle for the heading and qtip for the
    // content) that are setup in the change GridCellRenderer
    new QuickTip(grid);
  }
Ejemplo n.º 12
0
  /** 初始化界面。 */
  public MagazineManager() {
    curState = new State();

    BasePagingLoader loader = new PagingListService().getLoader(ModelNames.MAILTEMPLATE, criteria);
    loader.load(0, 10);
    store = new ListStore<BeanObject>(loader);
    toolBar = new PagingToolBar(10);
    toolBar.bind(loader);

    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    ColumnConfig title = new ColumnConfig(IMailTemplate.SUBJECT, "杂志标题", 200);
    columns.add(title);
    columns.add(new ColumnConfig(IMailTemplate.LASTMODIFY, "杂志上次编辑时间", 160));
    columns.add(new ColumnConfig(IMailTemplate.LASTSEND, "杂志上次发送时间", 160));
    ColumnConfig insert = new ColumnConfig("insert", "插入发送队列", 160);
    columns.add(insert);
    ColumnConfig actcol = new ColumnConfig("Action", "操作", 100);
    columns.add(actcol);
    ColumnModel cm = new ColumnModel(columns);

    grid = new Grid<BeanObject>(store, cm);
    grid.setLoadMask(true);
    grid.setBorders(true);

    ActionCellRenderer render = new ActionCellRenderer(grid);
    ActionCellRenderer insertRender = new ActionCellRenderer(grid);
    ActionCellRenderer.ActionInfo act = new ActionCellRenderer.ActionInfo();
    act.setImage("icon_edit.gif");
    act.setAction("editMagazine($id)");
    act.setTooltip("编辑");
    render.addAction(act);
    act = new ActionCellRenderer.ActionInfo();
    act.setImage("icon_trash.gif");
    act.setAction("deleteMagazine($id)");
    act.setTooltip("删除");
    render.addAction(act);
    act = new ActionCellRenderer.ActionInfo();
    act.setText("插入队列");
    act.setAction("insertMagazine($id)");
    act.setTooltip("插入队列");
    insertRender.addAction(act);

    actcol.setRenderer(render);
    insert.setRenderer(insertRender);

    ContentPanel panel = new ContentPanel();
    panel.setFrame(true);
    panel.setCollapsible(true);
    panel.setAnimCollapse(false);
    panel.setButtonAlign(HorizontalAlignment.CENTER);
    panel.setIconStyle("icon-table");
    panel.setLayout(new FitLayout());
    panel.add(grid);
    panel.setSize(850, 350);
    panel.setBottomComponent(toolBar);
    panel.setHeading("邮件杂志列表");
    panel.setButtonAlign(HorizontalAlignment.LEFT);

    // 添加新杂志
    final com.extjs.gxt.ui.client.widget.button.Button addMagazine =
        new com.extjs.gxt.ui.client.widget.button.Button("添加新杂志");
    addMagazine.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          public void componentSelected(ButtonEvent ce) {
            // add new magazine function
            NewMagazine.State state = new NewMagazine.State();
            state.execute();
          }
        });
    panel.addButton(addMagazine);

    add(panel);
    initJS(this);
  }
Ejemplo n.º 13
0
  private void createGesturePropertyForm() {
    FormPanel gesturePropertyForm = new FormPanel();
    gesturePropertyForm.setLabelAlign(LabelAlign.TOP);
    gesturePropertyForm.setHeaderVisible(false);

    final Text selectedCommand = new Text(SELECTED_COMMAND);

    ContentPanel commandTreeContainer = new ContentPanel();
    commandTreeContainer.setHeaderVisible(false);
    commandTreeContainer.setBorders(false);
    commandTreeContainer.setBodyBorder(false);
    commandTreeContainer.setSize(240, 150);
    commandTreeContainer.setLayout(new FitLayout());
    commandTreeContainer.setScrollMode(Scroll.AUTO);
    if (devicesAndMacrosTree == null) {
      devicesAndMacrosTree = TreePanelBuilder.buildCommandAndMacroTree();
      commandTreeContainer.add(devicesAndMacrosTree);
    }
    devicesAndMacrosTree.collapseAll();
    final AdapterField commandField = new AdapterField(commandTreeContainer);
    commandField.setFieldLabel("Select a command");
    commandField.setBorders(true);
    devicesAndMacrosTree
        .getSelectionModel()
        .addSelectionChangedListener(
            new SelectionChangedListener<BeanModel>() {
              public void selectionChanged(SelectionChangedEvent<BeanModel> se) {
                BeanModel commandModel = se.getSelectedItem();
                if (commandModel.getBean() != null) {
                  UICommandDTO uiCommand = commandModel.getBean();
                  selectedCommand.setText(SELECTED_COMMAND + uiCommand.getDisplayName());
                  selectedGesture.setUiCommandDTO(uiCommand);
                }
              }
            });

    final NavigateFieldSet navigateSet =
        new NavigateFieldSet(selectedGesture.getNavigate(), groups);
    navigateSet.setStyleAttribute("marginTop", "10px");
    navigateSet.setCheckboxToggle(true);
    navigateSet.addListener(
        Events.BeforeExpand,
        new Listener<FieldSetEvent>() {
          @Override
          public void handleEvent(FieldSetEvent be) {
            if (!selectedGesture.getNavigate().isSet()) {
              selectedGesture.getNavigate().setToLogical(ToLogicalType.setting);
            }
            navigateSet.update(selectedGesture.getNavigate());
          }
        });
    navigateSet.addListener(
        Events.BeforeCollapse,
        new Listener<FieldSetEvent>() {
          @Override
          public void handleEvent(FieldSetEvent be) {
            selectedGesture.getNavigate().clear();
          }
        });
    navigateSet.collapse();

    gesturePropertyForm.add(commandField);
    gesturePropertyForm.add(selectedCommand);
    gesturePropertyForm.add(navigateSet);
    BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
    add(gesturePropertyForm, centerData);

    gestureTypeListView.addListener(
        Events.Select,
        new Listener<ListViewEvent<BeanModel>>() {
          public void handleEvent(ListViewEvent<BeanModel> be) {
            Gesture gesture =
                gestureMaps.get(((Gesture) be.getModel().getBean()).getType().toString());
            if (!gesture.equals(selectedGesture)) {
              selectedGesture = gesture;
              devicesAndMacrosTree.collapseAll();
              if (selectedGesture.getUiCommandDTO() != null) {
                selectedCommand.setText(
                    SELECTED_COMMAND + selectedGesture.getUiCommandDTO().getDisplayName());
              } else {
                selectedCommand.setText(SELECTED_COMMAND);
              }
              if (selectedGesture.getNavigate().isSet()) {
                navigateSet.expand();
                navigateSet.fireEvent(Events.BeforeExpand);
              } else {
                navigateSet.collapse();
              }
            }
          }
        });
  }
Ejemplo n.º 14
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;
  }
Ejemplo n.º 15
0
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);

    setLayout(new FlowLayout(10));

    Folder model = TestData.getTreeModel();

    TreeStore<ModelData> store = new TreeStore<ModelData>();

    store.add(model.getChildren(), true);

    ColumnConfig name = new ColumnConfig("name", "Name", 100);
    name.setRenderer(new TreeGridCellRenderer<ModelData>());

    ColumnConfig date = new ColumnConfig("author", "Author", 100);

    ColumnConfig size = new ColumnConfig("genre", "Genre", 100);

    ColumnModel cm = new ColumnModel(Arrays.asList(name, date, size));

    ContentPanel cp = new ContentPanel();
    cp.setBodyBorder(false);
    cp.setHeading("TreeGrid");
    cp.setButtonAlign(HorizontalAlignment.CENTER);
    cp.setLayout(new FitLayout());
    cp.setFrame(true);
    cp.setSize(600, 300);

    TreeGrid<ModelData> tree = new TreeGrid<ModelData>(store, cm);
    tree.setBorders(true);
    tree.getStyle().setLeafIcon(Resources.ICONS.music());
    tree.setAutoExpandColumn("name");
    tree.setTrackMouseOver(false);

    cp.add(tree);

    add(cp);

    StoreFilterField<ModelData> filter =
        new StoreFilterField<ModelData>() {

          @Override
          protected boolean doSelect(
              Store<ModelData> store,
              ModelData parent,
              ModelData record,
              String property,
              String filter) {
            // only match leaf nodes
            if (record instanceof Folder) {
              return false;
            }
            String name = record.get("name");
            name = name.toLowerCase();
            if (name.startsWith(filter.toLowerCase())) {
              return true;
            }
            return false;
          }
        };
    filter.bind(store);

    ToolBar toolBar = new ToolBar();
    toolBar.setBorders(true);
    toolBar.add(new LabelToolItem("Filter:"));
    toolBar.add(filter);

    cp.setTopComponent(toolBar);
  }
Ejemplo n.º 16
0
  // 办公地址信息
  public ContentPanel createOfficePanel() {
    ContentPanel panel = new ContentPanel();
    panel.setSize(400, 400);
    CheckBoxSelectionModel cbs = new CheckBoxSelectionModel();
    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    columns.add(cbs.getColumn());
    ColumnConfig ccode = new ColumnConfig("ccode", "ccode", 100);
    columns.add(ccode);

    ColumnConfig column = new ColumnConfig("addrtype", "地址类型", 100);
    TextField<String> text = new TextField<String>();
    column.setEditor(new CellEditor(text));
    columns.add(column);
    ColumnConfig addr = new ColumnConfig("addr", "街道", 100);
    TextField<String> addrtext = new TextField<String>();
    addr.setEditor(new CellEditor(addrtext));
    columns.add(addr);

    ColumnConfig ncode = new ColumnConfig("ncode", "国别地区", 100);
    TextField<String> ncodetext = new TextField<String>();
    ncode.setEditor(new CellEditor(ncodetext));
    columns.add(ncode);

    ColumnConfig fax = new ColumnConfig("fax", "传真", 100);
    TextField<String> faxtext = new TextField<String>();
    fax.setEditor(new CellEditor(faxtext));
    columns.add(fax);

    ColumnModel cm = new ColumnModel(columns);

    ModelType type = new ModelType();
    type.setRoot("records");
    type.setRecordName("record");

    type.addField("ccode", "ccode");
    type.addField("idx");
    type.addField("addrtype");
    type.addField("addr");
    type.addField("ncode");
    type.addField("fax");
    StoreInfo info = new StoreInfo();

    info.setTablename("ccodeofficeaddress");
    info.setSql("select * from ccodeofficeaddress");
    info.setParent(store);
    info.setAutoinccolumn("idx");
    info.setLinkparentcolumns(new String[] {"ccode"});
    info.setKeyname(new String[] {"ccode", "idx"});

    BaseStore<JDBCModelData> officestore = new BaseStore<JDBCModelData>(type, info);
    officestore.setName("ccodeofficeaddress");
    BaseGrid officegrid = new BaseGrid(officestore, cm);
    cbs.setSelectionMode(SelectionMode.SINGLE);
    officegrid.setSelectionModel(cbs);
    // officegrid.setAutoExpandColumn("ccode");
    // panel.setLayout(new BorderLayout());
    panel.setLayout(new FitLayout());
    BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
    centerData.setMargins(new Margins(0));
    panel.add(officegrid);
    // officegrid.set

    registerStore(officestore);
    return panel;
  }
  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);
  }
  @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);
  }
  @Inject
  public ProjectIndicatorsContainer(
      ProjectSiteGridPanel siteEditor,
      SiteMap siteMap,
      final DesignPanel designPanel,
      Dispatcher service,
      EventBus eventBus) {

    this.siteEditor = siteEditor;
    this.siteMap = siteMap;
    this.designPanel = designPanel;
    this.service = service;
    this.eventBus = eventBus;

    BorderLayout borderLayout = new BorderLayout();
    borderLayout.setContainerStyle("x-border-layout-ct main-background");
    setLayout(borderLayout);

    ContentPanel mainPanel = new ContentPanel();
    mainPanel.setIcon(null);
    mainPanel.setLayout(new FitLayout());
    mainPanel.setSize(600, 300);

    // setIcon(IconImageBundle.ICONS.design());
    // map tab panel
    tabPanel = new TabPanel();
    tabPanel.setPlain(true);

    // map tab item
    mapTabItem = new TabItem("map");
    mapTabItem.setLayout(new FitLayout());
    mapTabItem.setEnabled(false);
    mapTabItem.setAutoHeight(true);
    mapTabItem.setEnabled(true);
    mapTabItem.add(siteMap);
    tabPanel.add(mapTabItem);

    // sites tab item
    sitesTabItem = new TabItem("sites");
    sitesTabItem.setLayout(new FitLayout());
    sitesTabItem.setEnabled(false);
    sitesTabItem.setAutoHeight(true);
    sitesTabItem.setEnabled(true);
    sitesTabItem.add(siteEditor);
    tabPanel.add(sitesTabItem);

    // buttons for indicator view
    newIndicatorButton = new Button("new indicator");
    newGroupButton = new Button("new group");
    reloadButton = new Button("reload button");

    mainPanel.add(newIndicatorButton);
    mainPanel.add(newGroupButton);
    mainPanel.add(reloadButton);

    BorderLayoutData centerLayout = new BorderLayoutData(Style.LayoutRegion.CENTER);
    centerLayout.setMargins(new Margins(0, 0, 0, 0));
    centerLayout.setSplit(true);
    centerLayout.setCollapsible(true);

    BorderLayoutData layout = new BorderLayoutData(Style.LayoutRegion.EAST);
    layout.setSplit(true);
    layout.setCollapsible(true);
    layout.setSize(375);
    layout.setMargins(new Margins(0, 0, 0, 5));

    add(designPanel, centerLayout);
    designPanel
        .getMappedIndicator()
        .addValueChangeHandler(
            new ValueChangeHandler<IndicatorDTO>() {

              @Override
              public void onValueChange(ValueChangeEvent<IndicatorDTO> event) {
                onMappedIndicatorChanged(event.getValue());
              }
            });

    add(tabPanel, layout);
    // setHeading(I18N.CONSTANTS.design() + " - " );

    siteEditor.addActionListener(
        new Listener<ComponentEvent>() {

          @Override
          public void handleEvent(ComponentEvent be) {
            if (UIActions.add.equals(be.getComponent().getItemId())) {
              addSite();
            }
          }
        });
  }
Ejemplo n.º 20
0
  // RefRecordInfoDialog
  private void buildRefRecordInfoDialog() {

    if (refRecordInfoDialog != null) {
      return;
    }
    refRecordInfoDialog = new Dialog();
    refRecordInfoDialog.setBodyBorder(false);
    refRecordInfoDialog.setWidth(940);
    refRecordInfoDialog.setHeight(540);
    refRecordInfoDialog.setIcon(IconHelper.create("images/information.png"));
    refRecordInfoDialog.setHeading("Reference Record Information");
    refRecordInfoDialog.setButtons(Dialog.OK);
    refRecordInfoDialog.setModal(true);
    refRecordInfoDialog
        .getButtonById(Dialog.OK)
        .addSelectionListener(
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent ce) {

                // refPersonInfoDialog.hide();
                refRecordInfoDialog.close();
              }
            });

    ContentPanel cp = new ContentPanel();
    cp.setFrame(false);
    cp.setLayout(new BorderLayout());
    cp.setSize(930, 500);

    formButtonContainer = new LayoutContainer();
    formButtonContainer.setScrollMode(Scroll.AUTOY);

    TableLayout identlayout = new TableLayout(2);
    identlayout.setWidth("100%");
    identlayout.setCellSpacing(5);
    identlayout.setCellVerticalAlign(VerticalAlignment.TOP);

    FormLayout toplayout = new FormLayout();

    TableLayout formlayout = new TableLayout(2);
    formlayout.setWidth("930"); // "100%"
    formlayout.setCellSpacing(5);
    formlayout.setCellVerticalAlign(VerticalAlignment.TOP);

    identifierContainer = new LayoutContainer();
    ;
    identifierContainer.setLayout(identlayout);
    FormPanel identifierPanel = setupForm("", 150, 854);
    identifierPanel.add(setupIdentifierfieldSet(865, 1));
    identifierContainer.add(identifierPanel);

    topContainer = new LayoutContainer();
    ;
    topContainer.setLayout(toplayout);
    topFormPanel = setupForm("", 150, 400);
    topFormPanel.setStyleAttribute("padding-left", "15px");

    formContainer = new LayoutContainer();
    formContainer.setLayout(formlayout);
    leftFormPanel = setupForm("", 150, 400);
    rightFormPanel = setupForm("", 150, 400);

    if (currentEntity != null) {

      if (currentEntity.getAttributes() != null) {

        // Groups
        List<EntityAttributeGroupWeb> sortedAttributeGroups = null;
        if (currentEntity.getEntityAttributeGroups() != null) {
          sortedAttributeGroups =
              new ArrayList<EntityAttributeGroupWeb>(
                  currentEntity.getEntityAttributeGroups().size());
          for (EntityAttributeGroupWeb entityGroup : currentEntity.getEntityAttributeGroups()) {
            // Info.display("Entity Group:", entityGroup.getName()+ ";
            // "+entityGroup.getDisplayOrder());
            sortedAttributeGroups.add(entityGroup);
          }
          Collections.sort(sortedAttributeGroups, GROUP_DISPLAY_ORDER);
        }

        // Attributes
        List<EntityAttributeWeb> sortedEntityAttributes =
            new ArrayList<EntityAttributeWeb>(currentEntity.getAttributes().size());
        if (currentEntity.getAttributes() != null) {
          for (EntityAttributeWeb entityAttribute : currentEntity.getAttributes()) {
            sortedEntityAttributes.add(entityAttribute);
          }
          // sort by display order
          Collections.sort(sortedEntityAttributes, ATTRIBUTE_DISPLAY_ORDER);
        }

        attributeFieldMap = new HashMap<String, Field<?>>();

        // Attributes with no group
        for (EntityAttributeWeb entityAttribute : sortedEntityAttributes) {
          // Info.display("Attribute:", entityAttribute.getName()
          // +"; "+entityAttribute.getDatatype().getDataTypeCd());

          if (entityAttribute.getEntityAttributeGroup() == null) {
            Field<?> field = createField(entityAttribute, true, false);
            if (field != null) {
              attributeFieldMap.put(entityAttribute.getName(), field);
              topFormPanel.add(field);
            }
          }
        }

        // Attributes with group
        if (sortedAttributeGroups != null) {
          boolean leftForm = true;
          for (EntityAttributeGroupWeb attributeGroup : sortedAttributeGroups) {

            FieldSet groupfieldSet =
                createGroupFields(attributeFieldMap, attributeGroup, sortedEntityAttributes, false);

            if (groupfieldSet != null) {
              if (leftForm) {
                leftFormPanel.add(groupfieldSet);
                leftForm = false;
              } else {
                rightFormPanel.add(groupfieldSet);
                leftForm = true;
              }
            }
          }
        }
      }
    }

    topContainer.add(topFormPanel);
    formContainer.add(leftFormPanel);
    formContainer.add(rightFormPanel);

    formButtonContainer.add(identifierContainer);
    formButtonContainer.add(topContainer);
    formButtonContainer.add(formContainer);

    BorderLayoutData data = new BorderLayoutData(LayoutRegion.CENTER);
    data.setMargins(new Margins(4, 2, 4, 2));

    cp.add(formButtonContainer, data);

    refRecordInfoDialog.add(cp);
  }
Ejemplo n.º 21
0
  public IncidentGrid(final Tabs tabs) {
    this.tabs = tabs;
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

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

    column = new ColumnConfig();
    column.setId("category");
    column.setHeader("Category");
    column.setWidth(100);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("status");
    column.setHeader("Status");
    column.setWidth(100);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("urgency");
    column.setHeader("Urgency");
    column.setWidth(100);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("impact");
    column.setHeader("Impact");
    column.setWidth(100);
    configs.add(column);

    ColumnModel cm = new ColumnModel(configs);

    final ListStore<Incident> store = new ListStore<Incident>();

    incidentManager.getIncidents(
        new AsyncCallback<List<Incident>>() {

          public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub

          }

          public void onSuccess(List<Incident> result) {
            List<Incident> filteredResult = new ArrayList<Incident>();
            if (tabs.getUser().getUserType().equals(UserType.ADMIN)) {
              filteredResult = result;
            } else {
              for (Incident i : result) {
                if (i.getUserName().equals(tabs.getUser().getName())) {
                  filteredResult.add(i);
                }
              }
            }
            store.add(filteredResult);
          }
        });

    ContentPanel cp = new ContentPanel();
    cp.setBodyBorder(false);
    cp.setHeading("Basic Grid");
    // cp.setButtonAlign(HorizontalAlignment.CENTER);
    cp.setLayout(new FitLayout());
    cp.setSize(600, 200);

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

    add(cp);
  }