From 083fdfbd6284f4b6c5faf96159c8874735083069 Mon Sep 17 00:00:00 2001 From: "kirill.safonov" Date: Mon, 26 Dec 2011 16:41:55 +0400 Subject: [PATCH] fix wizard buttons on Mac (IDEA-79302) --- .../intellij/ide/wizard/AbstractWizard.java | 10 +++++++--- .../intellij/ide/wizard/AbstractWizardEx.java | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java index 1753af12cf65..f6e6c3b2d616 100644 --- a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java +++ b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java @@ -358,7 +358,7 @@ public abstract class AbstractWizard extends DialogWrapper { protected void doNextAction() { // Commit data of current step final Step currentStep = mySteps.get(myCurrentStep); - boolean lastStep = getCurrentStep() == getNextStep(getCurrentStep()); + boolean lastStep = isLastStep(); LOG.assertTrue(currentStep != null); try { currentStep._commit(false); @@ -432,7 +432,7 @@ public abstract class AbstractWizard extends DialogWrapper { myIcon.setIcon(step.getIcon()); - if (SystemInfo.isMac && myCurrentStep == mySteps.size() - 1) { + if (SystemInfo.isMac && isLastStep()) { myFinishButton.setVisible(false); myNextButton.setText(IdeBundle.message("button.finish")); myNextButton.setVisible(true); @@ -441,13 +441,17 @@ public abstract class AbstractWizard extends DialogWrapper { else { myNextButton.setText(IdeBundle.message("button.wizard.next")); myFinishButton.setVisible(true); - myNextButton.setEnabled(mySteps.size() == 1 || myCurrentStep < mySteps.size() - 1); + myNextButton.setEnabled(mySteps.size() == 1 || !isLastStep()); myNextButton.setMnemonic('N'); } myPreviousButton.setEnabled(myCurrentStep > 0); } + protected boolean isLastStep() { + return myCurrentStep == mySteps.size() - 1; + } + protected JButton getNextButton() { return myNextButton; } diff --git a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizardEx.java b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizardEx.java index 9d2b039e3a19..0bfbf4744851 100644 --- a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizardEx.java +++ b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizardEx.java @@ -19,6 +19,7 @@ package com.intellij.ide.wizard; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.wm.IdeFocusManager; import org.jetbrains.annotations.Nullable; @@ -92,6 +93,10 @@ public class AbstractWizardEx extends AbstractWizard { return; } + if (isLastStep()) { + doOKAction(); + return; + } myCurrentStep = getNextStep(myCurrentStep); updateStep(); } @@ -112,6 +117,7 @@ public class AbstractWizardEx extends AbstractWizard { return getCurrentStepObject().getHelpId(); } + protected void updateStep() { super.updateStep(); updateButtons(); @@ -124,9 +130,19 @@ public class AbstractWizardEx extends AbstractWizard { } private void updateButtons() { - getNextButton().setEnabled(getCurrentStepObject().isComplete() && getCurrentStepObject().getNextStepId() != null); getPreviousButton().setEnabled(getCurrentStepObject().getPreviousStepId() != null); getFinishButton().setEnabled(canFinish()); + + if (SystemInfo.isMac && isLastStep()) { + getNextButton().setEnabled(getFinishButton().isEnabled()); + } + else { + getNextButton().setEnabled(getCurrentStepObject().isComplete() && !isLastStep()); + } + } + + protected boolean isLastStep() { + return myIndex2Step.get(myCurrentStep).getNextStepId() == null; } protected boolean canFinish() {