Exemplo n.º 1
0
 public void reset() {
   for (int i = 0; i < widget.getItemCount(); i++) {
     widget.setItemSelected(i, false);
   }
   widget.setSelectedIndex(-1);
   if (widget.getVisibleItemCount() <= 1) {
     widget.setSelectedIndex(0);
     widget.setItemSelected(0, true);
   }
 }
Exemplo n.º 2
0
 private void adjustListBox(boolean value) {
   applications.setEnabled(value);
   regions.setEnabled(value);
   if (!value) {
     for (int index = 0; index < applications.getItemCount(); index++) {
       applications.setItemSelected(index, false);
     }
     for (int index = 0; index < regions.getItemCount(); index++) {
       regions.setItemSelected(index, false);
     }
   }
 }
Exemplo n.º 3
0
  private ListBox createScheduleCombo() {
    final ScheduleEditor localThis = this;
    ListBox lb = new ListBox();
    lb.setVisibleItemCount(1);
    // lb.setStyleName("scheduleCombo"); //$NON-NLS-1$
    lb.addChangeHandler(
        new ChangeHandler() {

          @Override
          public void onChange(ChangeEvent event) {
            localThis.handleScheduleChange();
          }
        });

    // add all schedule types to the combobox
    for (ScheduleType schedType : EnumSet.range(ScheduleType.RUN_ONCE, ScheduleType.CRON)) {
      if (!isBlockoutDialog
          || (schedType != ScheduleType.CRON
              && schedType != ScheduleType.SECONDS
              && schedType != ScheduleType.MINUTES
              && schedType != ScheduleType.HOURS)) {
        lb.addItem(schedType.toString());
      }
    }
    lb.setItemSelected(0, true);

    return lb;
  }
Exemplo n.º 4
0
 private void setValueType(VariableDto variableDto) {
   for (int i = 0; i < valueType.getItemCount(); i++) {
     valueType.setItemSelected(i, valueType.getValue(i).equals(variableDto.getValueType()));
   }
   if (valueType.getSelectedIndex() == -1) {
     valueType.setSelectedIndex(0);
   }
 }
Exemplo n.º 5
0
 public void setValue(Object value) {
   if (value instanceof Collection && widget.isMultipleSelect()) {
     for (Iterator i = ((Collection) value).iterator(); i.hasNext(); ) {
       for (int j = 0; j < widget.getItemCount(); j++) {
         if (widget.getValue(j).equals(i.next())) {
           widget.setItemSelected(j, true);
         }
       }
     }
   } else {
     for (int i = 0; i < widget.getItemCount(); i++) {
       if (widget.getValue(i).equals(value)) {
         widget.setItemSelected(i, true);
         break;
       }
     }
   }
 }
Exemplo n.º 6
0
 public VerticalPanel getScreen(int comp, int mode, int id) {
   compID = id;
   // load the right Component
   compList.setItemSelected(comp, true);
   // set visibility
   checkVisibility();
   // load the right mode for the component
   return layoutPanel;
 }
Exemplo n.º 7
0
 public void setTariffList(ArrayList<CourseTariff> tariffList) {
   tariffListBox.clear();
   tariffListBox.insertItem("<" + constants.select() + ">", 0);
   for (int j = 0; j < tariffList.size(); j++) {
     tariffListBox.insertItem(
         tariffList.get(j).getName() + " - " + tariffList.get(j).getCosts() + " €", j + 1);
   }
   gradeListBox.setItemSelected(0, true);
 }
Exemplo n.º 8
0
 @Override
 public void onClick(ClickEvent event) {
   int index = previewZ.getSelectedIndex();
   if (previewZ.getItemCount() == 0) {
     return;
   }
   if (-1 == index) {
     index = 0;
   }
   previewA.setItemSelected(index, true);
 }
