use of org.hibernate.eclipse.console.actions.EditConsoleConfiguration 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.eclipse.console.actions.EditConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class KnownConfigurationsView method makeActions.
/**
*/
private void makeActions() {
this.actionGroup = new ConfigurationsViewActionGroup(this, viewer);
this.doubleAction = new Action() {
public void run() {
// TODO: make action dependent on having a connected console configuration!
ISelection selection = viewer.getSelection();
if (selection == null || selection.isEmpty()) {
return;
}
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
if (firstElement instanceof ConsoleConfiguration) {
new EditConsoleConfiguration((ConsoleConfiguration) firstElement).run();
} else if (firstElement instanceof BaseNode) {
BaseNode node = (BaseNode) firstElement;
ConsoleConfiguration consoleConfiguration = node.getConsoleConfiguration();
if (consoleConfiguration.isSessionFactoryCreated()) {
String hql = node.getHQL();
// open HQL Editor
HibernateConsolePlugin.getDefault().openScratchHQLEditor(consoleConfiguration.getName(), hql);
/**
* /
* // execute query and show results in
* // Hibernate Query result view - commented cause old version
* if(StringHelper.isNotEmpty( hql )) {
* try {
* if (getSite() != null && getSite().getPage() != null) {
* getSite().getPage().showView(QueryPageTabView.ID);
* }
* } catch (PartInitException e) {
* HibernateConsolePlugin.getDefault().logErrorMessage("Can't show QueryPageTabView.", e); //$NON-NLS-1$
* }
* consoleConfiguration.executeHQLQuery( hql );
* }
* /*
*/
}
} else if (selection instanceof TreeSelection) {
TreePath[] paths = ((TreeSelection) selection).getPaths();
TreePath path = paths[0];
Object last = path.getLastSegment();
ConsoleConfiguration consoleConfig = (ConsoleConfiguration) (path.getSegment(0));
if (last instanceof IPersistentClass || (last instanceof IProperty && ((IProperty) last).classIsPropertyClass())) {
try {
OpenMappingAction.run(consoleConfig, path);
} catch (PartInitException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("Can't find mapping file.", e);
} catch (JavaModelException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("Can't find mapping file.", e);
} catch (FileNotFoundException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("Can't find mapping file.", e);
}
} else {
for (int i = 0; i < paths.length; i++) {
if (viewer.getExpandedState(paths[i])) {
viewer.collapseToLevel(paths[i], 1);
} else {
viewer.expandToLevel(paths[i], 1);
}
}
}
}
}
};
}
Aggregations