Examples of StrutsModel


Examples of com.intellij.struts2.dom.struts.model.StrutsModel

* @author Dmitry Avdeev
*/
public class Struts2UrlConverter extends DeployedFileUrlConverter {

  public Collection<String> getTargetPaths(@NotNull final PsiFile sourceFile, @NotNull final WebFacet webFacet) {
    final StrutsModel combinedModel = StrutsManager.getInstance(sourceFile.getProject()).getCombinedModel(webFacet.getModule());
    if (combinedModel == null) {
      return Collections.emptyList();
    }

    final List<String> actionExtensions = StrutsConstantHelper.getActionExtensions(sourceFile);
    if (actionExtensions.isEmpty()) {
      return Collections.emptyList();
    }

    final String actionExtension = actionExtensions.get(0);

    @NonNls final ArrayList<String> list = new ArrayList<String>();
    combinedModel.processActions(new Processor<Action>() {
      public boolean process(final Action action) {
        for (final Result result : action.getResults()) {
          final PathReference pathReference = result.getValue();
          if (pathReference != null) {
            final PsiElement psiElement = pathReference.resolve();
View Full Code Here

Examples of com.intellij.struts2.dom.struts.model.StrutsModel

        psiClass.hasModifierProperty(PsiModifier.ABSTRACT) ||
        !JamCommonUtil.isPlainJavaFile(psiClass.getContainingFile())) {
      return null;
    }

    final StrutsModel strutsModel = StrutsManager.getInstance(psiClass.getProject()).getCombinedModel(module);
    if (strutsModel == null ||
        !strutsModel.isActionClass(psiClass)) {
      return null;
    }

    final LayeredIcon layeredIcon = new LayeredIcon(2);
    final Icon original = PsiClassImplUtil.getClassIcon(flags, psiClass);
View Full Code Here

Examples of com.intellij.struts2.dom.struts.model.StrutsModel

    myEdges.add(edge);
  }

  private void updateDataModel() {
    final StrutsModel model = StrutsManager.getInstance(myProject).getModelByFile(myFile);
    if (model == null) {
      return;
    }

    for (final StrutsPackage strutsPackage : model.getStrutsPackages()) {
      for (final Action action : strutsPackage.getActions()) {
        final ActionNode actionNode = new ActionNode(action, action.getName().getStringValue());
        addNode(actionNode);

        for (final Result result : action.getResults()) {
View Full Code Here

Examples of com.intellij.struts2.dom.struts.model.StrutsModel

   * @param context Invoking context.
   * @return <code>null</code> if no StrutsModel found in current file/module.
   */
  @Nullable
  public static StrutsModel getStrutsModelOrCombined(final ConvertContext context) {
    final StrutsModel modelByFile = getStrutsModel(context);
    if (modelByFile != null) {
      return modelByFile;
    }

    return StrutsManager.getInstance(context.getFile().getProject()).getCombinedModel(context.getModule());
View Full Code Here

Examples of com.intellij.struts2.dom.struts.model.StrutsModel

  public String getErrorMessage(@Nullable final String s, final ConvertContext convertContext) {
    return "Cannot resolve Struts package '" + s + "'";
  }

  private static List<StrutsPackage> getStrutsPackages(final ConvertContext convertContext) {
    final StrutsModel model = ConverterUtil.getStrutsModelOrCombined(convertContext);
    if (model == null) {
      return Collections.emptyList();
    }

    return model.getStrutsPackages();
  }
View Full Code Here

Examples of com.intellij.struts2.dom.struts.model.StrutsModel

  @NotNull
  public PsiReference[] getReferencesByElement(@NotNull final PsiElement psiElement,
                                               @NotNull final ProcessingContext context) {
    final StrutsManager strutsManager = StrutsManager.getInstance(psiElement.getProject());
    final StrutsModel strutsModel = strutsManager.getCombinedModel(psiElement);
    if (strutsModel == null) {
      return PsiReference.EMPTY_ARRAY;
    }

    final XmlAttributeValue xmlAttributeValue = (XmlAttributeValue) psiElement;
    final String path = xmlAttributeValue.getValue();

    // resolve to <action>
    final String actionName = TaglibUtil.trimActionPath(path);
    final String namespace = getNamespace(xmlAttributeValue);
    final List<Action> actions = strutsModel.findActionsByName(actionName, namespace);
    final Action action = actions.isEmpty() ? null : actions.get(0);

    final int bangIndex = StringUtil.indexOf(path, TaglibUtil.BANG_SYMBOL);
    if (bangIndex == -1) {
      return new PsiReference[]{new ActionReference(xmlAttributeValue, action, namespace, strutsModel)};
View Full Code Here

Examples of com.intellij.struts2.dom.struts.model.StrutsModel

  @NotNull
  public PsiReference[] getReferencesByElement(@NotNull final PsiElement psiElement,
                                               @NotNull final ProcessingContext context) {

    final StrutsManager strutsManager = StrutsManager.getInstance(psiElement.getProject());
    final StrutsModel strutsModel = strutsManager.getCombinedModel(psiElement);
    if (strutsModel == null) {
      return PsiReference.EMPTY_ARRAY;
    }

    return new PsiReference[]{new NamespaceReference((XmlAttributeValue) psiElement, strutsModel)
View Full Code Here

Examples of com.intellij.struts2.dom.struts.model.StrutsModel

        xmlTag.getAttributeValue(ACTION_ATTRIBUTE_NAME);
    if (actionPath == null) {
      return;
    }

    final StrutsModel strutsModel = StrutsManager.getInstance(element.getProject()).getCombinedModel(module);
    if (strutsModel == null) {
      return;
    }

    final String namespace = xmlTag.getAttributeValue("namespace");
    final List<Action> actions = strutsModel.findActionsByName(actionPath, namespace);
    if (actions.isEmpty()) {
      return;
    }

    // resolve to action method should be exactly 1
View Full Code Here

Examples of com.intellij.struts2.dom.struts.model.StrutsModel

    return files.isEmpty() ||
           files.size() != getActionsForClazz(project, clazz, module).size();
  }

  private static List<Action> getActionsForClazz(final Project project, final PsiClass clazz, final Module module) {
    final StrutsModel model = StrutsManager.getInstance(project).getCombinedModel(module);
    if (model == null) {
      return Collections.emptyList();
    }

    return model.findActionsByClass(clazz);
  }
View Full Code Here

Examples of com.intellij.struts2.dom.struts.model.StrutsModel

      final Module module = context.getModuleByFile(file);
      if (module != null &&
          enabledForModule.get(module)) {
        final PsiFile psiFile = psiManager.findFile(file);
        if (psiFile instanceof XmlFile) {
          final StrutsModel model = strutsManager.getModelByFile((XmlFile) psiFile);
          if (model != null) {
            for (final XmlFile configFile : model.getConfigFiles()) {
              ContainerUtil.addIfNotNull(configFile.getVirtualFile(), files);
            }
          }
        }
      }
View Full Code Here
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.