use of com.intellij.ui.TitledSeparator in project intellij-community by JetBrains.
the class EqualsHashCodeTemplatesPanel method createConfigurable.
@Override
protected UnnamedConfigurable createConfigurable(Couple<TemplateResource> item) {
final GenerateTemplateConfigurable equalsConfigurable = new GenerateTemplateConfigurable(item.first, GenerateEqualsHelper.getEqualsImplicitVars(myProject), myProject);
final GenerateTemplateConfigurable hashCodeConfigurable = new GenerateTemplateConfigurable(item.second, GenerateEqualsHelper.getHashCodeImplicitVars(), myProject);
return new UnnamedConfigurable() {
@Nullable
@Override
public JComponent createComponent() {
final Splitter splitter = new Splitter(true);
final JPanel eqPanel = new JPanel(new BorderLayout());
eqPanel.add(new TitledSeparator("Equals Template:"), BorderLayout.NORTH);
final JComponent eqPane = equalsConfigurable.createComponent();
eqPane.setPreferredSize(JBUI.size(300, 200));
eqPanel.add(eqPane, BorderLayout.CENTER);
splitter.setFirstComponent(eqPanel);
final JPanel hcPanel = new JPanel(new BorderLayout());
hcPanel.add(new TitledSeparator("HashCode Template:"), BorderLayout.NORTH);
final JComponent hcPane = hashCodeConfigurable.createComponent();
hcPane.setPreferredSize(JBUI.size(300, 200));
hcPanel.add(hcPane, BorderLayout.CENTER);
splitter.setSecondComponent(hcPanel);
return splitter;
}
@Override
public boolean isModified() {
return equalsConfigurable.isModified() || hashCodeConfigurable.isModified();
}
@Override
public void apply() throws ConfigurationException {
equalsConfigurable.apply();
hashCodeConfigurable.apply();
}
@Override
public void reset() {
equalsConfigurable.reset();
hashCodeConfigurable.reset();
}
@Override
public void disposeUIResources() {
equalsConfigurable.disposeUIResources();
hashCodeConfigurable.disposeUIResources();
}
};
}
use of com.intellij.ui.TitledSeparator in project intellij-community by JetBrains.
the class RunInspectionAction method runInspection.
public static void runInspection(@NotNull final Project project, @NotNull String shortName, @Nullable VirtualFile virtualFile, PsiElement psiElement, PsiFile psiFile) {
final PsiElement element = psiFile == null ? psiElement : psiFile;
final InspectionProfile currentProfile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
final InspectionToolWrapper toolWrapper = element != null ? currentProfile.getInspectionTool(shortName, element) : currentProfile.getInspectionTool(shortName, project);
LOGGER.assertTrue(toolWrapper != null, "Missed inspection: " + shortName);
final InspectionManagerEx managerEx = (InspectionManagerEx) InspectionManager.getInstance(project);
final Module module = virtualFile != null ? ModuleUtilCore.findModuleForFile(virtualFile, project) : null;
AnalysisScope analysisScope = null;
if (psiFile != null) {
analysisScope = new AnalysisScope(psiFile);
} else {
if (virtualFile != null && virtualFile.isDirectory()) {
final PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(virtualFile);
if (psiDirectory != null) {
analysisScope = new AnalysisScope(psiDirectory);
}
}
if (analysisScope == null && virtualFile != null) {
analysisScope = new AnalysisScope(project, Arrays.asList(virtualFile));
}
if (analysisScope == null) {
analysisScope = new AnalysisScope(project);
}
}
final AnalysisUIOptions options = AnalysisUIOptions.getInstance(project);
final FileFilterPanel fileFilterPanel = new FileFilterPanel();
fileFilterPanel.init(options);
final AnalysisScope initialAnalysisScope = analysisScope;
final BaseAnalysisActionDialog dialog = new BaseAnalysisActionDialog("Run '" + toolWrapper.getDisplayName() + "'", AnalysisScopeBundle.message("analysis.scope.title", InspectionsBundle.message("inspection.action.noun")), project, analysisScope, module != null ? module.getName() : null, true, options, psiElement) {
private InspectionToolWrapper myUpdatedSettingsToolWrapper;
@Nullable
@Override
protected JComponent getAdditionalActionSettings(Project project) {
final JPanel fileFilter = fileFilterPanel.getPanel();
if (toolWrapper.getTool().createOptionsPanel() != null) {
JPanel additionPanel = new JPanel();
additionPanel.setLayout(new BoxLayout(additionPanel, BoxLayout.Y_AXIS));
additionPanel.add(fileFilter);
//new InheritOptionsForToolPanel(toolWrapper.getShortName(), project);
myUpdatedSettingsToolWrapper = copyToolWithSettings(toolWrapper);
additionPanel.add(new TitledSeparator(IdeBundle.message("goto.inspection.action.choose.inherit.settings.from")));
JComponent optionsPanel = myUpdatedSettingsToolWrapper.getTool().createOptionsPanel();
LOGGER.assertTrue(optionsPanel != null);
if (UIUtil.hasScrollPane(optionsPanel)) {
additionPanel.add(optionsPanel);
} else {
additionPanel.add(ScrollPaneFactory.createScrollPane(optionsPanel, SideBorder.NONE));
}
return additionPanel;
} else {
return fileFilter;
}
}
@NotNull
@Override
public AnalysisScope getScope(@NotNull AnalysisUIOptions uiOptions, @NotNull AnalysisScope defaultScope, @NotNull Project project, Module module) {
final AnalysisScope scope = super.getScope(uiOptions, defaultScope, project, module);
final GlobalSearchScope filterScope = fileFilterPanel.getSearchScope();
if (filterScope == null) {
return scope;
}
scope.setFilter(filterScope);
return scope;
}
private AnalysisScope getScope() {
return getScope(options, initialAnalysisScope, project, module);
}
private InspectionToolWrapper getToolWrapper() {
return myUpdatedSettingsToolWrapper == null ? toolWrapper : myUpdatedSettingsToolWrapper;
}
@NotNull
@Override
protected Action[] createActions() {
final List<Action> actions = new ArrayList<>();
final boolean hasFixAll = toolWrapper.getTool() instanceof CleanupLocalInspectionTool;
actions.add(new AbstractAction(hasFixAll ? AnalysisScopeBundle.message("action.analyze.verb") : CommonBundle.getOkButtonText()) {
{
putValue(DEFAULT_ACTION, Boolean.TRUE);
}
@Override
public void actionPerformed(ActionEvent e) {
RunInspectionIntention.rerunInspection(getToolWrapper(), managerEx, getScope(), null);
close(DialogWrapper.OK_EXIT_CODE);
}
});
if (hasFixAll) {
actions.add(new AbstractAction("Fix All") {
@Override
public void actionPerformed(ActionEvent e) {
InspectionToolWrapper wrapper = getToolWrapper();
InspectionProfileImpl cleanupToolProfile = RunInspectionIntention.createProfile(wrapper, managerEx, null);
managerEx.createNewGlobalContext(false).codeCleanup(getScope(), cleanupToolProfile, "Cleanup by " + wrapper.getDisplayName(), null, false);
close(DialogWrapper.OK_EXIT_CODE);
}
});
}
actions.add(getCancelAction());
if (SystemInfo.isMac) {
Collections.reverse(actions);
}
return actions.toArray(new Action[actions.size()]);
}
};
dialog.showAndGet();
}
use of com.intellij.ui.TitledSeparator in project intellij-community by JetBrains.
the class MoveInstanceMethodDialog method createParametersPanel.
@Nullable
private JPanel createParametersPanel() {
myThisClassesMap = MoveInstanceMembersUtil.getThisClassesToMembers(myMethod);
myOldClassParameterNameFields = new HashMap<>();
if (myThisClassesMap.size() == 0)
return null;
JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true));
for (PsiClass aClass : myThisClassesMap.keySet()) {
final String text = RefactoringBundle.message("move.method.this.parameter.label", ObjectUtils.notNull(aClass.getName(), ""));
panel.add(new TitledSeparator(text, null));
String suggestedName = MoveInstanceMethodHandler.suggestParameterNameForThisClass(aClass);
final EditorTextField field = new EditorTextField(suggestedName, getProject(), StdFileTypes.JAVA);
field.setMinimumSize(new Dimension(field.getPreferredSize()));
myOldClassParameterNameFields.put(aClass, field);
panel.add(field);
}
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
return panel;
}
use of com.intellij.ui.TitledSeparator in project intellij-community by JetBrains.
the class MoveInstanceMethodDialog method createCenterPanel.
protected JComponent createCenterPanel() {
JPanel mainPanel = new JPanel(new GridBagLayout());
final TitledSeparator separator = new TitledSeparator();
mainPanel.add(separator, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0));
myList = createTargetVariableChooser();
myList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
validateTextFields(e.getFirstIndex());
}
});
separator.setText(RefactoringBundle.message("moveInstanceMethod.select.an.instance.parameter"));
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myList);
mainPanel.add(scrollPane, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0));
myVisibilityPanel = createVisibilityPanel();
mainPanel.add(myVisibilityPanel, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, JBUI.emptyInsets(), 0, 0));
final JPanel parametersPanel = createParametersPanel();
if (parametersPanel != null) {
mainPanel.add(parametersPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0));
}
mainPanel.add(initOpenInEditorCb(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0));
separator.setLabelFor(myList);
validateTextFields(myList.getSelectedIndex());
updateOnChanged(myList);
return mainPanel;
}
use of com.intellij.ui.TitledSeparator in project intellij-community by JetBrains.
the class IdeaTitledBorder method paintBorder.
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
int labelX = x + outsideInsets.left;
int labelY = y + outsideInsets.top;
TitledSeparator titledSeparator = getTitledSeparator(c);
JLabel label = titledSeparator.getLabel();
Dimension labelSize = label.getPreferredSize();
label.setSize(labelSize);
g.translate(labelX, labelY);
label.paint(g);
int separatorX = labelX + labelSize.width + TitledSeparator.SEPARATOR_LEFT_INSET;
int separatorY = labelY + (UIUtil.isUnderAquaLookAndFeel() ? 2 : labelSize.height / 2 - 1);
int separatorW = Math.max(0, width - separatorX - TitledSeparator.SEPARATOR_RIGHT_INSET);
int separatorH = 2;
JSeparator separator = titledSeparator.getSeparator();
separator.setSize(separatorW, separatorH);
g.translate(separatorX - labelX, separatorY - labelY);
separator.paint(g);
g.translate(-separatorX, -separatorY);
}
Aggregations