Package org.freeplane.features.format

Examples of org.freeplane.features.format.PatternFormat


    @Override
    public PatternFormat toValueObject(Object value) {
        if (value instanceof PatternFormat)
            return (PatternFormat) value;
        final PatternFormat patternFormat = PatternFormat.guessPatternFormat(value.toString());
        return (patternFormat == null) ? defaultPattern : patternFormat;
    }
View Full Code Here


        final PatternFormat patternFormat = PatternFormat.guessPatternFormat(value.toString());
        return (patternFormat == null) ? defaultPattern : patternFormat;
    }

    public String getSelectedPattern() {
        final PatternFormat selected = getSelected();
        return selected == null ? null : selected.getPattern();
    }
View Full Code Here

      testOnePattern(pattern);
    }
  }

  private void testOnePattern(String pattern) {
    final PatternFormat formatter = PatternFormat.guessPatternFormat(pattern);
    assertNotNull("could not create a formatter for pattern " + pattern, formatter);
    if (formatter.acceptsDate())
      System.err.println(pattern + "->" + formatter.formatObject(new Date()));
    else if (formatter.acceptsNumber())
      System.err.println(pattern + "->" + formatter.formatObject(1223.456789));
    else
      System.err.println(pattern + "->" + formatter.formatObject("Hello world!"));
  }
View Full Code Here

        "date_format");
    final Vector<DateFormatComboBoxElement> values = new Vector<DateFormatComboBoxElement>();
    final List<PatternFormat> datePatterns = FormatController.getController().getDateFormats();
    int selectedIndex = 0;
    for (int i = 0; i < datePatterns.size(); ++i) {
      final PatternFormat patternFormat = datePatterns.get(i);
      values.add(new DateFormatComboBoxElement(patternFormat));
      if (patternFormat.getPattern().equals(dateFormatPattern)) {
        dateFormat = patternFormat;
        selectedIndex = i;
      }
    }
    final JComboBox dateFormatChooser = new JComboBox(values);
View Full Code Here

                public void itemStateChanged(final ItemEvent e) {
                    if (handlingEvent || !formatChooser.isEnabled() || e.getStateChange() != ItemEvent.SELECTED)
                        return;
                    handlingEvent = true;
                    final PatternFormat newFormat = toPatternFormat(e.getItem());
                    final AttributeTable table = attributeView.getAttributeTable();
                    if (table.getSelectedColumn() == 1 && table.getSelectedRow() != -1) {
                        final Object value = table.getValueAt(table.getSelectedRow(), table.getSelectedColumn());
                        try {
                            final Object newValue = formatValue(newFormat, table, value);
                            if (newValue != null)
                              table.setValueAt(newValue, table.getSelectedRow(), table.getSelectedColumn());
                        }
                        catch (Exception e2) {
                            Controller.getCurrentController().getViewController()
                                .out("Pattern is not applicable: " + e2.getMessage());
                            LogUtils.warn("pattern is not applicable", e2);
                        }
                    }
                    handlingEvent = false;
                }

                public PatternFormat toPatternFormat(Object value) {
                    if (value instanceof PatternFormat)
                        return (PatternFormat) value;
                    final PatternFormat patternFormat = PatternFormat.guessPatternFormat(value.toString());
                    return (patternFormat == null) ? PatternFormat.getIdentityPatternFormat() : patternFormat;
                }

                private Object formatValue(final PatternFormat newFormat, final AttributeTable table,
                                           final Object objectToBeFormatted) {
View Full Code Here

TOP

Related Classes of org.freeplane.features.format.PatternFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.