private void initGUI() {
    mainContainer = new BorderLayoutContainer();
    refresButton = new TextButton("", ELearningController.ICONS.refresh());
    removeFromLectureButton =
        new TextButton("Remove form lecture", ELearningController.ICONS.delete());
    ListStore<Lecture> lectureListStore = new ListStore<Lecture>(lectureDataProperties.key());
    lectureComboBox =
        new ComboBox<Lecture>(
            lectureListStore,
            new LabelProvider<Lecture>() {
              public String getLabel(Lecture item) {
                return item.getLectureName();
              }
            });
    ListStore<Professor> professorListStore = new ListStore<Professor>(professorProperties.key());
    professorComboBox =
        new ComboBox<Professor>(
            professorListStore,
            new LabelProvider<Professor>() {
              public String getLabel(Professor item) {
                return item.getUsername();
              }
            });
    userGrid = createGrid();
    ToolBar toolBar = new ToolBar();

    lectureComboBox.setTriggerAction(ComboBoxCell.TriggerAction.ALL);
    lectureComboBox.setEditable(false);
    lectureComboBox.setAllowBlank(false);
    professorComboBox.setTriggerAction(ComboBoxCell.TriggerAction.ALL);
    professorComboBox.setEditable(false);
    professorComboBox.setAllowBlank(false);

    toolBar.setHorizontalSpacing(5);
    toolBar.add(refresButton);
    toolBar.add(new SeparatorToolItem());
    toolBar.add(new Label("Professor: "));
    toolBar.add(professorComboBox);
    toolBar.add(new Label("Lecture: "));
    toolBar.add(lectureComboBox);
    toolBar.add(new SeparatorToolItem());
    toolBar.add(removeFromLectureButton);

    mainContainer.setNorthWidget(toolBar, new BorderLayoutContainer.BorderLayoutData(30));
    mainContainer.setCenterWidget(userGrid);
    setState(ManageEnrolledStudentsController.IManageEnrolledStudentsState.NONE);
  }
Exemplo n.º 2
0
  @Override
  public Widget asWidget() {
    if (buttons == null) {
      // Simple
      final Dialog simple = new Dialog();
      simple.setHeadingText("Dialog Test");
      simple.setPredefinedButtons(PredefinedButton.YES, PredefinedButton.NO);
      simple.setBodyStyleName("pad-text");
      simple.add(new Label(TestData.DUMMY_TEXT_SHORT));
      simple.getBody().addClassName("pad-text");
      simple.setHideOnButtonClick(true);
      simple.setWidth(300);

      // Layout
      final Dialog complex = new Dialog();
      complex.setBodyBorder(false);
      complex.getHeader().setIcon(Resources.IMAGES.side_list());
      complex.setHeadingText("BorderLayout Dialog");
      complex.setWidth(400);
      complex.setHeight(225);
      complex.setHideOnButtonClick(true);

      BorderLayoutContainer layout = new BorderLayoutContainer();
      complex.add(layout);

      // Layout - west
      ContentPanel panel = new ContentPanel();
      panel.setHeadingText("West");
      BorderLayoutData data = new BorderLayoutData(150);
      data.setMargins(new Margins(0, 5, 0, 0));
      panel.setLayoutData(data);
      layout.setWestWidget(panel);

      // Layout - center
      panel = new ContentPanel();
      panel.setHeadingText("Center");
      layout.setCenterWidget(panel);

      // Auto Size - See the JavaDoc for Window for more information on auto size
      final FlowLayoutContainer flc = new FlowLayoutContainer();
      flc.add(new HTML("Press Add or Remove to modify content"));
      final Dialog autoSize = new Dialog();
      autoSize.setBodyBorder(false);
      autoSize.setHeadingText("Auto Size Dialog");
      autoSize.setHideOnButtonClick(true);
      autoSize.setWidget(flc);
      autoSize.setPixelSize(-1, -1);
      autoSize.setMinWidth(0);
      autoSize.setMinHeight(0);
      autoSize.setResizable(false);
      autoSize.setShadow(true);
      autoSize.addButton(
          new TextButton(
              "Add",
              new SelectHandler() {
                @Override
                public void onSelect(SelectEvent event) {
                  addAutoSizeContent(flc);
                  autoSize.forceLayout();
                }
              }));
      autoSize.addButton(
          new TextButton(
              "Remove",
              new SelectHandler() {
                @Override
                public void onSelect(SelectEvent event) {
                  int lastWidget = flc.getWidgetCount() - 1;
                  if (lastWidget > 0) {
                    flc.remove(lastWidget);
                    autoSize.forceLayout();
                  }
                }
              }));

      // Buttons
      buttons = new ButtonBar();
      buttons.setWidth(400);
      buttons.getElement().setMargins(10);

      TextButton b = new TextButton("Simple");
      b.addSelectHandler(
          new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
              simple.show();
            }
          });
      buttons.add(b);

      b = new TextButton("Layout");
      b.addSelectHandler(
          new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
              complex.show();
            }
          });
      buttons.add(b);

      b = new TextButton("Auto Size");
      b.addSelectHandler(
          new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
              autoSize.show();
            }
          });

      buttons.add(b);

      // Add some basic content to begin with
      for (int i = 0; i < 5; i++) {
        addAutoSizeContent(flc);
      }
    }

    return buttons;
  }
 @Override
 public void unmask() {
   mainContainer.unmask();
 }
 @Override
 public void mask() {
   mainContainer.mask();
 }