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 204828
Collapse All | Expand All

(-)a/editor.lib/test/unit/src/org/netbeans/editor/UndoableEditWrapperTest.java (-4 / +4 lines)
Lines 62-71 Link Here
62
import org.netbeans.api.editor.mimelookup.MimePath;
62
import org.netbeans.api.editor.mimelookup.MimePath;
63
import org.netbeans.api.editor.mimelookup.test.MockMimeLookup;
63
import org.netbeans.api.editor.mimelookup.test.MockMimeLookup;
64
import org.netbeans.junit.NbTestCase;
64
import org.netbeans.junit.NbTestCase;
65
import org.netbeans.modules.openide.text.NbDocumentRefactoringHack;
66
import org.openide.awt.UndoRedo;
65
import org.openide.awt.UndoRedo;
67
import org.openide.cookies.EditorCookie;
66
import org.openide.cookies.EditorCookie;
68
import org.openide.text.CloneableEditorSupport;
67
import org.openide.text.CloneableEditorSupport;
68
import org.openide.text.NbDocument;
69
import org.openide.util.Exceptions;
69
import org.openide.util.Exceptions;
70
import org.openide.util.Lookup;
70
import org.openide.util.Lookup;
71
import org.openide.windows.CloneableOpenSupport;
71
import org.openide.windows.CloneableOpenSupport;
Lines 99-110 Link Here
99
//        });
99
//        });
100
        doc.insertString(0, "Test", null);
100
        doc.insertString(0, "Test", null);
101
        Class wrapEditClass = TestingUndoableEditWrapper.WrapCompoundEdit.class;
101
        Class wrapEditClass = TestingUndoableEditWrapper.WrapCompoundEdit.class;
102
        assertNotNull(NbDocumentRefactoringHack.getEditToBeUndoneOfType(env.support, wrapEditClass));
102
        assertNotNull(NbDocument.getEditToBeUndoneOfType(env.support, wrapEditClass));
103
        Class wrapEditClass2 = TestingUndoableEditWrapper2.WrapCompoundEdit2.class;
103
        Class wrapEditClass2 = TestingUndoableEditWrapper2.WrapCompoundEdit2.class;
104
        assertNotNull(NbDocumentRefactoringHack.getEditToBeUndoneOfType(env.support, wrapEditClass2));
104
        assertNotNull(NbDocument.getEditToBeUndoneOfType(env.support, wrapEditClass2));
105
        
105
        
106
        // A trick to get whole edit
106
        // A trick to get whole edit
107
        UndoableEdit wholeEdit = NbDocumentRefactoringHack.getEditToBeUndoneOfType(env.support, UndoableEdit.class);
107
        UndoableEdit wholeEdit = NbDocument.getEditToBeUndoneOfType(env.support, UndoableEdit.class);
108
        assertTrue(wholeEdit instanceof List);
108
        assertTrue(wholeEdit instanceof List);
109
        @SuppressWarnings("unchecked")
109
        @SuppressWarnings("unchecked")
110
        List<? extends UndoableEdit> listEdit = (List<? extends UndoableEdit>) wholeEdit;
110
        List<? extends UndoableEdit> listEdit = (List<? extends UndoableEdit>) wholeEdit;
(-)a/editor.lib2/apichanges.xml (+15 lines)
Lines 107-112 Link Here
107
    <!-- ACTUAL CHANGES BEGIN HERE: -->
107
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
108
109
    <changes>
109
    <changes>
110
        <change id="UndoableEditWrapper">
111
            <summary>UndoableEditWrapper interface added</summary>
112
            <version major="1" minor="60"/>
113
            <date day="24" month="4" year="2012"/>
114
            <author login="mmetelka"/>
115
            <compatibility binary="compatible" source="compatible" semantic="compatible" addition="yes"/>
116
            <description>
117
                <p>
118
                    Added UndoableEditWrapper interface which allows wrapping
119
                    of document-generated undoable edit by custom wrapping undoable edit(s).
120
                </p>
121
            </description>
122
            <issue number="204828"/>
