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