示例#1
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;
  }
示例#2
0
  @Override
  public void initialize() {
    container =
        Panels.content(
            null,
            false,
            Layouts.vBoxLayout(
                VBoxLayout.VBoxLayoutAlign.STRETCH, new Layouts.LayoutOptions(new Padding(10))),
            "x-border-layout-ct");
    container.setScrollMode(Style.Scroll.AUTOY);
    container.addStyleName("contact-details-container");
    add(container);

    saveButton = Forms.button(I18N.CONSTANTS.save(), IconImageBundle.ICONS.save());
    deleteButton = Forms.button(I18N.CONSTANTS.delete(), IconImageBundle.ICONS.remove());
    exportButton = Forms.button(I18N.CONSTANTS.export(), IconImageBundle.ICONS.excel());

    toolBar = new ToolBar();
    toolBar.setAlignment(Style.HorizontalAlignment.LEFT);
    toolBar.setBorders(false);
    toolBar.add(saveButton);
    toolBar.add(deleteButton);
    toolBar.add(exportButton);

    container.setTopComponent(toolBar);
  }
示例#3
0
  public ServerEditor() {
    // create content:
    content = new ContentPanel();
    content.setBodyBorder(false);
    content.setHeaderVisible(false);
    content.setScrollMode(Scroll.AUTO);
    //		content.setHeading("Properties");
    content.setButtonAlign(HorizontalAlignment.RIGHT);

    // da toolbar
    ToolBar toolbar = new ToolBar();
    TextToolItem save = new TextToolItem("Save", "icon-save");
    toolbar.add(save);
    toolbar.add(new SeparatorToolItem());
    content.setTopComponent(toolbar);

    tabFolder = new TabPanel();
    tabFolder.setTabScroll(true);

    addTabs(tabFolder);

    RowLayout layout = new RowLayout(Orientation.VERTICAL);
    content.setLayout(layout);
    content.add(tabFolder, new RowData(1, 1));
  }
  private ContentPanel createMulti() {
    ContentPanel panel = new SamplePanel();
    panel.setHeading("Multi Columns");

    ToolBar toolBar = new ToolBar();
    panel.setTopComponent(toolBar);

    ButtonGroup group = new ButtonGroup(2);
    group.setHeading("Clipboard");

    Button btn = new Button("Cool", IconHelper.createStyle("add16"));
    group.add(btn);

    btn = new Button("Cut", IconHelper.createStyle("add16"));
    Menu menu = new Menu();
    menu.add(new MenuItem("Copy me"));
    btn.setMenu(menu);
    group.add(btn);

    btn = new Button("Copy", IconHelper.createStyle("add16"));
    group.add(btn);

    btn = new Button("Paste", IconHelper.createStyle("add16"));
    group.add(btn);

    toolBar.add(group);

    group = new ButtonGroup(2);
    group.setHeading("Other Bugus Actions");

    btn = new Button("Cool", IconHelper.createStyle("add16"));
    group.add(btn);

    btn = new Button("Cut", IconHelper.createStyle("add16"));
    menu = new Menu();
    menu.add(new MenuItem("Copy me"));
    btn.setMenu(menu);
    group.add(btn);

    btn = new Button("Copy", IconHelper.createStyle("add16"));
    group.add(btn);

    btn = new Button("Paste", IconHelper.createStyle("add16"));
    group.add(btn);

    toolBar.add(group);
    return panel;
  }
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());

    ContentPanel content = new ContentPanel();
    content.setHeaderVisible(false);
    content.setBodyBorder(false);
    content.setLayout(new FitLayout());

    grid = createGrid();
    content.add(grid);

    // 添加工具栏
    ToolBar toolBar = new ToolBar();
    Button printButton = new Button("打印", Resources.ICONS.printer());
    toolBar.add(printButton);

    content.setTopComponent(toolBar);
    add(content);
  }
  @Override
  public void addPanelContent() {
    //		contentPanel = new ContentPanel();
    contentPanel.setLayout(new FitLayout());
    //		contentPanel.setHeading("Snapshot Terms Chart View");
    IconSupplier.setIcon(contentPanel, IconSupplier.getPieChartIconName());

    if (store == null) store = getNewStore();

    if (chart == null) createChart();

    addHelpTool(contentPanel);
    contentPanel.getHeader().addTool(getParametersTool());

    contentPanel.setTopComponent(getButtonsBar());

    contentPanel.add(chart, new MarginData(20));

    add(contentPanel);

    if (snapshot != null && localStore) store.getLoader().load();
  }
  private ContentPanel createStandard() {
    ContentPanel panel = new SamplePanel();
    panel.setHeading("Standard");

    ToolBar toolBar = new ToolBar();

    Button btn = new Button("Cool", IconHelper.createStyle("add16"));
    toolBar.add(btn);
    Menu menu = new Menu();
    menu.add(new MenuItem("Ribbons are cool"));
    btn.setMenu(menu);
    toolBar.add(new SeparatorToolItem());

    btn = new Button("Cut", IconHelper.createStyle("add16"));
    menu = new Menu();
    menu.add(new MenuItem("Copy me"));
    toolBar.add(btn);

    btn = new Button("Copy", IconHelper.createStyle("add16"));
    toolBar.add(btn);

    btn = new Button("Paste", IconHelper.createStyle("add16"));
    toolBar.add(btn);
    menu = new Menu();
    menu.add(new MenuItem("Ribbons are cool"));
    btn.setMenu(menu);
    toolBar.add(new SeparatorToolItem());

    ToggleButton toggleBtn = new ToggleButton("Format");
    toggleBtn.toggle(true);
    toolBar.add(toggleBtn);

    panel.setTopComponent(toolBar);

    return panel;
  }
  @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);
  }
  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);
  }