123
        </change>
124
110
        <change id="EditorDocumentUtils.runExclusive">
125
        <change id="EditorDocumentUtils.runExclusive">
111
            <summary>EditorDocumentUtils.runExclusive method added</summary>
126
            <summary>EditorDocumentUtils.runExclusive method added</summary>
112
            <version major="1" minor="58"/>
127
            <version major="1" minor="58"/>
(-)a/editor.lib2/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.editor.lib2/1
2
OpenIDE-Module: org.netbeans.modules.editor.lib2/1
3
OpenIDE-Module-Implementation-Version: 30
3
OpenIDE-Module-Implementation-Version: 31
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/lib2/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/lib2/Bundle.properties
5
OpenIDE-Module-Layer: org/netbeans/modules/editor/lib2/resources/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/editor/lib2/resources/layer.xml
6
OpenIDE-Module-Needs: org.netbeans.modules.editor.actions
6
OpenIDE-Module-Needs: org.netbeans.modules.editor.actions
(-)a/editor.lib2/nbproject/project.properties (-1 / +1 lines)
Lines 43-49 Link Here
43
is.autoload=true
43
is.autoload=true
44
javac.source=1.6
44
javac.source=1.6
45
javac.compilerargs=-Xlint:unchecked
45
javac.compilerargs=-Xlint:unchecked
46
spec.version.base=1.59.0
46
spec.version.base=1.60.0
47
47
48
javadoc.arch=${basedir}/arch.xml
48
javadoc.arch=${basedir}/arch.xml
49
javadoc.apichanges=${basedir}/apichanges.xml
49
javadoc.apichanges=${basedir}/apichanges.xml
(-)a/editor.lib2/nbproject/project.xml (+1 lines)
Lines 189-194 Link Here
189
                <package>org.netbeans.api.editor</package>
189
                <package>org.netbeans.api.editor</package>
190
                <package>org.netbeans.api.editor.document</package>
190
                <package>org.netbeans.api.editor.document</package>
191
                <package>org.netbeans.spi.editor.codegen</package>
191
                <package>org.netbeans.spi.editor.codegen</package>
192
                <package>org.netbeans.spi.editor.document</package>
192
                <package>org.netbeans.spi.editor.highlighting</package>
193
                <package>org.netbeans.spi.editor.highlighting</package>
193
                <package>org.netbeans.spi.editor.highlighting.support</package>
194
                <package>org.netbeans.spi.editor.highlighting.support</package>
194
                <package>org.netbeans.spi.editor.typinghooks</package>
195
                <package>org.netbeans.spi.editor.typinghooks</package>
(-)a/editor.lib2/src/org/netbeans/spi/editor/document/UndoableEditWrapper.java (-2 / +2 lines)
Lines 51-56 Link Here
51
 * Instances should be registered by using @MimeRegistration.
51
 * Instances should be registered by using @MimeRegistration.
52
 *
52
 *
53
 * @author Miloslav Metelka
53
 * @author Miloslav Metelka
54
 * @since 1.60
54
 */
55
 */
