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();
}
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();
}
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;
}
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"));
}
}
}
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);
}
}
}
Aggregations