Search in sources :

Example 1 with TranslatedObject

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

the class AttributeConditionController method getValuesForProperty.

public ComboBoxModel getValuesForProperty(final Object selectedItem, TranslatedObject simpleCond) {
    final MapModel map = Controller.getCurrentController().getMap();
    final AttributeRegistry registry = AttributeRegistry.getRegistry(map);
    try {
        final AttributeRegistryElement element = registry.getElement(selectedItem.toString());
        final SortedComboBoxModel list = element.getValues();
        SortedComboBoxModel linkedList = new SortedComboBoxModel();
        for (int i = 0; i < list.getSize(); i++) {
            final Object value = list.getElementAt(i);
            final TextController textController = TextController.getController();
            if (!textController.isFormula(value, null, null)) {
                try {
                    final Object transformedValue = textController.getTransformedObject(value, map.getRootNode(), null);
                    linkedList.add(transformedValue);
                } catch (TransformationException e) {
                    LogUtils.severe(e);
                }
            }
        }
        values.setExtensionList(linkedList);
    } catch (NoSuchElementException e) {
        values.setExtensionList(null);
    }
    return values;
}
Also used : TransformationException(org.freeplane.features.text.TransformationException) TextController(org.freeplane.features.text.TextController) TranslatedObject(org.freeplane.core.resources.TranslatedObject) MapModel(org.freeplane.features.map.MapModel) SortedComboBoxModel(org.freeplane.core.util.collection.SortedComboBoxModel) NoSuchElementException(java.util.NoSuchElementException)

Example 2 with TranslatedObject

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

the class MFileManager method createDirectorySelector.

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

        @Override
        public void actionPerformed(ActionEvent e) {
            final JComboBox box = (JComboBox) e.getSource();
            final TranslatedObject obj = (TranslatedObject) 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++) {
            TranslatedObject item = (TranslatedObject) 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) TranslatedObject(org.freeplane.core.resources.TranslatedObject) JComboBoxWithBorder(org.freeplane.core.ui.components.JComboBoxWithBorder) File(java.io.File)

Example 3 with TranslatedObject

use of org.freeplane.core.resources.TranslatedObject 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 4 with TranslatedObject

use of org.freeplane.core.resources.TranslatedObject 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 5 with TranslatedObject

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

the class StyleControlGroup method addStyleControls.

private void addStyleControls(final DefaultFormBuilder formBuilder) {
    TranslatedObject[] automaticLayoutTypes = TranslatedObject.fromEnum(AutomaticLayout.class);
    mAutomaticLayoutComboBox = new JComboBoxWithBorder(automaticLayoutTypes);
    DefaultComboBoxModel automaticLayoutComboBoxModel = (DefaultComboBoxModel) mAutomaticLayoutComboBox.getModel();
    automaticLayoutComboBoxModel.addElement(AUTOMATIC_LAYOUT_DISABLED);
    automaticLayoutComboBoxModel.setSelectedItem(AUTOMATIC_LAYOUT_DISABLED);
    mAutomaticLayoutComboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (internalChange)
                return;
            final ModeController modeController = Controller.getCurrentModeController();
            AutomaticLayoutController al = modeController.getExtension(AutomaticLayoutController.class);
            TranslatedObject selectedItem = (TranslatedObject) mAutomaticLayoutComboBox.getSelectedItem();
            al.undoableDeactivateHook(Controller.getCurrentController().getMap().getRootNode());
            if (!selectedItem.equals(AUTOMATIC_LAYOUT_DISABLED)) {
                al.undoableActivateHook(Controller.getCurrentController().getMap().getRootNode(), (AutomaticLayout) selectedItem.getObject());
            }
        }
    });
    appendLabeledComponent(formBuilder, "AutomaticLayoutAction.text", mAutomaticLayoutComboBox);
}
Also used : AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) AutomaticLayout(org.freeplane.features.styles.AutomaticLayout) TranslatedObject(org.freeplane.core.resources.TranslatedObject) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ModeController(org.freeplane.features.mode.ModeController) JComboBoxWithBorder(org.freeplane.core.ui.components.JComboBoxWithBorder)

Aggregations

TranslatedObject (org.freeplane.core.resources.TranslatedObject)15 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)5 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 JComboBoxWithBorder (org.freeplane.core.ui.components.JComboBoxWithBorder)3 MapModel (org.freeplane.features.map.MapModel)3 ModeController (org.freeplane.features.mode.ModeController)3 StyleTranslatedObject (org.freeplane.features.styles.StyleTranslatedObject)3 File (java.io.File)2 ComboBoxEditor (javax.swing.ComboBoxEditor)2 FixedBasicComboBoxEditor (org.freeplane.core.ui.FixedBasicComboBoxEditor)2 NodeModel (org.freeplane.features.map.NodeModel)2 TextController (org.freeplane.features.text.TextController)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 AccessController (java.security.AccessController)1 NoSuchElementException (java.util.NoSuchElementException)1 ComboBoxModel (javax.swing.ComboBoxModel)1