示例#10
0
  public Widget aa() {
    int armStatus = ArmWrapper.FAILED;
    try {
      ArmWrapper.startTransaction(
          this, "com.base.myproject.client.busi.b2c.manager.ChartTest", "aa", new Object[] {});
      ContentPanel panel = new ContentPanel();
      panel.setAutoHeight(true);
      ToolBar tb = new ToolBar();
      Button addsuit = new Button("从商品库里添加套装商品");
      addsuit.setIconStyle("b2csuit");
      panel.setHeading("商品库,如果加入套装你必须先选择一行(必选)");
      tb.add(addsuit);
      panel.setTopComponent(tb);
      // addsuit.addListener(Events.Select, this);
      panel.setAutoWidth(true);
      CheckBoxSelectionModel cbs = new CheckBoxSelectionModel();
      List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
      columns.add(cbs.getColumn());
      ColumnConfig gcode = new ColumnConfig("gcode", "商品大类编码", 100);
      TextField<String> gcodetext = new TextField<String>();
      gcode.setEditor(new CellEditor(gcodetext));
      columns.add(gcode);
      ColumnConfig gname = new ColumnConfig("discountprice", "商品大类名称", 100);
      TextField<String> gnametext = new TextField<String>();
      gname.setEditor(new CellEditor(gnametext));
      columns.add(gname);

      ColumnConfig treecode = new ColumnConfig("price", "商品分类树编码", 100);

      TextField<String> treecodetext = new TextField<String>();
      treecode.setEditor(new CellEditor(treecodetext));
      columns.add(treecode);

      ColumnConfig b2cgcodecolumn = new ColumnConfig("b2cgcode", "商品编码", 100);
      TextField<String> b2cgcodetext = new TextField<String>();
      b2cgcodecolumn.setEditor(new CellEditor(b2cgcodetext));
      columns.add(b2cgcodecolumn);
      ColumnConfig b2cgname = new ColumnConfig("b2cgname", "商品名称", 100);
      TextField<String> b2cgnametext = new TextField<String>();
      b2cgname.setEditor(new CellEditor(b2cgnametext));
      columns.add(b2cgname);

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

      type.addField("gcode");
      type.addField("gname");
      type.addField("b2cgcode");
      type.addField("price");
      type.addField("discountprice");
      type.addField("b2cgname");
      type.addField("mainimagepath");
      type.addField("treecode");
      type.addField("detailimage");

      StoreInfo info = new StoreInfo();

      info.setTablename("b2cgcode");
      info.setKeyname(new String[] {"b2cgcode"});
      info.setSql("select * from b2cgcode");
      BaseStore<JDBCModelData> store = new BaseStore<JDBCModelData>(type, info);

      ChartModel model =
          new ChartModel(
              "Team Sales by Month", "font-size: 14px; font-family: Verdana; text-align: center;");
      model.setBackgroundColour("#fefefe");
      model.setLegend(new Legend(Position.TOP, true));
      model.setScaleProvider(ScaleProvider.ROUNDED_NEAREST_SCALE_PROVIDER);

      BarChart bar = new BarChart(BarStyle.GLASS);
      bar.setColour("#00aa00");
      BarDataProvider barProvider = new BarDataProvider("price", "b2cgname");
      barProvider.bind(store);
      bar.setDataProvider(barProvider);
      //  bar.addChartListener(listener);
      model.addChartConfig(bar);

      bar = new BarChart(BarStyle.GLASS);
      bar.setColour("#ff6600");
      barProvider = new BarDataProvider("discountprice");
      barProvider.bind(store);
      bar.setDataProvider(barProvider);
      // bar.addChartListener(listener);
      model.addChartConfig(bar);

      LineChart line = new LineChart();
      line.setAnimateOnShow(true);
      line.setText("Average");
      line.setColour("#FF0000");
      LineDataProvider lineProvider = new LineDataProvider("discountprice");
      lineProvider.bind(store);
      line.setDataProvider(lineProvider);
      model.addChartConfig(line);

      /*	    PieChart pie = new PieChart();
      PieDataProvider piedataprovider = new PieDataProvider("discountprice");
      piedataprovider.bind(store);
      pie.setDataProvider(piedataprovider);
      model.addChartConfig(pie);*/

      String url = "chart/open-flash-chart.swf";
      final Chart chart = new Chart(url);
      chart.setChartModel(model);
      chart.setHeight("300px");
      ContentPanel cp = new ContentPanel();
      cp.setHeading("Chart");
      cp.add(chart);
      ColumnModel cm = new ColumnModel(columns);
      BaseGrid grid = new BaseGrid(store, cm);
      grid.setHeight("300px");
      cp.add(grid);
      armStatus = ArmWrapper.GOOD;
      return cp;
    } finally {
      ArmWrapper.stopTransaction(
          "com.base.myproject.client.busi.b2c.manager.ChartTest", "aa", armStatus);
    }
  }
  private ContentPanel createMixed() {
    ContentPanel panel = new SamplePanel();
    panel.setHeading("Mix and match icon sizes");

    ToolBar toolBar = new ToolBar();
    panel.setTopComponent(toolBar);

    ButtonGroup group = new ButtonGroup(3);
    group.setHeading("Clipboard");
    toolBar.add(group);

    Button btn = new Button("Paste", Resources.ICONS.add32());
    btn.addStyleName("x-btn-as-arrow");
    btn.setScale(ButtonScale.LARGE);
    btn.setIconAlign(IconAlign.TOP);
    btn.setArrowAlign(ButtonArrowAlign.BOTTOM);
    TableData data = new TableData();
    data.setRowspan(3);

    group.add(btn, data);

    btn = new Button("Format", Resources.ICONS.add32());
    btn.setScale(ButtonScale.LARGE);
    btn.setIconAlign(IconAlign.TOP);
    btn.setArrowAlign(ButtonArrowAlign.BOTTOM);
    Menu menu = new Menu();
    menu.add(new MenuItem("Cool"));
    btn.setMenu(menu);
    group.add(btn, data);

    btn = new Button("Copy", IconHelper.createStyle("add16"));
    menu = new Menu();
    menu.add(new MenuItem("Copy me"));
    btn.setMenu(menu);
    group.add(btn);

    btn = new Button("Cut", IconHelper.createStyle("add16"));
    group.add(btn);

    btn = new Button("Paste", IconHelper.createStyle("add16"));
    group.add(btn);

    group = new ButtonGroup(3);
    group.setHeading("Clipboard");
    toolBar.add(group);

    btn = new Button("Paste", Resources.ICONS.add32());
    btn.addStyleName("x-btn-as-arrow");
    btn.setScale(ButtonScale.LARGE);
    btn.setIconAlign(IconAlign.TOP);
    btn.setArrowAlign(ButtonArrowAlign.BOTTOM);
    data = new TableData();
    data.setRowspan(3);

    group.add(btn, data);

    btn = new Button("Format", Resources.ICONS.add32());
    btn.setScale(ButtonScale.LARGE);
    btn.setIconAlign(IconAlign.TOP);
    btn.setArrowAlign(ButtonArrowAlign.BOTTOM);
    menu = new Menu();
    menu.add(new MenuItem("Cool"));
    btn.setMenu(menu);
    group.add(btn, data);

    btn = new Button("Copy", IconHelper.createStyle("add16"));
    menu = new Menu();
    menu.add(new MenuItem("Copy me"));
    btn.setMenu(menu);
    group.add(btn);

    btn = new Button("Cut", IconHelper.createStyle("add16"));
    group.add(btn);

    btn = new Button("Paste", IconHelper.createStyle("add16"));
    group.add(btn);
    return panel;
  }
  protected void onRender(Element target, int index) {
    super.onRender(target, index);

    final FitLayout fl = new FitLayout();

    LayoutContainer layoutContainer = new LayoutContainer();
    layoutContainer.setBorders(false);
    layoutContainer.setLayout(fl);

    VerticalPanel vp = new VerticalPanel();
    vp.setSpacing(3);

    ContentPanel cpGrid = new ContentPanel();
    cpGrid.setHeaderVisible(true);
    cpGrid.setHeading("Lista Dipendenti.");
    cpGrid.setBorders(false);
    cpGrid.setFrame(true);
    cpGrid.setHeight((h - 65));
    cpGrid.setWidth(w - 250);
    cpGrid.setScrollMode(Scroll.AUTO);
    cpGrid.setLayout(new FitLayout());
    cpGrid.setButtonAlign(HorizontalAlignment.CENTER);
    Resizable r = new Resizable(cpGrid);

    btnPrint = new Button();
    btnPrint.setEnabled(true);
    btnPrint.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.print24()));
    btnPrint.setIconAlign(IconAlign.TOP);
    btnPrint.setToolTip("Stampa");
    btnPrint.setSize(26, 26);
    btnPrint.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            SessionManagementService.Util.getInstance()
                .setDatiReportCostiDip(
                    "RIEP.COSTI",
                    store.getModels(),
                    new AsyncCallback<Boolean>() {

                      @Override
                      public void onFailure(Throwable caught) {
                        Window.alert("Error on setNomeReport()");
                      }

                      @Override
                      public void onSuccess(Boolean result) {
                        if (result) fp.submit();
                        else
                          Window.alert(
                              "Problemi durante il settaggio dei parametri in Sessione (http)");
                      }
                    });
          }
        });

    btnAdd = new Button();
    btnAdd.setStyleAttribute("padding-left", "2px");
    btnAdd.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.add()));
    btnAdd.setIconAlign(IconAlign.TOP);
    btnAdd.setSize(26, 26);
    btnAdd.setToolTip("Nuova Offerta");
    btnAdd.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            RiepilogoCostiDipendentiModel am =
                new RiepilogoCostiDipendentiModel(
                    0, 0, "", "0.00", "", "0", "0.00", "0.00", "0.00", "0.00", "0.00", "0.00", "",
                    "", "");

            gridRiepilogo.stopEditing();
            store.insert(am, 0);
            gridRiepilogo.startEditing(store.indexOf(am), 0);
          }
        });

    btnConfirm = new Button();
    btnConfirm.setEnabled(true);
    btnConfirm.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.confirm()));
    btnConfirm.setIconAlign(IconAlign.TOP);
    btnConfirm.setToolTip("Conferma modifiche");
    btnConfirm.setSize(26, 26);
    btnConfirm.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {

            RiepilogoCostiDipendentiModel c = new RiepilogoCostiDipendentiModel();

            for (Record record : store.getModifiedRecords()) {

              c = (RiepilogoCostiDipendentiModel) record.getModel();

              AdministrationService.Util.getInstance()
                  .editDatiCostiAzienda(
                      c,
                      new AsyncCallback<Boolean>() {

                        @Override
                        public void onFailure(Throwable caught) {
                          Window.alert("Errore di connessione on insertNewOffertaWithRda();");
                        }

                        @Override
                        public void onSuccess(Boolean result) {
                          if (result) {
                            caricaTabellaDati();
                          } else {
                            Window.alert(
                                "error: Impossibile effettuare l'inserimento/modifica dei dati!");
                          }
                        }
                      });
            }
          }
        });

    if ((ruolo.compareTo("PM") == 0)) {
      btnConfirm.disable();
      btnAdd.disable();
    }

    smplcmbxSede = new SimpleComboBox<String>();
    smplcmbxSede.setFieldLabel("Sede");
    smplcmbxSede.setWidth(65);
    smplcmbxSede.setEmptyText("Sede..");
    smplcmbxSede.setAllowBlank(false);
    smplcmbxSede.add("T");
    smplcmbxSede.add("B");
    smplcmbxSede.setStyleAttribute("padding-left", "2px");
    smplcmbxSede.addListener(
        Events.Select,
        new Listener<BaseEvent>() {
          @Override
          public void handleEvent(BaseEvent be) {
            caricaTabellaDati();
          }
        });

    // caricaTabellaDati();

    cm = new ColumnModel(createColumns());
    gridRiepilogo = new EditorGrid<RiepilogoCostiDipendentiModel>(store, cm);
    gridRiepilogo.setBorders(false);
    gridRiepilogo.setColumnLines(true);
    gridRiepilogo.setStripeRows(true);
    gridRiepilogo.setItemId("grid");
    gridRiepilogo.setSelectionModel(csm);

    fp.setMethod(FormPanel.METHOD_POST);
    fp.setAction(url);
    fp.addSubmitCompleteHandler(new FormSubmitCompleteHandler());
    fp.add(btnPrint);
    ContentPanel cp = new ContentPanel();
    cp.setHeaderVisible(false);
    cp.add(fp);

    ToolBar tlBar = new ToolBar();
    tlBar.add(smplcmbxSede);
    tlBar.add(btnAdd);
    tlBar.add(btnConfirm);
    tlBar.add(new SeparatorToolItem());
    tlBar.add(cp);

    cpGrid.setTopComponent(tlBar);
    cpGrid.add(gridRiepilogo);

    layoutContainer.add(cpGrid, new FitData(3, 3, 3, 3));

    add(layoutContainer);
  }
