Search in sources :

Example 6 with FilterController

use of org.gephi.filters.api.FilterController in project gephi by gephi.

the class QueryNode method isSelected.

private boolean isSelected() {
    FilterController fc = Lookup.getDefault().lookup(FilterController.class);
    FilterModel fm = fc.getModel();
    return (fm.isFiltering() || fm.isSelecting()) && fc.getModel().getCurrentQuery() == query;
//return FiltersTopComponent.findInstance().getUiModel().getSelectedRoot() == query;
}
Also used : FilterController(org.gephi.filters.api.FilterController) FilterModel(org.gephi.filters.api.FilterModel)

Example 7 with FilterController

use of org.gephi.filters.api.FilterController in project gephi by gephi.

the class RootNode method getDropType.

@Override
public PasteType getDropType(Transferable t, int action, int index) {
    final Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE);
    if (t.isDataFlavorSupported(FilterBuilderNode.DATA_FLAVOR)) {
        try {
            final FilterBuilder fb = (FilterBuilder) t.getTransferData(FilterBuilderNode.DATA_FLAVOR);
            return new PasteType() {

                @Override
                public Transferable paste() throws IOException {
                    FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
                    Query f = filterController.createQuery(fb);
                    filterController.add(f);
                    return null;
                }
            };
        } catch (UnsupportedFlavorException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    } else if (dropNode != null && dropNode instanceof SavedQueryNode) {
        return new PasteType() {

            @Override
            public Transferable paste() throws IOException {
                SavedQueryNode node = (SavedQueryNode) dropNode;
                FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
                filterController.add(node.getQuery());
                return null;
            }
        };
    } else if (dropNode != null && dropNode instanceof QueryNode && ((QueryNode) dropNode).getQuery().getParent() != null) {
        return new PasteType() {

            @Override
            public Transferable paste() throws IOException {
                QueryNode queryNode = (QueryNode) dropNode;
                FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
                filterController.removeSubQuery(queryNode.getQuery(), queryNode.getQuery().getParent());
                filterController.add(queryNode.getQuery());
                return null;
            }
        };
    }
    return null;
}
Also used : Query(org.gephi.filters.api.Query) SavedQueryNode(org.gephi.desktop.filters.library.SavedQueryNode) FilterBuilder(org.gephi.filters.spi.FilterBuilder) SavedQueryNode(org.gephi.desktop.filters.library.SavedQueryNode) Node(org.openide.nodes.Node) SavedQueryNode(org.gephi.desktop.filters.library.SavedQueryNode) FilterBuilderNode(org.gephi.desktop.filters.library.FilterBuilderNode) AbstractNode(org.openide.nodes.AbstractNode) PasteType(org.openide.util.datatransfer.PasteType) Transferable(java.awt.datatransfer.Transferable) FilterController(org.gephi.filters.api.FilterController) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException)

Example 8 with FilterController

use of org.gephi.filters.api.FilterController in project gephi by gephi.

the class SlotNode method getDropType.

@Override
public PasteType getDropType(final Transferable t, int action, int index) {
    final Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE);
    if (dropNode != null && dropNode instanceof QueryNode) {
        Query q = ((QueryNode) dropNode).getQuery();
        if (!Arrays.asList(q.getDescendantsAndSelf()).contains(parent)) {
            //Check if not parent
            return new PasteType() {

                @Override
                public Transferable paste() throws IOException {
                    QueryNode queryNode = (QueryNode) dropNode;
                    FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
                    filterController.setSubQuery(parent, queryNode.getQuery());
                    return null;
                }
            };
        }
    } else if (t.isDataFlavorSupported(FilterBuilderNode.DATA_FLAVOR)) {
        return new PasteType() {

            @Override
            public Transferable paste() throws IOException {
                try {
                    FilterBuilder builder = (FilterBuilder) t.getTransferData(FilterBuilderNode.DATA_FLAVOR);
                    FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
                    Query query = filterController.createQuery(builder);
                    filterController.setSubQuery(parent, query);
                } catch (UnsupportedFlavorException ex) {
                    Exceptions.printStackTrace(ex);
                }
                return null;
            }
        };
    }
    return null;
}
Also used : Query(org.gephi.filters.api.Query) FilterBuilder(org.gephi.filters.spi.FilterBuilder) Node(org.openide.nodes.Node) FilterBuilderNode(org.gephi.desktop.filters.library.FilterBuilderNode) AbstractNode(org.openide.nodes.AbstractNode) PasteType(org.openide.util.datatransfer.PasteType) Transferable(java.awt.datatransfer.Transferable) FilterController(org.gephi.filters.api.FilterController) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException)

Aggregations

FilterController (org.gephi.filters.api.FilterController)8 Query (org.gephi.filters.api.Query)4 FilterBuilder (org.gephi.filters.spi.FilterBuilder)3 AbstractNode (org.openide.nodes.AbstractNode)3 Node (org.openide.nodes.Node)3 PasteType (org.openide.util.datatransfer.PasteType)3 Transferable (java.awt.datatransfer.Transferable)2 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)2 IOException (java.io.IOException)2 FilterBuilderNode (org.gephi.desktop.filters.library.FilterBuilderNode)2 FilterModel (org.gephi.filters.api.FilterModel)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 SavedQueryNode (org.gephi.desktop.filters.library.SavedQueryNode)1 QueryNode (org.gephi.desktop.filters.query.QueryNode)1 FilterLibrary (org.gephi.filters.api.FilterLibrary)1 NotifyDescriptor (org.openide.NotifyDescriptor)1