예제 #1
0
파일: Setup.java 프로젝트: genievn/LD
  /** Prepares the SMTP form */
  private Tab setupSmtp(final ValuesManager vm) {
    // Prepare the SMTP connection tab
    Tab smtpTab = new Tab();
    smtpTab.setTitle(I18N.message("smtpserver"));
    final DynamicForm smtpForm = new DynamicForm();
    smtpForm.setDisabled(true);
    smtpForm.setID("smtpForm");
    smtpForm.setTitleOrientation(TitleOrientation.TOP);
    smtpForm.setValuesManager(vm);
    smtpTab.setPane(smtpForm);

    TextItem smtpHost = ItemFactory.newTextItem(SMTP_HOST, "host", null);
    smtpHost.setValue("localhost");
    smtpHost.setWrapTitle(false);

    IntegerItem smtpPort = ItemFactory.newIntegerItem(SMTP_PORT, "port", null);
    smtpPort.setValue(25);
    smtpPort.setWrapTitle(false);

    TextItem smtpUsername = ItemFactory.newTextItem(SMTP_USERNAME, "username", null);
    smtpUsername.setWrapTitle(false);

    PasswordItem smtpPassword = new PasswordItem();
    smtpPassword.setTitle(I18N.message("password"));
    smtpPassword.setName(SMTP_PASSWORD);
    smtpPassword.setWrapTitle(false);

    BooleanItem smtpSecureAuth = new BooleanItem();
    smtpSecureAuth.setTitle(I18N.message("secureauth"));
    smtpSecureAuth.setName(SMTP_SECURE_AUTH);
    smtpSecureAuth.setWrapTitle(false);
    smtpSecureAuth.setDefaultValue(false);

    SelectItem smtpConnectionSecurity = new SelectItem();
    smtpConnectionSecurity.setTitle(I18N.message("connectionsecurity"));
    smtpConnectionSecurity.setName("smtpConnectionSecurity");
    smtpConnectionSecurity.setDefaultValue(Constants.SMTP_SECURITY_NONE);
    smtpConnectionSecurity.setWrapTitle(false);
    LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
    valueMap.put(Constants.SMTP_SECURITY_NONE, I18N.message("none"));
    valueMap.put(Constants.SMTP_SECURITY_SSL, I18N.message("ssl"));
    valueMap.put(Constants.SMTP_SECURITY_TLS, I18N.message("tls"));
    valueMap.put(Constants.SMTP_SECURITY_TLS_IF_AVAILABLE, I18N.message("tlsavailable"));
    smtpConnectionSecurity.setValueMap(valueMap);

    TextItem smtpSender = ItemFactory.newEmailItem(SMTP_SENDER, "sender", false);
    smtpSender.setWrapTitle(false);
    smtpSender.setValue("*****@*****.**");

    smtpForm.setFields(
        smtpHost,
        smtpPort,
        smtpUsername,
        smtpPassword,
        smtpSender,
        smtpConnectionSecurity,
        smtpSecureAuth);
    return smtpTab;
  }
