Exemple #1
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));
  }
  @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);
  }
 private ToolBar buildToolBar() {
   ToolBar tool = new ToolBar();
   tool.add(buildFilterField());
   tool.add(buildSearchButton());
   tool.add(new FillToolItem());
   tool.add(buildNewToolRequestMenuItem());
   return tool;
 }
  public LatestVirtualReportItemsPanel() {
    setHeading("Virtual Level Monitoring");
    setLayout(new FitLayout());

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

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

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

    virtualGrid = new Grid<MonitoringResource>(virtualStore, cm);
    virtualGrid.setTitle(" Service Resources ");
    virtualGrid.setView(view);
    virtualGrid.setBorders(true);
    virtualGrid.getView().setForceFit(true);
    add(virtualGrid);
  }
 protected void enableSaveButtons(boolean enable) {
   if (enable)
     for (int i = 0; i < toolbar.getItemCount(); i++) {
       toolbar.getItem(i).enable();
     }
   else
     for (int i = 0; i < toolbar.getItemCount(); i++) {
       toolbar.getItem(i).disable();
     }
 }
  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;
  }
  public ToolBar initToolBar() {
    ToolBar toolBarButton = new ToolBar();
    Button refreshButton = new SubModuleToolbar(this.eventBus).getRefreshButton();
    AdaptId.adapt(refreshButton, IdElementsResource.INSTANCE.idConfigRefreshButton());

    Button exportButton = getExportButton();
    setButtonHidden(exportButton);

    Button downloadLogButton = getDownloadLogButton();
    setButtonHidden(downloadLogButton);

    toolBarButton.add(refreshButton);
    toolBarButton.add(exportButton);
    toolBarButton.add(downloadLogButton);
    return toolBarButton;
  }
  private void buildToolbar() {
    toolbar = new ToolBar();

    next = new Button();
    next.setIconStyle("icon-next");
    next.setText("Next " + NUMBER_OF_RESULTS + " Results");
    next.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            start += NUMBER_OF_RESULTS;
            if (start + NUMBER_OF_RESULTS > currentResults.getLength()) next.setEnabled(false);
            if (start > 0) prev.setEnabled(true);
            fillTable();
          }
        });

    prev = new Button();
    prev.setIconStyle("icon-previous");
    prev.setText("Previous " + NUMBER_OF_RESULTS + " Results");
    prev.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            start -= NUMBER_OF_RESULTS;
            if (start < 0) start = 0;
            if (start == 0) prev.setEnabled(false);
            if (start + NUMBER_OF_RESULTS < currentResults.getLength()) next.setEnabled(true);
            fillTable();
          }
        });

    toolbar.add(prev);
    toolbar.add(next);
  }
 protected void addItemsToToolBar() {
   toolbar.add(saveAndAddTaxa);
   toolbar.add(new SeparatorToolItem());
   toolbar.add(save);
   toolbar.add(new SeparatorToolItem());
   toolbar.add(saveAndExit);
   toolbar.add(new SeparatorToolItem());
   toolbar.add(cancel);
   toolbar.add(new SeparatorToolItem());
 }
  public void draw() {

    if (!drawn) {
      for (String definable : DefinitionCache.impl.getDefinables())
        addDefinition(definable, DefinitionCache.impl.getDefinition(definable));

      Button save = new Button();
      save.setText("Save");
      save.setIconStyle("icon-save");
      save.setTitle("Save");
      save.addListener(
          Events.Select,
          new Listener<BaseEvent>() {
            public void handleEvent(BaseEvent be) {
              save();
            }
          });

      Button add = new Button();
      add.setText("Add new definition");
      add.setIconStyle("icon-add");
      add.setTitle("Add new definition");
      add.addListener(
          Events.Select,
          new Listener<BaseEvent>() {
            public void handleEvent(BaseEvent be) {
              TextField<String> f = addDefinition("", "");
              layout();

              scrollIntoView(f);
            }
          });

      ToolBar toolbar = new ToolBar();
      toolbar.add(save);
      toolbar.add(add);
      setTopComponent(toolbar);

      drawn = true;
    }
  }
  @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);
  }
  /**
   * Creates, configures and adds the components palette toolbar.<br>
   *
   * @param componentsReceiver
   */
  private void addToolbar() {
    // the toolbar
    ToolBar gridToolBar = new ToolBar();
    setTopComponent(gridToolBar);

    SelectionListener<ButtonEvent> ttiAddListener =
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            GridSelectionModel<PaletteModelData> selectionModel = gComponents.getSelectionModel();
            List<PaletteModelData> lSelected = selectionModel.getSelectedItems();
            if (!lSelected.isEmpty()) {
              componentsReceiver.receiveComponents(lSelected);
              hide();
              selectionModel.deselectAll();
              ttiAddSelected.disable();
            }
          }
        };
    ttiAddSelected =
        buttonsSupport.addGenericButton(
            pmsMessages.labelAddSelected(), styles.iNew(), gridToolBar, ttiAddListener);
    ttiAddSelected.disable();

    gridToolBar.add(new FillToolItem());

    StoreFilterField<PaletteModelData> filter =
        new CustomizableStoreFilter<PaletteModelData>(
            Arrays.asList(
                new String[] {
                  PaletteModelData.PROPERTY_NAME, PaletteModelData.PROPERTY_DESCRIPTION
                }));
    filter.setHideLabel(false);
    filter.setFieldLabel(messages.labelFilter());
    filter.bind(sGrid);
    gridToolBar.add(filter);

    setTopComponent(gridToolBar);
  }
  public LatestPhysicalReportItemsPanel() {
    setHeading("Physical Level Monitoring");
    setLayout(new FitLayout());

    ToolBar toolBar = new ToolBar();
    ToolBar toolBarBottom = new ToolBar();
    Button reflesh = new Button("Refresh");
    reflesh.setIcon(IconHelper.createStyle("icon-email-add"));
    id = new TextField<String>();
    id.setFieldLabel("Physical ID");
    id.setAllowBlank(false);
    toolBar.add(new LabelToolItem("Physical ID: "));
    toolBar.add(id);
    toolBar.add(reflesh);
    setTopComponent(toolBar);
    lt = new LabelField("");
    setToolBar4Status("");
    toolBarBottom.add(lt);
    setBottomComponent(toolBarBottom);
    reflesh.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            setToolBar4Status("Loading data, please wait...");
            String physicalId = id.getValue();
            service = (MonitoringManagerWebServiceAsync) Registry.get("guiservice");
            service.getMonitoringResources(
                "physical",
                physicalId,
                new AsyncCallback<List<MonitoringResource>>() {
                  public void onFailure(Throwable caught) {
                    setToolBar4Status("Connection failed by loading data, please try again.");
                    Dispatcher.forwardEvent(MainEvents.Error, caught);
                  }

                  public void onSuccess(List<MonitoringResource> result) {
                    setToolBar4Status("");
                    getStore().removeAll();
                    if (result.size() > 0) {
                      store.add(result);
                    } else {
                      setToolBar4ErrorStatus("No data found.");
                    }
                  }
                });
          }
        });

    cm = new ColumnModel(OptimisResource.getColumnConfig());
    store = new ListStore<MonitoringResource>();
    grid = new Grid<MonitoringResource>(store, cm);
    grid.setTitle(" Physical Level Resources ");
    grid.setBorders(true);
    grid.getView().setForceFit(true);
    add(grid);
    setLayout(new FitLayout());
  }
  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;
  }
  private void createViewsButtons(ToolBar calendarToolbar) {
    final ToggleButton oneDay = new ToggleButton("<b>" + HarvesterUI.CONSTANTS.oneDay() + "</b>");
    final ToggleButton threeDay =
        new ToggleButton("<b>" + HarvesterUI.CONSTANTS.threeDay() + "</b>");
    final ToggleButton week = new ToggleButton("<b>" + HarvesterUI.CONSTANTS.week() + "</b>");
    final ToggleButton month = new ToggleButton("<b>" + HarvesterUI.CONSTANTS.month() + "</b>");
    month.toggle();

    oneDay.addListener(
        Events.OnClick,
        new Listener<ButtonEvent>() {
          public void handleEvent(ButtonEvent ce) {
            threeDay.toggle(false);
            week.toggle(false);
            month.toggle(false);
            oneDay.toggle(true);
            calendar.setView(CalendarViews.DAY, 1);
          }
        });

    threeDay.addListener(
        Events.OnClick,
        new Listener<ButtonEvent>() {
          public void handleEvent(ButtonEvent ce) {
            threeDay.toggle(true);
            week.toggle(false);
            month.toggle(false);
            oneDay.toggle(false);
            calendar.setView(CalendarViews.DAY, 3);
          }
        });

    week.addListener(
        Events.OnClick,
        new Listener<ButtonEvent>() {
          public void handleEvent(ButtonEvent ce) {
            threeDay.toggle(false);
            week.toggle(true);
            month.toggle(false);
            oneDay.toggle(false);
            calendar.setView(CalendarViews.DAY, 7);
          }
        });

    month.addListener(
        Events.OnClick,
        new Listener<ButtonEvent>() {
          public void handleEvent(ButtonEvent ce) {
            threeDay.toggle(false);
            week.toggle(false);
            month.toggle(true);
            oneDay.toggle(false);
            calendar.setView(CalendarViews.MONTH);
          }
        });

    calendarToolbar.add(oneDay);
    calendarToolbar.add(threeDay);
    calendarToolbar.add(week);
    calendarToolbar.add(month);
  }
  private ToolBar createCalendarToolbar() {
    ToolBar calendarToolbar = new ToolBar();

    currentMonthAndYear = new Button();
    DateTimeFormat formatter = DateTimeFormat.getFormat("MMMM yyyy");
    String result = formatter.format(calendar.getDate());
    currentMonthAndYear.setText(result);
    currentMonthAndYear.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            dpDialog.show();
            dpDialog.center();
          }
        });

    Button today = new Button("<b>" + HarvesterUI.CONSTANTS.today() + "</b>");
    today.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            ((DatePicker) dpDialog.getItem(0)).setValue(new Date());
            //                DateTimeFormat formatter = DateTimeFormat.getFormat("MMMM yyyy");
            //                String result = formatter.format(calendar.getDate());
            //                currentMonthAndYear.setText(result);
            //                calendarTaskManager.updateScheduleTasks();
          }
        });

    Button yearLeft = new Button("<b>" + "<<" + "</b>");
    yearLeft.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            DateWrapper dw = new DateWrapper(calendar.getDate());
            ((DatePicker) dpDialog.getItem(0)).setValue(dw.addMonths(-1).asDate());
            //                DateTimeFormat formatter = DateTimeFormat.getFormat("MMMM yyyy");
            //                String result = formatter.format(calendar.getDate());
            //                currentMonthAndYear.setText(result);
            //                calendarTaskManager.updateScheduleTasks();
          }
        });

    Button yearRight = new Button("<b>" + ">>" + "</b>");
    yearRight.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            DateWrapper dw = new DateWrapper(calendar.getDate());
            ((DatePicker) dpDialog.getItem(0)).setValue(dw.addMonths(1).asDate());
            //                DateTimeFormat formatter = DateTimeFormat.getFormat("MMMM yyyy");
            //                String result = formatter.format(calendar.getDate());
            //                currentMonthAndYear.setText(result);
            //                calendarTaskManager.updateScheduleTasks();
          }
        });

    calendarToolbar.add(today);
    calendarToolbar.add(new SeparatorToolItem());
    calendarToolbar.add(yearLeft);
    calendarToolbar.add(currentMonthAndYear);
    calendarToolbar.add(yearRight);
    calendarToolbar.add(new SeparatorToolItem());

    calendarToolbar.add(new FillToolItem());
    createViewsButtons(calendarToolbar);

    return calendarToolbar;
  }
  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;
  }
  /**
   * Creates the applicationToolBar in the viewport's north part. The applicationToolBar's buttons
   * lies on the user role.
   */
  private void createNorth() {
    ToolBar applicationToolBar = new ToolBar();
    List<String> roles = authority.getRoles();
    if (roles.contains(Role.ROLE_ADMIN)
        || (roles.contains(Role.ROLE_DESIGNER) && roles.contains(Role.ROLE_MODELER))) {
      applicationToolBar.add(createBMButton());
      applicationToolBar.add(createUDButton());
      SeparatorToolItem separatorItem = new SeparatorToolItem();
      separatorItem.setWidth("20");
      applicationToolBar.add(separatorItem);
      if (roles.contains(Role.ROLE_ADMIN)) {
        applicationToolBar.add(createAccountManageButton());
      }
      initSaveAndExportButtons();
      applicationToolBar.add(saveButton);
      applicationToolBar.add(exportButton);
      applicationToolBar.add(createOnLineTestBtn());
    } else if (roles.contains(Role.ROLE_DESIGNER) && !roles.contains(Role.ROLE_MODELER)) {
      initSaveAndExportButtons();
      applicationToolBar.add(saveButton);
      applicationToolBar.add(exportButton);
      applicationToolBar.add(createOnLineTestBtn());
    }
    applicationToolBar.add(new FillToolItem());
    applicationToolBar.add(createLogoutButton());

    BorderLayoutData data = new BorderLayoutData(Style.LayoutRegion.NORTH, 25);
    data.setMargins(new Margins(0, 5, 0, 5));
    viewport.add(applicationToolBar, data);
  }
