use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class HibernatePropertyPage method addSecondSection.
private void addSecondSection(Composite parent) {
// Label for owner field
Label ownerLabel = new Label(parent, SWT.NONE);
ownerLabel.setText(HibernateConsoleMessages.HibernatePropertyPage_default_hibernate_console_config);
Composite settingsPart = createDefaultComposite(parent, 2);
selectedConfiguration = new Combo(settingsPart, SWT.DROP_DOWN | SWT.READ_ONLY);
GridData gd = new GridData();
gd.widthHint = convertWidthInCharsToPixels(50);
selectedConfiguration.setLayoutData(gd);
selectedConfiguration.add(NONE);
// Populate owner text field
ConsoleConfiguration[] configurations = LaunchHelper.findFilteredSortedConsoleConfigs();
for (int i = 0; i < configurations.length; i++) {
ConsoleConfiguration configuration = configurations[i];
selectedConfiguration.add(configuration.getName());
}
details = new Link(settingsPart, SWT.NONE);
details.setText(HibernateConsoleMessages.HibernatePropertyPage_details);
details.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ConsoleConfiguration config = KnownConfigurations.getInstance().find(selectedConfiguration.getText());
if (config != null) {
new EditConsoleConfiguration(config).run();
}
}
});
selectedConfiguration.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
details.setEnabled(selectedConfiguration.getSelectionIndex() != 0);
}
});
Composite settingsPart2 = createDefaultComposite(parent, 2);
enableNamingStrategy = new Button(settingsPart2, SWT.CHECK);
enableNamingStrategy.setText(HibernateConsoleMessages.HibernatePropertyPage_use_naming_strategy);
enableNamingStrategy.setSelection(initNamingStrategy);
settings = new Control[] { ownerLabel, selectedConfiguration, details, enableNamingStrategy };
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class OpenQueryEditorAction method doRun.
protected boolean doRun(TreePath[] paths) {
boolean showed = false;
for (int i = 0; i < paths.length; i++) {
TreePath path = paths[i];
ConsoleConfiguration config = (ConsoleConfiguration) path.getSegment(0);
try {
openQueryEditor(config, generateQuery(path));
showed = true;
} catch (Exception he) {
HibernateConsolePlugin.getDefault().showError(null, HibernateConsoleMessages.OpenQueryEditorAction_exception_open_hql_editor, he);
}
}
return showed;
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class OpenSourceAction method run.
public void run() {
IStructuredSelection sel = getStructuredSelection();
if (!(sel instanceof TreeSelection)) {
return;
}
TreePath[] paths = ((TreeSelection) sel).getPaths();
for (int i = 0; i < paths.length; i++) {
TreePath path = paths[i];
Object lastSegment = path.getLastSegment();
IPersistentClass persClass = getPersistentClass(lastSegment);
ConsoleConfiguration consoleConfig = (ConsoleConfiguration) (path.getSegment(0));
String fullyQualifiedName = null;
if (lastSegment instanceof IProperty) {
Object prevSegment = path.getParentPath().getLastSegment();
if (prevSegment instanceof IProperty && ((IProperty) prevSegment).isComposite()) {
fullyQualifiedName = ((IValue) ((IProperty) prevSegment).getValue()).getComponentClassName();
}
}
if (fullyQualifiedName == null && persClass != null) {
fullyQualifiedName = persClass.getClassName();
}
try {
run(consoleConfig, lastSegment, fullyQualifiedName);
} catch (JavaModelException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenSourceAction_cannot_find_source_file, e);
} catch (PartInitException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenSourceAction_cannot_open_source_file, e);
} catch (FileNotFoundException e) {
HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenSourceAction_cannot_find_source_file, e);
}
}
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class CloseConfigAction method doCloseConfig.
protected void doCloseConfig() {
for (Iterator<?> i = getSelectedNonResources().iterator(); i.hasNext(); ) {
Object node = i.next();
if (!(node instanceof ConsoleConfiguration)) {
continue;
}
ConsoleConfiguration config = (ConsoleConfiguration) node;
((MTreeViewer) viewer).clearChildren(config);
config.reset();
viewer.refresh(node);
}
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class ConsoleConfigReadyUseBaseAction method clearCache.
@SuppressWarnings("rawtypes")
protected void clearCache() {
final IStructuredSelection selection = getStructuredSelection();
HashSet<ConsoleConfiguration> vecMonitorConsoleConfigsTmp = cloneMonitorConsoleConfigs();
for (ConsoleConfiguration consoleConfig : vecMonitorConsoleConfigsTmp) {
consoleConfig.removeConsoleConfigurationListener(this);
}
vecMonitorConsoleConfigsTmp.clear();
for (Iterator i = selection.iterator(); i.hasNext(); ) {
Object obj = i.next();
if (obj instanceof ConsoleConfiguration) {
ConsoleConfiguration consoleConfig = (ConsoleConfiguration) obj;
vecMonitorConsoleConfigsTmp.add(consoleConfig);
consoleConfig.addConsoleConfigurationListener(this);
}
}
vecMonitorConsoleConfigs = vecMonitorConsoleConfigsTmp;
super.clearCache();
}
Aggregations