示例#13
0
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());

    containerSizeStore = getContainerSizeStore();
    ironChestStore = getIronChestStore();
    bracketStore = getBracketStore();

    ContentPanel content = new ContentPanel();
    content.setHeaderVisible(false);
    content.setBodyBorder(false);
    content.setLayout(new RowLayout(Orientation.VERTICAL));

    LayoutContainer frame1 = new LayoutContainer();
    frame1.setStyleAttribute("padding", "10px");
    frame1.setStyleAttribute("backgroundColor", "#dfe8f6");
    frame1.setLayout(new BorderLayout());

    grid = createGrid();
    grid.getSelectionModel()
        .addListener(
            Events.SelectionChange,
            new Listener<SelectionChangedEvent<BeanModel>>() {
              public void handleEvent(SelectionChangedEvent<BeanModel> be) {
                store.rejectChanges();
                resetState();
              }
            });

    formPanel = createForm();

    BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 305);
    BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);

    frame1.add(grid, westData);
    frame1.add(formPanel, centerData);

    content.add(frame1);

    LayoutContainer frame2 = new LayoutContainer();
    frame2.setStyleAttribute("backgroundColor", "#dfe8f6");
    frame2.setLayout(new RowLayout(Orientation.HORIZONTAL));

    RowData data1 = new RowData(.45, 1);
    data1.setMargins(new Margins(10));
    RowData data2 = new RowData(.55, 1);
    data2.setMargins(new Margins(10));
    frame2.add(createTypeGrid(), data1);
    frame2.add(createBracketGrid(), data2);

    RowData data = new RowData(1, 0.5);
    content.add(frame1, data);
    content.add(frame2, data);

    // 添加工具栏
    ToolBar toolBar = new ToolBar();

    addButton = new Button("添加", Resources.ICONS.add());
    addButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            beanModel = beanModelFactory.createModel(new Container());
            formPanel.reset();
            formBindings.bind(beanModel);
            formBindings.addListener(
                Events.Bind,
                new Listener<BindingEvent>() {
                  @Override
                  public void handleEvent(BindingEvent be) {
                    formBindings
                        .getModel()
                        .set("customsDeclarationHeadId", selectedCustomsDeclarationHead.getId());
                    for (Field<?> field : formPanel.getFields()) {
                      field.clearInvalid();
                    }
                    formBindings.removeAllListeners();
                  }
                });
            formPanel.setReadOnly(false);
            formPanel.getFields().get(0).focus();
            saveButton.setVisible(true);
            cancelButton.setVisible(true);
            updateButton.setVisible(false);
            resetButton.setVisible(false);
            addButton.disable();
          }
        });
    toolBar.add(addButton);

    toolBar.add(new SeparatorToolItem());

    editButton = new Button("修改", Resources.ICONS.edit());
    editButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            if (grid.getSelectionModel().getSelection().size() > 0) {
              formBindings.bind((BeanModel) grid.getSelectionModel().getSelection().get(0));
              formPanel.setReadOnly(false);
              updateButton.enable();
              resetButton.enable();
              editButton.disable();
            } else {
              formBindings.unbind();
            }
          }
        });
    toolBar.add(editButton);

    toolBar.add(new SeparatorToolItem());

    deleteButton = new Button("删除", Resources.ICONS.delete());
    toolBar.add(deleteButton);
    deleteButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            MessageBox.confirm(
                "确认",
                "确定要删除选中的条目吗?",
                new Listener<MessageBoxEvent>() {
                  @Override
                  public void handleEvent(MessageBoxEvent be) {
                    if (be.getButtonClicked().getText() == GXT.MESSAGES.messageBox_yes()) {
                      delete();
                    }
                  }
                });
          }
        });

    if (permitedEnterprise != null) {
      if (permitedEnterprise.getCanAdd()) {
        addButton.enable();
      } else {
        addButton.disable();
      }
      if (permitedEnterprise.getCanUpdate()) {
        editButton.enable();
      } else {
        editButton.disable();
      }
      if (permitedEnterprise.getCanDelete()) {
        deleteButton.enable();
      } else {
        deleteButton.disable();
      }
    }

    content.setTopComponent(toolBar);
    add(content);
  }