Exemplo n.º 9
0
 void resetApplications(List<Application> apps) {
   if (apps != null && !apps.isEmpty()) {
     applications.clear();
     for (Application a : apps) {
       applications.addItem(a.toDisplay(), a.getId() + "");
     }
     for (int index = 0; index < applications.getItemCount(); index++) {
       int id = Integer.parseInt(applications.getValue(index));
       applications.setItemSelected(index, group.getApplicationIds().contains(id));
     }
   }
   adjustListBox(box.getValue());
 }
Exemplo n.º 10
0
  private void createResponseTypeColumn() {
    VerticalPanel rp = new VerticalPanel();
    upperLinePanel.add(rp);
    Label responseTypeLabel = new Label(myConstants.responseType() + ":");
    responseTypeLabel.setStyleName("keyLabel");
    rp.add(responseTypeLabel);

    final ListBox responseTypeListBox = new ListBox();
    responseTypeListBox.addItem(Input2.LIKERT_SMILEYS);
    responseTypeListBox.addItem(Input2.LIKERT);
    responseTypeListBox.addItem(Input2.OPEN_TEXT);
    responseTypeListBox.addItem(Input2.LIST);
    responseTypeListBox.addItem(Input2.NUMBER);
    responseTypeListBox.addItem(Input2.LOCATION);
    responseTypeListBox.addItem(Input2.PHOTO);
    // responseType.addItem(InputDAO.SOUND);
    // responseType.addItem(InputDAO.ACTIVITY);
    responseTypeListBox.setVisibleItemCount(1);
    int responseTypeSelectedIndex = 0;
    for (int i = 0; i < Input2.RESPONSE_TYPES.length; i++) {
      if (Input2.RESPONSE_TYPES[i].equals(input.getResponseType())) {
        responseTypeSelectedIndex = i;
        break;
      }
    }
    responseTypeListBox.setItemSelected(responseTypeSelectedIndex, true);
    rp.add(responseTypeListBox);

    responseTypeListBox.addChangeHandler(
        new ChangeHandler() {
          @Override
          public void onChange(ChangeEvent event) {
            input.setResponseType(
                responseTypeListBox.getItemText(responseTypeListBox.getSelectedIndex()));
            responseView.drawWidgetForInput(input);
            // inputPromptTextPanel.setVisible(!input.isInvisibleInput());
          }
        });
  }
Exemplo n.º 11
0
  public WgtGameHeaderInfo() {
    super();

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.add(new Label("Nom :"));
    m_name.addValueChangeHandler(
        new ValueChangeHandler<String>() {
          @Override
          public void onValueChange(ValueChangeEvent<String> p_event) {
            GameEngine.model().getGame().setName(m_name.getText());
            AppRoot.getEventBus().fireEvent(new ModelUpdateEvent(GameEngine.model()));
          }
        });
    hPanel.add(m_name);
    m_panel.add(hPanel);

    m_panel.add(new Label("Description :"));
    m_description.addValueChangeHandler(
        new ValueChangeHandler<String>() {
          @Override
          public void onValueChange(ValueChangeEvent<String> p_event) {
            GameEngine.model().getGame().setDescription(m_description.getText());
            AppRoot.getEventBus().fireEvent(new ModelUpdateEvent(GameEngine.model()));
          }
        });
    m_panel.add(m_description);

    hPanel = new HorizontalPanel();
    hPanel.add(new Label("Nombre maxi de joueur :"));
    m_maxPlayerCount.addItem("2");
    m_maxPlayerCount.addItem("3");
    m_maxPlayerCount.addItem("4");
    m_maxPlayerCount.addItem("5");
    m_maxPlayerCount.addItem("6");
    m_maxPlayerCount.addItem("7");
    m_maxPlayerCount.addItem("8");
    m_maxPlayerCount.addItem("9");
    m_maxPlayerCount.addItem("10");
    m_maxPlayerCount.addItem("11");
    m_maxPlayerCount.addItem("12");
    m_maxPlayerCount.setVisibleItemCount(1);
    m_maxPlayerCount.setItemSelected(2, true);
    m_maxPlayerCount.addChangeHandler(
        new ChangeHandler() {
          @Override
          public void onChange(ChangeEvent p_event) {
            GameEngine.model()
                .getGame()
                .setMaxNumberOfPlayer(m_maxPlayerCount.getSelectedIndex() + 2);
            AppRoot.getEventBus().fireEvent(new ModelUpdateEvent(GameEngine.model()));
          }
        });
    hPanel.add(m_maxPlayerCount);
    m_panel.add(hPanel);

    // fill UI
    onModelUpdate(GameEngine.model());

    initWidget(m_panel);

    // receive all model change
    AppRoot.getEventBus().addHandler(ModelUpdateEvent.TYPE, this);
  }