Exemple #19
0
  private Window createAccordionWindow() {
    final Window w = new Window();
    w.setMinimizable(true);
    w.setMaximizable(true);
    w.setIcon(IconHelper.createStyle("accordion"));
    w.setHeading("Contact list");
    w.setWidth(200);
    w.setHeight(350);

    ToolBar toolBar = new ToolBar();
    Button item = new Button();
    item.setIcon(IconHelper.createStyle("icon-connect"));
    toolBar.add(item);

    toolBar.add(new SeparatorToolItem());
    w.setTopComponent(toolBar);

    item = new Button();
    item.setIcon(IconHelper.createStyle("icon-user-add"));
    toolBar.add(item);

    item = new Button();
    item.setIcon(IconHelper.createStyle("icon-user-delete"));
    toolBar.add(item);

    w.setLayout(new AccordionLayout());

    ContentPanel cp = new ContentPanel();
    cp.setAnimCollapse(false);
    cp.setHeading("Online Users");
    cp.setScrollMode(Scroll.AUTO);
    cp.getHeader().addTool(new ToolButton("x-tool-refresh"));

    w.add(cp);

    TreeStore<ModelData> store = new TreeStore<ModelData>();
    TreePanel<ModelData> tree = new TreePanel<ModelData>(store);
    tree.setIconProvider(
        new ModelIconProvider<ModelData>() {

          public AbstractImagePrototype getIcon(ModelData model) {
            if (model.get("icon") != null) {
              return IconHelper.createStyle((String) model.get("icon"));
            } else {
              return null;
            }
          }
        });
    tree.setDisplayProperty("name");

    ModelData m = newItem("Eurecom", null);
    store.add(m, false);
    tree.setExpanded(m, true);

    store.add(m, newItem("Emerson Milton", "user-suit"), false);
    store.add(m, newItem("Christina Blake", "user-girl"), false);
    store.add(m, newItem("Heriberto Rush", "user-kid"), false);
    store.add(m, newItem("Candice Carson", "user-girl"), false);
    store.add(m, newItem("Bell Snedden", "user-kid"), false);
    store.add(m, newItem("Dirk Newman", "user-kid"), false);
    store.add(m, newItem("Chad Andrews", "user-suit"), false);

    m = newItem("Italy", null);
    store.add(m, false);
    tree.setExpanded(m, true);
    store.add(m, newItem("Benito Meeks", "user-suit"), false);
    store.add(m, newItem("Gail Horton", "user-girl"), false);

    m = newItem("Paris", null);
    store.add(m, false);
    tree.setExpanded(m, true);
    store.add(m, newItem("Claudio Engle", "user-suit"), false);
    store.add(m, newItem("Sine", "user-girl"), false);

    m = newItem("Hometown", null);
    store.add(m, false);
    tree.setExpanded(m, true);
    store.add(m, newItem("Hollie Voss", "user-girl"), false);

    cp.add(tree);

    cp = new ContentPanel();
    cp.setAnimCollapse(false);
    cp.setHeading("Settings");
    cp.setBodyStyleName("pad-text");
    cp.addText("Smape1");
    w.add(cp);

    cp = new ContentPanel();
    cp.setAnimCollapse(false);
    cp.setHeading("Blocked");
    cp.setBodyStyleName("pad-text");
    cp.addText("Smape2");
    w.add(cp);

    return w;
  }
  @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 ToolBar getToolBar() {
    final ToolBar bar = new ToolBar();
    bar.add(new FillToolItem());
    bar.add(
        new Button(
            "Unlock Selected Assessment",
            new SelectionListener<ButtonEvent>() {
              public void componentSelected(ButtonEvent ce) {
                final BaseModelData selected = grid.getSelectionModel().getSelectedItem();
                if (selected == null) {
                  WindowUtils.errorAlert("Please select an assessment.");
                  return;
                }

                final NativeDocument document = SimpleSISClient.getHttpBasicNativeDocument();
                document.delete(
                    "/management/locks/persistentlock/" + (String) selected.get("id"),
                    new GenericCallback<String>() {
                      public void onSuccess(String result) {
                        LockLoader.impl.removePersistentLock((String) selected.get("id"));
                        Info.display("Success", "Lock Released.");
                        draw(new DrawsLazily.DoneDrawingWithNothingToDoCallback());
                      }

                      public void onFailure(Throwable caught) {
                        WindowUtils.errorAlert("Could not release lock, please try again later.");
                      }
                    });
              }
            }));
    bar.add(new SeparatorToolItem());
    bar.add(
        groupButton =
            new Button(
                "Unlock All In Group",
                new SelectionListener<ButtonEvent>() {
                  public void componentSelected(ButtonEvent ce) {
                    final BaseModelData selected = grid.getSelectionModel().getSelectedItem();
                    if (selected == null) {
                      WindowUtils.errorAlert("Please select an assessment.");
                      return;
                    }

                    final NativeDocument document = SimpleSISClient.getHttpBasicNativeDocument();
                    document.delete(
                        "/management/locks/persistentlockgroup/"
                            + selected.get("groupid").toString(),
                        new GenericCallback<String>() {
                          public void onSuccess(String result) {
                            final String groupID = (String) selected.get("groupid");
                            final ArrayList<String> lockIDs = new ArrayList<String>();
                            for (RowData row : LockLoader.impl.getPersistentLockGroups()) {
                              if (groupID.equals(row.getField("groupid")))
                                lockIDs.add(row.getField("persistentlockid"));
                            }
                            LockLoader.impl.removePersistentLockGroup(
                                (String) selected.get("id"), lockIDs);
                            Info.display("Success", "Lock Released.");
                            draw(new DrawsLazily.DoneDrawingWithNothingToDoCallback());
                          }

                          public void onFailure(Throwable caught) {
                            WindowUtils.errorAlert(
                                "Could not release lock, please try again later.");
                          }
                        });
                  }
                }));
    return bar;
  }
  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();
          }
        });
  }
