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();
}
}
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;
}
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();
}
}
}
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));
}
Aggregations