Search in sources :

Example 1 with ITableFilter

use of org.hibernate.eclipse.console.model.ITableFilter in project jbosstools-hibernate by jbosstools.

the class TableFilterCellModifier method modify.

public void modify(Object element, String property, Object value) {
    ITableFilter tf = (ITableFilter) ((TableItem) element).getData();
    if ("inclusion".equals(property)) {
        // $NON-NLS-1$
        if (!value.equals(tf.getExclude())) {
            tf.setExclude((Boolean) value);
        }
    }
    if ("catalog".equals(property)) {
        // $NON-NLS-1$
        if (!value.equals(tf.getMatchCatalog())) {
            tf.setMatchCatalog((String) value);
        }
    }
    if ("schema".equals(property)) {
        // $NON-NLS-1$
        if (!value.equals(tf.getMatchSchema())) {
            tf.setMatchSchema((String) value);
        }
    }
    if ("name".equals(property)) {
        // $NON-NLS-1$
        if (!value.equals(tf.getMatchName())) {
            tf.setMatchName((String) value);
        }
    }
    tv.update(new Object[] { tf }, new String[] { property });
}
Also used : ITableFilter(org.hibernate.eclipse.console.model.ITableFilter)

Example 2 with ITableFilter

use of org.hibernate.eclipse.console.model.ITableFilter in project jbosstools-hibernate by jbosstools.

the class TableFilterView method doRemove.

protected void doRemove() {
    int sel = rightTable.getSelectionIndex();
    TableItem[] selection = rightTable.getSelection();
    for (int i = 0; i < selection.length; i++) {
        ITableFilter item = (ITableFilter) selection[i].getData();
        revEngDef.removeTableFilter(item);
    }
    rightTable.setSelection(Math.min(sel, rightTable.getItemCount() - 1));
}
Also used : ITableFilter(org.hibernate.eclipse.console.model.ITableFilter) TableItem(org.eclipse.swt.widgets.TableItem)

Example 3 with ITableFilter

use of org.hibernate.eclipse.console.model.ITableFilter 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 4 with ITableFilter

use of org.hibernate.eclipse.console.model.ITableFilter in project jbosstools-hibernate by jbosstools.

the class TableFilterView method doMoveDown.

protected void doMoveDown() {
    TableItem[] selection = rightTable.getSelection();
    for (int i = 0; i < selection.length; i++) {
        ITableFilter item = (ITableFilter) selection[i].getData();
        revEngDef.moveTableFilterDown(item);
    }
}
Also used : ITableFilter(org.hibernate.eclipse.console.model.ITableFilter) TableItem(org.eclipse.swt.widgets.TableItem)

Example 5 with ITableFilter

use of org.hibernate.eclipse.console.model.ITableFilter in project jbosstools-hibernate by jbosstools.

the class TableFilterView method doMoveUp.

protected void doMoveUp() {
    TableItem[] selection = rightTable.getSelection();
    for (int i = 0; i < selection.length; i++) {
        ITableFilter item = (ITableFilter) selection[i].getData();
        revEngDef.moveTableFilterUp(item);
    }
}
Also used : ITableFilter(org.hibernate.eclipse.console.model.ITableFilter) TableItem(org.eclipse.swt.widgets.TableItem)

Aggregations

ITableFilter (org.hibernate.eclipse.console.model.ITableFilter)8 TableItem (org.eclipse.swt.widgets.TableItem)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 StringWriter (java.io.StringWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ISelection (org.eclipse.jface.viewers.ISelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)1 TableContainer (org.hibernate.eclipse.console.workbench.TableContainer)1 IColumn (org.jboss.tools.hibernate.runtime.spi.IColumn)1 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)1