@NotNull private static JComponent createInformationPanel(@NotNull final String adapterHomePageUrl) { JLabel label1 = new JLabel("See"); HyperlinkLabel hyperlink = SwingHelper.createWebHyperlink(adapterHomePageUrl); JLabel label2 = new JLabel("for details."); JPanel panel = SwingHelper.newHorizontalPanel( Component.BOTTOM_ALIGNMENT, SwingHelper.newLeftAlignedVerticalPanel(label1, Box.createVerticalStrut(2)), hyperlink, Box.createHorizontalStrut(5), SwingHelper.newLeftAlignedVerticalPanel(label2, Box.createVerticalStrut(2))); return SwingHelper.wrapWithoutStretch(panel); }
@NotNull private JPanel createSelectDirectoryPanel( @NotNull Project project, @NotNull JTextField directoryTextField) { FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); String adapterName = getAssertFrameworkAdapterName(); String title = "Select a directory for " + adapterName + " files"; String description = adapterName + " source files will be copied to the selected directory"; TextFieldWithBrowseButton directoryTextFieldWithBrowseButton = new TextFieldWithBrowseButton(directoryTextField); directoryTextFieldWithBrowseButton.addBrowseFolderListener( title, description, project, fileChooserDescriptor); Dimension oldDimension = directoryTextFieldWithBrowseButton.getPreferredSize(); directoryTextFieldWithBrowseButton.setMaximumSize(oldDimension); JPanel panel = new JPanel(new BorderLayout(0, 2)); panel.add(new JLabel("Copy these files to directory:"), BorderLayout.NORTH); panel.add(directoryTextFieldWithBrowseButton, BorderLayout.CENTER); return SwingHelper.wrapWithHorizontalStretch(panel); }
public AddAdapterSupportDialog( @NotNull Project project, @NotNull PsiFile psiFileRequestor, @NotNull String assertionFrameworkName, @NotNull List<VirtualFile> adapterSourceFiles, @Nullable String adapterHomePageUrl) { super(project); myProject = project; myAssertFrameworkName = assertionFrameworkName; myAdapterSourceFiles = adapterSourceFiles; myFileRequestor = psiFileRequestor.getVirtualFile(); setModal(true); setTitle("Add " + getAssertFrameworkAdapterName()); myDirectoryTextField = new JTextField(); VirtualFile initialDir = findInitialDir(psiFileRequestor); if (initialDir != null) { myDirectoryTextField.setText(FileUtil.toSystemDependentName(initialDir.getPath())); } // widen preferred size to fit dialog's title myDirectoryTextField.setPreferredSize( new Dimension(350, myDirectoryTextField.getPreferredSize().height)); List<Component> components = Lists.newArrayList(); components.add(createFilesViewPanel(adapterSourceFiles)); components.add(Box.createVerticalStrut(10)); components.add(createSelectDirectoryPanel(project, myDirectoryTextField)); if (adapterHomePageUrl != null) { components.add(Box.createVerticalStrut(10)); components.add(createInformationPanel(adapterHomePageUrl)); } myContent = SwingHelper.newLeftAlignedVerticalPanel(components); setOKButtonText("Add"); super.init(); }