CVS: check authorization inside doNext() before actually doNext() for default project...
[fedora-idea.git] / plugins / cvs / cvs-plugin / src / com / intellij / cvsSupport2 / ui / experts / CvsWizard.java
blob4b14ec5be78171ef907df2d425e1f285966a985a
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.cvsSupport2.ui.experts;
18 import com.intellij.ide.wizard.AbstractWizard;
19 import com.intellij.openapi.project.Project;
21 import javax.swing.*;
23 /**
24 * author: lesya
26 public class CvsWizard extends AbstractWizard<WizardStep> {
27 protected CvsWizard(String title, Project project) {
28 super(title, project);
31 protected void init() {
32 super.init();
33 SwingUtilities.invokeLater(new Runnable() {
34 public void run() {
35 updateStep();
37 });
40 protected String getHelpID() {
41 return null;
44 @Override
45 protected void doNextAction() {
46 if ((myCurrentStep + 1) >= mySteps.size()) return;
47 final WizardStep nextStep = mySteps.get(myCurrentStep + 1);
48 if (! nextStep.preNextCheck()) {
49 return;
52 super.doNextAction();
55 public void updateStep() {
56 super.updateStep();
57 if (getNumberOfSteps() == 0) return;
58 WizardStep currentStep = getCurrentStepObject();
59 if (!currentStep.setActive()){
60 doPreviousAction();
61 return;
63 currentStep.getPreferredFocusedComponent().requestFocus();
64 if (!currentStep.nextIsEnabled()) {
65 getNextButton().setEnabled(false);
66 getFinishButton().setEnabled(false);
68 else {
69 getFinishButton().setEnabled((getCurrentStep() + 1) == getNumberOfSteps());
74 public void disableNextAndFinish() {
75 if (getNextButton().isEnabled() || getFinishButton().isEnabled()) {
76 updateStep();
80 public void enableNextAndFinish() {
81 if ((!getNextButton().isEnabled()) || (!getFinishButton().isEnabled())) {
82 updateStep();
86 protected void doOKAction() {
87 for (final WizardStep step : mySteps) {
88 step.saveState();
90 super.doOKAction();
93 public void dispose() {
94 try {
95 for (final WizardStep step : mySteps) {
96 step.dispose();
99 finally {
100 super.dispose();
104 public void goToPrevious() {
105 doPreviousAction();