fix wizard buttons on Mac (IDEA-79302)

This commit is contained in:
kirill.safonov
2011-12-26 16:44:39 +04:00
parent c660c3eeb3
commit 083fdfbd62
2 changed files with 24 additions and 4 deletions
@@ -358,7 +358,7 @@ public abstract class AbstractWizard<T extends Step> 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<T extends Step> 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<T extends Step> 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;
}
@@ -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<AbstractWizardStepEx> {
return;
}
if (isLastStep()) {
doOKAction();
return;
}
myCurrentStep = getNextStep(myCurrentStep);
updateStep();
}
@@ -112,6 +117,7 @@ public class AbstractWizardEx extends AbstractWizard<AbstractWizardStepEx> {
return getCurrentStepObject().getHelpId();
}
protected void updateStep() {
super.updateStep();
updateButtons();
@@ -124,9 +130,19 @@ public class AbstractWizardEx extends AbstractWizard<AbstractWizardStepEx> {
}
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() {