Java Code Examples for com.intellij.psi.impl.file.PsiDirectoryFactory#getQualifiedName()

The following examples show how to use com.intellij.psi.impl.file.PsiDirectoryFactory#getQualifiedName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlutterReduxGen.java    From haystack with MIT License 4 votes vote down vote up
private void genStructure(PageModel pageModel) {
    Project project = directory.getProject();
    PsiFileFactory factory = PsiFileFactory.getInstance(project);
    PsiDirectoryFactory directoryFactory =
            PsiDirectoryFactory.getInstance(directory.getProject());
    String packageName = directoryFactory.getQualifiedName(directory, true);

    FileSaver fileSaver = new IDEFileSaver(factory, directory, DartFileType.INSTANCE);

    fileSaver.setListener(fileName -> {
        int ok = Messages.showOkCancelDialog(
                textResources.getReplaceDialogMessage(fileName),
                textResources.getReplaceDialogTitle(), "OK", "NO",
                UIUtil.getQuestionIcon());
        return ok == 0;
    });

    final String moduleName =
            FileIndexFacade.getInstance(project).getModuleForFile(directory.getVirtualFile()).getName();

    Map<String, Object> rootMap = new HashMap<String, Object>();
    rootMap.put("ProjectName", moduleName);
    rootMap.put("PageType", pageModel.pageType);
    if (pageModel.pageType.equals(CUSTOMSCROLLVIEW)) {
        rootMap.put("GenerateCustomScrollView", true);
    } else {
        rootMap.put("GenerateCustomScrollView", false);
    }
    rootMap.put("PageName", pageModel.pageName);
    rootMap.put("ModelEntryName", pageModel.modelName);
    rootMap.put("GenerateListView", pageModel.genListView);
    rootMap.put("GenerateBottomTabBar", pageModel.genBottomTabBar);
    rootMap.put("GenerateAppBar", pageModel.genAppBar);
    rootMap.put("GenerateDrawer", pageModel.genDrawer);
    rootMap.put("GenerateTopTabBar", pageModel.genTopTabBar);
    rootMap.put("GenerateWebView", pageModel.genWebView);
    rootMap.put("GenerateActionButton", pageModel.genActionButton);

    rootMap.put("viewModelQuery", pageModel.viewModelQuery);
    rootMap.put("viewModelGet", pageModel.viewModelGet);
    rootMap.put("viewModelCreate", pageModel.viewModelCreate);
    rootMap.put("viewModelUpdate", pageModel.viewModelUpdate);
    rootMap.put("viewModelDelete", pageModel.viewModelDelete);

    rootMap.put("GenSliverFixedExtentList", pageModel.genSliverFixedList);
    rootMap.put("GenSliverGrid", pageModel.genSliverGrid);
    rootMap.put("GenSliverToBoxAdapter", pageModel.genSliverToBoxAdapter);
    rootMap.put("FabInAppBar", pageModel.genSliverFab);
    rootMap.put("GenSliverTabBar", pageModel.genSliverTabBar);
    rootMap.put("GenSliverTabView", pageModel.genSliverTabView);
    rootMap.put("IsCustomWidget", pageModel.isCustomWidget);

    if (pageModel.genActionButton) {
        rootMap.put("HasActionSearch", pageModel.hasActionSearch);
        rootMap.put("ActionList", pageModel.actionList);
        rootMap.put("ActionBtnCount", pageModel.actionList.size());
    } else {
        rootMap.put("HasActionSearch", false);
        rootMap.put("ActionList", new ArrayList<String>());
        rootMap.put("ActionBtnCount", 0);
    }
    if (!pageModel.isUIOnly) {
        for (ClassModel classModel : pageModel.classModels) {
            if (classModel.getName().equals(pageModel.modelName)) {
                rootMap.put("genDatabase", classModel.isGenDBModule());

                if (classModel.getUniqueField() != null) {
                    rootMap.put("clsUNName", classModel.getUniqueField());
                    rootMap.put("clsUNNameType", classModel.getUniqueFieldType());
                }
            }
            generateModelEntry(classModel, rootMap);
        }

        generateRepository(rootMap);
        generateRedux(rootMap);
    }
    generateFeature(rootMap, pageModel.isCustomWidget, pageModel.genSliverTabView);
}
 
Example 2
Source File: ClassFromJSONAction.java    From JSONToKotlinClass with MIT License 4 votes vote down vote up
@Override
public void onModelsReady(List<ClassModel> data, String singleFileName, int annotationsType) {
    AnnotationGenerator annotations = null;
    switch (annotationsType) {
        case 1:
            annotations = new GsonAnnotations();
            break;
        case 2:
            annotations = new FastJsonAnnotation();
            break;
        case 3:
            annotations = new MoshiAnnotations();
            break;
        case 4:
            annotations = new JacksonAnnotations();
            break;
    }

    Project project = directory.getProject();
    PsiFileFactory factory = PsiFileFactory.getInstance(project);
    PsiDirectoryFactory directoryFactory = PsiDirectoryFactory.getInstance(directory.getProject());
    String packageName = directoryFactory.getQualifiedName(directory, true);

    FileSaver fileSaver = new IDEFileSaver(factory, directory, KotlinFileType.INSTANCE);

    fileSaver.setListener(fileName -> {
        int ok = Messages.showOkCancelDialog(
                textResources.getReplaceDialogMessage(fileName),
                textResources.getReplaceDialogTitle(),
                UIUtil.getQuestionIcon());
        return ok == 0;
    });

    SourceFilesGenerator generator;
    if (singleFileName == null) {
        generator = new MultipleFilesGenerator(fileSaver, languageResolver, annotations);
    } else {
        generator = new SingleFileGenerator(singleFileName, languageResolver, annotations, fileSaver);
    }

    generator.setListener(filesCount ->
            NotificationsHelper.showNotification(directory.getProject(),
                    textResources.getGeneratedFilesMessage(filesCount))
    );

    generator.generateFiles(packageName, data);
}