Search in sources :

Example 1 with DiscordIntegrationProjectComponent

use of com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationProjectComponent in project Intellij-Discord-Integration by Almighty-Alpaca.

the class ToolsMenuDisableAnAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getData(PlatformDataKeys.PROJECT);
    if (project == null)
        return;
    DiscordIntegrationApplicationComponent applicationComponent = DiscordIntegrationApplicationComponent.getInstance();
    DiscordIntegrationProjectComponent projectComponent = DiscordIntegrationProjectComponent.getInstance(project);
    InstanceInfo instanceInfo = applicationComponent.getInstanceInfo();
    if (projectComponent != null) {
        ProjectInfo projectInfo = projectComponent.getProjectInfo();
        ProjectSettingsStorage settings = DiscordIntegrationProjectSettings.getInstance(project).getState();
        settings.setEnabled(!settings.isEnabled());
        applicationComponent.updateData(data -> data.projectSetSettings(System.currentTimeMillis(), instanceInfo, projectInfo, settings));
        update(e);
        DiscordIntegrationProjectConfigurable.getInstance(project).reset();
    }
}
Also used : Project(com.intellij.openapi.project.Project) ProjectSettingsStorage(com.almightyalpaca.jetbrains.plugins.discord.settings.data.storage.ProjectSettingsStorage) DiscordIntegrationProjectComponent(com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationProjectComponent) ProjectInfo(com.almightyalpaca.jetbrains.plugins.discord.data.ProjectInfo) DiscordIntegrationApplicationComponent(com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationApplicationComponent) InstanceInfo(com.almightyalpaca.jetbrains.plugins.discord.data.InstanceInfo)

Example 2 with DiscordIntegrationProjectComponent

use of com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationProjectComponent in project Intellij-Discord-Integration by Almighty-Alpaca.

the class EditorMouseListener method mousePressed.

@Override
public void mousePressed(EditorMouseEvent event) {
    LOG.trace("EditorMouseListener#mousePressed({})", event);
    FileDocumentManager documentManager = FileDocumentManager.getInstance();
    Project project = event.getEditor().getProject();
    DiscordIntegrationProjectComponent component = DiscordIntegrationProjectComponent.getInstance(project);
    if (component != null)
        component.updateTimeAccessed(documentManager.getFile(event.getEditor().getDocument()));
}
Also used : Project(com.intellij.openapi.project.Project) DiscordIntegrationProjectComponent(com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationProjectComponent) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager)

Example 3 with DiscordIntegrationProjectComponent

use of com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationProjectComponent in project Intellij-Discord-Integration by Almighty-Alpaca.

the class FileDocumentManagerListener method beforeDocumentSaving.

@Override
public void beforeDocumentSaving(@NotNull Document document) {
    LOG.trace("FileDocumentManagerListener#beforeDocumentSaving({})", document);
    Editor[] editors = EditorFactory.getInstance().getEditors(document);
    FileDocumentManager documentManager = FileDocumentManager.getInstance();
    for (Editor editor : editors) {
        Project project = editor.getProject();
        DiscordIntegrationProjectComponent component = DiscordIntegrationProjectComponent.getInstance(project);
        if (component != null)
            component.updateTimeAccessed(documentManager.getFile(document));
    }
}
Also used : Project(com.intellij.openapi.project.Project) DiscordIntegrationProjectComponent(com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationProjectComponent) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) Editor(com.intellij.openapi.editor.Editor)

Example 4 with DiscordIntegrationProjectComponent

use of com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationProjectComponent in project Intellij-Discord-Integration by Almighty-Alpaca.

the class FileEditorManagerListener method fileOpened.

@Override
public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
    LOG.trace("FileEditorManagerListener#fileOpened({}, {})", source, file);
    Project project = source.getProject();
    DiscordIntegrationProjectComponent component = DiscordIntegrationProjectComponent.getInstance(project);
    if (component != null)
        component.fileUpdateTimeAccessed(file);
}
Also used : Project(com.intellij.openapi.project.Project) DiscordIntegrationProjectComponent(com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationProjectComponent)

Example 5 with DiscordIntegrationProjectComponent

use of com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationProjectComponent in project Intellij-Discord-Integration by Almighty-Alpaca.

the class FileEditorManagerListener method selectionChanged.

@Override
public void selectionChanged(@NotNull FileEditorManagerEvent event) {
    LOG.trace("FileEditorManagerListener#selectionChanged({})", event);
    Project project = event.getManager().getProject();
    DiscordIntegrationProjectComponent component = DiscordIntegrationProjectComponent.getInstance(project);
    if (component != null)
        component.fileUpdateTimeAccessed(event.getNewFile());
}
Also used : Project(com.intellij.openapi.project.Project) DiscordIntegrationProjectComponent(com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationProjectComponent)

Aggregations

DiscordIntegrationProjectComponent (com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationProjectComponent)10 Project (com.intellij.openapi.project.Project)9 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)5 Editor (com.intellij.openapi.editor.Editor)3 InstanceInfo (com.almightyalpaca.jetbrains.plugins.discord.data.InstanceInfo)2 ProjectInfo (com.almightyalpaca.jetbrains.plugins.discord.data.ProjectInfo)2 Document (com.intellij.openapi.editor.Document)2 DiscordIntegrationApplicationComponent (com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationApplicationComponent)1 ProjectSettingsStorage (com.almightyalpaca.jetbrains.plugins.discord.settings.data.storage.ProjectSettingsStorage)1