Exemple #1
0
  public void addReason(String reason_, List form, int errorFlag) throws WingException {
    TextArea reason = form.addItem("reason", null).addTextArea("reason");
    reason.setLabel(T_reason);
    reason.setHelp(T_reason_help);

    if (!isAdvancedFormEnabled) {
      if (globalReason != null) reason.setValue(globalReason);
    } else {
      if (reason_ != null && errorFlag != org.dspace.submit.step.AccessStep.STATUS_COMPLETE)
        reason.setValue(reason_);
    }
  }
Exemple #2
0
  @Test
  public void testTextArea() {
    TextArea field = new TextArea("area");
    assertSame(field, field.toFocusControl());
    assertSame(field, field.toInputField());

    assertEquals(TextArea.DEFAULT_ROWS, field.getRows());
    field.setRows(10);
    assertEquals(10, field.getRows());

    assertEquals(TextArea.DEFAULT_COLS, field.getCols());
    field.setCols(100);
    assertEquals(100, field.getCols());

    assertEquals(null, field.getValue());
    field.setValue("abc");
    assertEquals("abc", field.getValue());

    assertFalse(field.isReadOnly());
    field.setReadOnly(true);
    assertTrue(field.isReadOnly());

    assertOut(field, "<textarea name='area' rows='10' cols='100' readonly>abc</textarea>");
  }
  @HibernateSessionThreadLocalConstructor
  @SuppressWarnings("serial")
  public MapGameDesignPanel(GameDesignGlobals globs) {
    super(false, globs);
    Game g = Game.getTL();
    TextArea titleTA;
    final Serializable uid = Mmowgli2UI.getGlobals().getUserID();

    titleTA = (TextArea) addEditLine("Map Title", "Game.mapTitle", g, g.getId(), "MapTitle").ta;
    titleTA.setValue(g.getMapTitle());
    titleTA.setRows(1);

    latTA = addEditLine("Map Initial Latitude", "Game.mmowgliMapLatitude");
    boolean lastRO = latTA.isReadOnly();
    latTA.setReadOnly(false);
    latTA.setValue("" + g.getMapLatitude());
    latTA.setRows(1);
    latTA.setReadOnly(lastRO);
    latTA.addValueChangeListener(
        new Property.ValueChangeListener() {
          @Override
          @MmowgliCodeEntry
          @HibernateOpened
          @HibernateClosed
          public void valueChange(ValueChangeEvent event) {
            HSess.init();
            try {
              String val = event.getProperty().getValue().toString();
              double lat = Double.parseDouble(val);
              Game g = Game.getTL();
              g.setMapLatitude(lat);
              Game.updateTL();
              GameEventLogger.logGameDesignChangeTL("Map latitude", val, uid);
            } catch (Exception ex) {
              new Notification(
                      "Parameter error",
                      "<html>Check for proper decimal format.</br>New value not committed.",
                      Notification.Type.WARNING_MESSAGE,
                      true)
                  .show(Page.getCurrent());
            }
            HSess.close();
          }
        });

    lonTA = addEditLine("Map Initial Longitude", "Game.mmowgliMapLongitude");
    lastRO = lonTA.isReadOnly();
    lonTA.setReadOnly(false);
    lonTA.setValue("" + g.getMapLongitude());
    lonTA.setRows(1);
    lonTA.setReadOnly(lastRO);
    lonTA.addValueChangeListener(
        new Property.ValueChangeListener() {
          @Override
          @MmowgliCodeEntry
          @HibernateOpened
          @HibernateClosed
          public void valueChange(ValueChangeEvent event) {
            // System.out.println("lon valueChange");
            HSess.init();
            try {
              String val = event.getProperty().getValue().toString();
              double lon = Double.parseDouble(val);
              Game g = Game.getTL();
              g.setMapLongitude(lon);
              Game.updateTL();
              GameEventLogger.logGameDesignChangeTL("Map longitude", val, uid);
            } catch (Exception ex) {
              new Notification(
                      "Parameter error",
                      "<html>Check for proper decimal format.</br>New value not committed.",
                      Notification.Type.WARNING_MESSAGE,
                      true)
                  .show(Page.getCurrent());
            }
            HSess.close();
          }
        });

    zoomTA = addEditLine("Map Initial Zoom", "Game.mmowgliMapZoom");
    lastRO = zoomTA.isReadOnly();
    zoomTA.setReadOnly(false);
    zoomTA.setValue("" + g.getMapZoom());
    zoomTA.setRows(1);
    zoomTA.setReadOnly(lastRO);
    zoomTA.addValueChangeListener(
        new Property.ValueChangeListener() {
          @Override
          @MmowgliCodeEntry
          @HibernateOpened
          @HibernateClosed
          public void valueChange(ValueChangeEvent event) {
            HSess.init();
            try {
              String val = event.getProperty().getValue().toString();
              int zoom = Integer.parseInt(val);
              Game g = Game.getTL();
              g.setMapZoom(zoom);
              Game.updateTL();
              GameEventLogger.logGameDesignChangeTL("Map zoom", val, uid);
            } catch (Exception ex) {
              new Notification(
                      "Parameter error",
                      "Check for proper integer format.</br>New value not committed.",
                      Notification.Type.WARNING_MESSAGE,
                      true)
                  .show(Page.getCurrent());
            }
            HSess.close();
          }
        });
    Button b;
    this.addComponentLine(
        b = new Button("Set to generic Mmowgli Map Defaults", new MapDefaultSetter()));
    b.setEnabled(!globs.readOnlyCheck(false));
  }