Search in sources :

Example 16 with ASelectableCondition

use of org.freeplane.features.filter.condition.ASelectableCondition in project freeplane by freeplane.

the class FilterController method applyFilter.

void applyFilter(final boolean force) {
    quickFilterAction.setSelected(isFilterActive());
    final ASelectableCondition selectedCondition = getSelectedCondition();
    final Filter filter = createFilter(selectedCondition);
    final ICondition condition = condition(filter);
    if (condition != selectedCondition && condition instanceof ASelectableCondition)
        getFilterConditions().setSelectedItem(condition);
    else
        applyFilter(filter, Controller.getCurrentController().getMap(), force);
}
Also used : ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition) ICondition(org.freeplane.features.filter.condition.ICondition)

Example 17 with ASelectableCondition

use of org.freeplane.features.filter.condition.ASelectableCondition in project freeplane by freeplane.

the class FilterController method addStandardConditions.

private void addStandardConditions() {
    final ASelectableCondition noFiltering = NO_FILTERING;
    filterConditions.insertElementAt(noFiltering, 0);
    if (selectedViewCondition == null) {
        selectedViewCondition = SelectedViewCondition.CreateCondition();
    }
    filterConditions.insertElementAt(selectedViewCondition, 1);
    if (filterConditions.getSelectedItem() == null) {
        filterConditions.setSelectedItem(noFiltering);
    }
    if (cloneOfSelectedViewCondition == null)
        cloneOfSelectedViewCondition = CloneOfSelectedViewCondition.CreateCondition();
    filterConditions.insertElementAt(cloneOfSelectedViewCondition, 2);
}
Also used : ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition)

Example 18 with ASelectableCondition

use of org.freeplane.features.filter.condition.ASelectableCondition in project freeplane by freeplane.

the class FindAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    if (selection == null) {
        return;
    }
    final NodeModel start = selection.getSelected();
    if (editor == null) {
        editor = new FilterConditionEditor(FilterController.getCurrentFilterController());
        editor.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(), BorderFactory.createEmptyBorder(5, 0, 5, 0)));
    } else {
        editor.mapChanged(start.getMap());
    }
    editor.addAncestorListener(new AncestorListener() {

        public void ancestorAdded(final AncestorEvent event) {
            final Component component = event.getComponent();
            final Window windowAncestor = SwingUtilities.getWindowAncestor(component);
            if (windowAncestor.isFocused())
                editor.focusInputField(true);
            else {
                windowAncestor.addWindowFocusListener(new WindowFocusListener() {

                    public void windowLostFocus(WindowEvent e) {
                    }

                    public void windowGainedFocus(WindowEvent e) {
                        windowAncestor.removeWindowFocusListener(this);
                        editor.focusInputField(true);
                    }
                });
                windowAncestor.toFront();
            }
            editor.removeAncestorListener(this);
        }

        public void ancestorMoved(final AncestorEvent event) {
        }

        public void ancestorRemoved(final AncestorEvent event) {
        }
    });
    final int run = UITools.showConfirmDialog(start, editor, TextUtils.getText("FindAction.text"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    final Container parent = editor.getParent();
    if (parent != null) {
        parent.remove(editor);
    }
    if (run != JOptionPane.OK_OPTION) {
        return;
    }
    final ASelectableCondition condition = editor.getCondition();
    findFirst(condition);
}
Also used : Window(java.awt.Window) NodeModel(org.freeplane.features.map.NodeModel) Container(java.awt.Container) IMapSelection(org.freeplane.features.map.IMapSelection) WindowEvent(java.awt.event.WindowEvent) AncestorListener(javax.swing.event.AncestorListener) Component(java.awt.Component) AncestorEvent(javax.swing.event.AncestorEvent) WindowFocusListener(java.awt.event.WindowFocusListener) ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition)

Example 19 with ASelectableCondition

use of org.freeplane.features.filter.condition.ASelectableCondition in project freeplane by freeplane.

the class QuickFilterAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final ASelectableCondition condition = filterEditor.getCondition();
    if (condition == null) {
        return;
    }
    if (condition.equals(filterController.getSelectedCondition()))
        filterController.applyNoFiltering();
    else {
        setSelected(false);
        filterController.apply(condition);
    }
}
Also used : ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition)

Example 20 with ASelectableCondition

use of org.freeplane.features.filter.condition.ASelectableCondition in project freeplane by freeplane.

the class QuickFindAction method executeAction.

public void executeAction(final boolean reFocusSearchInputField) {
    final ASelectableCondition condition = filterEditor.getCondition();
    if (condition == null) {
        return;
    }
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    if (selection == null) {
        return;
    }
    final NodeModel selected = selection.getSelected();
    final NodeModel next;
    try {
        filterEditor.setSearchingBusyCursor();
        next = filterController.findNext(selected, null, direction, condition);
    } finally {
        filterEditor.setSearchingDefaultCursor();
    }
    if (next != null) {
        FoundNodes.get(next.getMap()).displayFoundNode(next);
        if (reFocusSearchInputField) {
            // this is called by Enter key listener in FilterConditionEditor
            // => we want to re-focus the search term input field so that one can hit enter
            // again to find the next search result!
            filterEditor.focusInputField(false);
        }
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition)

Aggregations

ASelectableCondition (org.freeplane.features.filter.condition.ASelectableCondition)21 XMLElement (org.freeplane.n3.nanoxml.XMLElement)5 NodeModel (org.freeplane.features.map.NodeModel)4 IOException (java.io.IOException)3 IMapSelection (org.freeplane.features.map.IMapSelection)3 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 LinkedHashSet (java.util.LinkedHashSet)2 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2 JComponent (javax.swing.JComponent)2 FilterComposerDialog (org.freeplane.features.filter.FilterComposerDialog)2 ConditionFactory (org.freeplane.features.filter.condition.ConditionFactory)2 BorderLayout (java.awt.BorderLayout)1 Component (java.awt.Component)1 Container (java.awt.Container)1 Dimension (java.awt.Dimension)1 Window (java.awt.Window)1 WindowEvent (java.awt.event.WindowEvent)1 WindowFocusListener (java.awt.event.WindowFocusListener)1 BufferedInputStream (java.io.BufferedInputStream)1