use of com.intellij.ide.util.scopeChooser.ScopeChooserCombo in project intellij-community by JetBrains.
the class FindPopupScopeUIImpl method initComponents.
public void initComponents() {
Module[] modules = ModuleManager.getInstance(myProject).getModules();
String[] names = new String[modules.length];
for (int i = 0; i < modules.length; i++) {
names[i] = modules[i].getName();
}
Arrays.sort(names, String.CASE_INSENSITIVE_ORDER);
myModuleComboBox = new ComboBox<>(names);
ActionListener restartSearchListener = e -> scheduleResultsUpdate();
myModuleComboBox.addActionListener(restartSearchListener);
myDirectoryChooser = new FindPopupDirectoryChooser(myFindPopupPanel);
myScopeCombo = new ScopeChooserCombo();
myScopeCombo.init(myProject, true, true, FindSettings.getInstance().getDefaultScopeName(), new Condition<ScopeDescriptor>() {
final String projectFilesScopeName = PsiBundle.message("psi.search.scope.project");
final String moduleFilesScopeName;
{
String moduleScopeName = PsiBundle.message("search.scope.module", "");
final int ind = moduleScopeName.indexOf(' ');
moduleFilesScopeName = moduleScopeName.substring(0, ind + 1);
}
@Override
public boolean value(ScopeDescriptor descriptor) {
final String display = descriptor.getDisplay();
return !projectFilesScopeName.equals(display) && !display.startsWith(moduleFilesScopeName);
}
});
myScopeCombo.setBrowseListener(new ScopeChooserCombo.BrowseListener() {
private FindModel myModelSnapshot;
@Override
public void onBeforeBrowseStarted() {
myModelSnapshot = myHelper.getModel();
myFindPopupPanel.getCanClose().set(false);
}
@Override
public void onAfterBrowseFinished() {
if (myModelSnapshot != null) {
SearchScope scope = myScopeCombo.getSelectedScope();
if (scope != null) {
myModelSnapshot.setCustomScope(scope);
}
myFindPopupPanel.getCanClose().set(true);
}
}
});
myScopeCombo.getComboBox().addActionListener(restartSearchListener);
Disposer.register(myFindPopupPanel.getDisposable(), myScopeCombo);
}
use of com.intellij.ide.util.scopeChooser.ScopeChooserCombo in project intellij-community by JetBrains.
the class LayoutProjectCodeDialog method createUIComponents.
protected void createUIComponents() {
myScopeCombo = new ScopeChooserCombo(myProject, false, false, FindSettings.getInstance().getDefaultScopeName());
Disposer.register(myDisposable, myScopeCombo);
}
use of com.intellij.ide.util.scopeChooser.ScopeChooserCombo in project intellij-community by JetBrains.
the class SearchDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
myContentPanel = new JPanel(new BorderLayout());
myEditorPanel = createEditorContent();
myContentPanel.add(BorderLayout.CENTER, myEditorPanel);
myContentPanel.add(BorderLayout.SOUTH, Box.createVerticalStrut(8));
JComponent centerPanel = new JPanel(new BorderLayout());
{
JPanel panel = new JPanel(new BorderLayout());
panel.add(BorderLayout.CENTER, myContentPanel);
panel.add(BorderLayout.SOUTH, createTemplateManagementButtons());
centerPanel.add(BorderLayout.CENTER, panel);
}
JPanel optionsContent = new JPanel(new BorderLayout());
centerPanel.add(BorderLayout.SOUTH, optionsContent);
JPanel searchOptions = new JPanel();
searchOptions.setLayout(new GridLayout(getRowsCount(), 1, 0, 0));
searchOptions.setBorder(IdeBorderFactory.createTitledBorder(SSRBundle.message("ssdialog.options.group.border"), true));
myScopeChooserCombo = new ScopeChooserCombo(searchContext.getProject(), true, false, FindSettings.getInstance().getDefaultScopeName());
Disposer.register(myDisposable, myScopeChooserCombo);
JPanel allOptions = new JPanel(new BorderLayout());
if (myShowScopePanel) {
JPanel scopePanel = new JPanel(new GridBagLayout());
TitledSeparator separator = new TitledSeparator(SSRBundle.message("search.dialog.scope.label"), myScopeChooserCombo.getComboBox());
scopePanel.add(separator, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.insetsTop(5), 0, 0));
scopePanel.add(myScopeChooserCombo, new GridBagConstraints(0, 1, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.insetsLeft(10), 0, 0));
allOptions.add(scopePanel, BorderLayout.SOUTH);
myScopeChooserCombo.getComboBox().addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
initiateValidation();
}
});
}
buildOptions(searchOptions);
allOptions.add(searchOptions, BorderLayout.CENTER);
optionsContent.add(allOptions, BorderLayout.CENTER);
if (myRunFindActionOnClose) {
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
openInNewTab = new JCheckBox(FindBundle.message("find.open.in.new.tab.checkbox"));
openInNewTab.setSelected(FindSettings.getInstance().isShowResultsInSeparateView());
ToolWindow findWindow = ToolWindowManager.getInstance(searchContext.getProject()).getToolWindow(ToolWindowId.FIND);
openInNewTab.setEnabled(findWindow != null && findWindow.isAvailable());
panel.add(openInNewTab, BorderLayout.EAST);
optionsContent.add(BorderLayout.SOUTH, panel);
}
updateEditor();
return centerPanel;
}
use of com.intellij.ide.util.scopeChooser.ScopeChooserCombo in project intellij-community by JetBrains.
the class ScopePanel method createUIComponents.
private void createUIComponents() {
myRoot = this;
myCustomScopeSelection = new ScopeChooserCombo();
}
use of com.intellij.ide.util.scopeChooser.ScopeChooserCombo in project intellij-community by JetBrains.
the class ScopePanel method initComponent.
public void initComponent(@Nullable Module currentModule, final SearchScope scope) {
final ItemListener stateListener = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
myModuleSelection.setEnabled(myModuleScope.isSelected());
myDirectory.setEnabled(myDirectoryScope.isSelected());
myRecursive.setEnabled(myDirectoryScope.isSelected());
myCustomScopeSelection.setEnabled(myCustomScope.isSelected());
if (e.getStateChange() == ItemEvent.SELECTED) {
firePropertyChange("scope", null, getSelectedScope());
}
}
};
final ItemListener scopeListener = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
firePropertyChange("scope", null, getSelectedScope());
}
}
};
myWholeProjectScope.addItemListener(stateListener);
myWholeProjectScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.PROJECT);
myModuleScope.addItemListener(stateListener);
myModuleScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.MODULE);
myDirectoryScope.addItemListener(stateListener);
myDirectoryScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.DIRECTORY);
myCustomScope.addItemListener(stateListener);
myCustomScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.CUSTOM);
myModuleSelection.fillModules(myProject);
Module m;
if (scope.getModuleName() != null) {
if ((m = ModuleManager.getInstance(myProject).findModuleByName(scope.getModuleName())) == null) {
m = currentModule;
}
} else {
m = currentModule;
}
if (m != null) {
myModuleSelection.setSelectedModule(m);
}
myModuleSelection.addItemListener(scopeListener);
((ScopeChooserCombo) myCustomScopeSelection).init(myProject, true, true, scope.getScopeName());
myCustomScopeSelection.getComboBox().addItemListener(scopeListener);
myDirectory.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(DocumentEvent e) {
firePropertyChange("scope", null, getSelectedScope());
}
});
myDirectory.setText(scope.getPath());
myDirectory.addBrowseFolderListener("Select Path", "Select Path", myProject, FileChooserDescriptorFactory.createSingleFolderDescriptor());
myRecursive.setSelected(scope.isRecursive());
}
Aggregations