Search in sources :

Example 1 with ASelectableCondition

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

the class SlideEditorController method updateFilter.

private void updateFilter() {
    removeFilterComponent();
    final ASelectableCondition filterCondition = slide != null ? slide.getFilterCondition() : null;
    if (filterCondition != null) {
        final JComponent component = filterCondition.createGraphicComponent();
        filterConditionComponentBox.add(component);
    } else {
        filterConditionComponentBox.add(filterNotSetLabel);
    }
    filterConditionComponentBox.revalidate();
}
Also used : JComponent(javax.swing.JComponent) ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition)

Example 2 with ASelectableCondition

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

the class SlideEditorController method updateUI.

private void updateUI() {
    if (slide == null) {
        disableUI();
        checkBoxShowOnlySelectedNodes.setSelected(false);
        tglBtnPlaceSelectedNode.setSelected(false);
        tglbtnChangeZoom.setSelected(false);
        lblZoomFactor.setText("");
        checkBoxShowOnlySelectedNodes.setSelected(false);
        checkBoxShowAncestors.setSelected(false);
        checkBoxShowDescendants.setSelected(false);
        checkBoxShowAncestors.setSelected(false);
        tglbtnSetFilter.setSelected(false);
    } else {
        for (JComponent c : allButtons) c.setEnabled(true);
        final boolean showsOnlySpecificNodes = slide.showsOnlySpecificNodes();
        checkBoxShowOnlySelectedNodes.setSelected(showsOnlySpecificNodes);
        final boolean placesSelectedNode = slide.getPlacedNodeId() != null;
        tglBtnPlaceSelectedNode.setSelected(placesSelectedNode);
        setNodePlacementControlsEnabled(placesSelectedNode, slide.getPlacedNodePosition());
        final ASelectableCondition filterCondition = slide.getFilterCondition();
        if (!presentationState.isPresentationRunning())
            for (JComponent c : filterRelatedButtons) c.setEnabled(showsOnlySpecificNodes || filterCondition != null);
        final boolean changesZoom = slide.changesZoom();
        tglbtnChangeZoom.setSelected(changesZoom);
        lblZoomFactor.setText(changesZoom ? Math.round(slide.getZoom() * 100) + "%" : "");
        checkBoxShowOnlySelectedNodes.setSelected(showsOnlySpecificNodes);
        checkBoxShowAncestors.setSelected(slide.showsAncestors());
        checkBoxShowDescendants.setSelected(slide.showsDescendants());
        checkBoxShowAncestors.setSelected(slide.showsAncestors());
        tglbtnSetFilter.setSelected(filterCondition != null);
        tglbtnSetFoldingState.setSelected(slide.foldsNodes());
    }
    updateFilter();
}
Also used : JComponent(javax.swing.JComponent) ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition)

Example 3 with ASelectableCondition

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

the class FilterController method createFilter.

private Filter createFilter(final ASelectableCondition selectedCondition) {
    final ASelectableCondition filterCondition;
    if (selectedCondition == null || selectedCondition.equals(NO_FILTERING)) {
        filterCondition = null;
    } else if (selectedCondition instanceof ConditionSnapshotFactory) {
        filterCondition = ((ConditionSnapshotFactory) selectedCondition).createSnapshotCondition();
    } else {
        filterCondition = selectedCondition;
    }
    final Filter filter = new Filter(filterCondition, showAncestors.isSelected(), showDescendants.isSelected(), applyToVisibleNodeOnly.isSelected());
    return filter;
}
Also used : ConditionSnapshotFactory(org.freeplane.features.filter.condition.ConditionSnapshotFactory) ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition)

Example 4 with ASelectableCondition

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

the class FilterController method loadConditions.

void loadConditions(final DefaultComboBoxModel filterConditionModel, final String pathToFilterFile, final boolean showPopupOnError) throws IOException {
    try {
        final IXMLParser parser = XMLLocalParserFactory.createLocalXMLParser();
        File filterFile = new File(pathToFilterFile);
        final IXMLReader reader = new StdXMLReader(new BufferedInputStream(new FileInputStream(filterFile)));
        parser.setReader(reader);
        reader.setSystemID(filterFile.toURL().toString());
        final XMLElement loader = (XMLElement) parser.parse();
        final Vector<XMLElement> conditions = loader.getChildren();
        for (int i = 0; i < conditions.size(); i++) {
            final ASelectableCondition condition = getConditionFactory().loadCondition(conditions.get(i));
            if (condition != null) {
                filterConditionModel.addElement(condition);
            }
        }
    } catch (final FileNotFoundException e) {
    } catch (final AccessControlException e) {
    } catch (final Exception e) {
        LogUtils.warn(e);
        if (showPopupOnError) {
            UITools.errorMessage(TextUtils.getText("filters_not_loaded"));
        }
    }
}
Also used : IXMLReader(org.freeplane.n3.nanoxml.IXMLReader) FileNotFoundException(java.io.FileNotFoundException) AccessControlException(java.security.AccessControlException) XMLElement(org.freeplane.n3.nanoxml.XMLElement) FileInputStream(java.io.FileInputStream) ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition) FileNotFoundException(java.io.FileNotFoundException) AccessControlException(java.security.AccessControlException) IOException(java.io.IOException) BufferedInputStream(java.io.BufferedInputStream) IXMLParser(org.freeplane.n3.nanoxml.IXMLParser) StdXMLReader(org.freeplane.n3.nanoxml.StdXMLReader) File(java.io.File)

Example 5 with ASelectableCondition

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

the class FilterMenuBuilder method visit.

@Override
public void visit(Entry target) {
    final DefaultComboBoxModel filterConditions = filterController.getFilterConditions();
    final HashSet<String> usedNames = new HashSet<String>();
    for (int i = 0; i < filterConditions.getSize(); i++) {
        final ASelectableCondition condition = (ASelectableCondition) filterConditions.getElementAt(i);
        final String conditionName = condition.getUserName();
        if (conditionName != null && usedNames.add(conditionName)) {
            final ApplyNamedFilterAction action = new ApplyNamedFilterAction(filterController, condition);
            controller.addActionIfNotAlreadySet(action);
            new EntryAccessor().addChildAction(target, action);
        }
    }
}
Also used : EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition) HashSet(java.util.HashSet)

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