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;
25 import com.intellij.util.ui.GraphicsUtil;
30 public class ExportToHTMLDialog extends DialogWrapper{
31 private final Project myProject;
32 private JCheckBox myCbOpenInBrowser;
33 private TextFieldWithBrowseButton myTargetDirectoryField;
34 private final boolean myCanBeOpenInBrowser;
36 public ExportToHTMLDialog(Project project, final boolean canBeOpenInBrowser) {
39 myCanBeOpenInBrowser = canBeOpenInBrowser;
40 setOKButtonText(InspectionsBundle.message("inspection.export.save.button"));
41 setTitle(InspectionsBundle.message("inspection.export.dialog.title"));
46 protected JComponent createNorthPanel() {
47 myTargetDirectoryField = new TextFieldWithBrowseButton();
48 return com.intellij.codeEditor.printing.ExportToHTMLDialog.assignLabel(myTargetDirectoryField, myProject);
52 protected JComponent createCenterPanel() {
53 if (!myCanBeOpenInBrowser) return null;
54 OptionGroup optionGroup = new OptionGroup();
56 addOptions(optionGroup);
58 return optionGroup.createPanel();
61 protected void addOptions(OptionGroup optionGroup) {
62 myCbOpenInBrowser = new JCheckBox();
63 myCbOpenInBrowser.setText(InspectionsBundle.message("inspection.export.open.option"));
64 optionGroup.add(myCbOpenInBrowser);
68 ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(myProject);
69 if (myCanBeOpenInBrowser) {
70 myCbOpenInBrowser.setSelected(exportToHTMLSettings.OPEN_IN_BROWSER);
72 final String text = exportToHTMLSettings.OUTPUT_DIRECTORY;
73 myTargetDirectoryField.setText(text);
74 myTargetDirectoryField.setPreferredSize(new Dimension(GraphicsUtil.stringWidth(text, myTargetDirectoryField.getFont()) + 100, myTargetDirectoryField.getPreferredSize().height));
78 ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(myProject);
80 if (myCanBeOpenInBrowser) {
81 exportToHTMLSettings.OPEN_IN_BROWSER = myCbOpenInBrowser.isSelected();
83 exportToHTMLSettings.OUTPUT_DIRECTORY = myTargetDirectoryField.getText();