use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class ConsoleConfigurationBasedAction method updateSelection.
protected final boolean updateSelection(IStructuredSelection selection) {
boolean enabled = false;
if (!supportMultiple && selection.size() > 1)
return false;
for (Iterator<?> i = selection.iterator(); i.hasNext(); ) {
Object object = i.next();
if (object instanceof ConsoleConfiguration) {
ConsoleConfiguration consoleConfiguration = (ConsoleConfiguration) object;
enabled |= updateState(consoleConfiguration);
} else {
enabled = false;
}
}
return enabled;
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class DeleteConfigurationAction method run.
public void run() {
List<?> selectedNonResources = getSelectedNonResources();
boolean ccSelected = false;
Iterator<?> iter = selectedNonResources.iterator();
while (iter.hasNext()) {
if (iter.next() instanceof ConsoleConfiguration) {
ccSelected = true;
break;
}
}
if (!ccSelected)
return;
String question = HibernateConsoleMessages.DeleteConfigurationAction_do_you_wish_del_selected_config;
String title = HibernateConsoleMessages.DeleteConfigurationAction_delete_console_config;
if (selectedNonResources.size() > 1) {
question += HibernateConsoleMessages.DeleteConfigurationAction_str_1;
title += HibernateConsoleMessages.DeleteConfigurationAction_str_2;
}
question += HibernateConsoleMessages.DeleteConfigurationAction_str_3;
if (MessageDialog.openConfirm(null, title, question)) {
iter = selectedNonResources.iterator();
while (iter.hasNext()) {
Object selElement = iter.next();
if (selElement instanceof ConsoleConfiguration) {
ConsoleConfiguration element = (ConsoleConfiguration) selElement;
KnownConfigurations.getInstance().removeConfiguration(element, false);
}
}
part.refresh();
}
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class EditConsoleConfiguration method doRun.
protected void doRun() {
if (cfg == null) {
for (Iterator<?> i = getSelectedNonResources().iterator(); i.hasNext(); ) {
try {
Object node = i.next();
if (node instanceof ConsoleConfiguration) {
final ConsoleConfiguration config = (ConsoleConfiguration) node;
edit(config);
}
} catch (Exception he) {
HibernateConsolePlugin.getDefault().showError(null, HibernateConsoleMessages.EditConsoleConfiguration_exception_while_edit_config, he);
}
}
} else {
try {
edit(cfg);
} catch (Exception he) {
HibernateConsolePlugin.getDefault().showError(null, HibernateConsoleMessages.EditConsoleConfiguration_exception_while_edit_config, he);
}
}
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class TableFilterView method toggle.
protected void toggle(boolean exclude) {
ConsoleConfiguration cc = getConsoleConfiguration();
if (cc == null)
return;
ISelection selection = viewer.getSelection();
if (!selection.isEmpty()) {
StructuredSelection ss = (StructuredSelection) selection;
Iterator<?> iterator = ss.iterator();
while (iterator.hasNext()) {
Object sel = iterator.next();
ITableFilter filter = null;
if (sel instanceof ITable) {
ITable table = (ITable) sel;
filter = revEngDef.createTableFilter(cc);
if (StringHelper.isNotEmpty(table.getName())) {
filter.setMatchName(table.getName());
}
if (StringHelper.isNotEmpty(table.getCatalog())) {
filter.setMatchCatalog(table.getCatalog());
}
if (StringHelper.isNotEmpty(table.getSchema())) {
filter.setMatchSchema(table.getSchema());
}
filter.setExclude(Boolean.valueOf(exclude));
} else if (sel instanceof TableContainer) {
// assume its a
// schema!
TableContainer tc = (TableContainer) sel;
filter = revEngDef.createTableFilter(cc);
String schema = tc.getName();
if (schema == null || "".equals(schema)) {
// $NON-NLS-1$
// $NON-NLS-1$
filter.setMatchCatalog(".*");
// $NON-NLS-1$
filter.setMatchSchema(".*");
} else {
// fake catalog handling
String catalog = StringHelper.qualifier(schema);
schema = StringHelper.unqualify(schema);
// $NON-NLS-1$ //$NON-NLS-2$
filter.setMatchCatalog("".equals(catalog) ? ".*" : catalog);
// $NON-NLS-1$ //$NON-NLS-2$
filter.setMatchSchema("".equals(schema) ? ".*" : schema);
}
// $NON-NLS-1$
filter.setMatchName(".*");
filter.setExclude(Boolean.valueOf(exclude));
} else if (sel instanceof IColumn) {
// we ignore column since at the moment we dont know which table is there.
return;
} else {
filter = revEngDef.createTableFilter(cc);
filter.setExclude(Boolean.valueOf(exclude));
}
if (filter != null)
revEngDef.addTableFilter(filter);
}
} else {
ITableFilter filter = revEngDef.createTableFilter(cc);
// $NON-NLS-1$
filter.setMatchName(".*");
filter.setExclude(Boolean.valueOf(exclude));
revEngDef.addTableFilter(filter);
}
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class TableFilterWizardPage method createControl.
public void createControl(Composite parent) {
initializeDialogUnits(parent);
final ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
Composite container = new Composite(sc, SWT.NULL);
sc.setContent(container);
// container.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_CYAN));
GridLayout layout = new GridLayout();
container.setLayout(layout);
layout.numColumns = 3;
layout.verticalSpacing = 10;
consoleConfigurationName = new ComboDialogField(SWT.READ_ONLY);
consoleConfigurationName.setLabelText(HibernateConsoleMessages.TableFilterWizardPage_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.doFillIntoGrid(container, 3);
IDialogFieldListener fieldlistener = new IDialogFieldListener() {
public void dialogFieldChanged(DialogField field) {
dialogChanged();
}
};
consoleConfigurationName.setDialogFieldListener(fieldlistener);
TreeToTableComposite tfc = createTableFilterPart(container);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.horizontalSpan = 3;
tfc.setLayoutData(gd);
sc.setMinSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT));
setControl(sc);
if (selectedConfiguratonName != null) {
consoleConfigurationName.setText(selectedConfiguratonName);
}
dialogChanged();
sc.pack();
}
Aggregations