add new project and manage project actions (WEB-36796)

This commit is contained in:
Dennis Ushakov
2019-02-25 17:41:30 +03:00
parent 9b8e108254
commit a7a6dddf29
2 changed files with 30 additions and 7 deletions
@@ -9,8 +9,10 @@ import com.intellij.ide.fileTemplates.FileTemplateUtil;
import com.intellij.ide.fileTemplates.impl.FileTemplateBase;
import com.intellij.ide.util.projectWizard.ProjectTemplateFileProcessor;
import com.intellij.ide.util.projectWizard.ProjectTemplateParameterFactory;
import com.intellij.idea.ActionsBundle;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
@@ -98,12 +100,20 @@ public class SaveProjectAsTemplateAction extends AnAction implements DumbAware {
@Override
public void onSuccess() {
new Notification("Project Template",
"Template Created",
FileUtil.getNameWithoutExtension(file.getFileName().toString()) + " was successfully created.<br>" +
"It's available now in Project Wizard",
NotificationType.INFORMATION
).notify(getProject());
AnAction newProjectAction = ActionManager.getInstance().getAction(getNewProjectActionId());
newProjectAction.getTemplatePresentation().setText(ActionsBundle.actionText("NewDirectoryProject"));
AnAction manageAction = ActionManager.getInstance().getAction("ManageProjectTemplates");
Notification notification = new Notification("Project Template",
"Template Created",
FileUtil.getNameWithoutExtension(file.getFileName().toString()) +
" was successfully created",
NotificationType.INFORMATION
);
notification.addAction(newProjectAction);
if (manageAction != null) {
notification.addAction(manageAction);
}
notification.notify(getProject());
}
@Override
@@ -202,6 +212,19 @@ public class SaveProjectAsTemplateAction extends AnAction implements DumbAware {
}
}
static String getNewProjectActionId() {
if (PlatformUtils.isIntelliJ()) {
return "NewProject";
}
else if (PlatformUtils.isPhpStorm()) {
return "NewDirectoryProject";
} else if (PlatformUtils.isWebStorm()) {
return "NewWebStormDirectoryProject";
} else {
throw new IllegalStateException("Provide new project action id for your IDE");
}
}
private static void writeFile(String path,
final String text,
Project project, String prefix, ZipOutputStream stream, boolean overwrite) throws IOException {
+1 -1
View File
@@ -302,7 +302,7 @@
<group>
<action class="com.intellij.platform.templates.SaveProjectAsTemplateAction" text="Save Project as Template..."/>
<action class="com.intellij.platform.templates.ManageProjectTemplatesAction" text="Manage Project Templates..."/>
<action id="ManageProjectTemplates" class="com.intellij.platform.templates.ManageProjectTemplatesAction" text="Manage Project Templates..."/>
<add-to-group group-id="ToolsBasicGroup" anchor="after" relative-to-action="SaveFileAsTemplate"/>
</group>