|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.core.actions; import java.util.Enumeration; import java.awt.event.ActionEvent; import org.netbeans.core.NbPlaces; import org.openide.filesystems.FileSystem; import org.openide.filesystems.Repository; import org.openide.nodes.Node; import org.openide.actions.NewTemplateAction; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.actions.CallableSystemAction; import org.openide.util.actions.SystemAction; /** Creates a new object from template in the selected folder. * @see DataObject#isTemplate * * @author Rostislav Levy */ public class NewTemplateCallableAction extends CallableSystemAction { public String getName () { return NbBundle.getMessage(NewTemplateCallableAction.class, "NewTemplate"); } protected String iconResource () { return "org/netbeans/core/resources/actions/new.gif"; // NOI18N } public HelpCtx getHelpCtx () { return new HelpCtx (NewTemplateAction.class); } public void performAction () { Enumeration e = Repository.getDefault ().getFileSystems (); boolean isWritable = false; while (e.hasMoreElements ()) { FileSystem fs = (FileSystem)e.nextElement (); if (!fs.isHidden () && !fs.isReadOnly () && !fs.isDefault ()) { isWritable = true; break; } } NewTemplateAction a = (NewTemplateAction)SystemAction.get(NewTemplateAction.class); if (isWritable) { a.performAction(); } else { Node mountNode = NbPlaces.getDefault().repositorySettings (); a.actionPerformed(new ActionEvent(mountNode, ActionEvent.ACTION_PERFORMED, null)); } } protected boolean asynchronous() { return false; } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.