示例#14
0
 private void onMenuBarReady(AppEvent event) {
   viewportPanel.setTopComponent(event.<Component>getData());
 }
示例#15
0
 private void createTopToolbar() {
   topToolbar = new MainGridTopToolbar(this);
   mainGridPanel.setTopComponent(topToolbar);
 }
示例#16
0
  private void addRepoList() {
    ContentPanel panel =
        new ContentPanel() {
          {
            setHeaderVisible(false);
            setLayout(new FitLayout());
          }
        };

    Table table =
        new Table() {
          {
            setColumnModel(
                new TableColumnModel(
                    new TableColumn("name", "Repository", 175f),
                    new TableColumn("repoType", "Type", 50f),
                    new TableColumn("statusText", "Status", 200f) {
                      {
                        setRenderer(
                            new CellRenderer() {
                              public String render(Component item, String property, Object value) {
                                if (value == null) {
                                  return "<i>retrieving</i>";
                                }
                                return (String) value;
                              }
                            });
                      }
                    },
                    new TableColumn("resourceURI", "Repository Path", 1f) {
                      {
                        setRenderer(
                            new CellRenderer() {
                              public String render(Component item, String property, Object value) {
                                String path = (String) value;
                                path =
                                    Constants.HOST
                                        + path.replace(
                                            Constants.SERVICE_REPOSITORIES,
                                            Constants.CONTENT_REPOSITORIES);
                                return "<a href=\""
                                    + path
                                    + "\" target=\"_blank\">"
                                    + path
                                    + "</a>";
                              }
                            });
                      }
                    }));

            // This disables showing the repository when right clicking
            setSelectionModel(
                new TableSelectionModel() {
                  protected void onContextMenu(ContainerEvent event) {}
                });
          }
        };

    final RepoTableBinding tableBinding = new RepoTableBinding(table, server);
    tableBinding
        .getBinder()
        .addSelectionChangedListener(
            new SelectionChangedListener<Repository>() {
              public void selectionChanged(SelectionChangedEvent<Repository> event) {
                showRepoTree(event.getSelectedItem());
              }
            });

    ToolBar toolBar = new ToolBar();
    TextToolItem refreshButton =
        new TextToolItem("Refresh", "st-icon-refresh") {
          {
            addSelectionListener(
                new SelectionListener<ComponentEvent>() {
                  public void componentSelected(ComponentEvent ce) {
                    tableBinding.reload();
                    showRepoHelp();
                  }
                });
          }
        };
    toolBar.add(refreshButton);

    panel.setTopComponent(toolBar);
    panel.add(table);

    BorderLayoutData panelLayoutData =
        new BorderLayoutData(Style.LayoutRegion.NORTH) {
          {
            setSplit(true);
            setSize(200);
            setMinSize(150);
            setMaxSize(400);
          }
        };

    add(panel, panelLayoutData);

    final boolean editEnabled =
        ApplicationContext.instance().checkPermission("maintRepos", Permissions.EDIT);

    ContextMenuProvider tableMenu = new ContextMenuProvider(table);

    tableMenu.addAction(
        new Action<Repository>("View") {

          public void execute(Repository repo) {
            showRepoTree(repo);
          }
        });

    tableMenu.addAction(
        new Action<Repository>("Clear Cache") {

          public boolean supports(Repository repo) {
            return editEnabled && !repo.getRepoType().equals("virtual");
          }

          public void execute(Repository repo) {
            server.clearRepositoryCache(
                repo.getId(),
                null,
                new ResponseHandler() {

                  public void onError(Response response, Throwable error) {
                    MessageBox.alert(
                        "Error", "The server did not clear the repository's cache", null);
                  }

                  public void onSuccess(Response response, Object entity) {
                    // do nothing
                  }
                });
          }
        });

    tableMenu.addAction(
        new Action<Repository>("Re-Index") {

          public boolean supports(Repository repo) {
            return editEnabled;
          }

          public void execute(Repository repo) {
            server.reindexRepository(
                repo.getId(),
                null,
                new ResponseHandler() {

                  public void onError(Response response, Throwable error) {
                    MessageBox.alert("Error", "The server did not re-index the repository", null);
                  }

                  public void onSuccess(Response response, Object entity) {
                    // do nothing
                  }
                });
          }
        });

    tableMenu.addAction(
        new Action<Repository>("Rebuild Attributes") {

          public boolean supports(Repository repo) {
            return editEnabled;
          }

          public void execute(Repository repo) {
            server.rebuildRepositoryAttributes(
                repo.getId(),
                null,
                new ResponseHandler() {

                  public void onError(Response response, Throwable error) {
                    MessageBox.alert(
                        "Error", "The server did not rebuild attributes in the repository", null);
                  }

                  public void onSuccess(Response response, Object entity) {
                    // do nothing
                  }
                });
          }
        });

    tableMenu.addAction(
        new Action<Repository>("Block Proxy") {

          public boolean supports(Repository repo) {
            return editEnabled
                && "proxy".equals(repo.getRepoType())
                && "allow".equals(repo.getStatus().getProxyMode());
          }

          public void execute(Repository repo) {
            RepositoryStatusResource status = repo.getStatus().copy();
            status.setId(RepoServerUtil.toRepositoryId(repo.getResourceURI()));
            status.setProxyMode("blockedManual");

            server.updateRepositoryStatus(
                status,
                new ResponseHandler<RepositoryStatusResource>() {

                  public void onError(Response response, Throwable error) {
                    MessageBox.alert(
                        "Error",
                        "The server did not update the proxy repository status to blocked",
                        null);
                  }

                  public void onSuccess(Response response, RepositoryStatusResource status) {
                    tableBinding.updateRepoStatus(status);
                  }
                });
          }
        });

    tableMenu.addAction(
        new Action<Repository>("Allow Proxy") {

          public boolean supports(Repository repo) {
            return editEnabled
                && "proxy".equals(repo.getRepoType())
                && !"allow".equals(repo.getStatus().getProxyMode());
          }

          public void execute(Repository repo) {
            RepositoryStatusResource status = repo.getStatus().copy();
            status.setId(RepoServerUtil.toRepositoryId(repo.getResourceURI()));
            status.setProxyMode("allow");

            server.updateRepositoryStatus(
                status,
                new ResponseHandler<RepositoryStatusResource>() {

                  public void onError(Response response, Throwable error) {
                    MessageBox.alert(
                        "Error",
                        "The server did not update the proxy repository status to allow",
                        null);
                  }

                  public void onSuccess(Response response, RepositoryStatusResource status) {
                    tableBinding.updateRepoStatus(status);
                  }
                });
          }
        });

    tableMenu.addAction(
        new Action<Repository>("Put Out of Service") {

          public boolean supports(Repository repo) {
            return editEnabled && "inService".equals(repo.getStatus().getLocalStatus());
          }

          public void execute(Repository repo) {
            RepositoryStatusResource status = repo.getStatus().copy();
            status.setId(RepoServerUtil.toRepositoryId(repo.getResourceURI()));
            status.setLocalStatus("outOfService");

            server.updateRepositoryStatus(
                status,
                new ResponseHandler<RepositoryStatusResource>() {

                  public void onError(Response response, Throwable error) {
                    MessageBox.alert(
                        "Error", "The server did not put the repository out of service", null);
                  }

                  public void onSuccess(Response response, RepositoryStatusResource status) {
                    tableBinding.updateRepoStatus(status);
                  }
                });
          }
        });

    tableMenu.addAction(
        new Action<Repository>("Put in Service") {

          public boolean supports(Repository repo) {
            return editEnabled && "outOfService".equals(repo.getStatus().getLocalStatus());
          }

          public void execute(Repository repo) {
            RepositoryStatusResource status = repo.getStatus().copy();
            status.setId(RepoServerUtil.toRepositoryId(repo.getResourceURI()));
            status.setLocalStatus("inService");

            server.updateRepositoryStatus(
                status,
                new ResponseHandler<RepositoryStatusResource>() {

                  public void onError(Response response, Throwable error) {
                    MessageBox.alert(
                        "Error", "The server did not put the repository into service", null);
                  }

                  public void onSuccess(Response response, RepositoryStatusResource status) {
                    tableBinding.updateRepoStatus(status);
                  }
                });
          }
        });

    addListener(
        Events.Render,
        new Listener<BaseEvent>() {
          public void handleEvent(BaseEvent be) {
            tableBinding.reload();
          }
        });
  }