55
public interface UndoableEditWrapper {
56
public interface UndoableEditWrapper {
56
    
57
    
Lines 60-67 Link Here
60
     *
61
     *
61
     * @param edit original undoable edit generated by document (or previous wrapper).
62
     * @param edit original undoable edit generated by document (or previous wrapper).
62
     * @param doc document which generated the original undoable edit.
63
     * @param doc document which generated the original undoable edit.
63
     * @return wrap edit or original edit.
64
     * @return wrap edit instance (delegating to the given edit) or original edit.
64
     * @since 1.56
65
     */
65
     */
66
    @NonNull UndoableEdit wrap(@NonNull UndoableEdit edit, @NonNull Document doc);
66
    @NonNull UndoableEdit wrap(@NonNull UndoableEdit edit, @NonNull Document doc);
67
    
67
    
(-)a/openide.text/apichanges.xml (+18 lines)
Lines 49-54 Link Here
49
<apidef name="text">Text API</apidef>
49
<apidef name="text">Text API</apidef>
50
</apidefs>
50
</apidefs>
51
<changes>
51
<changes>
52
    <change id="NbDocument-getEditToBeUndoneOfType">
53
        <api name="text"/>
54
        <summary>Added NbDocument.getEditToBeUndoneOfType</summary>
55
        <version major="6" minor="47"/>
56
        <date day="24" month="4" year="2011"/>
57
        <author login="mmetelka"/>
58
        <compatibility addition="yes"/>
59
        <description>
60
            <p>
61
                Added NbDocument.getEditToBeUndoneOfType()
62
                and NbDocument.getEditToBeRedoneOfType()
63
                to retrieve custom undoable edits that wrap document-generated
64
                undoable edits.
65
            </p>
66
        </description>
67
        <class package="org.openide.text" name="CloneableEditorSupport"/>
68
        <issue number="199568"/>
69
    </change>
52
      <change id="NbDocument.openDocument">
70
      <change id="NbDocument.openDocument">
53
          <api name="text"/>
71
          <api name="text"/>
54
          <summary>Added methods <code>NbDocument.getDocument</code>, 
72
          <summary>Added methods <code>NbDocument.getDocument</code>, 
(-)a/openide.text/nbproject/project.properties (-1 / +1 lines)
Lines 47-53 Link Here
47
javadoc.arch=${basedir}/arch.xml
47
javadoc.arch=${basedir}/arch.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
49
49
50
spec.version.base=6.46
50
spec.version.base=6.47
51
test.config.stableBTD.includes=**/*Test.class
51
test.config.stableBTD.includes=**/*Test.class
52
test.config.stableBTD.excludes=\
52
test.config.stableBTD.excludes=\
53
    **/CloneableEditorSupportTest.class,\
53
    **/CloneableEditorSupportTest.class,\
(-)a/openide.text/src/org/netbeans/modules/openide/text/NbDocumentRefactoringHack.java (-79 lines)
Lines 1-79 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.openide.text;
43
44
import java.util.Collection;
45
import org.openide.cookies.EditorCookie;
46
import org.openide.text.NbDocument;
47
48
/**
49
 * * TODO: will be removed after API review
50
 */
51
public class NbDocumentRefactoringHack {
52
53
    public static abstract class APIAccessor {
54
55
        static {
56
            Class c = NbDocument.class;
57
            try {
58
                Class.forName(c.getName(), true, c.getClassLoader());
59
            } catch (Exception ex) {
60
                ex.printStackTrace();
61
            }
62
        }
63
64
        
65
        public static APIAccessor DEFAULT;
66
67
        public abstract <T> T getEditToBeUndoneOfType(EditorCookie ec, Class<T> type);
68
69
        public abstract <T> T getEditToBeRedoneOfType(EditorCookie ec, Class<T> type);
70
    }
71
72
    public static <T> T getEditToBeUndoneOfType(EditorCookie ec, Class<T> type) {
73
        return APIAccessor.DEFAULT.getEditToBeUndoneOfType(ec, type);
74
    }
75
76
    public static <T> T getEditToBeRedoneOfType(EditorCookie ec, Class<T> type) {
77
        return APIAccessor.DEFAULT.getEditToBeRedoneOfType(ec, type);
78
    }
79
}
(-)a/openide.text/src/org/openide/text/NbDocument.java (-26 / +29 lines)
Lines 57-63 Link Here
57
import javax.swing.text.*;
57
import javax.swing.text.*;
58
import javax.swing.undo.UndoableEdit;
58
import javax.swing.undo.UndoableEdit;
59
import org.netbeans.api.actions.Openable;
59
import org.netbeans.api.actions.Openable;
60
import org.netbeans.modules.openide.text.NbDocumentRefactoringHack;
61
import org.openide.DialogDisplayer;
60
import org.openide.DialogDisplayer;
62
import org.openide.NotifyDescriptor;
61
import org.openide.NotifyDescriptor;
63
import org.openide.awt.UndoRedo;
62
import org.openide.awt.UndoRedo;
Lines 534-566 Link Here
534
        ((Annotatable) doc).removeAnnotation(annotation);
533
        ((Annotatable) doc).removeAnnotation(annotation);
535
    }
534
    }
