コード例 #1
0
  {
    filter = new CityFilter();

    cityRPCService = GWT.create(CityRPCService.class);
    stateRPCService = GWT.create(StateRPCService.class);
    countryRPCService = GWT.create(CountryRPCService.class);

    textDescription = new TextItem(Attribute.DESCRIPTION, I18N.$.LABEL_DESCRIPTION());

    selectState = new SelectItem(Attribute.STATE, I18N.$.LABEL_STATE());
    selectState.setPickListHeight(100);

    selectCountry = new SelectItem(Attribute.COUNTRY, I18N.$.LABEL_COUNTRY());
    selectCountry.setPickListHeight(100);
    selectCountry.addChangeHandler(
        new ChangeHandler() {
          public void onChange(final ChangeEvent event) {
            stateRPCService.findByCountryId(
                Integer.parseInt((String) event.getValue()), stateFindCallback);
          }
        });

    fieldDescription = new ListGridField(Attribute.DESCRIPTION, I18N.$.LABEL_DESCRIPTION());
    fieldState = new ListGridField(Attribute.STATE, I18N.$.LABEL_STATE());
    fieldCountry = new ListGridField(Attribute.COUNTRY, I18N.$.LABEL_COUNTRY());
    fieldLastUpdate = new ListGridField(Attribute.LAST_UPDATE, I18N.$.LABEL_LAST_UPDATE());
    fieldLastUpdate.setCellFormatter(GWTUtils.getDateTimeCellFormatter());

    stateFindCallback =
        new AsyncCallback<List<StateDTO>>() {
          public void onFailure(final Throwable throwable) {
            GWTUtils.showError(throwable);
          }

          public void onSuccess(final List<StateDTO> dtos) {
            selectState.setValueMap(GWTUtils.getStateValueMap(dtos));
          }
        };

    countryFindCallback =
        new AsyncCallback<List<CountryDTO>>() {
          public void onFailure(final Throwable throwable) {
            GWTUtils.showError(throwable);
          }

          public void onSuccess(final List<CountryDTO> dtos) {
            selectCountry.setValueMap(GWTUtils.getCountryValueMap(dtos));
          }
        };
  }
コード例 #2
0
  public Canvas getViewPanel() {

    final TabSet tabSet = new TabSet();
    tabSet.setTabBarPosition(Side.TOP);

    // required so that the select item doesnt touch the tab pane
    tabSet.setTabBarThickness(25);
    tabSet.setTabBarAlign(Side.LEFT);
    tabSet.setWidth(400);
    tabSet.setHeight(200);

    final Tab statusTab = new Tab("Status");

    final Canvas statusPane = new Canvas();
    statusTab.setPane(statusPane);
    tabSet.addTab(statusTab);

    SelectItem selectItem = new SelectItem();
    selectItem.setValueMap("Development", "Staging", "Production");
    selectItem.setShowTitle(false);

    selectItem.setDefaultValue("Development");
    selectItem.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            statusPane.setContents(
                event.getValue()
                    + ": <span style='color:green;font-weight:bold'>Normal</span><br>");
          }
        });

    DynamicForm form = new DynamicForm();
    // form.setHeight(1);
    form.setPadding(0);
    form.setMargin(0);
    form.setCellPadding(1);
    form.setNumCols(1);
    form.setFields(selectItem);

    tabSet.setTabBarControls(TabBarControls.TAB_SCROLLER, TabBarControls.TAB_PICKER, form);
    return tabSet;
  }
