Package xgenerator.ui.swing

Examples of xgenerator.ui.swing.JGeneratorFrame


   * @author <a href="mailto:shushanlee@msn.com">liss</a>
   * @param e
   */
  public void metadataGeneratorActionPerformed(ActionEvent e) {
    if (null == jGeneratorFrame) {
      jGeneratorFrame = new JGeneratorFrame();
    }
    if(!jGeneratorFrame.isVisible()) {
      this.jGeneratorFrame.setVisible(true);
    }
    SwingUtilities.updateComponentTreeUI(jGeneratorFrame);
View Full Code Here


   * @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent)
   */
  public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    try {
      MetadataTable metadataTable = (MetadataTable) ui;
      JGeneratorFrame jGeneratorFrame = (JGeneratorFrame) metadataTable.getParentComponent();
      JComboBox datasourceComboBox = jGeneratorFrame.getDataSourceComboBox();
      Object selectedItem = datasourceComboBox.getSelectedItem();
      String datasourceName = StringUtils.toString(selectedItem);
      System.out.println("datasourceName=" + datasourceName);
     
      Vector dataVector = metadataService.getTables(datasourceName);
View Full Code Here

   * </p>
   * @author <a href="mailto:shushanlee@msn.com">liss</a>
   * @param e
   */
  public void queryMetadata(ActionEvent e) {
    JGeneratorFrame generatorGui = (JGeneratorFrame) ui;

    try {
      Object dataSourceNameObj = generatorGui.getDataSourceComboBox().getSelectedItem();
      Object tableNameObj = generatorGui.getTableComboBox().getSelectedItem();
      String dataSourceName = null != dataSourceNameObj ? dataSourceNameObj.toString() : null;
      String tableName = null != tableNameObj ? tableNameObj.toString() : null;
      System.out.println("dataSourceName=" + dataSourceName + " | tableName=" + tableName);
      if(StringUtils.isBlank(dataSourceName)) {
        throw new RuntimeException("请选择数据源!");
      }
      if(StringUtils.isBlank(tableName)) {
        throw new RuntimeException("请选择数据表!");
      }

      generatorGui.getStatusLabel().setText("数据源:" + dataSourceName + " 模型:" + tableName + " 正在加载元数据...");
     
      MetadataTable metadataTable = generatorGui.getMetadataTable();
      MetadataTableModel metadataTableModel = (MetadataTableModel) metadataTable.getModel();
      /*
       * 必须先设置TableModel,然后再设置TableColumnModel 在这里
       */
//      metadataTable.setModel(metadataTableModel); //在这里metadataTableModel没有变
//      metadataTable.setColumnModel(metadataTable.setPreferredTableColumnStyle());
     
      ModelMetadata modelMetadata = metadataTableModel.updateDataVector(dataSourceName, tableName);
      metadataTable.setPreferredTableColumnStyle();
      metadataTable.revalidate();
      metadataTable.updateUI();

      String filterTableNamePrefix = generatorGui.getFilterTableNamePrefixField().getText();
      String filterTableNameSuffix = generatorGui.getFilterTableNameSufferField().getText();
//      String filterColumnNamePrefix = generatorGui.getFilterColumnNamePrefixField().getText();
     
      generatorGui.getMetadataModelNameField().setText(tableName);
      generatorGui.getJavaModelNameField().setText(NotationUtils.upperCamelCase(tableName, NotationUtils.DEFAULT_NOTATION_SEPARATOR, filterTableNamePrefix, filterTableNameSuffix));
      generatorGui.getModelDescriptionField().setText(modelMetadata.getModelDescription());
      generatorGui.getStatusLabel().setText("数据源:" + dataSourceName + " 模型:" + tableName + " 加载元数据成功!");
    } catch (Exception ex) {
      ex.printStackTrace();
      generatorGui.getStatusLabel().setText(ex.getMessage());
      JOptionPane.showMessageDialog(ui, ex.getMessage());
    }
  }
View Full Code Here

   *
   * @param e
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    JGeneratorFrame generatorGui = (JGeneratorFrame) ui;
   
    try {
      MetadataTable metadataTable = generatorGui.getMetadataTable();
      TableModel metadataTableModel = metadataTable.getModel();
     
      final ModelMetadata modelMetadata = new ModelMetadata();
      final List<FieldMetadata> fieldMetadatas = new ArrayList<FieldMetadata>();
      modelMetadata.setFieldMetadatas(fieldMetadatas);
     
      /*
       * 获取表格数据
       */
      int rowCount = metadataTableModel.getRowCount();
      for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
        final FieldMetadata oneFieldMetadata = new FieldMetadata();
       
        final Object columnName = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.COLUMN_NAME_INDEX);
        final Object propertyNameObj = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.PROPERTY_NAME_INDEX);
        final Object displayName = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.DISPLAY_NAME_INDEX);
        final Object comments = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.COMMENTS_INDEX);
        final Object sqlDataTypeObj = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.SQL_DATA_TYPE_INDEX);
        final Object dataLengthObj = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.DATA_LENGTH_INDEX);
        final Object dataPrecisionObj = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.DATA_PRECISION_INDEX);
        final Object dataScaleObj = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.DATA_SCALE_INDEX);
        final Object propertyTypeObj = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.PROPERTY_TYPE_INDEX);
        final Object nullable = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.NULLABLE_INDEX);
        final Object dataDefault = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.DATA_DEFAULT_INDEX);
        final Object keyField = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.IS_KEY_FIELD_INDEX);
        final Object constraintType = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.CONSTRAINT_TYPE_INDEX);
        final Object referencingTable = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.REFERENCING_TABLE_INDEX);
        final Object referencingColumn = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.REFERENCING_COLUMN_INDEX);
        final Object deleteRule = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.DELETE_RULE_INDEX);
        final Object queryField = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.IS_QUERY_FIELD_INDEX);
        final Object queryMode = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.QUERY_MODE_INDEX);
        final Object componentType = metadataTableModel.getValueAt(rowIndex, MetadataTableModel.COMPONENT_TYPE_INDEX);
       
        oneFieldMetadata.setColumnName(StringUtils.toString(columnName));
        String propertyName = StringUtils.toString(propertyNameObj);
        oneFieldMetadata.setPropertyName(propertyName);
        oneFieldMetadata.setPropertyNameLowerCamelCase((NotationUtils.smallFirst(propertyName)));
        oneFieldMetadata.setPropertyNameUpperCamelCase((NotationUtils.capFirst(propertyName)));
        oneFieldMetadata.setPropertyNameUnderscore(NotationUtils.underscore(StringUtils.toString(columnName)));
        oneFieldMetadata.setPropertyNameStudlyCaps(NotationUtils.studlyCaps(propertyName));
        oneFieldMetadata.setDisplayName(StringUtils.toString(displayName));
        oneFieldMetadata.setComments(StringUtils.toString(comments));
        String sqlDataType = StringUtils.toString(sqlDataTypeObj);
        oneFieldMetadata.setSqlDataType(sqlDataType);
       
        if(null != dataLengthObj) {
          try {
            oneFieldMetadata.setDataLength(Integer.parseInt(StringUtils.toString(dataLengthObj)));
          } catch (Exception ex) {
            throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行," + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.DATA_LENGTH_INDEX] + "格式错误!");
          }
        }
        if(null != dataPrecisionObj) {
          try {
            oneFieldMetadata.setDataPrecision(Integer.parseInt(StringUtils.toString(dataPrecisionObj)));
          } catch (Exception ex) {
            throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行," + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.DATA_PRECISION_INDEX] + "格式错误!");
          }
        }
        if(null != dataScaleObj) {
          try {
            oneFieldMetadata.setDataScale(Integer.parseInt(StringUtils.toString(dataScaleObj)));
          } catch (Exception ex) {
            throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行," + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.DATA_SCALE_INDEX] + "格式错误!");
          }
        }

        oneFieldMetadata.setPropertyType(StringUtils.toString(propertyTypeObj));
        oneFieldMetadata.setNullable(Boolean.parseBoolean(StringUtils.toString(nullable)));
        oneFieldMetadata.setDataDefault(StringUtils.toString(dataDefault));
        oneFieldMetadata.setKeyField(Boolean.parseBoolean(StringUtils.toString(keyField)));
        oneFieldMetadata.setConstraintType(StringUtils.toString(constraintType));
        oneFieldMetadata.setReferencingTable(StringUtils.toString(referencingTable));
        oneFieldMetadata.setReferencingColumn(StringUtils.toString(referencingColumn));
        oneFieldMetadata.setDeleteRule(StringUtils.toString(deleteRule));
        oneFieldMetadata.setQueryField(Boolean.parseBoolean(StringUtils.toString(queryField)));
        oneFieldMetadata.setQueryMode(StringUtils.toString(queryMode));
        oneFieldMetadata.setComponentType(StringUtils.toString(componentType));
       
        fieldMetadatas.add(oneFieldMetadata);
      }
     
      /*
       * 2、验证表格数据
       */
      for (int rowIndex = 0; rowIndex < fieldMetadatas.size(); rowIndex++) {
        final FieldMetadata oneFieldMetadata = fieldMetadatas.get(rowIndex);
       
        //列名
        if(StringUtils.isBlank(oneFieldMetadata.getColumnName())) {
          throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行," + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.COLUMN_NAME_INDEX] + "不能为空!");
        }
        //属性名
        if(StringUtils.isBlank(oneFieldMetadata.getPropertyName())) {
          throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行," + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.PROPERTY_NAME_INDEX] + "不能为空!");
        }
        //列描述
        if(StringUtils.isBlank(oneFieldMetadata.getDisplayName())) {
          throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行," + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.DISPLAY_NAME_INDEX] + "不能为空!");
        }
        //数据类型
        String columnType = oneFieldMetadata.getSqlDataType();
        if(StringUtils.isBlank(columnType)) {
          throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行," + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.SQL_DATA_TYPE_INDEX] + "不能为空!");
        }
        //数据类型长度、浮点长度
        if (SqlDataTypeComboBoxModel.DATE_TYPE.equalsIgnoreCase(columnType)) {
          /*
          if(null != oneFieldMetadata.getDataLength()) {
            throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行,DATE类型" + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.DATA_LENGTH_INDEX] + "必须为空!");
          }
          if(null != oneFieldMetadata.getDataScale()) {
            throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行,DATE类型" + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.DATA_PRECISION_INDEX] + "必须为空!");
          }
          */
        } else {
          if(null == oneFieldMetadata.getDataLength()) {
            throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行," + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.DATA_LENGTH_INDEX] + "不能为空!");
          }
//          if(null == oneFieldMetadata.getFloatLength()) {
//            throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行,浮点长度不能为空!");
//          }
        }
        if(oneFieldMetadata.isKeyField()) {
          if (StringUtils.isBlank(oneFieldMetadata.getConstraintType())) {
            throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行," + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.CONSTRAINT_TYPE_INDEX] + "不能为空!");
          }
          if(ConstraintTypeComboBoxModel.FK_TYPE.equalsIgnoreCase(oneFieldMetadata.getConstraintType())) {
            if (StringUtils.isBlank(oneFieldMetadata.getReferencingTable())) {
              throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行," + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.REFERENCING_TABLE_INDEX] + "不能为空!");
            }
            if (StringUtils.isBlank(oneFieldMetadata.getReferencingColumn())) {
              throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行," + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.REFERENCING_COLUMN_INDEX] + "不能为空!");
            }
            if (StringUtils.isBlank(oneFieldMetadata.getDeleteRule())) {
              throw new IllegalArgumentException("元数据第" + (rowIndex + 1) + "行," + MetadataTableModel.COLUMN_NAMES[MetadataTableModel.DELETE_RULE_INDEX] + "不能为空!");
            }
          }
        }
      }// end of for loop

      /*
       * 获取代码生成选项数据
       */
      final String metadataModelName = generatorGui.getMetadataModelNameField().getText();
      final String modelDescription = generatorGui.getModelDescriptionField().getText();
      final Object encodingObj = generatorGui.getEncodingComboBox().getSelectedItem();
      final String encoding = StringUtils.toString(encodingObj);
     
      final Object riaObj = generatorGui.getRiaComboBox().getSelectedItem()// RIA技术
      final Object viewObj = generatorGui.getViewComboBox().getSelectedItem()// 表示层技术
      final Object webFrameworkObj = generatorGui.getWebFrameworkComboBox().getSelectedItem(); // web层框架
      final Object appFrameworkObj = generatorGui.getAppFrameworkComboBox().getSelectedItem(); // 业务层框架
      final Object persistenceFrameworkObj = generatorGui.getPersistenceFrameworkComboBox().getSelectedItem(); // 持久层框架
      final String ria = StringUtils.toString(riaObj);
      final String view = StringUtils.toString(viewObj);
      final String webFramework = StringUtils.toString(webFrameworkObj);
      final String appFramework = StringUtils.toString(appFrameworkObj);
      final String persistenceFramework = StringUtils.toString(persistenceFrameworkObj);
     
      final String projectLocation = generatorGui.getProjectLocationField().getText();
      final String src = generatorGui.getSrcField().getText();
      final String appConfig = generatorGui.getAppConfigField().getText();
      final String appResources = generatorGui.getAppResourcesField().getText();
      final String webRoot = generatorGui.getWebRootField().getText();
      final String webConfig = generatorGui.getWebConfigField().getText();
      final String webResources = generatorGui.getWebResourcesField().getText();
     
      final String j2eeSpecificationLevel = generatorGui.getJ2eeSpecificationLevelButtonGroup().getSelection().getActionCommand()//JavaEE规范选择
      final String notation = generatorGui.getNotationButtonGroup().getSelection().getActionCommand()//命名法选择
     
      /*
       * 个性化设置
       */
      final String packagePrefix = generatorGui.getPackagePrefixField().getText();
      final String subsystem = generatorGui.getSubsystemField().getText();
      final String module = generatorGui.getModuleField().getText();
      final String javaModelName = generatorGui.getJavaModelNameField().getText();
      final String actionSuffer = generatorGui.getActionSuffer().getText();
      final String actionFormSuffer = generatorGui.getActionFormSuffer().getText();
      final String serviceSuffer = generatorGui.getServiceSuffer().getText();
      final String serviceImplSuffer = generatorGui.getServiceImplSuffer().getText();
      final String daoSuffer = generatorGui.getDaoSuffer().getText();
      final String daoImplSuffer = generatorGui.getDaoImplSuffer().getText();
      final String metadataSuffer = generatorGui.getMetadataSuffer().getText();
      final String queryPrefix = generatorGui.getQueryPrefix().getText();
      final String createPrefix = generatorGui.getCreatePrefix().getText();
      final String editPrefix = generatorGui.getEditPrefix().getText();
      final String viewPrefix = generatorGui.getViewPrefix().getText();
      final String gridSuffer = generatorGui.getGridSuffer().getText();
      final String treeSuffer = generatorGui.getTreeSuffer().getText();
      final String windowSuffer = generatorGui.getWindowSuffer().getText();
      final String panelSuffer = generatorGui.getPanelSuffer().getText();
      final String gridPanelSuffer = generatorGui.getGridPanelSuffer().getText();
      final String treePanelSuffer = generatorGui.getTreePanelSuffer().getText();

      final boolean isGenerateRiaCode = generatorGui.getRiaCodeGenerateCheckBox().isSelected()//是否生成RIA代码
      final boolean isGenerateViewCode = generatorGui.getViewCodeGenerateCheckBox().isSelected()//是否生成页面代码
      final boolean isGenerateControllerCode = generatorGui.getControllerCodeGenerateCheckBox().isSelected(); // 是否生成控制器代码
      final boolean isGenerateAppCode = generatorGui.getAppCodeGenerateCheckBox().isSelected(); // 是否生成业务层代码
      final boolean isGeneratePersistenceCode = generatorGui.getPersistenceCodeGenerateCheckBox().isSelected(); // 是否生成持久层代码
     
      final String pageStyle = generatorGui.getPageStyle().getText()//页面样式
     
      /*
       * 验证模型基本信息
       */
      if (StringUtils.isBlank(metadataModelName)) {
        throw new IllegalArgumentException("元数据模型名称不能为空!");
      }
      if (StringUtils.isBlank(encoding)) {
        throw new IllegalArgumentException("字符编码不能为空!");
      }

      /*
       * 验证JavaEE规范级别与命名法
       */
      if (StringUtils.isBlank(j2eeSpecificationLevel)) {
        throw new IllegalArgumentException("Java EE规范级别不能为空!");
      }
      if (StringUtils.isBlank(notation)) {
        throw new IllegalArgumentException("命名法不能为空!");
      }
     
      /*
       * 验证技术架构选项
       */
      if (StringUtils.isBlank(view)) {
        throw new IllegalArgumentException("请选择一项视图技术!");
      }
      if (StringUtils.isBlank(webFramework)) {
        throw new IllegalArgumentException("请选择一个web框架!");
      }
      /*
      if (StringUtils.isBlank(appFramework) && StringUtils.isBlank(ria)) {
        throw new IllegalArgumentException("请选择一个应用框架!");
      }
      if (StringUtils.isBlank(persistenceFramework)) {
        throw new IllegalArgumentException("请选择一项持久层技术!");
      }
      if (StringUtils.isBlank(ria)) {
        throw new IllegalArgumentException("请选择一项富客户端技术!");
      }
      */

      /*
       * 验证项目设置选项
       */
      if (StringUtils.isBlank(projectLocation)) {
        throw new IllegalArgumentException("项目路径不能为空!");
      }
      if (StringUtils.isBlank(src)) {
        throw new IllegalArgumentException("src目录不能为空!");
      }if (StringUtils.isBlank(appConfig)) {
        throw new IllegalArgumentException("AppConfig目录不能为空!");
      }
      if (StringUtils.isBlank(appResources)) {
        throw new IllegalArgumentException("AppResources目录不能为空!");
      }
      if (StringUtils.isBlank(webRoot)) {
        throw new IllegalArgumentException("WebRoot目录不能为空!");
      }
      if (StringUtils.isBlank(webConfig)) {
        throw new IllegalArgumentException("WebConfig目录不能为空!");
      }
      if (StringUtils.isBlank(webResources)) {
        throw new IllegalArgumentException("WebResources目录不能为空!");
      }
     
      /*
       * 验证个性化设置
       */
      if (StringUtils.isBlank(packagePrefix)) {
        throw new IllegalArgumentException("应用包不能为空!");
      }
      if (StringUtils.isBlank(subsystem)) {
        throw new IllegalArgumentException("子系统不能为空!");
      }
      if (StringUtils.isBlank(module)) {
        throw new IllegalArgumentException("模块不能为空!");
      }
      if (StringUtils.isBlank(javaModelName)) {
        throw new IllegalArgumentException("Java模型名称不能为空!");
      }
      if (StringUtils.isBlank(actionSuffer)) {
        throw new IllegalArgumentException("Action后缀不能为空!");
      }
      if (StringUtils.isBlank(serviceSuffer)) {
        throw new IllegalArgumentException("Service后缀不能为空!");
      }
      if (StringUtils.isBlank(serviceImplSuffer)) {
        throw new IllegalArgumentException("ServiceImpl后缀不能为空!");
      }
      if (StringUtils.isBlank(daoSuffer)) {
        throw new IllegalArgumentException("Dao后缀不能为空!");
      }
      if (StringUtils.isBlank(daoImplSuffer)) {
        throw new IllegalArgumentException("DaoImpl后缀不能为空!");
      }
     
      /*
       * 验证代码生成选项数据
       */
      if(false == isGenerateRiaCode && false == isGenerateViewCode && false == isGenerateControllerCode && false == isGenerateAppCode && false == isGeneratePersistenceCode) {
        throw new IllegalArgumentException("请选择一层生成代码!");
      }
     
      modelMetadata.setMetadataModelName(metadataModelName);
      modelMetadata.setModelDescription(modelDescription);
      modelMetadata.setEncoding(encoding);

      modelMetadata.setJ2eeSpecificationLevel(j2eeSpecificationLevel);
      modelMetadata.setNotation(notation);
     
      modelMetadata.setRia(ria);
      modelMetadata.setView(view);
      modelMetadata.setWebFramework(webFramework);
      modelMetadata.setAppFramework(appFramework);
      modelMetadata.setPersistenceFramework(persistenceFramework);
     
      modelMetadata.setProjectLocation(projectLocation);
      modelMetadata.setSrc(src);
      modelMetadata.setAppConfig(appConfig);
      modelMetadata.setAppResources(appResources);
      modelMetadata.setWebRoot(webRoot);
      modelMetadata.setWebConfig(webConfig);
      modelMetadata.setWebResources(webResources);

      modelMetadata.setPackagePrefix(packagePrefix);
      modelMetadata.setSubsystem(subsystem);
      modelMetadata.setModule(module);
      modelMetadata.setJavaModelName(javaModelName);
      modelMetadata.setJavaModelNameLowerCase(javaModelName.toLowerCase());
      modelMetadata.setJavaModelNameLowerCamelCase(NotationUtils.smallFirst(javaModelName));
      modelMetadata.setJavaModelNameUpperCamelCase(NotationUtils.capFirst(javaModelName));
      modelMetadata.setJavaModelNameUnderscore(NotationUtils.underscore(metadataModelName));
      modelMetadata.setJavaModelNameStudlyCaps(NotationUtils.studlyCaps(javaModelName));
      modelMetadata.setActionSuffer(actionSuffer);
      modelMetadata.setActionFormSuffer(actionFormSuffer);
      modelMetadata.setServiceSuffer(serviceSuffer);
      modelMetadata.setServiceImplSuffer(serviceImplSuffer);
      modelMetadata.setDaoSuffer(daoSuffer);
      modelMetadata.setDaoImplSuffer(daoImplSuffer);
      modelMetadata.setMetadataSuffer(metadataSuffer);
      modelMetadata.setQueryPrefix(queryPrefix);
      modelMetadata.setQueryCapPrefix(NotationUtils.capFirst(queryPrefix));
      modelMetadata.setCreatePrefix(createPrefix);
      modelMetadata.setCreateCapPrefix(NotationUtils.capFirst(createPrefix));
      modelMetadata.setEditPrefix(editPrefix);
      modelMetadata.setEditCapPrefix(NotationUtils.capFirst(editPrefix));
      modelMetadata.setViewPrefix(viewPrefix);
      modelMetadata.setViewCapPrefix(NotationUtils.capFirst(viewPrefix));
      modelMetadata.setGridSuffer(gridSuffer);
      modelMetadata.setTreeSuffer(treeSuffer);
      modelMetadata.setWindowSuffer(windowSuffer);
      modelMetadata.setPanelSuffer(panelSuffer);
      modelMetadata.setGridPanelSuffer(gridPanelSuffer);
      modelMetadata.setTreePanelSuffer(treePanelSuffer);
     
      modelMetadata.setGenerateRiaCode(isGenerateRiaCode);
      modelMetadata.setGenerateViewCode(isGenerateViewCode);
      modelMetadata.setGenerateControllerCode(isGenerateControllerCode);
      modelMetadata.setGenerateAppCode(isGenerateAppCode);
      modelMetadata.setGeneratePersistenceCode(isGeneratePersistenceCode);
     
      modelMetadata.setPageStyle(pageStyle);
     
      /*
       * 确认生成代码
       */
      if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(ui, "确认生成代码?", "确认", JOptionPane.OK_CANCEL_OPTION)) {
        // 3、调用生成器
        Generator generator = GeneratorFactory.getGenerator(modelMetadata);
        String codes = generator.generateCode(modelMetadata);
//        System.out.println(codes);
        if(StringUtils.isNotBlank(codes)) {
          if(codes.startsWith("&@")) {
            codes = codes.substring(2);
          }
          codes = codes.replaceAll("&@", "\n");
        }
//        System.out.println(codes);
//        JOptionPane.showMessageDialog(ui, "代码生成成功!" + codes);
       
        JTextArea textArea = new JTextArea(codes);
        //通过设置textArea的列和行来设置对话框显示内容的大小
        textArea.setColumns(100);
        textArea.setRows(10);
//        textArea.setLineWrap(true);//超过设置的列数自动换行
        textArea.setLineWrap(false);
        textArea.setEditable(false);//设置不可编辑
        JOptionPane.showMessageDialog(ui, new JScrollPane(textArea), "代码生成成功", JOptionPane.INFORMATION_MESSAGE);//加入滚动条
        textArea.getParent().getParent().getParent().setLocation(0, 0);
       
        generatorGui.getStatusLabel().setText("代码生成成功!");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      generatorGui.getStatusLabel().setText("代码生成失败!");
      JOptionPane.showMessageDialog(ui, ex.getMessage());
    }
  }
View Full Code Here

   * @param e
   * @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent)
   */
  public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    MetadataTable metadataTable = (MetadataTable) ui;
    JGeneratorFrame jGeneratorFrame = (JGeneratorFrame) metadataTable.getParentComponent();
    JComboBox datasourceComboBox = jGeneratorFrame.getDataSourceComboBox();
    Object selectedItem = datasourceComboBox.getSelectedItem();
    String datasourceName = StringUtils.toString(selectedItem);
    System.out.println("datasourceName=" + datasourceName);
   
    int selectedRowIndex = metadataTable.getSelectedRow();
View Full Code Here

TOP

Related Classes of xgenerator.ui.swing.JGeneratorFrame

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.