|
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-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.project.ui; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.lang.reflect.Method; import java.util.*; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectUtils; import org.netbeans.modules.project.ui.actions.Actions; import org.openide.actions.NewTemplateAction; import org.openide.actions.RenameAction; import org.openide.filesystems.FileObject; import org.openide.loaders.*; import org.openide.nodes.Node; import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.openide.util.actions.SystemAction; import org.openide.windows.TopComponent; /** * Various hacks that should be solved better later. */ public class Hacks { /** @author Petr Hrebejk */ static void hackFolderActions() { DataLoaderPool dataLoaderPool = (DataLoaderPool) Lookup.getDefault().lookup(DataLoaderPool.class); DataLoader folderLoader = dataLoaderPool.firstProducerOf(DataFolder.class); ArrayList actions = new ArrayList(Arrays.asList(folderLoader.getActions())); int index = actions.indexOf(RenameAction.findObject(NewTemplateAction.class)); if (index >= 0) { actions.set(index , SystemAction.get(Actions.SystemNewFile.class)); folderLoader.setActions((SystemAction[])actions.toArray(new SystemAction[actions.size()])); } } private static Object windowSystemImpl = null; private static Method setProjectName = null; /** * Show name of project corresponding to selection in Main Window title bar. * @author Jesse Glick */ static void keepCurrentProjectNameUpdated() { try { Class windowSystemImplClazz = Class.forName( "org.netbeans.core.NbTopManager$WindowSystem", true, Thread.currentThread().getContextClassLoader()); windowSystemImpl = Lookup.getDefault().lookup(windowSystemImplClazz); if (windowSystemImpl != null) { setProjectName = windowSystemImplClazz.getMethod( "setProjectName", new Class[] {String.class}); } } catch (Exception e) { // OK. e.printStackTrace(); } if (setProjectName != null) { final TopComponent.Registry r = TopComponent.getRegistry(); r.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent ev) { if (TopComponent.Registry.PROP_ACTIVATED_NODES.equals(ev.getPropertyName())) { Node[] sel = r.getActivatedNodes(); Set/* |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 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.