Search in sources :

Example 1 with BrowseFilesListener

use of com.intellij.ide.util.BrowseFilesListener in project intellij-community by JetBrains.

the class ProjectConfigurable method createUIComponents.

private void createUIComponents() {
    myLanguageLevelCombo = new LanguageLevelCombo(JavaCoreBundle.message("default.language.level.description")) {

        @Override
        protected LanguageLevel getDefaultLevel() {
            Sdk sdk = myProjectJdkConfigurable.getSelectedProjectJdk();
            if (sdk == null)
                return null;
            JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk);
            return version == null ? null : version.getMaxLanguageLevel();
        }
    };
    final JTextField textField = new JTextField();
    final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
    outputPathsChooserDescriptor.setHideIgnored(false);
    BrowseFilesListener listener = new BrowseFilesListener(textField, "", ProjectBundle.message("project.compiler.output"), outputPathsChooserDescriptor);
    myProjectCompilerOutput = new FieldPanel(textField, null, null, listener, EmptyRunnable.getInstance());
    FileChooserFactory.getInstance().installFileCompletion(myProjectCompilerOutput.getTextField(), outputPathsChooserDescriptor, true, null);
}
Also used : JavaSdkVersion(com.intellij.openapi.projectRoots.JavaSdkVersion) BrowseFilesListener(com.intellij.ide.util.BrowseFilesListener) LanguageLevel(com.intellij.pom.java.LanguageLevel) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) JavaSdk(com.intellij.openapi.projectRoots.JavaSdk) Sdk(com.intellij.openapi.projectRoots.Sdk) FieldPanel(com.intellij.ui.FieldPanel)

Example 2 with BrowseFilesListener

use of com.intellij.ide.util.BrowseFilesListener in project intellij-community by JetBrains.

the class BuildElementsEditor method createOutputPathPanel.

private CommitableFieldPanel createOutputPathPanel(final String title, final CommitPathRunnable commitPathRunnable) {
    final JTextField textField = new JTextField();
    final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    outputPathsChooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, getModel().getModule());
    outputPathsChooserDescriptor.setHideIgnored(false);
    InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
    FileChooserFactory.getInstance().installFileCompletion(textField, outputPathsChooserDescriptor, true, null);
    final Runnable commitRunnable = () -> {
        if (!getModel().isWritable()) {
            return;
        }
        final String path = textField.getText().trim();
        if (path.length() == 0) {
            commitPathRunnable.saveUrl(null);
        } else {
            // should set only absolute paths
            String canonicalPath;
            try {
                canonicalPath = FileUtil.resolveShortWindowsName(path);
            } catch (IOException e) {
                canonicalPath = path;
            }
            commitPathRunnable.saveUrl(VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(canonicalPath)));
        }
    };
    final ActionListener listener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            commitRunnable.run();
        }
    };
    myPerModuleCompilerOutput.addActionListener(listener);
    textField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            commitRunnable.run();
        }
    });
    return new CommitableFieldPanel(textField, null, null, new BrowseFilesListener(textField, title, "", outputPathsChooserDescriptor) {

        @Override
        public void actionPerformed(ActionEvent e) {
            super.actionPerformed(e);
            commitRunnable.run();
        }
    }, null, commitRunnable);
}
Also used : ActionListener(java.awt.event.ActionListener) BrowseFilesListener(com.intellij.ide.util.BrowseFilesListener) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ActionEvent(java.awt.event.ActionEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) IOException(java.io.IOException) DocumentEvent(javax.swing.event.DocumentEvent)

Example 3 with BrowseFilesListener

use of com.intellij.ide.util.BrowseFilesListener in project intellij-community by JetBrains.

the class PluginModuleBuildConfEditor method createComponent.

@Override
public JComponent createComponent() {
    myPluginXML.addActionListener(new BrowseFilesListener(myPluginXML.getTextField(), DevKitBundle.message("deployment.directory.location", META_INF), DevKitBundle.message("saved.message.common", META_INF + File.separator + PLUGIN_XML), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR));
    myManifest.addActionListener(new BrowseFilesListener(myManifest.getTextField(), DevKitBundle.message("deployment.view.select", MANIFEST_MF), DevKitBundle.message("manifest.selection", MANIFEST_MF), BrowseFilesListener.SINGLE_FILE_DESCRIPTOR));
    myManifest.setEnabled(myBuildProperties.isUseUserManifest());
    myUseUserManifest.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final boolean selected = myUseUserManifest.isSelected();
            myManifest.setEnabled(selected);
        }
    });
    final GridBagConstraints gc = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(2), 0, 0);
    myWholePanel.add(myPluginXMLLabel, gc);
    myWholePanel.add(myPluginXML, gc);
    JPanel manifestPanel = new JPanel(new GridBagLayout());
    manifestPanel.setBorder(IdeBorderFactory.createTitledBorder(DevKitBundle.message("manifest.settings"), true));
    gc.insets.left = 0;
    manifestPanel.add(myUseUserManifest, gc);
    gc.insets.left = 2;
    gc.weighty = 1.0;
    manifestPanel.add(myManifest, gc);
    myWholePanel.add(manifestPanel, gc);
    myWholePanel.setBorder(JBUI.Borders.empty(5));
    return myWholePanel;
}
Also used : BrowseFilesListener(com.intellij.ide.util.BrowseFilesListener) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Aggregations

BrowseFilesListener (com.intellij.ide.util.BrowseFilesListener)3 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 JavaSdk (com.intellij.openapi.projectRoots.JavaSdk)1 JavaSdkVersion (com.intellij.openapi.projectRoots.JavaSdkVersion)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 LanguageLevel (com.intellij.pom.java.LanguageLevel)1 DocumentAdapter (com.intellij.ui.DocumentAdapter)1 FieldPanel (com.intellij.ui.FieldPanel)1 IOException (java.io.IOException)1 DocumentEvent (javax.swing.event.DocumentEvent)1