mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 19:02:13 +07:00
[mac] rework buttons for wizards
This commit is contained in:
@@ -81,7 +81,13 @@ public class NewProjectUtil {
|
||||
if (StorageScheme.DIRECTORY_BASED == dialog.getStorageScheme()) {
|
||||
final File ideaDir = new File(projectFilePath + File.separator + ".idea");
|
||||
if (!ideaDir.exists() && !ideaDir.mkdirs()) {
|
||||
Messages.showErrorDialog("Unable to create '.idea' directory at: " + projectFilePath, "Project initialization failed");
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Messages.showErrorDialog("Unable to create '.idea' directory at: " + projectFilePath, "Project initialization failed");
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -194,7 +200,7 @@ public class NewProjectUtil {
|
||||
final GeneralSettings settings = GeneralSettings.getInstance();
|
||||
int exitCode = settings.getConfirmOpenNewProject();
|
||||
if (exitCode == GeneralSettings.OPEN_PROJECT_ASK) {
|
||||
exitCode = Messages.showOkCancelDialog(IdeBundle.message("prompt.open.project.in.new.frame"), IdeBundle.message("title.new.project"),
|
||||
exitCode = Messages.showOkCancelDialog(projectToClose, IdeBundle.message("prompt.open.project.in.new.frame"), IdeBundle.message("title.new.project"),
|
||||
IdeBundle.message("button.existingframe"), IdeBundle.message("button.newframe"),
|
||||
Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption());
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -139,14 +140,14 @@ public class AddModuleWizard extends AbstractWizard<ModuleWizardStep> {
|
||||
preferredFocusedComponent.requestFocus();
|
||||
}
|
||||
else {
|
||||
if (isLastStep) {
|
||||
if (isLastStep && finishButton.isVisible()) {
|
||||
finishButton.requestFocus();
|
||||
}
|
||||
else {
|
||||
nextButton.requestFocus();
|
||||
}
|
||||
}
|
||||
getRootPane().setDefaultButton(isLastStep ? finishButton : nextButton);
|
||||
getRootPane().setDefaultButton(isLastStep && finishButton.isVisible()? finishButton : nextButton);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -231,9 +232,17 @@ public class AddModuleWizard extends AbstractWizard<ModuleWizardStep> {
|
||||
|
||||
private void updateButtons() {
|
||||
final boolean isLastStep = isLastStep(getCurrentStep());
|
||||
getNextButton().setEnabled(!isLastStep);
|
||||
getFinishButton().setEnabled(isLastStep);
|
||||
getRootPane().setDefaultButton(isLastStep ? getFinishButton() : getNextButton());
|
||||
|
||||
if (SystemInfo.isMac) {
|
||||
getNextButton().setEnabled(true);
|
||||
getFinishButton().setVisible(false);
|
||||
getNextButton().setText(isLastStep ? IdeBundle.message("button.finish") : IdeBundle.message("button.wizard.next"));
|
||||
getRootPane().setDefaultButton(getNextButton());
|
||||
} else {
|
||||
getNextButton().setEnabled(!isLastStep);
|
||||
getFinishButton().setEnabled(isLastStep);
|
||||
getRootPane().setDefaultButton(isLastStep ? getFinishButton() : getNextButton());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLastStep(int step) {
|
||||
|
||||
@@ -124,12 +124,11 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
|
||||
}
|
||||
|
||||
leftPanel.add(myHelpButton);
|
||||
leftPanel.add(myCancelButton);
|
||||
|
||||
panel.add(leftPanel, BorderLayout.WEST);
|
||||
|
||||
buttonPanel.add(myCancelButton);
|
||||
buttonPanel.add(Box.createHorizontalStrut(5));
|
||||
buttonPanel.add(myFinishButton);
|
||||
|
||||
if (mySteps.size() > 1) {
|
||||
buttonPanel.add(Box.createHorizontalStrut(5));
|
||||
buttonPanel.add(myPreviousButton);
|
||||
@@ -326,9 +325,13 @@ 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());
|
||||
LOG.assertTrue(currentStep != null);
|
||||
try {
|
||||
currentStep._commit(false);
|
||||
if (SystemInfo.isMac && lastStep) {
|
||||
doOKAction();
|
||||
}
|
||||
}
|
||||
catch (final CommitStepException exc) {
|
||||
Messages.showErrorDialog(
|
||||
@@ -338,8 +341,10 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
|
||||
return;
|
||||
}
|
||||
|
||||
myCurrentStep = getNextStep(myCurrentStep);
|
||||
updateStep();
|
||||
if (!SystemInfo.isMac || !lastStep) {
|
||||
myCurrentStep = getNextStep(myCurrentStep);
|
||||
updateStep();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -394,7 +399,16 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
|
||||
|
||||
myIcon.setIcon(step.getIcon());
|
||||
|
||||
myNextButton.setEnabled(mySteps.size() == 1 || myCurrentStep < mySteps.size() - 1);
|
||||
if (SystemInfo.isMac && myCurrentStep == mySteps.size() - 1) {
|
||||
myFinishButton.setVisible(false);
|
||||
myNextButton.setText(IdeBundle.message("button.finish"));
|
||||
}
|
||||
else {
|
||||
myNextButton.setText(IdeBundle.message("button.wizard.next"));
|
||||
myFinishButton.setVisible(true);
|
||||
myNextButton.setEnabled(mySteps.size() == 1 || myCurrentStep < mySteps.size() - 1);
|
||||
}
|
||||
|
||||
myPreviousButton.setEnabled(myCurrentStep > 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user