mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add new project and manage project actions (WEB-36796)
This commit is contained in:
+29
-6
@@ -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 {
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user