Skip to content

Commit

Permalink
Do refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
eray-felek-sonarsource committed Jan 9, 2025
1 parent 48b4e1c commit 61ccce4
Showing 1 changed file with 30 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ public void createToolWindowContent(Project project, ToolWindow toolWindow) {
mainPanel.add(connectWithYourTeamPage, PAGE_3);
mainPanel.add(reachOutToUsPage, "Page 4");

addButtons(welcomePageNextButton, mainPanel, learnAsYouCodePageBackButton, learnAsYouCodePageNextButton,
addButtonActionListeners(welcomePageNextButton, mainPanel, learnAsYouCodePageBackButton, learnAsYouCodePageNextButton,
connectWithYourTeamBackButton, connectWithYourTeamNextButton, reachOutToUsBackButton);

var contentFactory = ContentFactory.getInstance();
var content = contentFactory.createContent(mainPanel, "", false);
toolWindow.getContentManager().addContent(content);
}

private static void addButtons(JButton welcomePageNextButton, JPanel mainPanel, JButton learnAsYouCodePageBackButton,
private static void addButtonActionListeners(JButton welcomePageNextButton, JPanel mainPanel, JButton learnAsYouCodePageBackButton,
JButton learnAsYouCodePageNextButton, JButton connectWithYourTeamBackButton, JButton connectWithYourTeamNextButton,
JButton reachOutToUsBackButton) {
welcomePageNextButton.addActionListener(e -> {
Expand Down Expand Up @@ -220,36 +220,38 @@ private static void createWelcomePageLayout(JLabel stepLabel, JLabel titleLabel,

var centerPanel = createCenterPanel(stepLabel, titleLabel, welcomePageScrollPane, gbc);

gbc.gridy = 3;
gbc.anchor = GridBagConstraints.SOUTHEAST;
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0;
gbc.weighty = 0;

provideCommonButtonConstraints(gbc);

centerPanel.add(welcomePageNextButtonPanel, gbc);

welcomePagePanel.add(welcomePageImageLabel, BorderLayout.NORTH);
welcomePagePanel.add(centerPanel, BorderLayout.CENTER);
}

private static void provideCommonButtonConstraints(GridBagConstraints gbc) {
gbc.gridy = 3;
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0;
gbc.weighty = 0;
}

private static void createLearnAsYouCodePageLayout(JLabel stepLabel, JLabel label, JScrollPane pane,
JPanel backButtonPanel, JPanel nextButtonPanel,
JPanel page, JLabel imageLabel) {
var gbc = new GridBagConstraints();

var centerPanel = createCenterPanel(stepLabel, label, pane, gbc);

gbc.gridy = 3;
gbc.anchor = GridBagConstraints.SOUTHWEST;
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0;
gbc.weighty = 0;

provideCommonButtonConstraints(gbc);

centerPanel.add(backButtonPanel, gbc);

gbc.gridy = 3;
gbc.anchor = GridBagConstraints.SOUTHEAST;
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0;
gbc.weighty = 0;

centerPanel.add(nextButtonPanel, gbc);

page.add(imageLabel, BorderLayout.NORTH);
Expand All @@ -260,23 +262,19 @@ private static void createConnectWithYourTeamLayout(JLabel stepLabel, JLabel con
JScrollPane connectWithYourTeamPane,
JPanel connectWithYourTeamBackButtonPanel, JPanel connectWithYourTeamNextButtonPanel,
JPanel page, JLabel imageLabel) {
var gbc3 = new GridBagConstraints();
var gbc = new GridBagConstraints();

var page3CenterPanel = createCenterPanel(stepLabel, connectWithYourTeamLabel, connectWithYourTeamPane, gbc);

var page3CenterPanel = createCenterPanel(stepLabel, connectWithYourTeamLabel, connectWithYourTeamPane, gbc3);
gbc.anchor = GridBagConstraints.SOUTHEAST;

provideCommonButtonConstraints(gbc);

gbc3.gridy = 3;
gbc3.anchor = GridBagConstraints.SOUTHEAST;
gbc3.fill = GridBagConstraints.NONE;
gbc3.weightx = 0;
gbc3.weighty = 0;
page3CenterPanel.add(connectWithYourTeamNextButtonPanel, gbc3);
page3CenterPanel.add(connectWithYourTeamNextButtonPanel, gbc);

gbc3.gridy = 3;
gbc3.anchor = GridBagConstraints.SOUTHWEST;
gbc3.fill = GridBagConstraints.NONE;
gbc3.weightx = 0;
gbc3.weighty = 0;
page3CenterPanel.add(connectWithYourTeamBackButtonPanel, gbc3);
gbc.anchor = GridBagConstraints.SOUTHWEST;

page3CenterPanel.add(connectWithYourTeamBackButtonPanel, gbc);

page.add(imageLabel, BorderLayout.NORTH);
page.add(page3CenterPanel, BorderLayout.CENTER);
Expand All @@ -292,18 +290,14 @@ private static void createReachOutToUsPageLayout(JLabel stepLabel, Project proje
var closeButtonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
closeButtonPanel.add(closeButton);

gbc.gridy = 3;
gbc.anchor = GridBagConstraints.SOUTHWEST;
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0;
gbc.weighty = 0;

provideCommonButtonConstraints(gbc);

page4CenterPanel.add(backButtonPanel, gbc);

gbc.gridy = 3;
gbc.anchor = GridBagConstraints.SOUTHEAST;
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0;
gbc.weighty = 0;

page4CenterPanel.add(closeButtonPanel, gbc);

panel.add(imageLabel, BorderLayout.NORTH);
Expand Down

0 comments on commit 61ccce4

Please sign in to comment.