KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > subversion > ui > properties > SvnPropertiesAction


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.properties;
20
21 import java.awt.BorderLayout JavaDoc;
22 import java.awt.Dialog JavaDoc;
23 import java.io.File JavaDoc;
24 import javax.swing.JComponent JavaDoc;
25 import org.netbeans.modules.subversion.Subversion;
26 import org.netbeans.modules.subversion.client.SvnClient;
27 import org.netbeans.modules.subversion.ui.actions.ContextAction;
28 import org.netbeans.modules.subversion.util.Context;
29 import org.netbeans.modules.subversion.util.SvnUtils;
30 import org.openide.DialogDescriptor;
31 import org.openide.DialogDisplayer;
32 import org.openide.ErrorManager;
33 import org.openide.nodes.Node;
34 import org.openide.util.HelpCtx;
35 import org.openide.util.NbBundle;
36 import org.tigris.subversion.svnclientadapter.SVNClientException;
37 import org.tigris.subversion.svnclientadapter.SVNUrl;
38
39
40 /**
41  *
42  *
43  * @author Peter Pis
44  */

45 public final class SvnPropertiesAction extends ContextAction {
46     
47     protected boolean enable(Node[] nodes) {
48         return getContext(nodes).getRootFiles().length == 1;
49     }
50     
51     public String JavaDoc getName() {
52         return NbBundle.getMessage(SvnPropertiesAction.class, "CTL_PropertiesAction");
53     }
54     
55     protected String JavaDoc getBaseName(Node[] activatedNodes) {
56         return "CTL_MenuItem_Properties";
57     }
58
59     protected void performContextAction(Node[] nodes) {
60         final Context ctx = getContext(nodes);
61         String JavaDoc ctxDisplayName = getContextDisplayName(nodes);
62         File JavaDoc[] roots = ctx.getRootFiles();
63         final SVNUrl repositoryUrl = SvnUtils.getRepositoryRootUrl(roots[0]);
64         SvnClient client;
65         try {
66             client = Subversion.getInstance().getClient(repositoryUrl);
67         } catch (SVNClientException ex) {
68             ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); // should not hapen
69
return;
70         }
71         
72         final PropertiesPanel panel = new PropertiesPanel();
73         final PropertiesTable propTable;
74         propTable = new PropertiesTable(PropertiesTable.PROPERTIES_COLUMNS, new String JavaDoc[] { PropertiesTableModel.COLUMN_NAME_VALUE});
75         panel.setPropertiesTable(propTable);
76       
77         JComponent JavaDoc component = propTable.getComponent();
78         panel.propsPanel.setLayout(new BorderLayout JavaDoc());
79         panel.propsPanel.add(component, BorderLayout.CENTER);
80         SvnProperties svnProperties = new SvnProperties(panel, propTable, roots[0]);
81         DialogDescriptor dd = new DialogDescriptor(panel, org.openide.util.NbBundle.getMessage(SvnPropertiesAction.class, "CTL_PropertiesDialog_Title", ctxDisplayName)); // NOI18N
82
dd.setModal(true);
83         dd.setOptions(new Object JavaDoc[] {org.openide.util.NbBundle.getMessage(SvnPropertiesAction.class, "CTL_Properties_Action_Cancel")}); // NOI18N
84
dd.setHelpCtx(new HelpCtx(SvnPropertiesAction.class));
85         
86         panel.putClientProperty("contentTitle", ctxDisplayName); // NOI18N
87
panel.putClientProperty("DialogDescriptor", dd); // NOI18N
88
Dialog JavaDoc dialog = DialogDisplayer.getDefault().createDialog(dd);
89         dialog.pack();
90         dialog.setVisible(true);
91     }
92 }
93
94
Popular Tags