コード例 #1
0
  public WorkspaceManager() {
    PrettyFormLayout form = new PrettyFormLayout();
    form.addHeader(
        GuvnorImages.INSTANCE.WorkspaceManager(),
        new HTML("<b>" + constants.ManageWorkspaces() + "</b>"));
    form.startSection(constants.Workspaces());

    form.addAttribute("", buildDoubleList());

    HorizontalPanel hPanel = new HorizontalPanel();
    Button create = new Button(constants.AddWorkspace());
    create.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            WorkspaceEditor newCat =
                new WorkspaceEditor(
                    new Command() {
                      public void execute() {
                        refreshWorkspaceList();
                      }
                    });

            newCat.show();
          }
        });

    Button remove = new Button(constants.DeleteSelectedWorkspace());
    remove.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            if (availableWorkspacesListBox.getSelectedIndex() == -1) {
              Window.alert(constants.PleaseSelectAWorkspaceToRemove());
              return;
            }
            removeWorkspace();
          }
        });

    Button updateWorkspace = new Button(constants.UpdateSelectedWorkspace());
    updateWorkspace.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            if (availableWorkspacesListBox.getSelectedIndex() == -1) {
              Window.alert(constants.PleaseSelectAWorkspaceToUpdate());
              return;
            }

            updateWorkspace();
          }
        });
    hPanel.add(create);
    hPanel.add(remove);
    hPanel.add(updateWorkspace);

    form.addAttribute("", hPanel);

    form.endSection();
    initWidget(form);
  }
コード例 #2
0
  private Grid buildDoubleList() {
    Grid grid = new Grid(2, 5);

    availableWorkspacesListBox = new ListBox();
    availableWorkspacesListBox.setVisibleItemCount(10);
    availableWorkspacesListBox.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent arg0) {
            String selectedWorkspaceName =
                availableWorkspacesListBox.getItemText(
                    availableWorkspacesListBox.getSelectedIndex());
            refreshModuleList(selectedWorkspaceName);
          }
        });
    // availableWorkspaces.setWidth( "30%" );

    refreshWorkspaceList();

    try {
      availableModulesListBox.setVisibleItemCount(10);
      selectedModulesListBox.setVisibleItemCount(10);

      Grid btnsPanel = new Grid(2, 1);

      btnsPanel.setWidget(
          0,
          0,
          new Button(
              ">",
              new ClickHandler() {

                public void onClick(ClickEvent sender) {
                  copySelected(availableModulesListBox, selectedModulesListBox);
                }
              }));

      btnsPanel.setWidget(
          1,
          0,
          new Button(
              "&lt;",
              new ClickHandler() {

                public void onClick(ClickEvent sender) {
                  copySelected(selectedModulesListBox, availableModulesListBox);
                }
              }));

      grid.setWidget(0, 0, new SmallLabel(constants.Workspaces()));
      grid.setWidget(0, 2, new SmallLabel("Workspace: Available Modules"));
      grid.setWidget(0, 3, new SmallLabel(""));
      grid.setWidget(0, 4, new SmallLabel("Workspace: Selected Modules"));
      grid.setWidget(1, 0, availableWorkspacesListBox);
      grid.setWidget(1, 2, availableModulesListBox);
      grid.setWidget(1, 3, btnsPanel);
      grid.setWidget(1, 4, selectedModulesListBox);

      grid.getColumnFormatter().setWidth(0, "25%");
      grid.getColumnFormatter().setWidth(1, "10%");
      grid.getColumnFormatter().setWidth(2, "25%");
      grid.getColumnFormatter().setWidth(3, "15%");
      grid.getColumnFormatter().setWidth(4, "25%");
      return grid;
    } finally {
      // sce.setFilteringFacts( filteringFact );
    }
  }