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

(-)refactoring/apichanges.xml (-1 / +27 lines)
Lines 56-62 Link Here
56
    <changes>
56
    <changes>
57
57
58
<change>
58
<change>
59
    <api name="compiler"/>
59
    <api name="refactoring"/>
60
    <summary>UI Framewrok needs improvement for integration with CVS and for SafeDelete refactoring</summary>
61
    <version major="1" minor="5"/>
62
    <date day="20" month="5" year="2005"/>
63
    <author login="jbecicka"/>
64
    <compatibility addition="yes"/>
65
    <description>
66
methods added:
67
=============
68
ProblemDetails Problem.getDetails()
69
70
Classes added:
71
=============
72
ProblemDetails
73
ProblemDetailsFactory
74
ProblemDetailsImplementation
75
ReadOnlyFilesHandler
76
    </description>
77
    <class package="org.netbeans.modules.refactoring.api" name="Problem"/>
78
    <class package="org.netbeans.modules.refactoring.api" name="ProblemDetails"/>
79
    <class package="org.netbeans.modules.refactoring.spi" name="ProblemDetailsImplementation"/>
80
    <class package="org.netbeans.modules.refactoring.spi" name="ProblemDetailsFactory"/>
81
    <class package="org.netbeans.modules.refactoring.spi" name="ReadOnlyFilesHandler"/>
82
    <issue number="58561"/>
83
</change>
84
<change>
85
    <api name="refactoring"/>
60
    <summary>This API change is needed for rewrite of refactoring D'n'D support.</summary>
86
    <summary>This API change is needed for rewrite of refactoring D'n'D support.</summary>
61
    <version major="1" minor="4"/>
87
    <version major="1" minor="4"/>
62
    <date day="10" month="5" year="2005"/>
88
    <date day="10" month="5" year="2005"/>
(-)refactoring/nbproject/project.properties (-1 / +1 lines)
Lines 9-15 Link Here
9
# Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
9
# Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
10
# Microsystems, Inc. All Rights Reserved.
10
# Microsystems, Inc. All Rights Reserved.
11
11
12
spec.version.base=1.4.0
12
spec.version.base=1.5.0
13
13
14
javadoc.arch=${basedir}/arch/arch-refactoring.xml
14
javadoc.arch=${basedir}/arch/arch-refactoring.xml
15
javadoc.title=Refactoring API
15
javadoc.title=Refactoring API
(-)refactoring/src/org/netbeans/modules/refactoring/spi/AccessorImpl.java (+5 lines)
Lines 12-17 Link Here
12
 */
12
 */
13
package org.netbeans.modules.refactoring.spi;
13
package org.netbeans.modules.refactoring.spi;
14
14
15
import java.util.Collection;
15
import java.util.List;
16
import java.util.List;
16
import org.netbeans.modules.refactoring.SPIAccessor;
17
import org.netbeans.modules.refactoring.SPIAccessor;
17
import org.netbeans.modules.refactoring.api.RefactoringSession;
18
import org.netbeans.modules.refactoring.api.RefactoringSession;
Lines 25-29 Link Here
25
    public RefactoringElementsBag createBag(RefactoringSession session, List delegate) {
26
    public RefactoringElementsBag createBag(RefactoringSession session, List delegate) {
26
        assert session != null && delegate != null;
27
        assert session != null && delegate != null;
27
        return new RefactoringElementsBag(session, delegate);
28
        return new RefactoringElementsBag(session, delegate);
29
    }
30
    
31
    public Collection getReadOnlyFiles(RefactoringElementsBag bag) {
32
        return bag.getReadOnlyFiles();
28
    }
33
    }
