コード例 #1
0
  @Override
  public void initialize() {
    container =
        Panels.content(
            null,
            false,
            Layouts.vBoxLayout(
                VBoxLayout.VBoxLayoutAlign.STRETCH, new Layouts.LayoutOptions(new Padding(10))),
            "x-border-layout-ct");
    container.setScrollMode(Style.Scroll.AUTOY);
    container.addStyleName("contact-details-container");
    add(container);

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

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

    container.setTopComponent(toolBar);
  }
コード例 #2
0
ファイル: SplitButton.java プロジェクト: sajeeshnl/sigmah
  /** {@inheritDoc} */
  @Override
  public void setLoading(final boolean loading) {

    if (!this.loading && loading) {
      super.setEnabled(false);
      replaceIcon(IconImageBundle.ICONS.loading());

    } else if (this.loading && !loading) {
      super.setEnabled(initialEnabledState);
      setIcon(getIcon());
    }

    this.loading = loading;
  }
コード例 #3
0
  /**
   * Creates the toolbar of this component.
   *
   * @param enabled <code>true</code> to enable the buttons of this toolbar, <code>false</code> to
   *     disable them.
   * @return A new toolbar.
   */
  private ToolBar createToolbar(final ListStore<ReportReference> store) {
    final ToolBar toolbar = new ToolBar();

    // Creating buttons
    final Button createReportButton =
        new Button(I18N.CONSTANTS.reportCreateReport(), IconImageBundle.ICONS.add());

    // "Create" button action
    createReportButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            MessageBox.prompt(
                I18N.CONSTANTS.reportCreateReport(),
                I18N.CONSTANTS.reportName(),
                new Listener<MessageBoxEvent>() {

                  @Override
                  public void handleEvent(MessageBoxEvent be) {
                    if (Dialog.OK.equals(be.getButtonClicked().getItemId())) {
                      final String name = be.getValue();

                      final HashMap<String, Serializable> properties =
                          new HashMap<String, Serializable>();
                      properties.put("name", name);
                      properties.put("flexibleElementId", getId());
                      properties.put("reportModelId", getModelId());
                      properties.put("containerId", currentContainerDTO.getId());
                      if (currentContainerDTO instanceof ProjectDTO)
                        properties.put("projectId", currentContainerDTO.getId());

                      if (currentContainerDTO instanceof OrgUnitDTO)
                        properties.put("orgUnitId", currentContainerDTO.getId());

                      properties.put("multiple", true);

                      if (currentContainerDTO instanceof ProjectDTO)
                        properties.put(
                            "phaseName",
                            ((ProjectDTO) currentContainerDTO)
                                .getCurrentPhase()
                                .getPhaseModel()
                                .getName());

                      if (currentContainerDTO instanceof OrgUnitDTO)
                        properties.put("phaseName", null);

                      dispatch.execute(
                          new CreateEntity(ProjectReportDTO.ENTITY_NAME, properties),
                          new CommandResultHandler<CreateResult>() {

                            @Override
                            public void onCommandFailure(final Throwable caught) {
                              N10N.error(
                                  I18N.CONSTANTS.projectTabReports(),
                                  I18N.CONSTANTS.reportCreateError());
                            }

                            @Override
                            public void onCommandSuccess(final CreateResult result) {

                              final ProjectReportDTO createdProjetReport =
                                  (ProjectReportDTO) result.getEntity();

                              final ReportReference reference = new ReportReference();
                              reference.setId(createdProjetReport.getId());
                              reference.setName(name);
                              reference.setLastEditDate(new Date());
                              reference.setEditorName(auth().getUserShortName());
                              store.add(reference);

                              N10N.validNotif(
                                  I18N.CONSTANTS.projectTabReports(),
                                  I18N.CONSTANTS.reportCreateSuccess());
                            }
                          });
                    }
                  }
                });
          }
        });

    // Adding buttons to the toolbar
    toolbar.add(createReportButton);

    return toolbar;
  }