KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > refactoring > experimental > ui > CleanUpRefactoringUI


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Leon Chiver. All Rights Reserved.
17  */

18 package org.netbeans.modules.refactoring.experimental.ui;
19
20 import java.util.List JavaDoc;
21 import org.netbeans.modules.refactoring.api.AbstractRefactoring;
22 import org.netbeans.modules.refactoring.api.Problem;
23 import org.netbeans.modules.refactoring.experimental.CleanUpRefactoring;
24 import org.netbeans.modules.refactoring.spi.ui.CustomRefactoringPanel;
25 import org.netbeans.modules.refactoring.spi.ui.ParametersPanel;
26 import org.netbeans.modules.refactoring.spi.ui.RefactoringUI;
27 import org.openide.util.HelpCtx;
28
29 /**
30  * @author leon
31  */

32 public class CleanUpRefactoringUI implements RefactoringUI {
33
34     private CleanUpRefactoring refactoring;
35
36     private List JavaDoc/*<Resource>*/ resources;
37     
38     private CleanUpPanel refactoringPanel;
39     
40     public CleanUpRefactoringUI(CleanUpRefactoring refactoring, List JavaDoc/*<Resource>*/ resources) {
41         this.refactoring = refactoring;
42         this.resources = resources;
43     }
44     
45     public String JavaDoc getName() {
46         return org.openide.util.NbBundle.getMessage(CleanUpRefactoringUI.class, "LBL_CleanUp");
47     }
48     
49     public String JavaDoc getDescription() {
50         return org.openide.util.NbBundle.getMessage(CleanUpRefactoringUI.class, "LBL_CleanUp");
51     }
52     
53     public boolean isQuery() {
54         return false;
55     }
56     
57     public CustomRefactoringPanel getPanel(ParametersPanel parent) {
58         if (refactoringPanel == null) {
59             refactoringPanel = new CleanUpPanel(refactoring, resources);
60         }
61         return refactoringPanel;
62     }
63     
64     public Problem setParameters() {
65         refactoring.setResources(refactoringPanel.getSelectedResources());
66         //
67
refactoring.setRemoveUnusedImports(refactoringPanel.isRemoveUnusedImports());
68         //
69
refactoring.setRemoveRedundantCasts(refactoringPanel.isRemoveRedundantCasts());
70         //
71
refactoring.setRemoveUnusedFields(refactoringPanel.isRemoveUnusedFields());
72         refactoring.setRemoveUnusedLocalVars(refactoringPanel.isRemoveUnusedLocalVars());
73         refactoring.setRemoveUnusedCallableFeatures(refactoringPanel.isRemoveUnusedCallableFeatures());
74         refactoring.setRemoveUnusedClasses(refactoringPanel.isRemoveUnusedClasses());
75         refactoring.setCommentInsteadOfRemoving(refactoringPanel.isCommentInsteadOfRemoving());
76         return refactoring.fastCheckParameters();
77     }
78     
79     public Problem checkParameters() {
80         return refactoring.checkParameters();
81     }
82     
83     public boolean hasParameters() {
84         return true;
85     }
86     
87     public AbstractRefactoring getRefactoring() {
88         return refactoring;
89     }
90     
91     public HelpCtx getHelpCtx() {
92         return null;
93     }
94     
95 }
96
Popular Tags