Search in sources :

Example 1 with FilterController

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

the class FiltersPanel method stateChanged.

@Override
public void stateChanged(ChangeEvent e) {
    if (e.getSource() instanceof FilterUIModel) {
        if (uiModel.getSelectedQuery() != null && stopButton.isVisible()) {
            FilterController controller = Lookup.getDefault().lookup(FilterController.class);
            controller.filterVisible(uiModel.getSelectedRoot());
        } else if (uiModel.getSelectedQuery() != null && selectButton.isSelected()) {
            FilterController controller = Lookup.getDefault().lookup(FilterController.class);
            controller.selectVisible(uiModel.getSelectedRoot());
        }
    } else if (e.getSource() instanceof FilterModel) {
        if (uiModel.getSelectedQuery() != null && filterModel.getCurrentQuery() == null) {
            //Remove case
            if (!Arrays.asList(filterModel.getQueries()).contains(uiModel.getSelectedRoot())) {
                uiModel.setSelectedQuery(null);
            }
        } else if (filterModel.getCurrentQuery() != null && filterModel.getCurrentQuery() != uiModel.getSelectedQuery() && filterModel.getCurrentQuery() != uiModel.getSelectedRoot()) {
            uiModel.setSelectedQuery(filterModel.getCurrentQuery());
        }
    }
    updateControls();
    updateEnabled(true);
}
Also used : FilterController(org.gephi.filters.api.FilterController) FilterModel(org.gephi.filters.api.FilterModel)

Example 2 with FilterController

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

the class SavedQueryNodeDefaultAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent ev) {
    SavedQueryNode node = (SavedQueryNode) ev.getSource();
    FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
    filterController.add(node.getQuery());
}
Also used : FilterController(org.gephi.filters.api.FilterController)

Example 3 with FilterController

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

the class FiltersPanel method initEvents.

private void initEvents() {
    resetButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            FilterController controller = Lookup.getDefault().lookup(FilterController.class);
            for (Query query : filterModel.getQueries()) {
                controller.remove(query);
            }
            //                uiModel.setSelectedQuery(null);
            controller.selectVisible(null);
            controller.filterVisible(null);
            ((FiltersExplorer) libraryTree).setup(manager, filterModel, uiModel);
            stopButton.setVisible(false);
            filterButton.setVisible(true);
        }
    });
    filterButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //selectButton.setSelected(false);
            if (uiModel.getSelectedQuery() != null) {
                FilterController controller = Lookup.getDefault().lookup(FilterController.class);
                controller.filterVisible(uiModel.getSelectedRoot());
                stopButton.setSelected(false);
                stopButton.setVisible(true);
                filterButton.setVisible(false);
            }
        }
    });
    stopButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            FilterController controller = Lookup.getDefault().lookup(FilterController.class);
            controller.filterVisible(null);
            controller.selectVisible(null);
            stopButton.setVisible(false);
            filterButton.setSelected(true);
            filterButton.setVisible(true);
        }
    });
    selectButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //filterButton.setSelected(false);
            if (uiModel.getSelectedQuery() != null) {
                FilterController controller = Lookup.getDefault().lookup(FilterController.class);
                controller.selectVisible(uiModel.getSelectedRoot());
            }
        }
    });
    exportColumnButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (uiModel.getSelectedQuery() != null) {
                FilterController controller = Lookup.getDefault().lookup(FilterController.class);
                NotifyDescriptor.InputLine question = new NotifyDescriptor.InputLine(NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.exportColumn.input"), NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.exportColumn.input.title"));
                if (DialogDisplayer.getDefault().notify(question) == NotifyDescriptor.OK_OPTION) {
                    String input = question.getInputText();
                    if (input != null && !input.isEmpty()) {
                        controller.exportToColumn(input, uiModel.getSelectedRoot());
                    }
                }
            }
        }
    });
    exportWorkspaceButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (uiModel.getSelectedQuery() != null) {
                FilterController controller = Lookup.getDefault().lookup(FilterController.class);
                controller.exportToNewWorkspace(uiModel.getSelectedRoot());
            }
        }
    });
    exportLabelVisible.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (uiModel.getSelectedQuery() != null) {
                FilterController controller = Lookup.getDefault().lookup(FilterController.class);
                controller.exportToLabelVisible(uiModel.getSelectedRoot());
            }
        }
    });
    /*autoRefreshButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
        if (filterModel.isAutoRefresh() != autoRefreshButton.isSelected()) {
        FilterController controller = Lookup.getDefault().lookup(FilterController.class);
        controller.setAutoRefresh(autoRefreshButton.isSelected());
        }
        }
        });*/
    updateEnabled(false);
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) ActionListener(java.awt.event.ActionListener) Query(org.gephi.filters.api.Query) ActionEvent(java.awt.event.ActionEvent) FilterController(org.gephi.filters.api.FilterController)

Example 4 with FilterController

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

the class CategoryNode method getDropType.

@Override
public PasteType getDropType(final Transferable t, int action, int index) {
    if (category == null || !category.equals(FiltersExplorer.QUERIES)) {
        return null;
    }
    final Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE);
    if (dropNode != null && dropNode instanceof QueryNode) {
        return new PasteType() {

            @Override
            public Transferable paste() throws IOException {
                QueryNode queryNode = (QueryNode) dropNode;
                FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
                FilterLibrary library = filterController.getModel().getLibrary();
                library.saveQuery(queryNode.getQuery());
                return null;
            }
        };
    }
    return null;
}
Also used : QueryNode(org.gephi.desktop.filters.query.QueryNode) Node(org.openide.nodes.Node) QueryNode(org.gephi.desktop.filters.query.QueryNode) AbstractNode(org.openide.nodes.AbstractNode) PasteType(org.openide.util.datatransfer.PasteType) FilterLibrary(org.gephi.filters.api.FilterLibrary) FilterController(org.gephi.filters.api.FilterController)

Example 5 with FilterController

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

the class FilterBuilderNodeDefaultAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent ev) {
    FilterBuilderNode node = (FilterBuilderNode) ev.getSource();
    FilterBuilder builder = node.getBuilder();
    FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
    Query function = filterController.createQuery(builder);
    filterController.add(function);
}
Also used : Query(org.gephi.filters.api.Query) FilterBuilder(org.gephi.filters.spi.FilterBuilder) FilterController(org.gephi.filters.api.FilterController)

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