29
}
34
}
(-)refactoring/src/org/netbeans/modules/refactoring/spi/ProblemDetailsFactory.java (+35 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.refactoring.spi;
15
16
import org.netbeans.modules.refactoring.APIAccessor;
17
import org.netbeans.modules.refactoring.api.ProblemDetails;
18
19
/**
20
 * Factory class for ProblemDetails
21
 * @author Jan Becicka
22
 * @since 1.4.0
23
 */
24
public class ProblemDetailsFactory {
25
    /**
26
     * Factory method for creating API instances of ProblemDetails from SPI instances
27
     * of ProblemDetailsImplementation
28
     * @see ProblemDetails
29
     * @see ProblemDetailsImplementation
30
     */
31
    public static ProblemDetails createProblemDetails(ProblemDetailsImplementation pdi) {
32
        return APIAccessor.DEFAULT.createProblemDetails(pdi);
33
    }
34
    
35
}
(-)refactoring/src/org/netbeans/modules/refactoring/spi/ProblemDetailsImplementation.java (+42 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.refactoring.spi;
15
16
import javax.swing.Action;
17
18
/**
19
 * Typical implementation will invoke UI component on showDetails() call
20
 * This UI component will display ProblemDetails. There will be a button, or 
21
 * similar UI control, which will be connected to rerunRefactoringAction to 
22
 * invoke refactoring again once the Problem is fixed.
23
 * @author Jan Becicka
24
 * @since 1.4.0
25
 */
26
public interface ProblemDetailsImplementation {
27
    
28
    /**
29
     * This method will typically invoke component with ProblemDetails.
30
     * It is fully upon clients, how this component will be implemented.
31
     * @param rerunRefactoringAction this action is passed to client component
32
     * to allow clients to rerun refactoring once the Problem is fixed.
33
     */
34
    void showDetails(Action rerunRefactoringAction);
35
36
    /**
37
     * Message that will be displayed in parameters panel as a hint to suggest user,
38
     * that there are more details available.
39
     */
40
    String getDetailsHint();
41
    
42
}
(-)refactoring/src/org/netbeans/modules/refactoring/spi/ReadOnlyFilesHandler.java (+43 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.refactoring.spi;
15
16
import java.util.Collection;
17
import org.netbeans.modules.refactoring.api.Problem;
18
19
/**
20
 * Interface for factory classes which allows to create Problem, which ProblemDetails 
21
 * can handle read only files. Typically VCS can turn read only files into read write.
22
 * Implementation of ReadOnlyFilesHandler is required to be registered in Lookup.
23
 * More then one instance is not allowed to be registered.
24
 * @author Jan Becicka
25
 * @since 1.4.0
26
 */
27
public interface ReadOnlyFilesHandler {
28
    
29
    /**
30
     * Create a Problem, which ProblemDetails 
31
     * can handle read only files. Typically VCS can turn read only files into
32
     * read write.
33
     * Typical implementation will be following:
34
     * <pre>
35
     * new Problem(false,
36
     *    "Some files needs to be checked out for editing",
37
     *     ProblemDetailsFactory.createProblemDetails(new VCSDetailsImpl(files))
38
     * );
39
     * </pre>
40
     * @see ProblemDetailsImplementation
41
     */
42
    public Problem createProblem(Collection files); 
43
}
(-)refactoring/src/org/netbeans/modules/refactoring/spi/RefactoringElementsBag.java (+16 lines)
Lines 14-23 Link Here
14
package org.netbeans.modules.refactoring.spi;
14
package org.netbeans.modules.refactoring.spi;
15
15
16
import java.util.*;
16
import java.util.*;
17
import org.netbeans.jmi.javamodel.Resource;
18
import org.netbeans.modules.javacore.api.JavaModel;
17
import org.netbeans.modules.refactoring.APIAccessor;
19
import org.netbeans.modules.refactoring.APIAccessor;
18
import org.netbeans.modules.refactoring.CheckUtils;
20
import org.netbeans.modules.refactoring.CheckUtils;
19
import org.netbeans.modules.refactoring.SPIAccessor;
21
import org.netbeans.modules.refactoring.SPIAccessor;
20
import org.netbeans.modules.refactoring.api.*;
22
import org.netbeans.modules.refactoring.api.*;
23
import org.openide.filesystems.FileObject;
21
24
22
/**
25
/**
23
 * Container holding RefactoringElements
26
 * Container holding RefactoringElements
Lines 30-35 Link Here
30
    
33
    
31
    private final List delegate;
34
    private final List delegate;
32
    private final RefactoringSession session;
35
    private final RefactoringSession session;
36
    private Collection readOnlyFiles = new HashSet();
33
    
37
    
34
    /**
38
    /**
35
     * Creates an instance of RefactoringElementsBag
39
     * Creates an instance of RefactoringElementsBag
Lines 55-60 Link Here
55
    public Problem add(AbstractRefactoring refactoring, RefactoringElementImplementation el) {
59
    public Problem add(AbstractRefactoring refactoring, RefactoringElementImplementation el) {
56
        Problem p = null;
60
        Problem p = null;
57
        if (CheckUtils.isRefactoringElementReadOnly(el)) {
61
        if (CheckUtils.isRefactoringElementReadOnly(el)) {
62
            Resource resource = el.getJavaElement().getResource();
63
            FileObject file;
64
            if (resource == null) {
65
                file = el.getParentFile();
66
            } else {
67
                file = JavaModel.getFileObject(resource);
68
            }
69
            readOnlyFiles.add(file);    
58
            el.setEnabled(false);
70
            el.setEnabled(false);
59
            el.setStatus(el.READ_ONLY);
71
            el.setStatus(el.READ_ONLY);
60
            delegate.add(el);
72
            delegate.add(el);
Lines 103-107 Link Here
103
    
115
    
104
    public RefactoringSession getSession() {
116
    public RefactoringSession getSession() {
105
        return session;
117
        return session;
118
    }
119
    
120
    Collection getReadOnlyFiles() {
121
        return readOnlyFiles;
106
    }
122
    }
107
}
123
}
(-)refactoring/src/org/netbeans/modules/refactoring/api/AbstractRefactoring.java (+22 lines)
Lines 15-29 Link Here
15
import java.util.ArrayList;
15
import java.util.ArrayList;
16
import java.util.Collection;
16
import java.util.Collection;
17
import java.util.Iterator;
17
import java.util.Iterator;
18
import java.util.List;
18
import org.netbeans.modules.javacore.api.JavaModel;
19
import org.netbeans.modules.javacore.api.JavaModel;
19
import org.netbeans.modules.javacore.JMManager;
20
import org.netbeans.modules.javacore.JMManager;
20
import org.netbeans.modules.refactoring.APIAccessor;
21
import org.netbeans.modules.refactoring.APIAccessor;
21
import org.netbeans.modules.refactoring.ProgressSupport;
22
import org.netbeans.modules.refactoring.ProgressSupport;
23
import org.netbeans.modules.refactoring.SPIAccessor;
22
import org.netbeans.modules.refactoring.spi.GuardedBlockHandler;
24
import org.netbeans.modules.refactoring.spi.GuardedBlockHandler;
23
import org.netbeans.modules.refactoring.spi.GuardedBlockHandlerFactory;
25
import org.netbeans.modules.refactoring.spi.GuardedBlockHandlerFactory;
24
import org.netbeans.modules.refactoring.spi.ProgressProvider;
26
import org.netbeans.modules.refactoring.spi.ProgressProvider;
27
import org.netbeans.modules.refactoring.spi.ReadOnlyFilesHandler;
25
import org.netbeans.modules.refactoring.spi.RefactoringPlugin;
28
import org.netbeans.modules.refactoring.spi.RefactoringPlugin;
26
import org.netbeans.modules.refactoring.spi.RefactoringPluginFactory;
29
import org.netbeans.modules.refactoring.spi.RefactoringPluginFactory;
30
import org.openide.ErrorManager;
27
import org.openide.util.Lookup;
31
import org.openide.util.Lookup;
28
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
32
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
29
33
Lines 271-277 Link Here
271
            if (problem!=null && problem.isFatal())
275
            if (problem!=null && problem.isFatal())
272
                return problem;
276
                return problem;
273
        }
277
        }
278
        ReadOnlyFilesHandler handler = getROHandler();
279
        if (handler!=null) {
280
            Collection files = SPIAccessor.DEFAULT.getReadOnlyFiles(elements);
281
            problem = chainProblems(handler.createProblem(files), problem);
282
        }
283
        
274
        return problem;
284
        return problem;
285
    }
286
    
287
    private ReadOnlyFilesHandler getROHandler() {
288
        Lookup.Result result = Lookup.getDefault().lookup(new Lookup.Template(ReadOnlyFilesHandler.class));
289
        List handlers = (List) result.allInstances();
290
        if (handlers.size() == 0) {
291
            return null;
292
        }
293
        if (handlers.size() > 1) {
294
            ErrorManager.getDefault().log(ErrorManager.WARNING, "Multiple instances of ReadOnlyFilesHandler found in Lookup; only using first one: " + handlers); //NOI18N
295
        }
296
        return (ReadOnlyFilesHandler) handlers.get(0);
275
    }
297
    }
276
    
298
    
277
    private Problem pluginsCheckParams(Problem problem) {
299
    private Problem pluginsCheckParams(Problem problem) {
(-)refactoring/src/org/netbeans/modules/refactoring/api/AccessorImpl.java (+7 lines)
Lines 14-19 Link Here
14
14
15
import java.util.Collection;
15
import java.util.Collection;
16
import org.netbeans.modules.refactoring.APIAccessor;
16
import org.netbeans.modules.refactoring.APIAccessor;
17
import org.netbeans.modules.refactoring.spi.ProblemDetailsImplementation;
17
18
18
/**
19
/**
19
 *
20
 *
Lines 28-31 Link Here
28
    public Problem chainProblems(Problem p, Problem p1) {
29
    public Problem chainProblems(Problem p, Problem p1) {
29
        return AbstractRefactoring.chainProblems(p, p1);
30
        return AbstractRefactoring.chainProblems(p, p1);
30
    }
31
    }
32
    
33
    public ProblemDetails createProblemDetails(ProblemDetailsImplementation pdi) {
34
        assert pdi != null;
35
        return new ProblemDetails(pdi);
36
    }
37
    
31
}
38
}
(-)refactoring/src/org/netbeans/modules/refactoring/api/Problem.java (+16 lines)
Lines 12-17 Link Here
12
 */
12
 */
13
package org.netbeans.modules.refactoring.api;
13
package org.netbeans.modules.refactoring.api;
14
14
15
import org.netbeans.modules.refactoring.spi.ui.RefactoringUI;
16
15
/** Class used to represent problems encountered when performing
17
/** Class used to represent problems encountered when performing
16
 * various refactoring calls. Problems can be chained (using setNext method)
18
 * various refactoring calls. Problems can be chained (using setNext method)
17
 * - every problem can point to the following problem.
19
 * - every problem can point to the following problem.
Lines 22-27 Link Here
22
    private final boolean fatal;
24
    private final boolean fatal;
23
    private final String message;
25
    private final String message;
24
    private Problem next = null;
26
    private Problem next = null;
27
    private ProblemDetails details;
25
    
28
    
26
    /** Creates new instance of Problem class.
29
    /** Creates new instance of Problem class.
27
     * @param fatal Indicates whether the problem is fatal.
30
     * @param fatal Indicates whether the problem is fatal.
Lines 32-37 Link Here
32
        this.message = message;
35
        this.message = message;
33
    }
36
    }
34
    
37
    
38
    public Problem(boolean fatal, String message, ProblemDetails details) {
39
        this(fatal, message);
40
        this.details = details;
41
    }
42
    
35
    /** Indicates whether the problem is fatal.
43
    /** Indicates whether the problem is fatal.
36
     * @return <code>true</code> if the problem is fatal, otherwise returns <code>false</code>.
44
     * @return <code>true</code> if the problem is fatal, otherwise returns <code>false</code>.
37
     */
45
     */
Lines 64-68 Link Here
64
            throw new IllegalStateException("Cannot change \"next\" property of Problem."); //NOI18N
72
            throw new IllegalStateException("Cannot change \"next\" property of Problem."); //NOI18N
65
        }
73
        }
66
        this.next = next;
74
        this.next = next;
75
    }
