Search in sources :

Example 1 with NamedObject

use of org.freeplane.core.resources.NamedObject in project freeplane by freeplane.

the class PriorityConditionController method getValuesForProperty.

public ComboBoxModel getValuesForProperty(final Object property, NamedObject simpleCond) {
    final Object[] items = new Object[10];
    for (int i = 1; i < 10; ++i) {
        items[i - 1] = STORE.getMindIcon("full-" + Integer.toString(i));
    }
    final ComboBoxModel box = new DefaultComboBoxModel(items);
    return box;
}
Also used : NamedObject(org.freeplane.core.resources.NamedObject) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ComboBoxModel(javax.swing.ComboBoxModel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 2 with NamedObject

use of org.freeplane.core.resources.NamedObject 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 NamedObject selectedCondition = (NamedObject) 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 : NamedObject(org.freeplane.core.resources.NamedObject) ListCellRenderer(javax.swing.ListCellRenderer) IElementaryConditionController(org.freeplane.features.filter.condition.IElementaryConditionController) FixedBasicComboBoxEditor(org.freeplane.core.ui.FixedBasicComboBoxEditor) NamedObject(org.freeplane.core.resources.NamedObject) ComboBoxEditor(javax.swing.ComboBoxEditor) FixedBasicComboBoxEditor(org.freeplane.core.ui.FixedBasicComboBoxEditor)

Example 3 with NamedObject

use of org.freeplane.core.resources.NamedObject in project freeplane by freeplane.

the class MFileManager method createDirectorySelector.

@Override
protected JComponent createDirectorySelector(final JFileChooser chooser) {
    final JComboBox box = new JComboBox();
    box.setEditable(false);
    final File dir = getLastCurrentDir() != null ? getLastCurrentDir() : chooser.getCurrentDirectory();
    final File templateDir = defaultStandardTemplateDir();
    final File userTemplateDir = defaultUserTemplateDir();
    box.addItem(new NamedObject(dir, TextUtils.getText("current_dir")));
    box.addItem(new NamedObject(templateDir, TextUtils.getText("template_dir")));
    box.addItem(new NamedObject(userTemplateDir, TextUtils.getText("user_template_dir")));
    box.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            final JComboBox box = (JComboBox) e.getSource();
            final NamedObject obj = (NamedObject) box.getSelectedItem();
            final File dir = (File) obj.getObject();
            chooser.setCurrentDirectory(dir);
        }
    });
    File selectedDir = chooser.getCurrentDirectory();
    final String selectedPath = selectedDir.getAbsolutePath();
    if (!selectedDir.equals(dir)) {
        for (int i = 0; i < box.getItemCount(); i++) {
            NamedObject item = (NamedObject) box.getItemAt(i);
            File itemDir = (File) item.getObject();
            if (itemDir.getAbsolutePath().equals(selectedPath)) {
                box.setSelectedItem(item);
                break;
            }
        }
    }
    return box;
}
Also used : JComboBox(javax.swing.JComboBox) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) NamedObject(org.freeplane.core.resources.NamedObject) File(java.io.File)

Example 4 with NamedObject

use of org.freeplane.core.resources.NamedObject in project freeplane by freeplane.

the class FrameController method getTextDateTimeEditor.

public static ComboBoxEditor getTextDateTimeEditor() {
    final ContainerComboBoxEditor editor = new ContainerComboBoxEditor();
    final NamedObject keyText = new NamedObject("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 NamedObject keyDate = new NamedObject("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 NamedObject keyDateTime = new NamedObject("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) StyleNamedObject(org.freeplane.features.styles.StyleNamedObject) NamedObject(org.freeplane.core.resources.NamedObject) FixedBasicComboBoxEditor(org.freeplane.core.ui.FixedBasicComboBoxEditor) TimeComboBoxEditor(org.freeplane.features.time.TimeComboBoxEditor) ContainerComboBoxEditor(org.freeplane.core.ui.components.ContainerComboBoxEditor) StyleNamedObject(org.freeplane.features.styles.StyleNamedObject) NamedObject(org.freeplane.core.resources.NamedObject) FormattedObject(org.freeplane.features.format.FormattedObject)

Example 5 with NamedObject

use of org.freeplane.core.resources.NamedObject in project freeplane by freeplane.

the class AutomaticLayoutController method getStyle.

private IStyle getStyle(final NodeModel node, AutomaticLayout layout) {
    if (layout == null || node.isLeaf() && !layout.equals(AutomaticLayout.ALL))
        return null;
    final int depth = node.depth();
    final MapModel map = node.getMap();
    final MapStyleModel extension = MapStyleModel.getExtension(map);
    final String name = depth == 0 ? "AutomaticLayout.level.root" : "AutomaticLayout.level," + depth;
    final NamedObject obj = NamedObject.format(name);
    final IStyle style = StyleFactory.create(obj);
    if (extension.getStyleNode(style) != null) {
        return style;
    }
    return null;
}
Also used : NamedObject(org.freeplane.core.resources.NamedObject) MapModel(org.freeplane.features.map.MapModel)

Aggregations

NamedObject (org.freeplane.core.resources.NamedObject)14 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)4 MapModel (org.freeplane.features.map.MapModel)3 StyleNamedObject (org.freeplane.features.styles.StyleNamedObject)3 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 File (java.io.File)2 ComboBoxEditor (javax.swing.ComboBoxEditor)2 JComboBox (javax.swing.JComboBox)2 FixedBasicComboBoxEditor (org.freeplane.core.ui.FixedBasicComboBoxEditor)2 ModeController (org.freeplane.features.mode.ModeController)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 NoSuchElementException (java.util.NoSuchElementException)1 ComboBoxModel (javax.swing.ComboBoxModel)1 JCheckBox (javax.swing.JCheckBox)1 JFileChooser (javax.swing.JFileChooser)1 JLabel (javax.swing.JLabel)1