-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from nocalhost/dev-tian-add-233-support
feat: add 2023.3 support
- Loading branch information
Showing
11 changed files
with
331 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Existent IDE versions can be found in the following repos: | ||
# https://www.jetbrains.com/intellij-repository/releases/ | ||
# https://www.jetbrains.com/intellij-repository/snapshots/ | ||
ideaVersion=IU-2023.3 | ||
|
||
# see org.gradle.api.JavaVersion | ||
javaCompatibility=VERSION_17 | ||
|
||
# Get the number from the IDE's download page | ||
# For more info, see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description | ||
sinceBuild=233.11799.241 | ||
untilBuild=233.* | ||
|
||
# plugin versions from intellij marketplace https://plugins.jetbrains.com | ||
goPluginVersion=233.11799.196 | ||
phpPluginVersion=233.11799.300 | ||
pythonPluginVersion=233.11799.300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
propertiesPluginEnvironmentNameProperty=platformVersion | ||
# Supported platforms: 203, 211, 212, 213, 223, 231 | ||
platformVersion=232 | ||
# Supported platforms: 203, 211, 212, 213, 223, 231, ... | ||
platformVersion=233 | ||
|
||
kotlin.code.style=official | ||
version=0.6.30 | ||
version=0.6.31 |
149 changes: 149 additions & 0 deletions
149
src/233/main/java/dev/nocalhost/plugin/intellij/exception/NocalhostNotifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
package dev.nocalhost.plugin.intellij.exception; | ||
|
||
import com.intellij.ide.BrowserUtil; | ||
import com.intellij.notification.Notification; | ||
import com.intellij.notification.NotificationDisplayType; | ||
import com.intellij.notification.NotificationGroup; | ||
import com.intellij.notification.NotificationListener; | ||
import com.intellij.notification.NotificationType; | ||
import com.intellij.openapi.application.ApplicationManager; | ||
import com.intellij.openapi.extensions.PluginId; | ||
import com.intellij.openapi.options.ShowSettingsUtil; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.util.NlsContexts; | ||
import com.intellij.openapi.wm.ToolWindowManager; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.jetbrains.annotations.NonNls; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.swing.event.HyperlinkEvent; | ||
|
||
import dev.nocalhost.plugin.intellij.topic.NocalhostExceptionPrintNotifier; | ||
import icons.NocalhostIcons; | ||
|
||
public class NocalhostNotifier { | ||
|
||
public static final String NOCALHOST_NOTIFICATION_ID = "Nocalhost.Notification"; | ||
public static final String NOCALHOST_ERROR_NOTIFICATION_ID = "Nocalhost.Notification.Error"; | ||
|
||
public static final NotificationGroup NOCALHOST_NOTIFICATION = | ||
NotificationGroup.create( | ||
"Nocalhost.Notification", NotificationDisplayType.BALLOON, false, "Nocalhost", | ||
"Nocalhost", PluginId.getId("dev.nocalhost.nocalhost-intellij-plugin")); | ||
public static final NotificationGroup NOCALHOST_ERROR_NOTIFICATION = | ||
NotificationGroup.create( | ||
"Nocalhost.Notification.Error", NotificationDisplayType.STICKY_BALLOON, true, "Nocalhost", | ||
"Nocalhost", PluginId.getId("dev.nocalhost.nocalhost-intellij-plugin")); | ||
|
||
private final Project project; | ||
|
||
public NocalhostNotifier(Project project) { | ||
this.project = project; | ||
} | ||
|
||
public static NocalhostNotifier getInstance(Project project) { | ||
return project.getService(NocalhostNotifier.class); | ||
} | ||
|
||
@NotNull | ||
public Notification notify(@NotNull Notification notification) { | ||
notification.notify(project); | ||
return notification; | ||
} | ||
|
||
@NotNull | ||
public Notification notifyError(@NlsContexts.NotificationTitle @NotNull String title, | ||
@NlsContexts.NotificationContent @NotNull String message) { | ||
return notify(NOCALHOST_ERROR_NOTIFICATION, NOCALHOST_ERROR_NOTIFICATION_ID, title, message, NotificationType.ERROR, null); | ||
} | ||
|
||
@NotNull | ||
public Notification notifyError(@NlsContexts.NotificationTitle @NotNull String title, | ||
@NlsContexts.NotificationContent @NotNull String message, | ||
@NotNull String eMessage) { | ||
String content = String.format("<html>%s <a href=\"nocalhost.show\">Show More</a></html>", message); | ||
return notify(NOCALHOST_ERROR_NOTIFICATION, NOCALHOST_ERROR_NOTIFICATION_ID, title, content, NotificationType.ERROR, new NotificationListener.Adapter() { | ||
@Override | ||
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) { | ||
ToolWindowManager.getInstance(project).getToolWindow("Nocalhost Console").activate(() -> { | ||
project.getMessageBus().syncPublisher(NocalhostExceptionPrintNotifier.NOCALHOST_EXCEPTION_PRINT_NOTIFIER_TOPIC) | ||
.action(title, message, eMessage); | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
public void notifyBinaryNotFound(String binary) { | ||
String content = String.format("<html>%s binary not found. <a href=\"nocalhost.setting\">Setting</a></html>", binary); | ||
notify(NOCALHOST_ERROR_NOTIFICATION, NOCALHOST_ERROR_NOTIFICATION_ID, "Nocalhost", content, NotificationType.ERROR, new NotificationListener.Adapter() { | ||
@Override | ||
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) { | ||
ShowSettingsUtil showSettingsUtil = ApplicationManager.getApplication().getService(ShowSettingsUtil.class); | ||
showSettingsUtil.showSettingsDialog(project, "Nocalhost"); | ||
} | ||
}); | ||
} | ||
|
||
public void notifyVersionTips() { | ||
String content = "<html>nocalhost plugin need upgrade. <a href=\"nocalhost.setting\">upgrade plugin</a></html>"; | ||
notify(NOCALHOST_ERROR_NOTIFICATION, NOCALHOST_ERROR_NOTIFICATION_ID, "Nocalhost", content, NotificationType.ERROR, new NotificationListener.Adapter() { | ||
@Override | ||
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) { | ||
BrowserUtil.browse("https://plugins.jetbrains.com/plugin/16058-nocalhost/versions"); | ||
} | ||
}); | ||
} | ||
|
||
|
||
@NotNull | ||
public Notification notifyError(@NlsContexts.NotificationTitle @NotNull String title, | ||
@NlsContexts.NotificationContent @NotNull String message, | ||
@Nullable NotificationListener listener) { | ||
return notify(NOCALHOST_ERROR_NOTIFICATION, NOCALHOST_ERROR_NOTIFICATION_ID, title, message, NotificationType.ERROR, listener); | ||
} | ||
|
||
@NotNull | ||
public Notification notifySuccess(@NlsContexts.NotificationTitle @NotNull String title, | ||
@NlsContexts.NotificationContent @NotNull String message) { | ||
return notify(NOCALHOST_NOTIFICATION, NOCALHOST_NOTIFICATION_ID, title, message, NotificationType.INFORMATION, null); | ||
} | ||
|
||
@NotNull | ||
public Notification notifySuccess(@NlsContexts.NotificationTitle @NotNull String title, | ||
@NlsContexts.NotificationContent @NotNull String message, | ||
@Nullable NotificationListener listener) { | ||
return notify(NOCALHOST_NOTIFICATION, NOCALHOST_NOTIFICATION_ID, title, message, NotificationType.INFORMATION, listener); | ||
} | ||
|
||
@NotNull | ||
private Notification notify(@NotNull NotificationGroup notificationGroup, | ||
@NonNls @Nullable String displayId, | ||
@NlsContexts.NotificationTitle @NotNull String title, | ||
@NlsContexts.NotificationContent @NotNull String message, | ||
@NotNull NotificationType type, | ||
@Nullable NotificationListener listener) { | ||
Notification notification = createNotification(notificationGroup, displayId, title, message, type, listener); | ||
return notify(notification); | ||
} | ||
|
||
private static Notification createNotification(@NotNull NotificationGroup notificationGroup, | ||
@NonNls @Nullable String displayId, | ||
@NlsContexts.NotificationTitle @NotNull String title, | ||
@NlsContexts.NotificationContent @NotNull String message, | ||
@NotNull NotificationType type, | ||
@Nullable NotificationListener listener) { | ||
|
||
if (StringUtils.isBlank(message)) { | ||
message = title; | ||
title = ""; | ||
} | ||
Notification notification = notificationGroup.createNotification(title, message, type); | ||
if (listener != null) { | ||
notification.setListener(listener); | ||
} | ||
notification.setDisplayId(StringUtils.trimToEmpty(displayId)); | ||
return notification; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/233/main/java/dev/nocalhost/plugin/intellij/ui/action/workload/OpenProjectExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package dev.nocalhost.plugin.intellij.ui.action.workload; | ||
|
||
import com.intellij.ide.RecentProjectsManagerBase; | ||
import com.intellij.ide.impl.OpenProjectTask; | ||
import com.intellij.openapi.application.ApplicationManager; | ||
|
||
import java.nio.file.Paths; | ||
|
||
public class OpenProjectExecutor { | ||
|
||
public static void open(String projectPath) { | ||
var task = OpenProjectTask.build(); | ||
ApplicationManager.getApplication().executeOnPooledThread(() -> { | ||
RecentProjectsManagerBase.getInstanceEx().openProjectSync(Paths.get(projectPath), task); | ||
}); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/233/main/java/dev/nocalhost/plugin/intellij/ui/sync/NocalhostSyncPopup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package dev.nocalhost.plugin.intellij.ui.sync; | ||
|
||
import com.intellij.dvcs.ui.BranchActionGroupPopup; | ||
import com.intellij.ide.DataManager; | ||
import com.intellij.openapi.actionSystem.ActionGroup; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.wm.WindowManager; | ||
import com.intellij.ui.popup.PopupFactoryImpl; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
import dev.nocalhost.plugin.intellij.commands.data.NhctlDevAssociateQueryResult; | ||
import dev.nocalhost.plugin.intellij.topic.NocalhostSyncUpdateNotifier; | ||
|
||
public class NocalhostSyncPopup { | ||
private final Project project; | ||
private final ActionGroup actions; | ||
private NocalhostSyncPopup(@NotNull Project project, @NotNull ActionGroup actions) { | ||
this.project = project; | ||
this.actions = actions; | ||
} | ||
|
||
public static NocalhostSyncPopup getInstance(@NotNull Project project, @NotNull ActionGroup actions) { | ||
return new NocalhostSyncPopup(project, actions); | ||
} | ||
|
||
public BranchActionGroupPopup asListPopup() { | ||
var statusBar = WindowManager.getInstance().getStatusBar(project); | ||
var popup = new BranchActionGroupPopup("Nocalhost Sync Manage", project, (action) -> false, actions, "Nocalhost.Sync.Manage", DataManager.getInstance().getDataContext(statusBar.getComponent())); | ||
project.getMessageBus().connect(popup).subscribe( | ||
NocalhostSyncUpdateNotifier.NOCALHOST_SYNC_UPDATE_NOTIFIER_TOPIC, | ||
(NocalhostSyncUpdateNotifier) results -> update(popup, results) | ||
); | ||
return popup; | ||
} | ||
|
||
private void update(@NotNull BranchActionGroupPopup popup, @NotNull List<NhctlDevAssociateQueryResult> results) { | ||
List<Object> items = popup.getListStep().getValues(); | ||
items.forEach(x -> { | ||
var item = (PopupFactoryImpl.ActionItem) x; | ||
if (item.getAction() instanceof ServiceActionGroup) { | ||
var group = (ServiceActionGroup) item.getAction(); | ||
results.forEach(it -> { | ||
if (group.compare(it)) { | ||
group.setResult(it); | ||
} | ||
}); | ||
} | ||
}); | ||
popup.update(); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
src/233/main/java/dev/nocalhost/plugin/intellij/utils/FileChooseUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package dev.nocalhost.plugin.intellij.utils; | ||
|
||
import com.intellij.openapi.fileChooser.FileChooser; | ||
import com.intellij.openapi.fileChooser.FileChooserDescriptor; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.LocalFileSystem; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public final class FileChooseUtil { | ||
public static FileChooserDescriptor singleFileChooserDescriptor() { | ||
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false); | ||
return fileChooserDescriptor; | ||
} | ||
|
||
public static FileChooserDescriptor singleDirectoryChooserDescriptor() { | ||
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false); | ||
return fileChooserDescriptor; | ||
} | ||
|
||
public static Path chooseSingleFile(Project project) { | ||
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) | ||
.withFileFilter(f -> !f.isDirectory()); | ||
VirtualFile virtualFile = FileChooser.chooseFile(fileChooserDescriptor, project, null); | ||
if (virtualFile == null) { | ||
return null; | ||
} | ||
return virtualFile.toNioPath().toAbsolutePath(); | ||
} | ||
|
||
public static Path chooseSingleFile(Project project, String title, Path root, Set<String> filenames) { | ||
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) | ||
.withTitle(title) | ||
.withRoots(LocalFileSystem.getInstance().findFileByNioFile(root)) | ||
.withFileFilter(f -> !f.isDirectory() && filenames.contains(f.getName())); | ||
VirtualFile virtualFile = FileChooser.chooseFile(fileChooserDescriptor, project, null); | ||
if (virtualFile == null) { | ||
return null; | ||
} | ||
return virtualFile.toNioPath().toAbsolutePath(); | ||
} | ||
|
||
public static Path chooseSingleDirectory(Project project) { | ||
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false) | ||
.withFileFilter(VirtualFile::isDirectory); | ||
VirtualFile virtualFile = FileChooser.chooseFile(fileChooserDescriptor, project, null); | ||
if (virtualFile == null) { | ||
return null; | ||
} | ||
return virtualFile.toNioPath().toAbsolutePath(); | ||
} | ||
|
||
public static Path chooseSingleDirectory(Project project, String title, String message) { | ||
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false) | ||
.withTitle(title) | ||
.withDescription(message) | ||
.withFileFilter(VirtualFile::isDirectory); | ||
VirtualFile virtualFile = FileChooser.chooseFile(fileChooserDescriptor, project, null); | ||
if (virtualFile == null) { | ||
return null; | ||
} | ||
return virtualFile.toNioPath().toAbsolutePath(); | ||
} | ||
|
||
public static Path chooseSingleFileOrDirectory(Project project) { | ||
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, true, false, false, false, false); | ||
VirtualFile virtualFile = FileChooser.chooseFile(fileChooserDescriptor, project, null); | ||
if (virtualFile == null) { | ||
return null; | ||
} | ||
return virtualFile.toNioPath().toAbsolutePath(); | ||
} | ||
|
||
public static List<Path> chooseFilesAndDirectories(Project project) { | ||
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, true, false, false, false, true); | ||
VirtualFile[] virtualFiles = FileChooser.chooseFiles(fileChooserDescriptor, project, null); | ||
return Arrays.stream(virtualFiles).map(e -> e.toNioPath()).collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters