1 19 package org.netbeans.modules.subversion.ui.properties; 20 21 import java.awt.BorderLayout ; 22 import java.awt.Dialog ; 23 import java.io.File ; 24 import javax.swing.JComponent ; 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 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 getName() { 52 return NbBundle.getMessage(SvnPropertiesAction.class, "CTL_PropertiesAction"); 53 } 54 55 protected String getBaseName(Node[] activatedNodes) { 56 return "CTL_MenuItem_Properties"; 57 } 58 59 protected void performContextAction(Node[] nodes) { 60 final Context ctx = getContext(nodes); 61 String ctxDisplayName = getContextDisplayName(nodes); 62 File [] 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); return; 70 } 71 72 final PropertiesPanel panel = new PropertiesPanel(); 73 final PropertiesTable propTable; 74 propTable = new PropertiesTable(PropertiesTable.PROPERTIES_COLUMNS, new String [] { PropertiesTableModel.COLUMN_NAME_VALUE}); 75 panel.setPropertiesTable(propTable); 76 77 JComponent component = propTable.getComponent(); 78 panel.propsPanel.setLayout(new BorderLayout ()); 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)); dd.setModal(true); 83 dd.setOptions(new Object [] {org.openide.util.NbBundle.getMessage(SvnPropertiesAction.class, "CTL_Properties_Action_Cancel")}); dd.setHelpCtx(new HelpCtx(SvnPropertiesAction.class)); 85 86 panel.putClientProperty("contentTitle", ctxDisplayName); panel.putClientProperty("DialogDescriptor", dd); Dialog dialog = DialogDisplayer.getDefault().createDialog(dd); 89 dialog.pack(); 90 dialog.setVisible(true); 91 } 92 } 93 94 | Popular Tags |