use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class TypeMappingView method doRefreshTree.
protected void doRefreshTree() {
ConsoleConfiguration configuration = KnownConfigurations.getInstance().find(getConsoleConfigurationName());
viewer.setInput(new LazyDatabaseSchema(configuration));
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class HibernateJpaProject method getDefaultSchema.
/*
* The sequence is(from biggest priority to lowest):
* 1) Configuration.getProperty() (if cc.hasConfiguration())
* 2) ConsoleConfiguration.getPreference().getProperty()-uses hibernate.properties
* 3) JpaProject user overrides
* 4) persistence.xml
* 5) logic from superclass
*/
@Override
public String getDefaultSchema() {
String schema = null;
ConsoleConfiguration cc = getDefaultConsoleConfiguration();
if (cc != null) {
if (cc.hasConfiguration()) {
// was not build yet
IConfiguration configuration = cc.getConfiguration();
if (configuration.getProperties().containsKey(getEnvironment().getDefaultSchema())) {
schema = configuration.getProperty(getEnvironment().getDefaultSchema());
}
}
Properties properties = cc.getPreferences().getProperties();
if (properties != null && properties.containsKey(getEnvironment().getDefaultSchema())) {
schema = properties.getProperty(getEnvironment().getDefaultSchema());
}
}
if (schema == null) {
BasicHibernateProperties prop = getBasicHibernateProperties();
if (getUserOverrideDefaultSchema() != null) {
schema = getUserOverrideDefaultSchema();
} else if (prop != null && prop.getSchemaDefault() != null) {
schema = prop.getSchemaDefault();
}
}
return schema != null ? schema : super.getDefaultSchema();
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class HibernateJpaProject method getDefaultCatalog.
/*
* The sequence is(from biggest priority to lowest):
* 1) Configuration.getProperty() (if cc.hasConfiguration())
* 2) ConsoleConfiguration.getPreference().getProperty()-uses hibernate.properties
* 3) JpaProject user overrides
* 4) persistence.xml
* 5) logic from superclass
*/
@Override
public String getDefaultCatalog() {
String catalog = null;
BasicHibernateProperties prop = getBasicHibernateProperties();
ConsoleConfiguration cc = getDefaultConsoleConfiguration();
if (cc != null) {
if (cc.hasConfiguration()) {
// was not build yet
IConfiguration configuration = cc.getConfiguration();
if (configuration.getProperties().containsKey(getEnvironment().getDefaultCatalog())) {
catalog = configuration.getProperty(getEnvironment().getDefaultCatalog());
}
}
Properties properties = cc.getPreferences().getProperties();
if (properties != null && properties.containsKey(getEnvironment().getDefaultCatalog())) {
catalog = properties.getProperty(getEnvironment().getDefaultCatalog());
}
}
if (catalog == null) {
if (getUserOverrideDefaultCatalog() != null) {
catalog = getUserOverrideDefaultCatalog();
} else if (prop != null && prop.getCatalogDefault() != null) {
catalog = prop.getCatalogDefault();
}
}
return catalog != null ? catalog : super.getDefaultCatalog();
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class GenerateInitWizardPage method createConsoleConfiguration.
private String createConsoleConfiguration() {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
String dialect = determineDialect();
String ccName = launchManager.generateLaunchConfigurationName(HibernateConsoleMessages.AddConfigurationAction_hibernate);
ConsoleConfigurationPreferences prefs = new EclipseConsoleConfigurationPreferences(ccName, ConfigurationMode.JPA, getHibernateVersion(), jpaProject.getName(), true, null, null, null, new IPath[0], new IPath[0], null, null, getConnectionProfileName(), dialect);
ConsoleConfiguration cc = new ConsoleConfiguration(prefs);
KnownConfigurations.getInstance().addConfiguration(cc, false);
return ccName;
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class GenerateInitWizardPage method createControl.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
container.setLayout(layout);
layout.numColumns = numColumns;
layout.verticalSpacing = 10;
outputdir = new StringButtonDialogField(new IStringButtonAdapter() {
public void changeControlPressed(DialogField field) {
IPath[] paths = DialogSelectionHelper.chooseFolderEntries(getShell(), PathHelper.pathOrNull(outputdir.getText()), HibernateConsoleMessages.CodeGenerationSettingsTab_select_output_dir, HibernateConsoleMessages.CodeGenerationSettingsTab_choose_dir_for_generated_files, false);
if (paths != null && paths.length == 1) {
outputdir.setText(((paths[0]).toOSString()));
}
}
});
outputdir.setText(getDefaultOutput());
outputdir.setDialogFieldListener(fieldlistener);
outputdir.setLabelText(HibernateConsoleMessages.CodeGenerationSettingsTab_output_dir);
outputdir.setButtonLabel(HibernateConsoleMessages.CodeGenerationSettingsTab_browse);
Control[] controls = outputdir.doFillIntoGrid(container, numColumns);
// Hack to tell the text field to stretch!
((GridData) controls[1].getLayoutData()).grabExcessHorizontalSpace = true;
setPageComplete(!StringHelper.isEmpty(getOutputDir()));
createChildControls(container);
useConsoleConfiguration = new Button(container, SWT.CHECK);
useConsoleConfiguration.setText(Messages.GenerateInitWizardPage_use_console_configuration);
useConsoleConfiguration.setSelection(true);
useConsoleConfiguration.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
consoleConfigurationName.setEnabled(useConsoleConfiguration.getSelection());
hibernateVersion.setEnabled(!useConsoleConfiguration.getSelection());
connectionProfileName.setEnabled(!useConsoleConfiguration.getSelection());
schemaName.setEnabled(!useConsoleConfiguration.getSelection());
dialectName.setEnabled(!useConsoleConfiguration.getSelection());
dialogChanged();
}
});
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = numColumns;
useConsoleConfiguration.setLayoutData(gd);
consoleConfigurationName = new ComboDialogField(SWT.READ_ONLY);
consoleConfigurationName.setLabelText(HibernateConsoleMessages.CodeGenerationSettingsTab_console_configuration);
ConsoleConfiguration[] cfg = LaunchHelper.findFilteredSortedConsoleConfigs();
String[] names = new String[cfg.length];
for (int i = 0; i < cfg.length; i++) {
ConsoleConfiguration configuration = cfg[i];
names[i] = configuration.getName();
}
consoleConfigurationName.setItems(names);
consoleConfigurationName.setText(jpaProject.getDefaultConsoleConfigurationName());
consoleConfigurationName.setDialogFieldListener(fieldlistener);
consoleConfigurationName.doFillIntoGrid(container, numColumns);
hibernateVersion = new ComboDialogField(SWT.READ_ONLY);
hibernateVersion.setLabelText(HibernateConsoleMessages.ConsoleConfigurationMainTab_0);
hibernateVersion.setItems(ServiceLookup.getVersions());
hibernateVersion.selectItem(0);
hibernateVersion.setDialogFieldListener(fieldlistener);
hibernateVersion.doFillIntoGrid(container, numColumns);
hibernateVersion.setEnabled(false);
createDBGroup(container, numColumns);
setControl(container);
if (StringHelper.isEmpty(consoleConfigurationName.getText())) {
setPageComplete(false);
}
}
Aggregations