Exemple #23
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);
    }
  }
Exemple #24
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;
  }
  public RightPropertiesPanel() {

    setHeading(Constants.MENU_PROPS);
    setLayout(new FitLayout());

    ToolBar toolBarSelection = new ToolBar();
    LabelToolItem labelComponents = new LabelToolItem("Component:   ");
    toolBarSelection.add(labelComponents);
    labelComponents.setVisible(true);
    setTopComponent(toolBarSelection);

    listComponents = new SimpleComboBox<String>();
    updateFileList("Folders", listComponents);
    listComponents.add(Constants.COMPONENT_SPMANAGERWEB_NAME);
    listComponents.add("Test");
    listComponents.setForceSelection(true);
    listComponents.setEditable(false);
    listComponents.setTriggerAction(ComboBox.TriggerAction.ALL);
    listComponents.setEmptyText("- Choose a component -");
    listComponents.setFieldLabel("Component");
    listComponents.setWidth(200);
    toolBarSelection.add(listComponents);

    listComponents.addSelectionChangedListener(
        new SelectionChangedListener() {

          @Override
          public void selectionChanged(SelectionChangedEvent se) {
            selectedComponent = listComponents.getSimpleValue();
            output.setEmptyText(
                "Select a component and configuration file to display and press \"Load\"");
            updateFileList(selectedComponent, listFiles);
          }
        });

    LabelToolItem labelFiles = new LabelToolItem("    File:   ");
    toolBarSelection.add(labelFiles);
    labelFiles.setVisible(true);

    listFiles = new SimpleComboBox<String>();
    listFiles.setForceSelection(true);
    listFiles.setEditable(false);
    listFiles.setTriggerAction(ComboBox.TriggerAction.ALL);
    listFiles.setEmptyText("-Choose a file-");
    listFiles.setFieldLabel("File");
    listFiles.setAutoWidth(false);
    listFiles.setWidth(250);
    toolBarSelection.add(listFiles);

    listFiles.addSelectionChangedListener(
        new SelectionChangedListener() {

          @Override
          public void selectionChanged(SelectionChangedEvent se) {
            output.setEmptyText(
                "Select a component and configuration file to display and press \"Load\"");
            output.clear();
          }
        });

    Button loadButton = new Button("Load");
    toolBarSelection.add(loadButton);

    loadButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            updateFileContent();
          }
        });

    currentOutput = "Select a component and configuration file to display and press \"Load\"";
    output = new TextArea();
    output.addStyleName("demo-TextArea");
    output.setWidth("800px");
    output.setHeight("400px");
    output.setReadOnly(true);
    output.setEmptyText("Select a component and configuration file to display and press \"Load\"");
    output.setVisible(true);
    add(output);
  }