示例#17
0
  private ContentPanel getGeneralSection() {
    if (generalSectionPanel == null) {

      final ManagementServiceAsync managementService = Registry.get(PIGE.MANAGEMENT_SERVICE);
      generalSectionPanel = new ContentPanel();
      generalSectionPanel.setHeaderVisible(false);
      generalSectionPanel.setLayout(new RowLayout(Orientation.VERTICAL));
      generalSectionPanel.setBorders(false);

      ToolBar buttonBar = new ToolBar();
      generalSectionPanel.setTopComponent(buttonBar);
      Button updateConfigsBtn = new Button(messages.update());
      updateConfigsBtn.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.saveIcon()));
      buttonBar.add(updateConfigsBtn);
      updateConfigsBtn.addSelectionListener(
          new SelectionListener<ButtonEvent>() {

            @Override
            public void componentSelected(ButtonEvent event) {
              ServerConfigs sc = new ServerConfigs();
              sc.setValue(
                  ServerConfigs.ATT_MAINTENANCE_MODE_ACTIVATED,
                  maintenanceModeActivated.toString());
              sc.setValue(ServerConfigs.ATT_MAINTENANCE_MODE_INFO, mmInfoArea.getValue());
              sc.setValue(ServerConfigs.ATT_EMAIL_ENABLED, emailServiceEnabled.toString());
              sc.setValue(ServerConfigs.LOAN_TERM_VERIFICATOR_ENABLED, ltvEnabled.toString());
              sc.setValue(ServerConfigs.MAINTENANCE_RECALL_SERVICE_ENABLED, mrsEnabled.toString());
              managementService.setConfigurations(
                  sc,
                  new AsyncCallback() {

                    @Override
                    public void onSuccess(Object o) {
                      PIGE.setServerOperationModeStatus();
                      StatusBar statusBar = Registry.get(AppWidgets.APP_STATUS_BAR);
                      statusBar.setTimedText(messages.updateSuccessful());
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                      PIGE.handleException(caught);
                    }
                  });
            }
          });

      Html generatTitle = new Html(messages.general());
      generatTitle.addStyleName("pige-management-section-title");
      generalSectionPanel.add(generatTitle, new RowData(1, 25, new Margins(3)));
      LayoutContainer maintenancePanel = new LayoutContainer();
      maintenancePanel.setWidth(1);
      maintenancePanel.setBorders(false);
      maintenancePanel.setLayout(new RowLayout(Orientation.VERTICAL));

      // Maintenance mode
      Html maintenanceTitle = new Html(messages.maintenanceMode());
      maintenanceTitle.addStyleName("pige-management-topic-title");
      maintenancePanel.add(maintenanceTitle, new RowData(1, 20));
      Html maintenanceModeText = new Html(messages.maintenanceModeText());
      maintenancePanel.add(maintenanceModeText, new RowData(1, -1));
      LayoutContainer maintenanceConfigPanel = new LayoutContainer();
      maintenanceConfigPanel.setLayout(new RowLayout(Orientation.HORIZONTAL));
      maintenancePanel.add(maintenanceConfigPanel, new RowData(1, 75));
      mmInfoArea = new TextArea();
      mmActivatedBtn = new ToggleButton(messages.activated());
      mmActivatedBtn.setSize(75, 22);
      mmActivatedBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      mmActivatedBtn.setToggleGroup("mm-state");
      mmDeactivatedBtn = new ToggleButton(messages.deactivated());
      mmDeactivatedBtn.setSize(75, 22);
      mmDeactivatedBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      mmDeactivatedBtn.setToggleGroup("mm-state");
      Listener mmButtonListener =
          new Listener<ButtonEvent>() {

            @Override
            public void handleEvent(ButtonEvent event) {
              if (mmActivatedBtn.isPressed()) {
                maintenanceModeActivated = Boolean.TRUE;
              } else {
                maintenanceModeActivated = Boolean.FALSE;
              }
            }
          };
      mmActivatedBtn.addListener(Events.Toggle, mmButtonListener);
      mmDeactivatedBtn.addListener(Events.Toggle, mmButtonListener);
      LayoutContainer buttonPanel = new LayoutContainer();
      buttonPanel.setLayout(new RowLayout(Orientation.VERTICAL));
      buttonPanel.add(mmActivatedBtn);
      buttonPanel.add(mmDeactivatedBtn);
      maintenanceConfigPanel.add(buttonPanel, new RowData(100, 1, new Margins(3)));
      maintenanceConfigPanel.add(mmInfoArea, new RowData(1, 1));
      generalSectionPanel.add(maintenancePanel, new RowData(1, -1, new Margins(5)));

      // Email
      LayoutContainer emailServicePanel = new LayoutContainer();
      emailServicePanel.setWidth(1);
      emailServicePanel.setBorders(false);
      emailServicePanel.setLayout(new RowLayout(Orientation.VERTICAL));
      Html emailServiceTitle = new Html(messages.emailService());
      emailServiceTitle.addStyleName("pige-management-topic-title");
      emailServicePanel.add(emailServiceTitle, new RowData(1, 20));
      Html emailServiceText = new Html(messages.emailServiceText());
      emailServicePanel.add(emailServiceText, new RowData(1, -1));
      LayoutContainer emailServiceConfigPanel = new LayoutContainer();
      emailServiceConfigPanel.setLayout(new RowLayout(Orientation.HORIZONTAL));
      emailServicePanel.add(emailServiceConfigPanel, new RowData(1, 75));
      emailEnabledBtn = new ToggleButton(messages.activated());
      emailEnabledBtn.setSize(75, 22);
      emailEnabledBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      emailEnabledBtn.setToggleGroup("email-service-state");
      emailDisabledBtn = new ToggleButton(messages.deactivated());
      emailDisabledBtn.setSize(75, 22);
      emailDisabledBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      emailDisabledBtn.setToggleGroup("email-service-state");
      Listener emailServiceButtonListener =
          new Listener<ButtonEvent>() {

            @Override
            public void handleEvent(ButtonEvent event) {
              if (emailEnabledBtn.isPressed()) {
                emailServiceEnabled = Boolean.TRUE;
              } else {
                emailServiceEnabled = Boolean.FALSE;
              }
            }
          };
      emailEnabledBtn.addListener(Events.Toggle, emailServiceButtonListener);
      emailDisabledBtn.addListener(Events.Toggle, emailServiceButtonListener);
      buttonPanel = new LayoutContainer();
      buttonPanel.setLayout(new RowLayout(Orientation.VERTICAL));
      buttonPanel.add(emailEnabledBtn);
      buttonPanel.add(emailDisabledBtn);
      emailServiceConfigPanel.add(buttonPanel, new RowData(100, 1, new Margins(3)));
      generalSectionPanel.add(emailServicePanel, new RowData(1, -1, new Margins(5)));

      // Vérificateur d'échéance des emprunts
      LayoutContainer ltvServicePanel = new LayoutContainer();
      ltvServicePanel.setWidth(1);
      ltvServicePanel.setBorders(false);
      ltvServicePanel.setLayout(new RowLayout(Orientation.VERTICAL));
      Html ltvTitle = new Html(messages.loanTermVerification());
      ltvTitle.addStyleName("pige-management-topic-title");
      ltvServicePanel.add(ltvTitle, new RowData(1, 20));
      Html ltvText = new Html(messages.loanTermVerificationText());
      ltvServicePanel.add(ltvText, new RowData(1, -1));
      LayoutContainer ltvConfigPanel = new LayoutContainer();
      ltvConfigPanel.setLayout(new RowLayout(Orientation.HORIZONTAL));
      ltvServicePanel.add(ltvConfigPanel, new RowData(1, 75));
      ltvEnabledBtn = new ToggleButton(messages.activated());
      ltvEnabledBtn.setSize(75, 22);
      ltvEnabledBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      ltvEnabledBtn.setToggleGroup("ltv-state");
      ltvDisabledBtn = new ToggleButton(messages.deactivated());
      ltvDisabledBtn.setSize(75, 22);
      ltvDisabledBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      ltvDisabledBtn.setToggleGroup("ltv-state");
      Listener ltvButtonListener =
          new Listener<ButtonEvent>() {

            @Override
            public void handleEvent(ButtonEvent event) {
              if (ltvEnabledBtn.isPressed()) {
                ltvEnabled = Boolean.TRUE;
              } else {
                ltvEnabled = Boolean.FALSE;
              }
            }
          };
      ltvEnabledBtn.addListener(Events.Toggle, ltvButtonListener);
      ltvDisabledBtn.addListener(Events.Toggle, ltvButtonListener);
      buttonPanel = new LayoutContainer();
      buttonPanel.setLayout(new RowLayout(Orientation.VERTICAL));
      buttonPanel.add(ltvEnabledBtn);
      buttonPanel.add(ltvDisabledBtn);
      ltvConfigPanel.add(buttonPanel, new RowData(100, 1, new Margins(3)));
      generalSectionPanel.add(ltvServicePanel, new RowData(1, -1, new Margins(5)));

      // Service de rappel des maintenances.
      LayoutContainer mrsServicePanel = new LayoutContainer();
      mrsServicePanel.setWidth(1);
      mrsServicePanel.setBorders(false);
      mrsServicePanel.setLayout(new RowLayout(Orientation.VERTICAL));
      Html mrsTitle = new Html(messages.maintenanceRecalLService());
      mrsTitle.addStyleName("pige-management-topic-title");
      mrsServicePanel.add(mrsTitle, new RowData(1, 20));
      Html mrsText = new Html(messages.maintenanceRecalLServiceTxt());
      mrsServicePanel.add(mrsText, new RowData(1, -1));
      LayoutContainer mrsConfigPanel = new LayoutContainer();
      mrsConfigPanel.setLayout(new RowLayout(Orientation.HORIZONTAL));
      mrsServicePanel.add(mrsConfigPanel, new RowData(1, 75));
      mrsEnabledBtn = new ToggleButton(messages.activated());
      mrsEnabledBtn.setSize(75, 22);
      mrsEnabledBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      mrsEnabledBtn.setToggleGroup("mrs-state");
      mrsDisabledBtn = new ToggleButton(messages.deactivated());
      mrsDisabledBtn.setSize(75, 22);
      mrsDisabledBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      mrsDisabledBtn.setToggleGroup("mrs-state");
      Listener mrsButtonListener =
          new Listener<ButtonEvent>() {

            @Override
            public void handleEvent(ButtonEvent event) {
              if (mrsEnabledBtn.isPressed()) {
                mrsEnabled = Boolean.TRUE;
              } else {
                mrsEnabled = Boolean.FALSE;
              }
            }
          };
      mrsEnabledBtn.addListener(Events.Toggle, mrsButtonListener);
      mrsDisabledBtn.addListener(Events.Toggle, mrsButtonListener);
      buttonPanel = new LayoutContainer();
      buttonPanel.setLayout(new RowLayout(Orientation.VERTICAL));
      buttonPanel.add(mrsEnabledBtn);
      buttonPanel.add(mrsDisabledBtn);
      mrsConfigPanel.add(buttonPanel, new RowData(100, 1, new Margins(3)));
      generalSectionPanel.add(mrsServicePanel, new RowData(1, -1, new Margins(5)));
    }
    return generalSectionPanel;
  }
  @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);
  }