Package com.intellij.struts2.dom.struts.strutspackage

Examples of com.intellij.struts2.dom.struts.strutspackage.GlobalResults


        if (directory == null ||
            directory.findFile(StrutsConstants.STRUTS_XML_DEFAULT_FILENAME) != null) {
          return;
        }

        final StrutsFileTemplateProvider templateProvider = new StrutsFileTemplateProvider(module);
        final FileTemplate strutsXmlTemplate = templateProvider.determineFileTemplate();

        try {
          final StrutsFacetConfiguration strutsFacetConfiguration = strutsFacet.getConfiguration();

          // create empty struts.xml & fileset with all found struts-*.xml files (struts2.jar, plugins)
          final PsiElement psiElement = FileTemplateUtil.createFromTemplate(strutsXmlTemplate,
                                                                            StrutsConstants.STRUTS_XML_DEFAULT_FILENAME,
                                                                            null,
                                                                            directory);
          final Set<StrutsFileSet> empty = Collections.emptySet();
          final StrutsFileSet fileSet = new StrutsFileSet(StrutsFileSet.getUniqueId(empty),
                                                          StrutsFileSet.getUniqueName("Default File Set", empty),
                                                          strutsFacetConfiguration);
          fileSet.addFile(((XmlFile) psiElement).getVirtualFile());

          final StrutsConfigsSearcher searcher = new StrutsConfigsSearcher(module);
          searcher.search();
          final MultiMap<VirtualFile, PsiFile> jarConfigFiles = searcher.getJars();
          for (final VirtualFile virtualFile : jarConfigFiles.keySet()) {
            final Collection<PsiFile> psiFiles = jarConfigFiles.get(virtualFile);
            for (final PsiFile psiFile : psiFiles) {
              fileSet.addFile(psiFile.getVirtualFile());
            }
          }
          strutsFacetConfiguration.getFileSets().add(fileSet);


          // create filter & mapping in web.xml (if present)
          new WriteCommandAction.Simple(modifiableRootModel.getProject()) {
            protected void run() throws Throwable {
              final WebFacet webFacet = strutsFacet.getWebFacet();

              final ConfigFile configFile = webFacet.getWebXmlDescriptor();
              if (configFile == null) return;

              final XmlFile webXmlFile = configFile.getXmlFile();
              final WebApp webApp = JamCommonUtil.getRootElement(webXmlFile, WebApp.class, null);
              if (webApp == null) return;
              if (!FileModificationService.getInstance().prepareFileForWrite(webXmlFile)) return;

              final Filter strutsFilter = webApp.addFilter();
              strutsFilter.getFilterName().setStringValue("struts2");

              @NonNls final String filterClass = templateProvider.is21orNewer() ?
                  StrutsConstants.STRUTS_2_1_FILTER_CLASS :
                  StrutsConstants.STRUTS_2_0_FILTER_CLASS;
              strutsFilter.getFilterClass().setStringValue(filterClass);

              final FilterMapping filterMapping = webApp.addFilterMapping();
View Full Code Here


  @NotNull
  protected PsiElement[] create(final String newName, final PsiDirectory directory) throws Exception {
    @NonNls final String fileName = getFileName(newName);

    final Module module = ModuleUtilCore.findModuleForPsiElement(directory);
    StrutsFileTemplateProvider templateProvider = new StrutsFileTemplateProvider(module);
    final FileTemplate strutsXmlTemplate = templateProvider.determineFileTemplate();
    final PsiElement file = FileTemplateUtil.createFromTemplate(strutsXmlTemplate,
                                                                fileName,
                                                                null,
                                                                directory);
    return new PsiElement[]{file};
View Full Code Here

*/
public abstract class StrutsLightHighlightingTestCase extends BasicLightHighlightingTestCase {

  @Override
  protected LocalInspectionTool[] getHighlightingInspections() {
    return new LocalInspectionTool[]{new Struts2ModelInspection()};
  }
View Full Code Here

        if (file == null) {
          continue;
        }
        final PsiFile psiFile = psiManager.findFile(file);
        if (psiFile instanceof XmlFile) {
          final StrutsRoot strutsRootDom = getDom((XmlFile) psiFile);
          if (strutsRootDom != null) {
            files.add((XmlFile) psiFile);
// TODO           addIncludes(files, strutsRootDom);
          }
        }
View Full Code Here

  private static void registerDocumentationProviders() {
    ElementPresentationManager.registerDocumentationProvider(new NullableFunction<Object, String>() {
      public String fun(final Object o) {
        if (o instanceof Action) {
          final Action action = (Action) o;
          final StrutsPackage strutsPackage = action.getStrutsPackage();

          final DocumentationBuilder builder = new DocumentationBuilder();
          final PsiClass actionClass = action.searchActionClass();
          builder.addLine("Action", action.getName().getStringValue())
                 .addLine("Class", actionClass != null ? actionClass.getQualifiedName() : null)
                 .addLine("Method", action.getMethod().getStringValue())
                 .addLine("Package", strutsPackage.getName().getStringValue())
                 .addLine("Namespace", strutsPackage.searchNamespace());

          return builder.getText();
        }
View Full Code Here

  @Override
  public PsiReference[] getReferencesByElement(@NotNull final PsiElement psiElement,
                                               @NotNull final ProcessingContext processingContext) {
    final Result result = (Result)DomUtil.getDomElement(psiElement);
    assert result != null : psiElement.getText();
    final Action action = result.getParentOfType(Action.class, true);
    assert action != null : psiElement.getText();
    final PsiClass actionClass = action.searchActionClass();
    if (actionClass == null) {
      return PsiReference.EMPTY_ARRAY;
    }

    final int tagValueStartOffset = ElementManipulators.getOffsetInElement(result.getXmlTag());
View Full Code Here

    // 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

        return false;
      }

      // suppress paths with wildcard reference
      if (ConverterUtil.hasWildcardReference(stringValue)) {
        final Action action = DomUtil.getParentOfType(value, Action.class, true);
        return action != null && !action.isWildcardMapping();
      }

      // "${actionProperty}"
      if (StringUtil.startsWith(stringValue, "${")) {
        return false;
View Full Code Here

    if (!(paramsElement instanceof Result)) {
      return PsiReference.EMPTY_ARRAY;
    }

    Result result = (Result)paramsElement;
    Action action = DomUtil.getParentOfType(result, Action.class, true);
    assert action != null;

    return new PsiReference[]{new MergingBeanPropertyPathReference(nameAttributeValue,
                                                                   action, result)};
  }
View Full Code Here

          return builder.getText();
        }

        if (o instanceof Result) {
          final Result result = (Result) o;
          final PathReference pathReference = result.getValue();
          final String displayPath = pathReference != null ? pathReference.getPath() : "???";
          final ResultType resultType = result.getEffectiveResultType();
          final String resultTypeValue = resultType != null ? resultType.getName().getStringValue() : "???";

          final DocumentationBuilder builder = new DocumentationBuilder();
          builder.addLine("Path", displayPath)
                 .addLine("Type", resultTypeValue);
View Full Code Here

TOP

Related Classes of com.intellij.struts2.dom.struts.strutspackage.GlobalResults

Copyright © 2018 www.massapicom. 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.