536
535
537
        /**
536
    /**
538
     * TODO: will be removed after API review
537
     * Get an edit of given type that would be undone if an undo operation would be invoked
538
     * at this time for an editor cookie.
539
     * <br>
540
     * The edit to be undone may be composed from instances of various undoable edit types
541
     * (see <a href="@TOP@/org/netbeans/spi/editor/document/UndoableEditWrapper.html">UndoableEditWrapper</a>).
542
     *
543
     * @param <T> type of undoable edit to be retrieved.
544
     * @param ec editor cookie providing an undo/redo manager.
545
     * @param type class of undoable edit to be retrieved.
546
     * @return undoable edit of given type or null if there is no edit to be undone
547
     *  or an instance of the given type is not contained in the edit to be undone.
548
     * @since 6.47
539
     */
549
     */
540
    
550
    public static <T> T getEditToBeUndoneOfType(EditorCookie ec, Class<T> type) {
541
    static {
542
        NbDocumentRefactoringHack.APIAccessor.DEFAULT = new APIAccessorImpl();
543
    }
544
545
    private static class APIAccessorImpl extends NbDocumentRefactoringHack.APIAccessor {
546
547
        @Override
548
        public <T> T getEditToBeUndoneOfType(EditorCookie ec, Class<T> type) {
549
            return NbDocument.getEditToBeUndoneOfType(ec, type);
550
        }
551
552
        @Override
553
        public <T> T getEditToBeRedoneOfType(EditorCookie ec, Class<T> type) {
554
            return NbDocument.getEditToBeRedoneOfType(ec, type);
555
        }
556
557
    }
558
559
    static <T> T getEditToBeUndoneOfType(EditorCookie ec, Class<T> type) {
560
        return getEditToBeUndoneRedoneOfType(ec, type, false);
551
        return getEditToBeUndoneRedoneOfType(ec, type, false);
561
    }
552
    }
562
553
563
    static <T> T getEditToBeRedoneOfType(EditorCookie ec, Class<T> type) {
554
    /**
555
     * Get an edit of given type that would be redone if a redo operation would be invoked
556
     * at this time for an editor cookie.
557
     * <br>
558
     * The edit to be undone may be composed from instances of various undoable edit types
559
     * (see <a href="@TOP@/org/netbeans/spi/editor/document/UndoableEditWrapper.html">UndoableEditWrapper</a>).
560
     *
561
     * @param <T> type of undoable edit to be retrieved.
562
     * @param ec editor cookie providing an undo/redo manager.
563
     * @param type class of undoable edit to be retrieved.
564
     * @return undoable edit of given type or null if there is no edit to be redone
565
     *  or an instance of the given type is not contained in the edit to be redone.
566
     * @since 6.47
567
     */
568
    public static <T> T getEditToBeRedoneOfType(EditorCookie ec, Class<T> type) {
564
        return getEditToBeUndoneRedoneOfType(ec, type, true);
569
        return getEditToBeUndoneRedoneOfType(ec, type, true);
565
    }
570
    }
566
571
Lines 588-595 Link Here
588
        return null;
593
        return null;
589
    }
594
    }
590
595
591
    //End of TODO
