Skip to content

Commit

Permalink
Automatically open the talkthrough after installation
Browse files Browse the repository at this point in the history
  • Loading branch information
eray-felek-sonarsource committed Jan 10, 2025
1 parent 61ccce4 commit 062931f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.sonarlint.intellij;

import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.wm.ToolWindowManager;
import org.jetbrains.annotations.NotNull;

public class OpenWelcomePageOnceOneProjectOpened implements StartupActivity {

@Override
public void runActivity(@NotNull Project project) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
return;
}

var properties = PropertiesComponent.getInstance();
var hasWalkthroughRunOnce = "hasWalkthroughRunOnce";

if (!properties.getBoolean(hasWalkthroughRunOnce, false)) {
properties.setValue(hasWalkthroughRunOnce, true);
openWelcomePage(project);
}
}

private static void openWelcomePage(Project project) {
var toolWindow = ToolWindowManager.getInstance(project).getToolWindow("Welcome to SonarQube for IDE");

if (toolWindow == null) {
return;
}

toolWindow.show();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ public class SonarLintWalkthroughToolWindow implements ToolWindowFactory, DumbAw
protected static final String FONT = "Arial";
protected static final String EDITOR_PANE_TYPE = "text/html";
protected static final String PREVIOUS = "Previous";
protected static final int width = 300;
protected static final int height = 200;

@Override
public void createToolWindowContent(Project project, ToolWindow toolWindow) {
var font = UIUtil.getLabelFont();
var mainPanel = new JPanel(new CardLayout());
mainPanel.setPreferredSize(new Dimension(70, 100));
mainPanel.setPreferredSize(new Dimension(width, height));

var welcomePage = new JPanel(new BorderLayout());
var learnAsYouCodePage = new JPanel(new BorderLayout());
Expand All @@ -90,7 +92,7 @@ public void createToolWindowContent(Project project, ToolWindow toolWindow) {

var welcomePageScrollPane = new JScrollPane(welcomePageText);
welcomePageScrollPane.setBorder(null);
welcomePageScrollPane.setPreferredSize(new Dimension(70, 100));
welcomePageScrollPane.setPreferredSize(new Dimension(width, height));

var welcomePageNextButton = new JButton("Next: Learn as you code");

Expand All @@ -110,7 +112,7 @@ public void createToolWindowContent(Project project, ToolWindow toolWindow) {

var learnAsYouCodeScrollPane = new JScrollPane(learnAsYouCodeText);
learnAsYouCodeScrollPane.setBorder(null);
learnAsYouCodeScrollPane.setPreferredSize(new Dimension(70, 100));
learnAsYouCodeScrollPane.setPreferredSize(new Dimension(width, height));

var learnAsYouCodePageBackButton = new JButton(PREVIOUS);
var learnAsYouCodePageNextButton = new JButton("Next: Connect with your team");
Expand All @@ -133,7 +135,7 @@ public void createToolWindowContent(Project project, ToolWindow toolWindow) {

var connectWithYourTeamScrollPane = new JScrollPane(connectWithYourTeamDescription);
connectWithYourTeamScrollPane.setBorder(null);
connectWithYourTeamScrollPane.setPreferredSize(new Dimension(70, 100));
connectWithYourTeamScrollPane.setPreferredSize(new Dimension(width, height));
var connectWithYourTeamBackButton = new JButton(PREVIOUS);
var connectWithYourTeamNextButton = new JButton("Next: Reach out to us");

Expand All @@ -157,7 +159,7 @@ public void createToolWindowContent(Project project, ToolWindow toolWindow) {

var reachOutToUsPane = new JScrollPane(reachOutToUsDescription);
reachOutToUsPane.setBorder(null);
reachOutToUsPane.setPreferredSize(new Dimension(70, 100));
reachOutToUsPane.setPreferredSize(new Dimension(width, 100));
var reachOutToUsBackButton = new JButton(PREVIOUS);

var reachOutToUsBackButtonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
<moduleService serviceImplementation="org.sonarlint.intellij.config.module.SonarLintModuleSettingsStore"/>

<postStartupActivity implementation="org.sonarlint.intellij.StartServicesOnProjectOpened"/>
<postStartupActivity implementation="org.sonarlint.intellij.OpenWelcomePageOnceOneProjectOpened"/>

<notificationGroup id="SonarQube for IDE: In Context Promotions"
displayType="BALLOON"/>
Expand Down

0 comments on commit 062931f

Please sign in to comment.