Package com.intellij.struts2.gotosymbol

Source Code of com.intellij.struts2.gotosymbol.GoToActionSymbolProvider

/*
* Copyright 2010 The authors
* Licensed 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 com.intellij.struts2.gotosymbol;

import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.module.Module;
import com.intellij.struts2.dom.struts.action.Action;
import com.intellij.struts2.dom.struts.model.StrutsManager;
import com.intellij.struts2.dom.struts.model.StrutsModel;
import com.intellij.struts2.facet.StrutsFacet;
import com.intellij.util.Processor;
import com.intellij.util.xml.model.gotosymbol.GoToSymbolProvider;
import icons.Struts2Icons;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.Set;

/**
* Go to {@link Action} by name (CTRL+ALT+SHIFT+N).
*
* @author Yann Cébron
*/
public class GoToActionSymbolProvider extends GoToSymbolProvider {

  protected boolean acceptModule(final Module module) {
    return StrutsFacet.getInstance(module) != null;
  }

  protected void addNames(@NotNull final Module module, final Set<String> result) {
    final StrutsModel strutsModel = StrutsManager.getInstance(module.getProject()).getCombinedModel(module);
    if (strutsModel == null) {
      return;
    }

    strutsModel.processActions(new Processor<Action>() {
      public boolean process(final Action action) {
        result.add(action.getName().getStringValue());
        return true;
      }
    });
  }

  protected void addItems(@NotNull final Module module, final String name, final List<NavigationItem> result) {
    final StrutsModel strutsModel = StrutsManager.getInstance(module.getProject()).getCombinedModel(module);
    if (strutsModel == null) {
      return;
    }

    final List<Action> actions = strutsModel.findActionsByName(name, null);
    for (final Action action : actions) {
      final NavigationItem item = createNavigationItem(action.getXmlTag(),
                                                       action.getName().getStringValue() +
                                                       " [" + action.getNamespace() + "]",
                                                       Struts2Icons.Action);
      result.add(item);
    }
  }

}
TOP

Related Classes of com.intellij.struts2.gotosymbol.GoToActionSymbolProvider

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.