This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 179501
Collapse All | Expand All

(-)a/editor.lib/src/org/netbeans/editor/BaseDocument.java (+4 lines)
Lines 139-144 Link Here
139
    /** This document's version. It's accessed by DocumentUtilities.getDocumentVersion(). */
139
    /** This document's version. It's accessed by DocumentUtilities.getDocumentVersion(). */
140
    private static final String VERSION_PROP = "version"; //NOI18N
140
    private static final String VERSION_PROP = "version"; //NOI18N
141
141
142
    /** Timestamp when this document was last modified. It's accessed by DocumentUtilities.getDocumentVersion(). */
143
    private static final String LAST_MODIFICATION_TIMESTAMP_PROP = "last-modification-timestamp"; //NOI18N
144
142
    /** Line separator property for reading files in */
145
    /** Line separator property for reading files in */
143
    public static final String READ_LINE_SEPARATOR_PROP = DefaultEditorKit.EndOfLineStringProperty;
146
    public static final String READ_LINE_SEPARATOR_PROP = DefaultEditorKit.EndOfLineStringProperty;
144
147
Lines 2128-2133 Link Here
2128
2131
2129
    /* package */ void incrementDocVersion() {
2132
    /* package */ void incrementDocVersion() {
2130
        ((AtomicLong) getProperty(VERSION_PROP)).incrementAndGet();
2133
        ((AtomicLong) getProperty(VERSION_PROP)).incrementAndGet();
2134
        ((AtomicLong) getProperty(LAST_MODIFICATION_TIMESTAMP_PROP)).set(System.currentTimeMillis());
2131
    }
2135
    }
2132
2136
2133
    /** Compound edit that write-locks the document for the whole processing
2137
    /** Compound edit that write-locks the document for the whole processing
(-)a/editor.util/apichanges.xml (+14 lines)
Lines 104-109 Link Here
104
104
105
  <changes>
105
  <changes>
106
106
107
    <change id="DocumentUtilities.getDocumentTimestamp-added">
108
      <summary>Added DocumentUtilities.getDocumentTimestamp(Document)</summary>
109
        <version major="1" minor="34"/>
110
        <date day="14" month="1" year="2010"/>
111
        <author login="vstejskal"/>
112
        <compatibility addition="yes" deletion="no" modification="no" binary="compatible" semantic="compatible" />
113
        <description>
114
        <p>
115
            Adding DocumentUtilities.getDocumentTimestamp(Document) to provide access
116
            to documents' timestamp property.
117
        </p>
118
        </description>
119
    </change>
120
107
    <change id="DocumentUtilities.getDocumentVersion-added">
121
    <change id="DocumentUtilities.getDocumentVersion-added">
108
      <summary>Added DocumentUtilities.getDocumentVersion(Document)</summary>
122
      <summary>Added DocumentUtilities.getDocumentVersion(Document)</summary>
109
        <version major="1" minor="28"/>
123
        <version major="1" minor="28"/>
(-)a/editor.util/manifest.mf (-1 / +1 lines)
Lines 2-5 Link Here
2
OpenIDE-Module: org.netbeans.modules.editor.util/1
2
OpenIDE-Module: org.netbeans.modules.editor.util/1
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/lib/editor/util/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/lib/editor/util/Bundle.properties
4
AutoUpdate-Show-In-Client: false
4
AutoUpdate-Show-In-Client: false
5
OpenIDE-Module-Specification-Version: 1.33
5
OpenIDE-Module-Specification-Version: 1.34
(-)a/editor.util/src/org/netbeans/lib/editor/util/swing/DocumentUtilities.java (+20 lines)
Lines 73-78 Link Here
73
    
73
    
74
    /** BaseDocument's version. */
74
    /** BaseDocument's version. */
75
    private static final String VERSION_PROP = "version"; //NOI18N
75
    private static final String VERSION_PROP = "version"; //NOI18N
76
    private static final String LAST_MODIFICATION_TIMESTAMP_PROP = "last-modification-timestamp"; //NOI18N
76
77
77
    private static final Object TYPING_MODIFICATION_DOCUMENT_PROPERTY = new Object();
78
    private static final Object TYPING_MODIFICATION_DOCUMENT_PROPERTY = new Object();
78
    
79
    
Lines 878-881 Link Here
878
        Object version = doc.getProperty(VERSION_PROP);
879
        Object version = doc.getProperty(VERSION_PROP);
879
        return version instanceof AtomicLong ? ((AtomicLong) version).get() : 0;
880
        return version instanceof AtomicLong ? ((AtomicLong) version).get() : 0;
880
    }
881
    }
882
883
    /**
884
     * Attempts to get the timestamp of a <code>Document</code>. Netbeans editor
885
     * documents are versioned and timestamped whenever they are modified.
886
     * This method can be used to read the timestamp of the most recent modification.
887
     * The timestamp is a number of milliseconds returned from <code>System.currentTimeMillis()</code>
888
     * at the document modification.
889
     *
890
     * @param doc The document to get the timestamp for.
891
     *
892
     * @return The document's timestamp or <code>0</code> if the document does not
893
     *   support timestamps (ie. is not a netbeans editor document).
894
     *
895
     * @since 1.34
896
     */
897
    public static long getDocumentTimestamp(Document doc) {
898
        Object version = doc.getProperty(LAST_MODIFICATION_TIMESTAMP_PROP);
899
        return version instanceof AtomicLong ? ((AtomicLong) version).get() : 0;
900
    }
881
}
901
}

Return to bug 179501