예제 #1
0
  @Override
  public ToolBar initToolBar() {
    SubModuleToolbar toolbar = new SubModuleToolbar(getEventBus());

    final Button importUser = new Button();

    importUser.setText(I18nUtils.getMessages().user_button_importUsers());
    importUser.setTitle(I18nUtils.getMessages().user_button_importUsers_tip());
    importUser.setIcon(AbstractImagePrototype.create(Icons.INSTANCE.user()));
    importUser.enable();
    importUser.addListener(
        Events.OnClick,
        new Listener<BaseEvent>() {

          public void handleEvent(BaseEvent be) {
            initUserImportView();
          }
        });
    toolbar.add(importUser);

    return toolbar;
  }
  @Override
  public ToolBar initToolBar() {
    SubModuleToolbar toolbar = new SubModuleToolbar(getEventBus(), getSubModule().hasEditRight());
    final Button bmToolbarButton =
        new Button(
            I18nUtils.getMessages().project_button_BranchManagment(),
            AbstractImagePrototype.create(Icons.INSTANCE.branches()));
    AdaptId.adapt(bmToolbarButton, IdElementsAdmResource.INSTANCE.idBranchManagementButton());
    bmToolbarButton.disable();
    bmToolbarButton.setTitle(I18nUtils.getMessages().project_button_BranchManagment());
    bmToolbarButton.addListener(
        Events.OnClick,
        new Listener<BaseEvent>() {

          public void handleEvent(BaseEvent be) {
            ModelData selected = getSelectedItem();
            if (selected != null && bmToolbarButton.isEnabled()) {
              Object obj = selected.get(ProjectBeanDesc.id.getName());
              int projectId = 0;
              if (obj != null) {
                projectId = (Integer) obj;
              }
              String name = selected.get(ProjectBeanDesc.label.getName());
              String warning = selected.get(ProjectBeanDesc.warning.getName());
              if (warning == null) {
                Window window = new BranchManagmentWindow(projectId, name);
                window.show();
              } else {
                String messageTitle = "<font size='3'>" + "Can't manage branches:" + "<font/><br>";
                String messageDetail =
                    "<I><font size='2' style='color:red'>" + warning + "<font/><I/>";
                String message = messageTitle + messageDetail;
                MessageBox.alert("Warning", message, null);
              }
            }
          }
        });

    if (!getSubModule().hasEditRight()) {
      GXTUtils.hideComponents(bmToolbarButton);
    }

    getEventBus()
        .addHandler(
            SubModuleEvent.getType(),
            new SubModuleHandler() {

              public void onEvent(SubModuleEvent event) {
                if (event.getEventType() == EventType.OnGridSelect
                    && getSubModule().hasEditRight()) {
                  bmToolbarButton.enable();
                } else if (event.getEventType() == EventType.OnGridUnselect
                    || event.getEventType() == EventType.OnClickCancel) {
                  bmToolbarButton.disable();
                }
              }
            });

    toolbar.add(bmToolbarButton);
    return toolbar;
  }