コード例 #3
0
ファイル: Setup.java プロジェクト: genievn/LD
  /** Prepares the database tab */
  private Tab setupDatabase(final ValuesManager vm) {
    // Prepare the map with all database engines
    engines.put(
        MYSQL,
        new String[] {
          "MySQL 5.x",
          "com.mysql.jdbc.Driver",
          "jdbc:mysql://<server>[,<failoverhost>][<:3306>]/<database>",
          "org.hibernate.dialect.MySQLDialect",
          "SELECT 1"
        });
    engines.put(
        "PostgreSQL",
        new String[] {
          "PostgreSQL 9.x",
          "org.postgresql.Driver",
          "jdbc:postgresql:[<//server>[<:5432>/]]<database>",
          "org.hibernate.dialect.PostgreSQLDialect",
          "SELECT 1"
        });
    engines.put(
        ORACLE,
        new String[] {
          "Oracle 10g/11g",
          "oracle.jdbc.driver.OracleDriver",
          "jdbc:oracle:thin:@<server>[<:1521>]:<sid>",
          "org.hibernate.dialect.Oracle10gDialect",
          "SELECT 1 FROM DUAL"
        });
    engines.put(
        SQLSERVER,
        new String[] {
          "SQL Server 2005/2008",
          "net.sourceforge.jtds.jdbc.Driver",
          "jdbc:jtds:sqlserver://<server>[:<1433>]/<database>;instance=<instance>",
          "org.hibernate.dialect.SQLServerDialect",
          "SELECT 1"
        });

    Tab databaseTab = new Tab();
    databaseTab.setTitle(I18N.message("database"));

    final DynamicForm databaseForm = new DynamicForm();
    databaseForm.setWidth(450);
    databaseForm.setID("database");
    databaseForm.setValuesManager(vm);
    databaseForm.setDisabled(true);

    RadioGroupItem dbType = new RadioGroupItem();
    dbType.setName(DB_TYPE);
    dbType.setWrapTitle(false);
    dbType.setRequired(true);
    dbType.setVertical(false);
    dbType.setValueMap(I18N.message(INTERNAL), I18N.message("external"));
    dbType.setValue(I18N.message(INTERNAL));
    dbType.setRedrawOnChange(true);
    dbType.setTitle(I18N.message("dbtype"));

    // The database engine, if the External db was chosen
    SelectItem dbEngine = new SelectItem();
    dbEngine.setTitle(I18N.message("dbengine"));
    dbEngine.setWrapTitle(false);
    dbEngine.setVisible(false);
    dbEngine.setName(DB_ENGINE);
    dbEngine.setDefaultValue(MYSQL);
    LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
    for (String engine : engines.keySet()) {
      valueMap.put(engine, engines.get(engine)[0]);
    }
    dbEngine.setValueMap(valueMap);
    dbEngine.setShowIfCondition(
        new FormItemIfFunction() {
          public boolean execute(FormItem item, Object value, DynamicForm form) {
            return !I18N.message(INTERNAL).equals(databaseForm.getValue(DB_TYPE));
          }
        });
    RequiredIfValidator ifValidator = new RequiredIfValidator();
    ifValidator.setExpression(
        new RequiredIfFunction() {
          public boolean execute(FormItem formItem, Object value) {
            return !I18N.message(INTERNAL).equals(databaseForm.getValue(DB_TYPE));
          }
        });
    dbEngine.setValidators(ifValidator);
    dbEngine.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            String selectedItem = (String) event.getValue();
            databaseForm.getField(DB_DRIVER).setValue(engines.get(selectedItem)[1]);
            databaseForm.getField(DB_URL).setValue(engines.get(selectedItem)[2]);
          }
        });

    // The driver for the external DB
    TextItem dbDriver = ItemFactory.newTextItem(DB_DRIVER, "driverclass", null);
    dbDriver.setVisible(false);
    dbDriver.setDefaultValue(engines.get(MYSQL)[1]);
    dbDriver.setWrapTitle(false);
    dbDriver.setShowIfCondition(
        new FormItemIfFunction() {
          public boolean execute(FormItem item, Object value, DynamicForm form) {
            return !I18N.message(INTERNAL).equals(databaseForm.getValue(DB_TYPE));
          }
        });
    dbDriver.setValidators(ifValidator);

    // The connection URL to external DB
    TextItem dbUrl = ItemFactory.newTextItem(DB_URL, "connectionurl", null);
    dbUrl.setWidth(200);
    dbUrl.setVisible(false);
    dbUrl.setDefaultValue(engines.get(MYSQL)[2]);
    dbUrl.setWrapTitle(false);
    dbUrl.setShowIfCondition(
        new FormItemIfFunction() {
          public boolean execute(FormItem item, Object value, DynamicForm form) {
            return !I18N.message(INTERNAL).equals(databaseForm.getValue(DB_TYPE));
          }
        });
    dbUrl.setValidators(ifValidator);

    // The username to access the external DB
    TextItem dbUsername = ItemFactory.newTextItem(DB_USERNAME, "username", null);
    dbUsername.setVisible(false);
    dbUsername.setWrapTitle(false);
    dbUsername.setShowIfCondition(
        new FormItemIfFunction() {
          public boolean execute(FormItem item, Object value, DynamicForm form) {
            return !I18N.message(INTERNAL).equals(databaseForm.getValue(DB_TYPE));
          }
        });

    // The password to access the external DB
    PasswordItem dbPassword = new PasswordItem();
    dbPassword.setVisible(false);
    dbPassword.setTitle(I18N.message("password"));
    dbPassword.setName(DB_PASSWORD);
    dbPassword.setWrapTitle(false);
    dbPassword.setShowIfCondition(
        new FormItemIfFunction() {
          public boolean execute(FormItem item, Object value, DynamicForm form) {
            return !I18N.message(INTERNAL).equals(databaseForm.getValue(DB_TYPE));
          }
        });

    databaseForm.setFields(dbType, dbEngine, dbDriver, dbUrl, dbUsername, dbPassword);
    databaseTab.setPane(databaseForm);
    return databaseTab;
  }