Search in sources :

Example 1 with ProjectInfo

use of com.almightyalpaca.jetbrains.plugins.discord.data.ProjectInfo 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 ProjectInfo

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

the class PresenceRenderer method apply.

@Nullable
@Override
public DiscordRichPresence apply(@NotNull PresenceRenderContext context) {
    LOG.trace("DiscordRichPresence#apply({})", context);
    if (context.isEmpty())
        return null;
    InstanceInfo instance = context.getInstance();
    ProjectInfo project = context.getProject();
    FileInfo file = context.getFile();
    DiscordRichPresence presence = new DiscordRichPresence();
    if (instance != null) {
        InstanceInfo.DistributionInfo distribution = instance.getDistribution();
        if (project != null) {
            presence.details = "Working on " + project.getName();
            presence.startTimestamp = project.getTimeOpened() / 1000;
            if (project.getSettings().getDescription() != null) {
                presence.state = project.getSettings().getDescription();
            } else if (file != null && instance.getSettings().isShowFiles()) {
                presence.state = (file.isReadOnly() && instance.getSettings().isShowReadingInsteadOfWriting() ? "Reading " : "Editing ") + (instance.getSettings().isShowFileExtensions() ? file.getName() : file.getBaseName());
                presence.largeImageKey = file.getAssetName(instance.getSettings().isShowUnknownImageFile()) + "-large";
                presence.largeImageText = file.getLanguageName();
                presence.smallImageKey = distribution.getAssetName(instance.getSettings().isShowUnknownImageIDE()) + "-small";
                presence.smallImageText = "Using " + distribution.getName() + " version " + distribution.getVersion();
            }
        }
        if (presence.largeImageKey == null || presence.largeImageKey.equals("none-large")) {
            presence.largeImageKey = distribution.getAssetName(instance.getSettings().isShowUnknownImageIDE()) + "-large";
            presence.largeImageText = "Using " + distribution.getName() + " version " + distribution.getVersion();
            presence.smallImageKey = null;
            presence.smallImageText = null;
        }
    }
    return presence;
}
Also used : FileInfo(com.almightyalpaca.jetbrains.plugins.discord.data.FileInfo) ProjectInfo(com.almightyalpaca.jetbrains.plugins.discord.data.ProjectInfo) InstanceInfo(com.almightyalpaca.jetbrains.plugins.discord.data.InstanceInfo) DiscordRichPresence(club.minnced.discord.rpc.DiscordRichPresence) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with ProjectInfo

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

the class DiscordIntegrationProjectConfigurable method apply.

@Override
public void apply() {
    if (this.panel != null) {
        this.panel.apply();
        InstanceInfo instance = this.applicationComponent.getInstanceInfo();
        DiscordIntegrationProjectComponent component = DiscordIntegrationProjectComponent.getInstance(this.settingsProviderProject.getProject());
        if (component != null) {
            ProjectInfo project = component.getProjectInfo();
            this.applicationComponent.updateData(data -> data.instanceSetSettings(System.currentTimeMillis(), instance, this.settingsProviderApplication.getSettings()));
            this.applicationComponent.updateData(data -> data.projectSetSettings(System.currentTimeMillis(), instance, project, this.settingsProviderProject.getSettings()));
            this.applicationComponent.checkExperiementalWindowListener();
        }
    }
}
Also used : DiscordIntegrationProjectComponent(com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationProjectComponent) ProjectInfo(com.almightyalpaca.jetbrains.plugins.discord.data.ProjectInfo) InstanceInfo(com.almightyalpaca.jetbrains.plugins.discord.data.InstanceInfo)

Example 4 with ProjectInfo

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

the class DiscordIntegrationProjectComponent method projectOpened.

@Override
public synchronized void projectOpened() {
    ProjectInfo projectInfo = new ProjectInfo(this.project);
    this.projectInfo = projectInfo;
    this.applicationComponent.updateData(data -> data.projectAdd(System.currentTimeMillis(), this.applicationComponent.getInstanceInfo(), projectInfo));
}
Also used : ProjectInfo(com.almightyalpaca.jetbrains.plugins.discord.data.ProjectInfo)

Aggregations

ProjectInfo (com.almightyalpaca.jetbrains.plugins.discord.data.ProjectInfo)4 InstanceInfo (com.almightyalpaca.jetbrains.plugins.discord.data.InstanceInfo)3 DiscordIntegrationProjectComponent (com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationProjectComponent)2 DiscordRichPresence (club.minnced.discord.rpc.DiscordRichPresence)1 DiscordIntegrationApplicationComponent (com.almightyalpaca.jetbrains.plugins.discord.components.DiscordIntegrationApplicationComponent)1 FileInfo (com.almightyalpaca.jetbrains.plugins.discord.data.FileInfo)1 ProjectSettingsStorage (com.almightyalpaca.jetbrains.plugins.discord.settings.data.storage.ProjectSettingsStorage)1 Project (com.intellij.openapi.project.Project)1 Nullable (org.jetbrains.annotations.Nullable)1