Search in sources :

Example 46 with ConsoleConfiguration

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;
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration)

Example 47 with ConsoleConfiguration

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();
    }
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration)

Example 48 with ConsoleConfiguration

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);
        }
    }
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) CoreException(org.eclipse.core.runtime.CoreException)

Example 49 with ConsoleConfiguration

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);
    }
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) ITableFilter(org.hibernate.eclipse.console.model.ITableFilter) TableContainer(org.hibernate.eclipse.console.workbench.TableContainer) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ITable(org.jboss.tools.hibernate.runtime.spi.ITable)

Example 50 with ConsoleConfiguration

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();
}
Also used : IDialogFieldListener(org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GridLayout(org.eclipse.swt.layout.GridLayout) ComboDialogField(org.eclipse.jdt.internal.ui.wizards.dialogfields.ComboDialogField) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ComboDialogField(org.eclipse.jdt.internal.ui.wizards.dialogfields.ComboDialogField) DialogField(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField)

Aggregations

ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)107 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)19 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)17 CoreException (org.eclipse.core.runtime.CoreException)16 PartInitException (org.eclipse.ui.PartInitException)13 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)12 KnownConfigurations (org.hibernate.console.KnownConfigurations)11 JavaModelException (org.eclipse.jdt.core.JavaModelException)10 TreePath (org.eclipse.jface.viewers.TreePath)10 Test (org.junit.Test)10 File (java.io.File)9 ArrayList (java.util.ArrayList)9 FileNotFoundException (java.io.FileNotFoundException)8 IPath (org.eclipse.core.runtime.IPath)8 TreeSelection (org.eclipse.jface.viewers.TreeSelection)8 IService (org.jboss.tools.hibernate.runtime.spi.IService)8 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)7 IEditorPart (org.eclipse.ui.IEditorPart)7 ConsoleConfigurationPreferences (org.hibernate.console.preferences.ConsoleConfigurationPreferences)7 GridLayout (org.eclipse.swt.layout.GridLayout)6