예제 #2
0
파일: Setup.java 프로젝트: genievn/LD
  /** Prepares the language form */
  private Tab setupLanguage(final ValuesManager vm) {
    Tab languageTab = new Tab();
    languageTab.setTitle(I18N.message(LANGUAGE));

    SelectItem languageItem = ItemFactory.newLanguageSelector(LANGUAGE, false, true);
    languageItem.setTitle(I18N.message("defaultlang"));
    languageItem.setRequired(true);
    languageItem.setValue(I18N.getLocale());

    final DynamicForm languageForm = new DynamicForm();
    languageForm.setID("languageForm");
    languageForm.setValuesManager(vm);
    languageForm.setFields(languageItem);
    languageForm.setDisabled(true);
    languageTab.setPane(languageForm);
    return languageTab;
  }
  private Tab fullTextSearchTab(JcrExplorer jackrabbitExplorer) {
    Tab searchFullTextTab = new Tab();
    searchFullTextTab.setTitle("Full Text Search");
    final DynamicForm searchFullTextForm = new DynamicForm();
    searchFullTextForm.setID("searchFullTextForm");
    searchFullTextForm.setNumCols(3);
    searchFullTxt.setName("searchFullTxt");
    searchFullTxt.setTitle("Full Text Search");
    searchFullTxt.setWidth(250);
    searchFullTxt.setRequired(true);
    //		RegExpValidator regExpValidator = new RegExpValidator();
    //		regExpValidator.setExpression("^[\\w\\d\\_\\.]{1,}$");
    //		searchFullTxt.setValidateOnChange(true);
    //		searchFullTxt.setValidators(regExpValidator);
    SubmitItem searchFullTextSubmitItem = new SubmitItem("searchFullTextSubmitItem");
    searchFullTextSubmitItem.setTitle("Search");
    searchFullTextSubmitItem.setWidth(100);
    class SearchFullTextSubmitValuesHandler implements SubmitValuesHandler {
      private JcrExplorer jackrabbitExplorer;

      public SearchFullTextSubmitValuesHandler(JcrExplorer jackrabbitExplorer) {
        this.jackrabbitExplorer = jackrabbitExplorer;
      }

      public void onSubmitValues(com.smartgwt.client.widgets.form.events.SubmitValuesEvent event) {
        if (searchFullTextForm.validate()) {
          JcrExplorer.showLoadingImg();
          JcrExplorer.service.fullTextSearch(
              searchFullTxt.getValue().toString(), new SearchServiceCallback(jackrabbitExplorer));
        }
      }
    };
    searchFullTextForm.addSubmitValuesHandler(
        new SearchFullTextSubmitValuesHandler(jackrabbitExplorer));
    searchFullTextForm.setSaveOnEnter(true);
    searchFullTxt.setStartRow(true);
    searchFullTxt.setEndRow(false);
    searchFullTextSubmitItem.setStartRow(false);
    searchFullTextSubmitItem.setEndRow(true);
    searchFullTextForm.setItems(searchFullTxt, searchFullTextSubmitItem);
    searchFullTextTab.setPane(searchFullTextForm);
    return searchFullTextTab;
  }
예제 #4
0
파일: Setup.java 프로젝트: genievn/LD
  /** Prepares the repository form */
  private Tab setupRepository(final ValuesManager vm) {
    // Prepare the tab used to configure the repository where documents and
    // other data will be stored
    Tab repositoryTab = new Tab();
    repositoryTab.setTitle(I18N.message("repository"));

    final DynamicForm repositoryForm = new DynamicForm();
    repositoryForm.setID("repositoryForm");
    repositoryForm.setValuesManager(vm);
    TextItem repositoryItem = ItemFactory.newTextItem(REPOSITORY_FOLDER, "repofolder", null);
    repositoryItem.setWidth(200);
    repositoryItem.setRequired(true);
    repositoryItem.setWrapTitle(false);
    repositoryItem.setDefaultValue(getDefaultFolder());
    repositoryForm.setFields(repositoryItem);
    repositoryForm.setDisabled(true);

    repositoryTab.setPane(repositoryForm);
    return repositoryTab;
  }
  private Tab xpathSearchTab(JcrExplorer jackrabbitExplorer) {
    Tab searchXpathTab = new Tab();
    searchXpathTab.setTitle("Xpath Search");
    final DynamicForm searchXpathForm = new DynamicForm();
    searchXpathForm.setID("searchXpathForm");
    searchXpathForm.setNumCols(3);
    searchXpathTxt.setName("searchXpathTxt");
    searchXpathTxt.setTitle("Xpath Search");
    searchXpathTxt.setWidth(250);
    searchXpathTxt.setRequired(true);
    SubmitItem searchXpathSubmitItem = new SubmitItem("searchXpathSubmitItem");
    searchXpathSubmitItem.setTitle("Search");
    searchXpathSubmitItem.setWidth(100);
    class SearchXpathSubmitValuesHandler implements SubmitValuesHandler {
      private JcrExplorer jackrabbitExplorer;

      public SearchXpathSubmitValuesHandler(JcrExplorer jackrabbitExplorer) {
        this.jackrabbitExplorer = jackrabbitExplorer;
      }

      public void onSubmitValues(com.smartgwt.client.widgets.form.events.SubmitValuesEvent event) {
        if (searchXpathForm.validate()) {
          JcrExplorer.showLoadingImg();
          JcrExplorer.service.xpathSearch(
              searchXpathTxt.getValue().toString(), new SearchServiceCallback(jackrabbitExplorer));
        }
      }
    };
    searchXpathForm.addSubmitValuesHandler(new SearchXpathSubmitValuesHandler(jackrabbitExplorer));
    searchXpathForm.setSaveOnEnter(true);
    searchXpathTxt.setStartRow(true);
    searchXpathTxt.setEndRow(false);
    searchXpathSubmitItem.setStartRow(false);
    searchXpathSubmitItem.setEndRow(true);
    searchXpathForm.setItems(searchXpathTxt, searchXpathSubmitItem);
    searchXpathTab.setPane(searchXpathForm);
    return searchXpathTab;
  }
