Java Module name_Java Module.getName方法代码示例

import com.intellij.openapi.module.Module; //导入方法依赖的package包/类

private void createTheme(@NotNull Project project, Module module) {

String[] commands = {"echo", "0", "|", "php", "bin/plugin", "devtools", "new-theme",

"--name", themeData.getName(),

"--description", themeData.getDescription(),

"--developer", themeData.getDeveloper(),

"--email", themeData.getEmail()};

GravProjectSettings settings = GravProjectSettings.getInstance(project);

ModuleRootManager root = ModuleRootManager.getInstance(module);

VirtualFile srcFile = null;

for (VirtualFile file : root.getSourceRoots()) {

if (file.isDirectory() && file.getName().contentEquals("src")) {

srcFile = file;

break;

}

}

if (srcFile == null) {

if (settings != null && settings.withSrcDirectory) {

NotificationHelper.showBaloon("No source root found in module " + module.getName() + "",

MessageType.ERROR, project);

return;

} else {

srcFile = FileCreateUtil.getParentDirectory(module.getModuleFile(), module.getName());

}

}

VirtualFile finalSrcFile = srcFile;

ProcessUtils processUtils = new ProcessUtils(commands, new File(finalSrcFile.getPath()));

Task.Backgroundable t = new Task.Backgroundable(project, "Create New Grav Theme in Module " + module.getName() + "") {

@Override

public boolean shouldStartInBackground() {

return true;

}

@Override

public void onSuccess() {

super.onSuccess();

String output = processUtils.getOutputAsString();

if (processUtils.getErrorOutput() != null) {

NotificationHelper.showBaloon(processUtils.getErrorOutput(), MessageType.ERROR, project);

} else {

NotificationHelper.showBaloon("Theme " + themeData.getName() + " was created", MessageType.INFO, project);

}

}

@Override

public void run(@NotNull ProgressIndicator indicator) {

processUtils.execute();

}

};

ProgressManager.getInstance().run(t);

}

import com.intellij.openapi.module.Module; //导入方法依赖的package包/类 private void createTheme(@NotNull Project project, Module module) { String[] commands = {"echo", "0", "|", "php", "bin/plugin", "devtools", "new-theme", "--name", themeData.getName(), "--description", themeData.getDescription(), "--developer", themeData.getDeveloper(), "--email", themeData.getEmail()}; GravProjectSettings settings = GravProjectSettings.getInstance(project); ModuleRootManager root = ModuleRootManager.getInstance(module); VirtualFile srcFile = null; for (VirtualFile file : root.getSourceRoots()) { if (file.isDirectory() && file.getName().contentEquals("src")) { srcFile = file; break; } } if (srcFile == null) { if (settings != null && settings.withSrcDirectory) { NotificationHelper.showBaloon("No source root found in module " + module.getName() + "", MessageType.ERROR, project); return; } else { srcFile = FileCreateUtil.getParentDirectory(module.getModuleFile(), module.getName()); } } VirtualFile finalSrcFile = srcFile; ProcessUtils processUtils = new ProcessUtils(commands, new File(finalSrcFile.getPath())); Task.Backgroundable t = new Task.Backgroundable(project, "Create New Grav Theme in Module " + module.getName() + "") { @Override public boolean shouldStartInBackground() { return true; } @Override public void onSuccess() { super.onSuccess(); String output = processUtils.getOutputAsString(); if (processUtils.getErrorOutput() != null) { NotificationHelper.showBaloon(processUtils.getErrorOutput(), MessageType.ERROR, project); } else { NotificationHelper.showBaloon("Theme " + themeData.getName() + " was created", MessageType.INFO, project); } } @Override public void run(@NotNull ProgressIndicator indicator) { processUtils.execute(); } }; ProgressManager.getInstance().run(t); }
经验分享 程序员 微信小程序 职场和发展