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.
17 package com.intellij.codeInspection.export;
19 import com.intellij.codeEditor.printing.ExportToHTMLSettings;
20 import com.intellij.codeInspection.InspectionsBundle;
21 import com.intellij.openapi.project.Project;
22 import com.intellij.openapi.ui.DialogWrapper;
23 import com.intellij.openapi.ui.TextFieldWithBrowseButton;
24 import com.intellij.ui.OptionGroup;
28 public class ExportToHTMLDialog extends DialogWrapper{
29 private final Project myProject;
30 protected JCheckBox myCbOpenInBrowser;
31 protected TextFieldWithBrowseButton myTargetDirectoryField;
32 protected final boolean myCanBeOpenInBrowser;
34 public ExportToHTMLDialog(Project project, final boolean canBeOpenInBrowser) {
37 myCanBeOpenInBrowser = canBeOpenInBrowser;
38 setOKButtonText(InspectionsBundle.message("inspection.export.save.button"));
39 setTitle(InspectionsBundle.message("inspection.export.dialog.title"));
44 protected JComponent createNorthPanel() {
45 OptionGroup optionGroup = new OptionGroup();
47 myTargetDirectoryField = new TextFieldWithBrowseButton();
48 optionGroup.add(com.intellij.codeEditor.printing.ExportToHTMLDialog.assignLabel(myTargetDirectoryField, myProject));
50 return optionGroup.createPanel();
54 protected JComponent createCenterPanel() {
55 if (!myCanBeOpenInBrowser) return null;
56 OptionGroup optionGroup = new OptionGroup();
58 addOptions(optionGroup);
60 return optionGroup.createPanel();
63 protected void addOptions(OptionGroup optionGroup) {
64 myCbOpenInBrowser = new JCheckBox();
65 myCbOpenInBrowser.setText(InspectionsBundle.message("inspection.export.open.option"));
66 optionGroup.add(myCbOpenInBrowser);
70 ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(myProject);
71 if (myCanBeOpenInBrowser) {
72 myCbOpenInBrowser.setSelected(exportToHTMLSettings.OPEN_IN_BROWSER);
74 myTargetDirectoryField.setText(exportToHTMLSettings.OUTPUT_DIRECTORY);
78 ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(myProject);
80 if (myCanBeOpenInBrowser) {
81 exportToHTMLSettings.OPEN_IN_BROWSER = myCbOpenInBrowser.isSelected();
83 exportToHTMLSettings.OUTPUT_DIRECTORY = myTargetDirectoryField.getText();