예제 #6
0
파일: Setup.java 프로젝트: genievn/LD
  /** Prepares the registration form */
  private Tab setupRegistration(final ValuesManager vm) {
    Tab registrationTab = new Tab();
    registrationTab.setTitle(I18N.message("registration"));

    TextItem regName = ItemFactory.newTextItem(REG_NAME, "name", null);
    regName.setWrapTitle(false);

    TextItem regOrganization = ItemFactory.newTextItem(REG_ORGANIZATION, "organization", null);
    regOrganization.setWrapTitle(false);

    TextItem regWebsite = ItemFactory.newTextItem(REG_WEBSITE, "website", null);
    regWebsite.setWrapTitle(false);

    TextItem regEmail = ItemFactory.newEmailItem(REG_EMAIL, "email", false);
    regEmail.setWrapTitle(false);

    final DynamicForm regForm = new DynamicForm();
    regForm.setID("regForm");
    regForm.setValuesManager(vm);
    regForm.setFields(regName, regEmail, regOrganization, regWebsite);

    registrationTab.setPane(regForm);
    return registrationTab;
  }
  public Canvas getViewPanel() {

    HStack hStack = new HStack();
    hStack.setWidth(300);
    hStack.setHeight(100);
    hStack.setShowEdges(true);
    hStack.setCanAcceptDrop(true);
    hStack.setAnimateMembers(true);
    hStack.setDropLineThickness(4);

    final Label focusLabel = new Label();
    focusLabel.setID("focusLabel");
    focusLabel.setAlign(Alignment.CENTER);
    focusLabel.setTop(150);
    focusLabel.setWidth(300);
    focusLabel.setHeight(50);

    final Img bluePawn = new Img();
    bluePawn.setID("bluePawn");
    bluePawn.setLayoutAlign(Alignment.CENTER);
    bluePawn.setWidth(48);
    bluePawn.setHeight(48);
    bluePawn.setCanFocus(true);
    bluePawn.setSrc("pieces/48/pawn_blue.png");
    bluePawn.setCanDragReposition(true);
    bluePawn.setCanDrop(true);
    bluePawn.setDragAppearance(DragAppearance.TARGET);
    bluePawn.addDrawHandler(
        new DrawHandler() {
          public void onDraw(DrawEvent event) {
            bluePawn.focus();
          }
        });
    bluePawn.addFocusChangedHandler(
        new FocusChangedHandler() {
          public void onFocusChanged(FocusChangedEvent event) {
            changeLabel(focusLabel, bluePawn.getID(), event.getHasFocus());
          }
        });

    ComboBoxItem field1 = new ComboBoxItem();
    field1.setName("field1");
    field1.setValueMap("Option 1", "Option 2");

    DateItem field2 = new DateItem();
    field2.setName("field2");

    final DynamicForm simpleForm = new DynamicForm();
    simpleForm.setID("simpleForm");
    simpleForm.setLayoutAlign(Alignment.CENTER);
    simpleForm.setHeight(48);
    simpleForm.setFields(field1, field2);
    simpleForm.addFocusChangedHandler(
        new FocusChangedHandler() {
          public void onFocusChanged(FocusChangedEvent event) {
            changeLabel(focusLabel, simpleForm.getID(), event.getHasFocus());
          }
        });

    final Img greenPawn = new Img();
    greenPawn.setID("greenPawn");
    greenPawn.setLayoutAlign(Alignment.CENTER);
    greenPawn.setWidth(48);
    greenPawn.setHeight(48);
    greenPawn.setCanFocus(true);
    greenPawn.setSrc("pieces/48/pawn_green.png");
    greenPawn.setCanDragReposition(true);
    greenPawn.setCanDrop(true);
    greenPawn.setDragAppearance(DragAppearance.TARGET);
    greenPawn.addFocusChangedHandler(
        new FocusChangedHandler() {
          public void onFocusChanged(FocusChangedEvent event) {
            changeLabel(focusLabel, greenPawn.getID(), event.getHasFocus());
          }
        });

    hStack.addMember(bluePawn);
    hStack.addMember(simpleForm);
    hStack.addMember(greenPawn);

    VLayout vLayout = new VLayout();
    vLayout.setMembersMargin(10);
    vLayout.addMember(hStack);
    vLayout.addMember(focusLabel);

    return vLayout;
  }
예제 #8
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;
  }