예제 #1
0
  /**
   * 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);
  }
예제 #2
0
  private void addToolBars() {
    ToolBar toolbar = new ToolBar();
    ToolBar bottomToolbar = new ToolBar();

    SelectionListener<ButtonEvent> lNew =
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            showcreationPanel();
          }
        };
    buttonsSupport.addAddButton(toolbar, lNew);
    toolbar.add(new SeparatorToolItem());

    SelectionListener<ButtonEvent> lEdit =
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            SetFilterModelData selected = grid.getSelectionModel().getSelectedItem();
            if (selected != null) {
              showEditionPanel(selected);
            }
          }
        };
    bEdit = buttonsSupport.addEditButton(toolbar, lEdit);
    bEdit.disable();
    toolbar.add(new SeparatorToolItem());

    SelectionListener<ButtonEvent> lDelete =
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            Listener<MessageBoxEvent> lConfirm1 =
                new Listener<MessageBoxEvent>() {
                  public void handleEvent(MessageBoxEvent be) {
                    if (be.getButtonClicked().getItemId().equals(Dialog.YES)) {
                      SetFilterModelData selected = grid.getSelectionModel().getSelectedItem();
                      if (selected != null) {
                        tryDeleteSetFilter(selected);
                      }
                    }
                  }
                };
            MessageBox.confirm(
                    messages.headerConfirmWindow(),
                    pmsMessages.msgConfirmDeleteSetFilter(),
                    lConfirm1)
                .setModal(true);
          }
        };
    bDelete = buttonsSupport.addDeleteButton(toolbar, lDelete);
    bDelete.disable();
    toolbar.add(new SeparatorToolItem());

    SelectionListener<ButtonEvent> lDeleteAll =
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            Listener<MessageBoxEvent> lConfirm1 =
                new Listener<MessageBoxEvent>() {
                  public void handleEvent(MessageBoxEvent be) {
                    if (be.getButtonClicked().getItemId().equals(Dialog.YES)) {
                      tryDeleteAllSetFilter();
                    }
                  }
                };
            MessageBox.confirm(
                    messages.headerConfirmWindow(),
                    pmsMessages.msgConfirmDeleteAllSetFilter(),
                    lConfirm1)
                .setModal(true);
          }
        };
    buttonsSupport.addGenericButton(
        pmsMessages.labelDeleteAll(), styles.iDelete(), toolbar, lDeleteAll);

    toolbar.add(new FillToolItem());
    SelectionListener<IconButtonEvent> lRefresh =
        new SelectionListener<IconButtonEvent>() {
          @Override
          public void componentSelected(IconButtonEvent ce) {
            tryGetSetFilters();
          }
        };
    buttonsSupport.addRefreshButton(toolbar, lRefresh);

    SelectionListener<ButtonEvent> lExport =
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            portalsService.exportSetFilters(
                portalId,
                new AsyncCallback<String>() {

                  public void onSuccess(String result) {
                    pmsUtil.exportPmsFile(result);
                  }

                  public void onFailure(Throwable caught) {
                    util.error(pmsMessages.msgExportError());
                  }
                });
          }
        };
    buttonsSupport.addGenericButton(
        pmsMessages.labelExport(), pmsStyles.exportIcon(), bottomToolbar, lExport);
    buttonsSupport.addSeparator(bottomToolbar);

    SelectionListener<ButtonEvent> lImport =
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            PortalImportWindow w = PmsFactory.getInstance().getPortalImportWindow();
            w.setPortalId(portalId);
            w.setPortalImportType(EPortalImportExportType.COLLECTIONS);
            w.show();
          }
        };
    buttonsSupport.addGenericButton(
        pmsMessages.labelImport(), pmsStyles.importIcon(), bottomToolbar, lImport);

    setTopComponent(toolbar);
    setBottomComponent(bottomToolbar);
  }