-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actions for refreshing managed dependencies and clearing haxelib cache
- Loading branch information
Showing
12 changed files
with
214 additions
and
61 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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/intellij/plugins/haxe/haxelib/HaxelibNotifier.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,26 @@ | ||
package com.intellij.plugins.haxe.haxelib; | ||
|
||
import com.intellij.notification.NotificationGroupManager; | ||
import com.intellij.notification.NotificationType; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.plugins.haxe.HaxeBundle; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class HaxelibNotifier { | ||
|
||
public static void notifyMissingLib(@Nullable Project project, String content) { | ||
NotificationGroupManager.getInstance() | ||
.getNotificationGroup("haxe.haxelib.warning") | ||
.createNotification(content, NotificationType.WARNING) | ||
.setTitle(HaxeBundle.message("haxe.haxelib.library.dependencies")) | ||
.setContent(HaxeBundle.message("haxe.haxelib.library.missing", content)) | ||
//.addAction(new DumbAwareAction() { | ||
// //TODO create haxelib install logic | ||
// @Override | ||
// public void actionPerformed(@NotNull AnActionEvent e) { | ||
// | ||
// } | ||
//}) | ||
.notify(project); | ||
} | ||
} |
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
57 changes: 57 additions & 0 deletions
57
src/main/java/com/intellij/plugins/haxe/ide/actions/haxelib/ClearHaxeLibCacheAction.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,57 @@ | ||
package com.intellij.plugins.haxe.ide.actions.haxelib; | ||
|
||
import com.intellij.openapi.actionSystem.*; | ||
import com.intellij.openapi.project.DumbAware; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.plugins.haxe.buildsystem.hxml.psi.HXMLFile; | ||
import com.intellij.plugins.haxe.buildsystem.lime.LimeOpenFlUtil; | ||
import com.intellij.plugins.haxe.haxelib.HaxelibCache; | ||
import com.intellij.psi.xml.XmlFile; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class ClearHaxeLibCacheAction extends AnAction implements DumbAware { | ||
@Override | ||
public @NotNull ActionUpdateThread getActionUpdateThread() { | ||
return ActionUpdateThread.BGT; | ||
} | ||
|
||
@Override | ||
public void update(@NotNull AnActionEvent event) { | ||
super.update(event); | ||
Presentation p = event.getPresentation(); | ||
p.setEnabled(isAvailable(event)); | ||
p.setVisible(isVisible(event)); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(@NotNull AnActionEvent event) { | ||
HaxelibCache.getInstance().reload(); | ||
} | ||
|
||
protected boolean isAvailable(AnActionEvent e) { | ||
return getProject(e) != null && isVisible(e); | ||
} | ||
|
||
protected boolean isVisible(AnActionEvent e) { | ||
return switch (e.getPlace()) { | ||
case "EditorPopup" -> isProjectFile(e); | ||
case "ProjectViewPopup" -> true; | ||
default -> false; | ||
}; | ||
} | ||
|
||
private static boolean isProjectFile(AnActionEvent e) { | ||
Object file = e.getDataContext().getData("psi.File"); | ||
if (file instanceof XmlFile xmlFile) { | ||
return LimeOpenFlUtil.isLimeFile(xmlFile) || LimeOpenFlUtil.isOpenFlFile(xmlFile); | ||
} | ||
return file instanceof HXMLFile; | ||
} | ||
|
||
@Nullable | ||
private static Project getProject(AnActionEvent e) { | ||
DataContext context = e.getDataContext(); | ||
return CommonDataKeys.PROJECT.getData(context); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...main/java/com/intellij/plugins/haxe/ide/actions/haxelib/SyncProjectLibraryListAction.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,57 @@ | ||
package com.intellij.plugins.haxe.ide.actions.haxelib; | ||
|
||
import com.intellij.openapi.actionSystem.*; | ||
import com.intellij.openapi.project.DumbAware; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.plugins.haxe.buildsystem.hxml.psi.HXMLFile; | ||
import com.intellij.plugins.haxe.buildsystem.lime.LimeOpenFlUtil; | ||
import com.intellij.plugins.haxe.haxelib.HaxelibProjectUpdater; | ||
import com.intellij.psi.xml.XmlFile; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class SyncProjectLibraryListAction extends AnAction implements DumbAware { | ||
|
||
@Override | ||
public void update(@NotNull AnActionEvent event) { | ||
super.update(event); | ||
Presentation p = event.getPresentation(); | ||
p.setEnabled(isAvailable(event)); | ||
p.setVisible(isVisible(event)); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(@NotNull AnActionEvent e) { | ||
HaxelibProjectUpdater instance = HaxelibProjectUpdater.INSTANCE; | ||
Project project = getProject(e); | ||
HaxelibProjectUpdater.ProjectTracker tracker = instance.findProjectTracker(project); | ||
if(tracker!= null) instance.synchronizeClasspaths(tracker); | ||
} | ||
|
||
protected boolean isAvailable(AnActionEvent e) { | ||
return getProject(e) != null && isVisible(e); | ||
} | ||
|
||
protected boolean isVisible(AnActionEvent e) { | ||
return switch (e.getPlace()) { | ||
case "EditorPopup" -> isProjectFile(e); | ||
case "ProjectViewPopup" -> true; | ||
default -> false; | ||
}; | ||
} | ||
|
||
private static boolean isProjectFile(AnActionEvent e) { | ||
Object file = e.getDataContext().getData("psi.File"); | ||
if (file instanceof XmlFile xmlFile) { | ||
return LimeOpenFlUtil.isLimeFile(xmlFile) || LimeOpenFlUtil.isOpenFlFile(xmlFile); | ||
} | ||
return file instanceof HXMLFile; | ||
} | ||
|
||
@Nullable | ||
private static Project getProject(AnActionEvent e) { | ||
DataContext context = e.getDataContext(); | ||
return CommonDataKeys.PROJECT.getData(context); | ||
} | ||
|
||
} |
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
Oops, something went wrong.