Search in sources :

Example 1 with IElementaryConditionController

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

the class FilterConditionEditor method setValuesEditor.

private void setValuesEditor() {
    final Object selectedProperty = filteredPropertiesComponent.getSelectedItem();
    final IElementaryConditionController conditionController = filterController.getConditionFactory().getConditionController(selectedProperty);
    final TranslatedObject selectedCondition = (TranslatedObject) elementaryConditions.getSelectedItem();
    final boolean canSelectValues = conditionController.canSelectValues(selectedProperty, selectedCondition);
    values.setEnabled(canSelectValues);
    values.setEditable(false);
    values.setModel(conditionController.getValuesForProperty(selectedProperty, selectedCondition));
    final ComboBoxEditor valueEditor = conditionController.getValueEditor(selectedProperty, selectedCondition);
    values.setEditor(valueEditor != null ? valueEditor : new FixedBasicComboBoxEditor());
    setValuesEnterKeyListener();
    final ListCellRenderer valueRenderer = conditionController.getValueRenderer(selectedProperty, selectedCondition);
    values.setRenderer(valueRenderer != null ? valueRenderer : filterController.getConditionRenderer());
    values.setEditable(conditionController.canEditValues(selectedProperty, selectedCondition));
    if (values.getModel().getSize() > 0) {
        values.setSelectedIndex(0);
    }
    caseSensitive.setEnabled(canSelectValues && conditionController.isCaseDependent(selectedProperty, selectedCondition));
    approximateMatching.setEnabled(canSelectValues && conditionController.supportsApproximateMatching(selectedProperty, selectedCondition));
}
Also used : TranslatedObject(org.freeplane.core.resources.TranslatedObject) ListCellRenderer(javax.swing.ListCellRenderer) IElementaryConditionController(org.freeplane.features.filter.condition.IElementaryConditionController) FixedBasicComboBoxEditor(org.freeplane.core.ui.FixedBasicComboBoxEditor) TranslatedObject(org.freeplane.core.resources.TranslatedObject) ComboBoxEditor(javax.swing.ComboBoxEditor) FixedBasicComboBoxEditor(org.freeplane.core.ui.FixedBasicComboBoxEditor)

Example 2 with IElementaryConditionController

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

the class FilterConditionEditor method mapChanged.

/**
 */
public void mapChanged(final MapModel newMap) {
    if (newMap != null) {
        if (lastMap != null && lastMap.get() == newMap) {
            return;
        }
        filteredPropertiesModel.removeAllElements();
        final Iterator<IElementaryConditionController> conditionIterator = filterController.getConditionFactory().conditionIterator();
        while (conditionIterator.hasNext()) {
            final IElementaryConditionController next = conditionIterator.next();
            filteredPropertiesModel.addExtensionList(next.getFilteredProperties());
            filteredPropertiesModel.setSelectedItem(filteredPropertiesModel.getElementAt(0));
        }
    } else {
        filteredPropertiesComponent.setSelectedIndex(-1);
        filteredPropertiesModel.setExtensionList(null);
    }
    lastMap = new WeakReference<MapModel>(newMap);
}
Also used : IElementaryConditionController(org.freeplane.features.filter.condition.IElementaryConditionController) MapModel(org.freeplane.features.map.MapModel)

Aggregations

IElementaryConditionController (org.freeplane.features.filter.condition.IElementaryConditionController)2 ComboBoxEditor (javax.swing.ComboBoxEditor)1 ListCellRenderer (javax.swing.ListCellRenderer)1 TranslatedObject (org.freeplane.core.resources.TranslatedObject)1 FixedBasicComboBoxEditor (org.freeplane.core.ui.FixedBasicComboBoxEditor)1 MapModel (org.freeplane.features.map.MapModel)1