Skip to content

Commit

Permalink
Improvement: Convert projectComponent to poststartupactivity (#503)
Browse files Browse the repository at this point in the history
Convert InitialConfigurationComponent from project component to postStartupActivity
  • Loading branch information
robert3005 authored Jul 6, 2021
1 parent 69279a7 commit 03439c6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-503.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Convert InitialConfigurationComponent from project component to postStartupActivity
links:
- https://github.com/palantir/palantir-java-format/pull/503
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Google Inc. All Rights Reserved.
* (c) Copyright 2021 Palantir Technologies Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,17 +16,14 @@

package com.palantir.javaformat.intellij;

import com.intellij.openapi.components.ProjectComponent;

final class InitialConfigurationComponent implements ProjectComponent {
private final PalantirJavaFormatSettings settings;

public InitialConfigurationComponent(PalantirJavaFormatSettings settings) {
this.settings = settings;
}
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import org.jetbrains.annotations.NotNull;

public final class InitialConfigurationStartupActivity implements StartupActivity.DumbAware {
@Override
public void projectOpened() {
public void runActivity(@NotNull Project project) {
PalantirJavaFormatSettings settings = PalantirJavaFormatSettings.getInstance(project);
if (settings.isUninitialized()) {
settings.setEnabled(false);
}
Expand Down
9 changes: 1 addition & 8 deletions idea-plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
-->
<depends>com.intellij.modules.java</depends>

<project-components>
<component>
<implementation-class>
com.palantir.javaformat.intellij.InitialConfigurationComponent
</implementation-class>
</component>
</project-components>

<extensions defaultExtensionNs="com.intellij">
<projectConfigurable instance="com.palantir.javaformat.intellij.PalantirJavaFormatConfigurable"
id="palantir-java-format.settings"
Expand All @@ -26,6 +18,7 @@
<projectService serviceInterface="com.intellij.psi.codeStyle.CodeStyleManager"
serviceImplementation="com.palantir.javaformat.intellij.PalantirCodeStyleManager"
overrides="true"/>
<postStartupActivity implementation="com.palantir.javaformat.intellij.InitialConfigurationStartupActivity"/>
</extensions>

</idea-plugin>

0 comments on commit 03439c6

Please sign in to comment.