KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > subversion > ui > wizards > importstep > ImportPreviewStep


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 Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.subversion.ui.wizards.importstep;
20
21 import java.awt.BorderLayout JavaDoc;
22 import java.io.File JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Map JavaDoc;
25 import javax.swing.JComponent JavaDoc;
26
27 import org.netbeans.modules.subversion.*;
28 import org.netbeans.modules.subversion.ui.commit.CommitTable;
29 import org.netbeans.modules.subversion.ui.commit.CommitTableModel;
30 import org.netbeans.modules.subversion.ui.wizards.AbstractStep;
31 import org.netbeans.modules.subversion.util.Context;
32 import org.openide.util.HelpCtx;
33
34 /**
35  * @author Tomas Stupka
36  */

37 public class ImportPreviewStep extends AbstractStep {
38     
39     private PreviewPanel previewPanel;
40     private Context context;
41     private CommitTable table;
42     
43     public ImportPreviewStep(Context context) {
44         this.context = context;
45     }
46     
47     public HelpCtx getHelp() {
48         return new HelpCtx(ImportStep.class);
49     }
50
51     protected JComponent JavaDoc createComponent() {
52         if (previewPanel == null) {
53             previewPanel = new PreviewPanel();
54
55             //TableSorter sorter = SvnModuleConfig.getDefault().getImportTableSorter();
56
//if(sorter==null) {
57
table = new CommitTable(previewPanel.tableLabel, CommitTable.IMPORT_COLUMNS, new String JavaDoc[] { CommitTableModel.COLUMN_NAME_PATH });
58             //} else {
59
// table = new CommitTable(previewPanel.tableLabel, CommitTable.IMPORT_COLUMNS, sorter);
60
//}
61

62             JComponent JavaDoc component = table.getComponent();
63             previewPanel.tablePanel.setLayout(new BorderLayout JavaDoc());
64             previewPanel.tablePanel.add(component, BorderLayout.CENTER);
65         }
66         return previewPanel;
67     }
68
69     protected void validateBeforeNext() {
70         validateUserInput();
71     }
72
73     public void validateUserInput() {
74         if(table != null && table.getCommitFiles().size() > 0) {
75             valid();
76         } else {
77             invalid(org.openide.util.NbBundle.getMessage(ImportPreviewStep.class, "CTL_Import_NothingToImport")); // NOI18N
78
}
79     }
80
81     public void setup(String JavaDoc repositoryPath, String JavaDoc rootLocalPath) {
82         FileStatusCache cache = Subversion.getInstance().getStatusCache();
83         File JavaDoc[] files = cache.listFiles(context, FileInformation.STATUS_LOCAL_CHANGE);
84
85         if (files.length == 0) {
86             return;
87         }
88
89         if(repositoryPath != null) {
90             table.setRootFile(repositoryPath, rootLocalPath);
91         }
92
93         SvnFileNode[] nodes;
94         ArrayList JavaDoc<SvnFileNode> nodesList = new ArrayList JavaDoc<SvnFileNode>(files.length);
95
96         for (int i = 0; i<files.length; i++) {
97             File JavaDoc file = files[i];
98             SvnFileNode node = new SvnFileNode(file);
99             nodesList.add(node);
100         }
101         nodes = nodesList.toArray(new SvnFileNode[files.length]);
102         table.setNodes(nodes);
103
104         validateUserInput();
105     }
106
107     public Map JavaDoc getCommitFiles() {
108         return table.getCommitFiles();
109     }
110     
111     public void storeTableSorter() {
112         //SvnModuleConfig.getDefault().setImportTableSorter(table.getSorter());
113
}
114
115 }
116
117
Popular Tags