592
593
    /**
596
    /**
594
     * Get the document associated with a file.
597
     * Get the document associated with a file.
595
     *
598
     *
(-)a/refactoring.api/nbproject/project.properties (-1 / +1 lines)
Lines 4-8 Link Here
4
javadoc.apichanges=${basedir}/apichanges.xml
4
javadoc.apichanges=${basedir}/apichanges.xml
5
javadoc.title=Refactoring API
5
javadoc.title=Refactoring API
6
6
7
spec.version.base=1.24.0
7
spec.version.base=1.25.0
8
test.config.stableBTD.includes=**/*Test.class
8
test.config.stableBTD.includes=**/*Test.class
(-)a/refactoring.api/nbproject/project.xml (-3 / +3 lines)
Lines 55-61 Link Here
55
                    <compile-dependency/>
55
                    <compile-dependency/>
56
                    <run-dependency>
56
                    <run-dependency>
57
                        <release-version>1</release-version>
57
                        <release-version>1</release-version>
58
                        <implementation-version/>
58
                        <specification-version>1.60</specification-version>
59
                    </run-dependency>
59
                    </run-dependency>
60
                </dependency>
60
                </dependency>
61
                <dependency>
61
                <dependency>
Lines 163-172 Link Here
163
                </dependency>
163
                </dependency>
164
                <dependency>
164
                <dependency>
165
                    <code-name-base>org.openide.text</code-name-base>
165
                    <code-name-base>org.openide.text</code-name-base>
166
                     <build-prerequisite/>
166
                    <build-prerequisite/>
167
                    <compile-dependency/>
167
                    <compile-dependency/>
168
                    <run-dependency>
168
                    <run-dependency>
169
                        <implementation-version/>
169
                        <specification-version>6.47</specification-version>
170
                    </run-dependency>
170
                    </run-dependency>
171
                </dependency>
171
                </dependency>
172
                <dependency>
172
                <dependency>
(-)a/refactoring.api/src/org/netbeans/modules/refactoring/spi/BackupFacility2.java (-2 / +4 lines)
Lines 53-59 Link Here
53
import java.util.*;
53
import java.util.*;
54
import java.util.logging.Logger;
54
import java.util.logging.Logger;
55
import org.netbeans.editor.BaseDocument;
55
import org.netbeans.editor.BaseDocument;
56
import org.netbeans.modules.openide.text.NbDocumentRefactoringHack;
57
import org.netbeans.modules.refactoring.spi.impl.UndoableWrapper;
56
import org.netbeans.modules.refactoring.spi.impl.UndoableWrapper;
58
import org.netbeans.modules.refactoring.spi.impl.UndoableWrapper.UndoableEditDelegate;
57
import org.netbeans.modules.refactoring.spi.impl.UndoableWrapper.UndoableEditDelegate;
59
import org.openide.cookies.EditorCookie;
58
import org.openide.cookies.EditorCookie;
Lines 62-67 Link Here
62
import org.openide.loaders.DataObject;
61
import org.openide.loaders.DataObject;
63
import org.openide.loaders.DataObjectNotFoundException;
62
import org.openide.loaders.DataObjectNotFoundException;
64
import org.openide.text.CloneableEditorSupport;
63
import org.openide.text.CloneableEditorSupport;
64
import org.openide.text.NbDocument;
65
import org.openide.util.Exceptions;
65
import org.openide.util.Exceptions;
66
import org.openide.util.Lookup;
66
import org.openide.util.Lookup;
67
67
Lines 257-263 Link Here
257
                    } else {
257
                    } else {
258
                        EditorCookie editor = dob.getLookup().lookup(EditorCookie.class);
258
                        EditorCookie editor = dob.getLookup().lookup(EditorCookie.class);
259
                        if (editor != null  && doc!=null && editor.isModified()) {
259
                        if (editor != null  && doc!=null && editor.isModified()) {
260
                            UndoableEditDelegate edit = undo?NbDocumentRefactoringHack.getEditToBeUndoneOfType(editor, UndoableWrapper.UndoableEditDelegate.class):NbDocumentRefactoringHack.getEditToBeRedoneOfType(editor, UndoableWrapper.UndoableEditDelegate.class);
260
                            UndoableEditDelegate edit = undo
261
                                    ? NbDocument.getEditToBeUndoneOfType(editor, UndoableWrapper.UndoableEditDelegate.class)
262
                                    : NbDocument.getEditToBeRedoneOfType(editor, UndoableWrapper.UndoableEditDelegate.class);
261
                            if (edit == null) {
263
                            if (edit == null) {
262
                                try {
264
                                try {
263
                                    LOG.fine("Editor Undo Different");
265
                                    LOG.fine("Editor Undo Different");

Return to bug 204828