Search in sources :

Example 1 with FixedBasicComboBoxEditor

use of org.freeplane.core.ui.FixedBasicComboBoxEditor in project freeplane by freeplane.

the class FrameController method getTextDateTimeEditor.

public static ComboBoxEditor getTextDateTimeEditor() {
    final ContainerComboBoxEditor editor = new ContainerComboBoxEditor();
    final TranslatedObject keyText = new TranslatedObject("text", "1Ab");
    final BasicComboBoxEditor textEditor = new FixedBasicComboBoxEditor() {

        private Object oldItem;

        @Override
        public void setItem(Object object) {
            oldItem = object;
            if (object instanceof FormattedDate)
                super.setItem("");
            else
                super.setItem(object);
        }

        @Override
        public Object getItem() {
            final Object item = super.getItem();
            final Object oldItem = this.oldItem;
            this.oldItem = null;
            if (item != null && oldItem != null && item.toString().equals(oldItem.toString()))
                return oldItem;
            if (ResourceController.getResourceController().getBooleanProperty("parse_data") && item instanceof String) {
                final Object scannedObject = ScannerController.getController().parse((String) item);
                return scannedObject;
            }
            return item;
        }
    };
    editor.put(keyText, textEditor);
    final TranslatedObject keyDate = new TranslatedObject("date", "");
    keyDate.setIcon(dateIcon);
    final TimeComboBoxEditor dateComboBoxEditor = new TimeComboBoxEditor(false) {

        @Override
        public void setItem(Object object) {
            if (object instanceof FormattedDate && !((FormattedDate) object).containsTime())
                super.setItem(object);
            else
                super.setItem(null);
        }
    };
    dateComboBoxEditor.setItem();
    editor.put(keyDate, dateComboBoxEditor);
    final TranslatedObject keyDateTime = new TranslatedObject("date_time", "");
    keyDateTime.setIcon(dateTimeIcon);
    final TimeComboBoxEditor dateTimeComboBoxEditor = new TimeComboBoxEditor(true) {

        @Override
        public void setItem(Object object) {
            if (object instanceof FormattedDate && ((FormattedDate) object).containsTime())
                super.setItem(object);
            else
                super.setItem(null);
        }
    };
    dateTimeComboBoxEditor.setItem();
    editor.put(keyDateTime, dateTimeComboBoxEditor);
    return editor;
}
Also used : BasicComboBoxEditor(javax.swing.plaf.basic.BasicComboBoxEditor) FixedBasicComboBoxEditor(org.freeplane.core.ui.FixedBasicComboBoxEditor) FormattedDate(org.freeplane.features.format.FormattedDate) StyleTranslatedObject(org.freeplane.features.styles.StyleTranslatedObject) TranslatedObject(org.freeplane.core.resources.TranslatedObject) FixedBasicComboBoxEditor(org.freeplane.core.ui.FixedBasicComboBoxEditor) TimeComboBoxEditor(org.freeplane.features.time.TimeComboBoxEditor) ContainerComboBoxEditor(org.freeplane.core.ui.components.ContainerComboBoxEditor) StyleTranslatedObject(org.freeplane.features.styles.StyleTranslatedObject) TranslatedObject(org.freeplane.core.resources.TranslatedObject) FormattedObject(org.freeplane.features.format.FormattedObject)

Example 2 with FixedBasicComboBoxEditor

use of org.freeplane.core.ui.FixedBasicComboBoxEditor 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 3 with FixedBasicComboBoxEditor

use of org.freeplane.core.ui.FixedBasicComboBoxEditor in project freeplane by freeplane.

the class MUIFactory method createSizeBox.

public Container createSizeBox() {
    final JComboBox sizeBox = new JComboBoxWithBorder(size);
    sizeBox.setPrototypeDisplayValue("88888");
    sizeBox.setPreferredSize(sizeBox.getPreferredSize());
    sizeBox.setEditor(new FixedBasicComboBoxEditor());
    sizeBox.setEditable(true);
    return sizeBox;
}
Also used : JComboBox(javax.swing.JComboBox) FixedBasicComboBoxEditor(org.freeplane.core.ui.FixedBasicComboBoxEditor) JComboBoxWithBorder(org.freeplane.core.ui.components.JComboBoxWithBorder)

Aggregations

FixedBasicComboBoxEditor (org.freeplane.core.ui.FixedBasicComboBoxEditor)3 TranslatedObject (org.freeplane.core.resources.TranslatedObject)2 ComboBoxEditor (javax.swing.ComboBoxEditor)1 JComboBox (javax.swing.JComboBox)1 ListCellRenderer (javax.swing.ListCellRenderer)1 BasicComboBoxEditor (javax.swing.plaf.basic.BasicComboBoxEditor)1 ContainerComboBoxEditor (org.freeplane.core.ui.components.ContainerComboBoxEditor)1 JComboBoxWithBorder (org.freeplane.core.ui.components.JComboBoxWithBorder)1 IElementaryConditionController (org.freeplane.features.filter.condition.IElementaryConditionController)1 FormattedDate (org.freeplane.features.format.FormattedDate)1 FormattedObject (org.freeplane.features.format.FormattedObject)1 StyleTranslatedObject (org.freeplane.features.styles.StyleTranslatedObject)1 TimeComboBoxEditor (org.freeplane.features.time.TimeComboBoxEditor)1