blob: 62ce32c2106af9761f48551f9e8cae1f41b3770d [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.beans.beaninfo;
import org.openide.nodes.Node;
import org.openide.util.NbBundle;
import org.openide.util.HelpCtx;
import org.openide.util.actions.NodeAction;
/**
* Toggles selection.
*
* @author Petr Hrebejk
*/
public class BiToggleAction extends NodeAction {
static final long serialVersionUID =3773842179168178798L;
/** generated Serialized Version UID */
//static final long serialVersionUID = 1391479985940417455L;
//private static final Class[] cookieClasses = new Class[] { BiFeatureNode.class };
/** Human presentable name of the action. This should be
* presented as an item in a menu.
* @return the name of the action
*/
public String getName () {
return NbBundle.getBundle (GenerateBeanInfoAction.class).getString ("CTL_TOGGLE_MenuItem");
}
/*
public Class[] cookieClasses() {
return cookieClasses;
}
*/
/** The action's icon location.
* @return the action's icon location
*/
protected String iconResource () {
return null;
//return "/org/netbeans/modules/javadoc/resources/searchDoc.gif"; // NOI18N
}
/*
public int mode () {
return CookieAction.MODE_ALL;
}
*/
/** Help context where to find more about the action.
* @return the help context for this action
*/
public HelpCtx getHelpCtx () {
return HelpCtx.DEFAULT_HELP;
}
protected boolean enable( Node[] activatedNodes ) {
activatedNodes = BiPanel.getSelectedNodes();
if ( activatedNodes.length < 1 )
return false;
for(int i = 0; i <activatedNodes.length; i++ ) {
if( activatedNodes[i].getCookie( BiFeatureNode.class ) == null )
return false;
BiFeature biFeature = (activatedNodes[i].getCookie( BiFeatureNode.class )).getBiFeature();
BiAnalyser biAnalyser = (activatedNodes[i].getCookie( BiFeatureNode.class )).getBiAnalyser();
if( ( biFeature instanceof BiFeature.Property || biFeature instanceof BiFeature.IdxProperty ) && biAnalyser.isNullProperties() )
return false;
if( biFeature instanceof BiFeature.EventSet && biAnalyser.isNullEventSets() )
return false;
if( biFeature instanceof BiFeature.Method && biAnalyser.isNullMethods() )
return false;
}
return true;
}
/** This method is called by one of the "invokers" as a result of
* some user's action that should lead to actual "performing" of the action.
* This default implementation calls the assigned actionPerformer if it
* is not null otherwise the action is ignored.
*/
public void performAction ( Node[] nodes ) {
nodes = BiPanel.getSelectedNodes();
if ( nodes.length < 1 )
return;
for(int i = 0; i < nodes.length; i++ ) {
if( nodes[i].getCookie( BiFeatureNode.class ) != null )
(nodes[i].getCookie( BiFeatureNode.class )).toggleSelection();
}
}
}