76
77
    /**
78
     * Getter for ProblemDetails
79
     * @return instance of ProblemDetails or null
80
     */
81
    public ProblemDetails getDetails() {
82
        return details;
67
    }
83
    }
68
}
84
}
(-)refactoring/src/org/netbeans/modules/refactoring/api/ProblemDetails.java (+50 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.refactoring.api;
15
16
import javax.swing.Action;
17
import org.netbeans.modules.refactoring.spi.ProblemDetailsImplementation;
18
19
/**
20
 * This class holds details of a Problem
21
 * @author Jan Becicka
22
 * @since 1.4.0
23
 */
24
public final class ProblemDetails {
25
    
26
    private ProblemDetailsImplementation pdi;
27
    
28
    ProblemDetails (ProblemDetailsImplementation pdi) {
29
        this.pdi=pdi;
30
    }
31
    
32
    /**
33
     * This method will typically invoke component with ProblemDetails.
34
     * It is fully upon clients, how this component will be implemented.
35
     * @param rerunRefactoringAction this action is passed to client component
36
     * to allow clients to invoke refactoring once the Problem is fixed.
37
     * @see ProblemDetailsImplementation
38
     */
39
    public void showDetails(Action rerunRefactoringAction) {
40
        pdi.showDetails(rerunRefactoringAction);
41
    }
42
    
43
    /**
44
     * Message that will be displayed in parameters panel as a hint to suggest user,
45
     * that there are more details available.
46
     */
47
    public String getDetailsHint() {
48
        return pdi.getDetailsHint();
49
    }
50
}
(-)refactoring/arch/arch-refactoring.xml (-3 / +1 lines)
Lines 413-424 Link Here
413
Yes. We search for:
413
Yes. We search for:
414
<ul>
414
<ul>
415
<li><api group="lookup" name="org.netbeans.api.javahelp.Help" type="import" category="official"/></li>
415
<li><api group="lookup" name="org.netbeans.api.javahelp.Help" type="import" category="official"/></li>
416
<li><api group="lookup" name="org.openide.loaders.DataLoaderPool" type="import" category="official" />
417
      - to register OperationListener and allow automatic refactorings.
418
  </li>
419
<li><code>org.openide.nodes.Node</code> - listens to <api group="lookup" name="org.openide.util.ContextGlobalProvider" type="import" category="official" /> (resp. <code>org.openide.util.Utilities.actionsGlobalContext()</code> lookup) to look for active node in <code>RefactoringSubMenuAction</code></li>
416
<li><code>org.openide.nodes.Node</code> - listens to <api group="lookup" name="org.openide.util.ContextGlobalProvider" type="import" category="official" /> (resp. <code>org.openide.util.Utilities.actionsGlobalContext()</code> lookup) to look for active node in <code>RefactoringSubMenuAction</code></li>
420
<li>all instances of <api group="lookup" name="org.netbeans.modules.refactoring.spi.RefactoringPluginFactory" type="export" category="friend" /></li>
417
<li>all instances of <api group="lookup" name="org.netbeans.modules.refactoring.spi.RefactoringPluginFactory" type="export" category="friend" /></li>
421
<li>all instances of <api group="lookup" name="org.netbeans.modules.refactoring.spi.GuardedBlockHandlerFactory" type="export" category="friend" /></li>
418
<li>all instances of <api group="lookup" name="org.netbeans.modules.refactoring.spi.GuardedBlockHandlerFactory" type="export" category="friend" /></li>
419
<li>an instance of  <api group="lookup" name="org.netbeans.modules.refactoring.spi.ReadOnlyFilesHandler" type="export" category="friend" /></li>
422
</ul>
420
</ul>
423
 </answer>
421
 </answer>
424
422

Return to bug 59091