private void populateMetaData(DataSource dataSource) { Connection connection = null; try { try { connection = dataSource.getConnection(); DatabaseMetaData metaData = connection.getMetaData(); CommonParameters.set( CommonParameters.DATABASE_PRODUCT_NAME, metaData.getDatabaseProductName()); CommonParameters.set( CommonParameters.DATABASE_PRODUCT_VERSION, metaData.getDatabaseProductVersion()); CommonParameters.set( CommonParameters.DATABASE_MINOR_VERSION, metaData.getDatabaseMinorVersion() + EMPTY); CommonParameters.set( CommonParameters.DATABASE_MAJOR_VERSION, metaData.getDatabaseMajorVersion() + EMPTY); CommonParameters.set(CommonParameters.DATABASE_DRIVER_NAME, metaData.getDriverName()); CommonParameters.set( CommonParameters.DATABASE_DRIVER_MINOR_VERSION, metaData.getDriverMinorVersion() + EMPTY); CommonParameters.set( CommonParameters.DATABASE_DRIVER_MAJOR_VERSION, metaData.getDriverMajorVersion() + EMPTY); CommonParameters.set( CommonParameters.DATABASE_CONNECTION_CLASS_NAME, connection.getClass().getCanonicalName()); } finally { if (connection != null) { connection.close(); } } } catch (SQLException e) { logger.error(e.getMessage(), e); } }
private WrappedDataSource getFromSession() { DataSource dataSource = null; dataSource = (DataSource) CommonParameters.getObject(DATASOURCE_DEFAULT); if (dataSource != null) { WrappedDataSource wrappedDataSource = new WrappedDataSource(dataSource); return wrappedDataSource; } return null; }
@Override protected void createFieldEditors() { Text text = null; StringFieldEditor databaseDriverNameField = new StringFieldEditor( CommonParameters.DATABASE_DRIVER_NAME, "&Driver Name:", getFieldEditorParent()); text = databaseDriverNameField.getTextControl(getFieldEditorParent()); text.setEditable(false); text.setText( CommonParameters.get(CommonParameters.DATABASE_DRIVER_NAME) != null ? CommonParameters.get(CommonParameters.DATABASE_DRIVER_NAME) : DatabasePreferencePage.N_A); addField(databaseDriverNameField); StringFieldEditor databaseMinorVersionField = new StringFieldEditor( CommonParameters.DATABASE_DRIVER_MINOR_VERSION, "&Minor Version:", getFieldEditorParent()); text = databaseMinorVersionField.getTextControl(getFieldEditorParent()); text.setEditable(false); text.setText( CommonParameters.get(CommonParameters.DATABASE_DRIVER_MINOR_VERSION) != null ? CommonParameters.get(CommonParameters.DATABASE_DRIVER_MINOR_VERSION) : DatabasePreferencePage.N_A); addField(databaseMinorVersionField); StringFieldEditor databaseMajorVersionField = new StringFieldEditor( CommonParameters.DATABASE_DRIVER_MAJOR_VERSION, "&Major Version:", getFieldEditorParent()); text = databaseMajorVersionField.getTextControl(getFieldEditorParent()); text.setEditable(false); text.setText( CommonParameters.get(CommonParameters.DATABASE_DRIVER_MAJOR_VERSION) != null ? CommonParameters.get(CommonParameters.DATABASE_DRIVER_MAJOR_VERSION) : DatabasePreferencePage.N_A); addField(databaseMajorVersionField); StringFieldEditor databaseConnectionClassNameField = new StringFieldEditor( CommonParameters.DATABASE_CONNECTION_CLASS_NAME, "&Connection Class Name:", getFieldEditorParent()); text = databaseConnectionClassNameField.getTextControl(getFieldEditorParent()); text.setEditable(false); text.setText( CommonParameters.get(CommonParameters.DATABASE_CONNECTION_CLASS_NAME) != null ? CommonParameters.get(CommonParameters.DATABASE_CONNECTION_CLASS_NAME) : DatabasePreferencePage.N_A); addField(databaseConnectionClassNameField); }
private void createTableColumns() { if (getTableName() == null) { return; } try { Connection connection = null; try { connection = DataSourceFacade.getInstance() .getDataSource(CommonParameters.getRequest()) .getConnection(); List<TableColumn> availableTableColumns = new ArrayList<TableColumn>(); ResultSet primaryKeys = DBUtils.getPrimaryKeys(connection, getTableName()); while (primaryKeys.next()) { String columnName = primaryKeys.getString("COLUMN_NAME"); // $NON-NLS-1$ TableColumn tableColumn = new TableColumn(columnName, 0, true, true); availableTableColumns.add(tableColumn); } ResultSet columns = DBUtils.getColumns(connection, getTableName()); while (columns.next()) { // columns String columnName = columns.getString("COLUMN_NAME"); // $NON-NLS-1$ int columnType = columns.getInt("DATA_TYPE"); // $NON-NLS-1$ TableColumn tableColumn = new TableColumn(columnName, columnType, false, true); if (!exists(availableTableColumns, tableColumn)) { availableTableColumns.add(tableColumn); } } setTableColumns(availableTableColumns.toArray(new TableColumn[] {})); } finally { if (connection != null) { connection.close(); } } } catch (Exception e) { logger.error(ERROR_ON_LOADING_TABLE_COLUMNS_FROM_DATABASE_FOR_GENERATION, e); } }
@SuppressWarnings("serial") public EditorWidget(final Composite parent, final boolean javaScriptEditor) { super(parent, SWT.NONE); super.setLayout(new FillLayout()); browser = new Browser(this, SWT.NONE); browser.setUrl(CommonParameters.getContextPath() + EDITOR_URL); browser.addProgressListener( new ProgressListener() { @Override public void completed(final ProgressEvent event) { loaded = true; updateWidgetContents(); if (javaScriptEditor && DebugModelFacade.getDebugModel() != null) { final DebugSessionModel session = DebugModelFacade.getDebugModel().getActiveSession(); if (session != null && session.getCurrentLineBreak() != null) { final String filePath = session.getCurrentLineBreak().getBreakpoint().getFullPath(); final String path = CommonUtils.formatToRuntimePath( ICommonConstants.ARTIFACT_TYPE.SCRIPTING_SERVICES, filePath); final int[] breakpoints = DebugModelFacade.getDebugModel().getBreakpointsMetadata().getBreakpoints(path); loadBreakpoints(breakpoints); } } } @Override public void changed(final ProgressEvent event) { // } }); // DO NOT REMOVE THIS new BrowserFunction(browser, "saveCalled") { // $NON-NLS-1$ @Override public Object function(final Object[] arguments) { if (listener != null) { listener.save(); } return null; } }; // DO NOT REMOVE THIS new BrowserFunction(browser, "dirtyChanged") { // $NON-NLS-1$ @Override public Object function(final Object[] arguments) { if (listener != null) { listener.dirtyStateChanged((Boolean) arguments[0]); } return null; } }; // DO NOT REMOVE THIS new BrowserFunction(browser, "setBreakpoint") { // $NON-NLS-1$ @Override public Object function(final Object[] arguments) { if ((listener != null) && (arguments[0] != null) && (arguments[0] instanceof Number)) { listener.setBreakpoint(((Number) arguments[0]).intValue()); } return null; } }; // DO NOT REMOVE THIS new BrowserFunction(browser, "clearBreakpoint") { // $NON-NLS-1$ @Override public Object function(final Object[] arguments) { if ((listener != null) && (arguments[0] != null) && (arguments[0] instanceof Number)) { listener.clearBreakpoint(((Number) arguments[0]).intValue()); } return null; } }; }