示例#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;
  }
  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;
  }
  /** Instantiates a new digital object menu view. */
  @Inject
  public DigitalObjectMenuView(final LangConstants lang, final EventBus eventBus) {
    this.lang = lang;
    this.eventBus = eventBus;

    layout = new VLayout();

    layout.setHeight100();
    layout.setWidth100();
    layout.setOverflow(Overflow.AUTO);

    relatedGrid = new ListGrid();
    relatedGrid.setWidth100();
    relatedGrid.setHeight100();
    relatedGrid.setShowSortArrow(SortArrow.CORNER);
    relatedGrid.setShowAllRecords(true);
    relatedGrid.setAutoFetchData(false);
    relatedGrid.setCanHover(true);
    relatedGrid.setCanSort(false);
    ListGridField field1 = new ListGridField("relation", lang.relation());
    field1.setWidth("40%");
    ListGridField field2 = new ListGridField("uuid", "PID");
    field2.setWidth("*");
    relatedGrid.setFields(field1, field2);
    sectionRelated = new SectionStackSection();
    sectionRelated.setID(SECTION_RELATED_ID);
    sectionRelated.setTitle(lang.referencedBy());
    sectionRelated.setResizeable(true);
    sectionRelated.setItems(relatedGrid);
    sectionRelated.setExpanded(false);

    sideNavGrid =
        new ListGrid() {

          @Override
          protected Canvas getRollOverCanvas(Integer rowNum, Integer colNum) {
            final ListGridRecord rollOverRecord = this.getRecord(rowNum);
            if (rollOverCanvas == null) {
              rollOverCanvas = new HLayout();
              rollOverCanvas.setSnapTo("TR");
              rollOverCanvas.setWidth(50);
              rollOverCanvas.setHeight(22);
            }

            if (rollOverCanvas.getChildren().length > 0) {
              rollOverCanvas.removeChild(rollOverCanvas.getChildren()[0]);
            }
            final String lockOwner = rollOverRecord.getAttributeAsString(Constants.ATTR_LOCK_OWNER);
            if (lockOwner != null) {
              ImgButton lockImg = new ImgButton();
              lockImg.setShowDown(false);
              lockImg.setShowRollOver(false);
              lockImg.setLayoutAlign(Alignment.CENTER);

              if ("".equals(lockOwner)) {
                lockImg.setSrc("icons/16/lock_lock_all.png");
              } else if (lockOwner.length() > 0) {
                lockImg.setSrc("icons/16/lock_lock_all_red.png");
              }

              lockImg.setPrompt(lang.lockInfoButton());
              lockImg.setHeight(16);
              lockImg.setWidth(16);
              lockImg.addClickHandler(
                  new com.smartgwt.client.widgets.events.ClickHandler() {

                    @Override
                    public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
                      EditorSC.objectIsLock(
                          lang,
                          new LockInfo(
                              lockOwner,
                              rollOverRecord.getAttributeAsString(Constants.ATTR_LOCK_DESCRIPTION),
                              rollOverRecord.getAttributeAsStringArray(
                                  Constants.ATTR_TIME_TO_EXP_LOCK)));
                    }
                  });
              rollOverCanvas.addChild(lockImg);
            }
            return rollOverCanvas;
          }
        };
    sideNavGrid.setShowSelectionCanvas(false);

    sideNavGrid.setWidth100();
    sideNavGrid.setHeight100();
    sideNavGrid.setShowSortArrow(SortArrow.CORNER);
    sideNavGrid.setShowAllRecords(true);
    sideNavGrid.setAutoFetchData(true);
    sideNavGrid.setCanHover(true);
    sideNavGrid.setHoverOpacity(75);
    sideNavGrid.setHoverStyle("interactImageHover");
    sideNavGrid.setShowRollOverCanvas(true);

    final DynamicForm form = new DynamicForm();
    form.setHeight(1);
    form.setWidth(60);
    form.setNumCols(1);

    selectItem.setWidth(60);
    selectItem.setShowTitle(false);
    selectItem.setValueMap(lang.me(), lang.all());
    selectItem.setDefaultValue(lang.me());
    selectItem.setHoverOpacity(75);
    selectItem.setHoverStyle("interactImageHover");
    selectItem.addItemHoverHandler(
        new ItemHoverHandler() {

          @Override
          public void onItemHover(ItemHoverEvent event) {
            selectItem.setPrompt(
                DigitalObjectMenuView.this.lang.showModifiedHint() + selectItem.getValue());
          }
        });
    selectItem.addChangedHandler(
        new ChangedHandler() {

          @Override
          public void onChanged(ChangedEvent event) {
            getUiHandlers().refreshRecentlyModified();
          }
        });

    form.setFields(selectItem);
    form.setTitle("by:");

    sectionRecentlyModified = new SectionStackSection();
    sectionRecentlyModified.setTitle(lang.recentlyModified());
    sectionRecentlyModified.setResizeable(true);
    sectionRecentlyModified.setItems(sideNavGrid);
    sectionRecentlyModified.setControls(form);
    sectionRecentlyModified.setExpanded(true);

    sectionStack = new SectionStack();
    sectionStack.addSection(sectionRelated);
    sectionStack.addSection(sectionRecentlyModified);
    sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE);
    sectionStack.setAnimateSections(true);
    sectionStack.setWidth100();
    sectionStack.setHeight100();
    sectionStack.setOverflow(Overflow.HIDDEN);
    layout.addMember(sectionStack);
  }
示例#4
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;
  }