Exemple #26
0
  /** Creates and configures the toolbar.<br> */
  private void addToolBar() {
    ToolBar toolBar = new ToolBar();

    // "new" button
    SelectionListener<ToolBarEvent> lNew =
        new SelectionListener<ToolBarEvent>() {
          @Override
          public void componentSelected(ToolBarEvent tbe) {
            showDetailsPanel(null);
          }
        };
    buttonsHelper.addGenericButton(
        commonMessagesBundle.labelAdd(), stylesBundle.iconAddUser(), toolBar, lNew);
    buttonsHelper.addSeparator(toolBar);

    // "delete" button
    SelectionListener<ToolBarEvent> lDelete =
        new SelectionListener<ToolBarEvent>() {
          @Override
          public void componentSelected(ToolBarEvent tbe) {
            final PortalUserSelModelData selected = grid.getSelectionModel().getSelectedItem();
            if (selected != null) {
              Listener<WindowEvent> listener =
                  new Listener<WindowEvent>() {
                    public void handleEvent(WindowEvent be) {
                      if (be.buttonClicked.getItemId().equals(Dialog.YES)) { // confirmed
                        tryRemoveUser(selected);
                      }
                    }
                  };
              MessageBox.confirm(
                      "Confirmar eliminación de Usuario",
                      "¿Seguro que desea eliminar el Usuario seleccionado?",
                      listener)
                  .setModal(true);
            }
          }
        };
    ttiDelete =
        buttonsHelper.addGenericButton(
            commonMessagesBundle.labelDelete(), stylesBundle.iconDeleteUser(), toolBar, lDelete);
    buttonsHelper.addSeparator(toolBar);

    // "edit" button
    SelectionListener<ToolBarEvent> lEdit =
        new SelectionListener<ToolBarEvent>() {
          @Override
          public void componentSelected(ToolBarEvent ce) {
            PortalUserSelModelData selected = grid.getSelectionModel().getSelectedItem();
            if (selected != null) {
              tryRetrieveAndDisplayDetails(selected);
            }
          }
        };
    ttiEdit = buttonsHelper.addEditButton(toolBar, lEdit);
    buttonsHelper.addSeparator(toolBar);

    // change password button
    SelectionListener<ToolBarEvent> lChangePwd =
        new SelectionListener<ToolBarEvent>() {
          @Override
          public void componentSelected(ToolBarEvent ce) {
            PortalUserSelModelData selected = grid.getSelectionModel().getSelectedItem();
            if (selected != null) {
              openChangePwdWindow(selected);
            }
          }
        };
    ttiChangePwd =
        buttonsHelper.addGenericButton(
            "Cambiar contraseña", usersStylesBundle.iconChangePassword(), toolBar, lChangePwd);
    toolBar.add(ttiChangePwd);

    toolBar.add(new FillToolItem());

    filter =
        new CustomizableStoreFilter<PortalUserSelModelData>(
            Arrays.asList(
                new String[] {
                  PortalUserSelModelData.PROPERTY_NAME, PortalUserSelModelData.PROPERTY_DISPLAY_NAME
                }));
    filter.bind(store);
    filter.setHideLabel(false);
    toolBar.add(new AdapterToolItem(filter));

    IconButton bRefresh =
        buttonsHelper.addRefreshButton(
            toolBar,
            new SelectionListener<IconButtonEvent>() {
              @Override
              public void componentSelected(IconButtonEvent ce) {
                tryGetUsers();
              }
            });
    bRefresh.setToolTip(new ToolTipConfig(TOOLTIP_REFRESH));

    // disable remove and edit buttons
    enableButtons(false);

    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);
  }
  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);
  }
  @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);
  }
  @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);
  }