Exemplo n.º 12
0
 @Override
 public void onModelUpdate(GameEngine p_modelSender) {
   m_name.setText(p_modelSender.getGame().getName());
   m_description.setText(p_modelSender.getGame().getDescription());
   m_maxPlayerCount.setItemSelected(p_modelSender.getGame().getMaxNumberOfPlayer() - 2, true);
 }
Exemplo n.º 13
0
 public void setRegionIds(List<Integer> regionIds) {
   for (int index = 0; index < regions.getItemCount(); index++) {
     int id = Integer.parseInt(regions.getValue(index));
     regions.setItemSelected(index, regionIds.contains(id));
   }
 }
Exemplo n.º 14
0
 public void setApplicationIds(List<Integer> applicationIds) {
   for (int index = 0; index < applications.getItemCount(); index++) {
     int id = Integer.parseInt(applications.getValue(index));
     applications.setItemSelected(index, applicationIds.contains(id));
   }
 }
  private void createComponent() {
    hlBack = new Anchor("<<back");
    hlBack.addClickHandler(this);
    vPanel.add(hlBack);
    ProjectItems projectItems = currentUser.getProjectItems();
    if (projectItems.getProjectItemCount() == 0) {
      vPanel.add(new HTML("You are not subscribed to any projects."));
    } else {
      vPanel.add(form);
      lbProjects = new ListBox(false);
      lbProjects.addChangeHandler(this);
      vPanel.setSize("1000px", "500px");
      table.setCellSpacing(5);
      table.setCellPadding(0);
      table.setWidth("100%");
      tbName.setWidth("300px");
      // tbDescription.setWidth("300px");
      txtFileNotes.setHeight("75px");
      upload.setName("uploadFormElement");
      // fileUpload.setName("fileuploadFormElement");
      tbName.setName("name");
      tbDescription.setName("description");
      txtFileNotes.setName("notes");
      lbProjects.setName("projectDetails");
      btnSubmit.addClickHandler(this);
      txtWarnings.setStylePrimaryName("warnings");
      txtWarningDesc.setStylePrimaryName("warnings");
      txtFileNotes.setCharacterWidth(50);
      tbName.setMaxLength(50);
      // tbDescription.setMaxLength(255);
      // tbDescription.setText("");
      txtLogin = new TextBox();
      txtLogin.setName("user");
      txtLogin.setVisible(false);

      txtProject = new TextBox();
      txtProject.setName("projectName");
      txtProject.setVisible(false);

      int projectId = currentUser.getPreferredProjectId();

      for (int i = 0; i < projectItems.getProjectItemCount(); i++) {
        ProjectItem item = projectItems.getProjectItem(i);
        lbProjects.addItem(item.getProjectName(), String.valueOf(item.getProjectId()));
        if (projectId > 0) {
          if (projectId == item.getProjectId()) {
            lbProjects.setItemSelected(i, true);
          }
        } else {
          lbProjects.setItemSelected(0, true);
        }
      }

      table.setText(0, 0, "");
      table.setWidget(0, 1, txtWarnings);
      table.setText(1, 0, "");
      table.setWidget(1, 1, txtWarningDesc);
      table.setWidget(2, 0, new HTML("<b>Name:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(2, 1, tbName);
      table.setWidget(3, 0, new HTML("<b>File:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(3, 1, upload);
      // table.setWidget(4, 0, new HTML("<b>Description:</b>&nbsp;&nbsp;&nbsp;"));
      // table.setWidget(4, 1, fileUpload);
      table.setWidget(5, 0, new HTML("<b>Project:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(5, 1, lbProjects);
      table.setWidget(6, 0, new HTML("<b>Notes:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(6, 1, txtFileNotes);
      table.setWidget(7, 1, btnSubmit);
      table.setWidget(7, 2, txtLogin);
      table.setWidget(7, 3, txtProject);

      table.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(3, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(4, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(5, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(5, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(6, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(6, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(7, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(7, 0, HasVerticalAlignment.ALIGN_TOP);

      table.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(2, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(2, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(3, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(3, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(4, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(4, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(5, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(5, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(6, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(6, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(7, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(7, 1, HasVerticalAlignment.ALIGN_TOP);

      form.add(table);

      form.setAction(UPLOAD_ACTION_URL);
      form.setEncoding(FormPanel.ENCODING_MULTIPART);
      form.setMethod(FormPanel.METHOD_POST);

      form.addSubmitHandler(
          new FormPanel.SubmitHandler() {
            public void onSubmit(SubmitEvent event) {
              // This event is fired just before the form is submitted. We can
              // take this opportunity to perform validation.
              String fileName1 = upload.getFilename().trim();
              // String fileName2 = fileUpload.getFilename().trim();
              // System.out.println("File1: " + fileName1);
              if (fileName1.length() == 0 && tbName.getText().length() == 0) {
                txtWarnings.setHTML("*Please upload a file.");
                txtWarningDesc.setHTML("*Please enter the Job name.");
                event.cancel();
              }
              if ((fileName1.length() == 0) && tbName.getText().length() != 0) {
                txtWarnings.setText("");
                txtWarningDesc.setText("");
                txtWarnings.setHTML("*Please upload a file.");
                event.cancel();
              }
              if ((!(fileName1.length() == 0)) && tbName.getText().length() == 0) {
                txtWarnings.setText("");
                txtWarningDesc.setText("");
                txtWarnings.setHTML("*Please enter the Job name.");
                event.cancel();
              }
            }
          });

      form.addSubmitCompleteHandler(
          new FormPanel.SubmitCompleteHandler() {
            public void onSubmitComplete(SubmitCompleteEvent event) {
              txtFileNotes.setText("");
              txtWarningDesc.setText("");
              String sessionID = Cookies.getCookie("sid");
              if (sessionID != null) {
                String result = event.getResults();
                System.out.println("UploadJob Result: " + result);
                // Log.info("Result: " + result);
                String[] results = result.split("~");
                /*for(int i = 0; i < results.length; i++)
                {
                	 System.out.println(results[i]);
                	 try
                	 {
                		 jobId = Integer.parseInt(results[0]);
                	 }
                	 catch(NumberFormatException e)
                	 {
                		 e.printStackTrace();
                	 }
                }*/
                int jobId = -1;
                try {
                  jobId = Integer.parseInt(results[0]);
                } catch (NumberFormatException e) {
                  e.printStackTrace();
                }
                // Code modified
                if (jobId == 0) {
                  txtWarnings.setHTML(results[1]);
                }
                // Code modified
                // txtWarnings.setHTML(results[1]);

                else {
                  if (currentUser.getUsertype().equalsIgnoreCase("user")) {
                    History.newItem("userJobList");
                  } else {
                    if (tab == 0) {

                      History.newItem("adminJobList");
                    } else {
                      History.newItem("jobList");
                    }
                    // AdminPage adminPage = new AdminPage(tab);
                    // RootPanel.get("content").add(adminPage);
                  }
                }
              } else {
                Login login = new Login();
                login.displayLoginBox();
              }
            }
          });
    }
  }
  private void init() {

    setModal(true);
    setAnimationEnabled(true);
    ensureDebugId("cwDialogBox");
    setText("New Recipe");

    // Create a table to layout the content
    VerticalPanel dialogContents = new VerticalPanel();
    setWidget(dialogContents);

    HorizontalPanel namePanel = new HorizontalPanel();
    namePanel.setSpacing(6);
    namePanel.add(new Label("Name:"));
    nameTextBox = new TextBox();
    nameTextBox.setWidth("600px");
    namePanel.add(nameTextBox);

    HorizontalPanel categoriesPanel = new HorizontalPanel();
    categoriesPanel.setSpacing(6);
    categoriesPanel.add(new Label("Category"));

    category.addItem("Fish");
    category.addItem("Meat");
    category.addItem("Poultry");
    categoriesPanel.add(category);

    categoriesPanel.add(new Label("Cuisine"));

    cuisine.addItem("American");
    cuisine.addItem("Mexican");
    cuisine.addItem("Italian");
    categoriesPanel.add(cuisine);

    categoriesPanel.add(new Label("Occasion"));

    occasion.addItem("Easter");
    occasion.addItem("Summer");
    occasion.addItem("Thanksgiving");
    categoriesPanel.add(occasion);

    categoriesPanel.add(new Label("Serves"));

    serves.addItem("1");
    serves.addItem("4");
    serves.addItem("12");
    serves.setItemSelected(1, true);
    categoriesPanel.add(serves);

    ingredients = new TextArea();
    ingredients.setTitle("Ingredients");
    ingredients.setHeight("200px");
    ingredients.setWidth("600px");

    Label ingredientsLabel = new Label("Ingredients");

    directions = new TextArea();
    directions.setTitle("Directions");
    directions.setHeight("200px");
    directions.setWidth("600px");

    Label directionsLabel = new Label("Directions");

    FlexTable grid = new FlexTable();
    grid.setWidget(0, 0, ingredientsLabel);
    grid.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
    grid.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
    grid.setWidget(0, 1, ingredients);
    dialogContents.add(namePanel);
    grid.setWidget(1, 0, directionsLabel);
    grid.setWidget(1, 1, directions);
    dialogContents.setCellHeight(namePanel, "50px");
    dialogContents.add(categoriesPanel);
    dialogContents.setCellHeight(namePanel, "50px");
    dialogContents.add(grid);

    // Add a close button at the bottom of the dialog
    Button closeButton =
        new Button(
            "Close",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                hide();
              }
            });

    Button createButton =
        new Button(
            "Create Recipe",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                GWT.log("Creating Recipe: " + nameTextBox.getText(), null);
                addRecipe(
                    new RecipeTO(
                        nameTextBox.getText(),
                        category.getValue(category.getSelectedIndex()),
                        cuisine.getValue(cuisine.getSelectedIndex()),
                        occasion.getValue(occasion.getSelectedIndex()),
                        serves.getValue(serves.getSelectedIndex()),
                        ingredients.getText(),
                        directions.getText()));
                hide();
              }
            });

    Button saveButton =
        new Button(
            "Save Recipe",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                GWT.log("Updating Recipe: " + nameTextBox.getText(), null);
                updateRecipe(
                    new RecipeTO(
                        nameTextBox.getText(),
                        category.getValue(category.getSelectedIndex()),
                        cuisine.getValue(cuisine.getSelectedIndex()),
                        occasion.getValue(occasion.getSelectedIndex()),
                        serves.getValue(serves.getSelectedIndex()),
                        ingredients.getText(),
                        directions.getText()));
                hide();
                mainView.loadRecipes();
                RootPanel.get("stockList").remove(0);
                RootPanel.get("stockList").add(mainView);
                History.newItem("hoho");
              }
            });

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    // Display update or create button if recipe exists and is being edited
    if (recipeExists) {
      buttonPanel.add(saveButton);
    } else {
      buttonPanel.add(createButton);
    }
    buttonPanel.add(closeButton);
    dialogContents.add(buttonPanel);

    // Return the dialog box
  }