update copyright
[fedora-idea.git] / plugins / ui-designer / src / com / intellij / uiDesigner / wizard / DataBindingWizard.java
blob08b9afeac46366429afbfcd92bec1cf773e7e9f8
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.uiDesigner.wizard;
18 import com.intellij.CommonBundle;
19 import com.intellij.ide.wizard.AbstractWizard;
20 import com.intellij.openapi.application.ApplicationManager;
21 import com.intellij.openapi.command.CommandProcessor;
22 import com.intellij.openapi.diagnostic.Logger;
23 import com.intellij.openapi.project.Project;
24 import com.intellij.openapi.ui.Messages;
25 import com.intellij.openapi.vfs.VirtualFile;
26 import com.intellij.uiDesigner.UIDesignerBundle;
27 import org.jetbrains.annotations.NotNull;
29 import javax.swing.*;
31 /**
32 * @author Anton Katilin
33 * @author Vladimir Kondratyev
35 public final class DataBindingWizard extends AbstractWizard{
36 private static final Logger LOG = Logger.getInstance("#com.intellij.uiDesigner.wizard.DataBindingWizard");
37 private final WizardData myData;
38 private final Project myProject;
39 private final BeanStep myBeanStep;
41 public DataBindingWizard(@NotNull final Project project, @NotNull final VirtualFile formFile, @NotNull final WizardData data) {
42 super(UIDesignerBundle.message("title.data.binding.wizard"), project);
43 myProject = project;
44 myData = data;
46 myBeanStep = new BeanStep(myData);
47 addStep(myBeanStep);
48 addStep(new BindCompositeStep(myData));
50 init();
52 if (!data.myBindToNewBean) {
53 doNextAction();
57 public JComponent getPreferredFocusedComponent() {
58 return myBeanStep.myTfShortClassName;
61 protected void updateStep() {
62 super.updateStep();
63 // "Finish" button is enabled only at the last step
64 getFinishButton().setEnabled(getCurrentStep() == mySteps.size() - 1);
67 protected void doOKAction() {
68 CommandProcessor.getInstance().executeCommand(
69 myProject,
70 new Runnable() {
71 public void run() {
72 ApplicationManager.getApplication().runWriteAction(
73 new Runnable() {
74 public void run() {
75 try {
76 Generator.generateDataBindingMethods(myData);
77 DataBindingWizard.super.doOKAction();
79 catch (Generator.MyException exc) {
80 Messages.showErrorDialog(
81 getContentPane(),
82 exc.getMessage(),
83 CommonBundle.getErrorTitle()
91 "",
92 null
96 protected String getHelpID() {
97 return "guiDesigner.formCode.dataBind";