mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,6 +28,7 @@ import com.intellij.ui.TableUtil;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.ui.EditableModel;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -71,7 +72,7 @@ public class ProcessedModulesTable extends JPanel {
|
||||
|
||||
final JPanel panel = ToolbarDecorator.createDecorator(myTable)
|
||||
.disableUpDownActions()
|
||||
.setPreferredSize(new Dimension(100, 155))
|
||||
.setPreferredSize(JBUI.size(100, 155))
|
||||
.createPanel();
|
||||
add(panel, BorderLayout.CENTER);
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,12 +39,12 @@ import com.intellij.packaging.artifacts.*;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactCompileScope;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -135,7 +135,7 @@ public class BuildArtifactsBeforeRunTaskProvider extends BeforeRunTaskProvider<B
|
||||
pointers.addAll(task.getArtifactPointers());
|
||||
ArtifactChooser chooser = new ArtifactChooser(new ArrayList<ArtifactPointer>(pointers));
|
||||
chooser.markElements(task.getArtifactPointers());
|
||||
chooser.setPreferredSize(new Dimension(400, 300));
|
||||
chooser.setPreferredSize(JBUI.size(400, 300));
|
||||
|
||||
DialogBuilder builder = new DialogBuilder(myProject);
|
||||
builder.setTitle(CompilerBundle.message("build.artifacts.before.run.selector.title"));
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.xdebugger.impl.ui.TextViewer;
|
||||
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
|
||||
import com.intellij.xdebugger.impl.ui.tree.actions.XFetchValueActionBase;
|
||||
@@ -95,7 +96,7 @@ public class ViewTextAction extends XFetchValueActionBase {
|
||||
protected JComponent createCenterPanel() {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(myTextViewer, BorderLayout.CENTER);
|
||||
panel.setPreferredSize(new Dimension(300, 200));
|
||||
panel.setPreferredSize(JBUI.size(300, 200));
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -255,7 +255,7 @@ public class PositionManagerImpl implements PositionManager {
|
||||
baseClassNameRef.set(parentClassName);
|
||||
}
|
||||
else {
|
||||
LOG.error("The name of a parent of a local (anonymous) class is null");
|
||||
LOG.error("The name of a parent " + topLevelClass + " of a local (anonymous) class " + psiClass + " is null");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,7 @@ import com.intellij.openapi.util.registry.ui.RegistryCheckBox;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.StateRestoringCheckBox;
|
||||
import com.intellij.ui.classFilter.ClassFilterEditor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -179,7 +179,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
panel.add(myCbEnableToString, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 0, 0));
|
||||
panel.add(myRbAllThatOverride, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 12, 0, 0), 0, 0));
|
||||
panel.add(myRbFromList, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 12, 0, 0), 0, 0));
|
||||
myToStringFilterEditor.setMinimumSize(new Dimension(50, 100));
|
||||
myToStringFilterEditor.setMinimumSize(JBUI.size(50, 100));
|
||||
panel.add(myToStringFilterEditor, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 12, 0, 0), 0, 0));
|
||||
|
||||
return panel;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,15 +15,16 @@
|
||||
*/
|
||||
package com.intellij.debugger.ui;
|
||||
|
||||
import com.intellij.debugger.DebuggerManagerEx;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImports;
|
||||
import com.intellij.debugger.DebuggerManagerEx;
|
||||
import com.intellij.debugger.engine.evaluation.DefaultCodeFragmentFactory;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImports;
|
||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.impl.PositionUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -66,7 +67,7 @@ public class CompletedInputDialog extends DialogWrapper {
|
||||
|
||||
myPanel.add(myCombo, new GridBagConstraints(0, 1, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
|
||||
new Insets(0, 1, 0, 1), 0, 0));
|
||||
myPanel.setPreferredSize(new Dimension(200, 50));
|
||||
myPanel.setPreferredSize(JBUI.size(200, 50));
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,6 +40,7 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.sun.jdi.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -102,7 +103,7 @@ public class ExportDialog extends DialogWrapper {
|
||||
protected JComponent createCenterPanel() {
|
||||
myTextArea.setEditable(false);
|
||||
JScrollPane pane = ScrollPaneFactory.createScrollPane(myTextArea);
|
||||
pane.setPreferredSize(new Dimension(400, 300));
|
||||
pane.setPreferredSize(JBUI.size(400, 300));
|
||||
return pane;
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,6 +26,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.classFilter.ClassFilterEditor;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -55,13 +56,13 @@ public class EditClassFiltersDialog extends DialogWrapper {
|
||||
Box mainPanel = Box.createHorizontalBox();
|
||||
|
||||
myClassFilterEditor = new ClassFilterEditor(myProject, myChooserFilter, "reference.viewBreakpoints.classFilters.newPattern");
|
||||
myClassFilterEditor.setPreferredSize(new Dimension(400, 200));
|
||||
myClassFilterEditor.setPreferredSize(JBUI.size(400, 200));
|
||||
myClassFilterEditor.setBorder(IdeBorderFactory.createTitledBorder(
|
||||
DebuggerBundle.message("class.filters.dialog.inclusion.filters.group"), false));
|
||||
mainPanel.add(myClassFilterEditor);
|
||||
|
||||
myClassExclusionFilterEditor = new ClassFilterEditor(myProject, myChooserFilter, "reference.viewBreakpoints.classFilters.newPattern");
|
||||
myClassExclusionFilterEditor.setPreferredSize(new Dimension(400, 200));
|
||||
myClassExclusionFilterEditor.setPreferredSize(JBUI.size(400, 200));
|
||||
myClassExclusionFilterEditor.setBorder(IdeBorderFactory.createTitledBorder(
|
||||
DebuggerBundle.message("class.filters.dialog.exclusion.filters.group"), false));
|
||||
mainPanel.add(myClassExclusionFilterEditor);
|
||||
|
||||
+5
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,13 +15,14 @@
|
||||
*/
|
||||
package com.intellij.debugger.ui.breakpoints;
|
||||
|
||||
import com.intellij.ui.classFilter.ClassFilter;
|
||||
import com.intellij.debugger.InstanceFilter;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.InstanceFilter;
|
||||
import com.intellij.debugger.ui.InstanceFilterEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.classFilter.ClassFilter;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -48,7 +49,7 @@ public class EditInstanceFiltersDialog extends DialogWrapper{
|
||||
Box mainPanel = Box.createHorizontalBox();
|
||||
|
||||
myInstanceFilterEditor = new InstanceFilterEditor(myProject);
|
||||
myInstanceFilterEditor.setPreferredSize(new Dimension(400, 200));
|
||||
myInstanceFilterEditor.setPreferredSize(JBUI.size(400, 200));
|
||||
myInstanceFilterEditor.setBorder(IdeBorderFactory.createTitledBorder(
|
||||
DebuggerBundle.message("instance.filters.dialog.instance.filters.group"), false));
|
||||
mainPanel.add(myInstanceFilterEditor);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,6 +34,7 @@ import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.FormBuilder;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -518,7 +519,7 @@ abstract class ProjectLayoutPanel<T> extends JPanel {
|
||||
FormBuilder builder = FormBuilder.createFormBuilder().setVertical(true);
|
||||
builder.addLabeledComponent("&Name:", myNameField);
|
||||
builder.addLabeledComponent(getSplitDialogChooseFilesPrompt(), myChooser);
|
||||
myChooser.setPreferredSize(new Dimension(450, 300));
|
||||
myChooser.setPreferredSize(JBUI.size(450, 300));
|
||||
return builder.getPanel();
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,6 +43,7 @@ import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -120,12 +121,12 @@ public class AddSupportForFrameworksPanel implements Disposable {
|
||||
|
||||
JPanel treePanel = new JPanel(new BorderLayout());
|
||||
treePanel.add(ScrollPaneFactory.createScrollPane(myFrameworksTree), BorderLayout.CENTER);
|
||||
treePanel.setMinimumSize(new Dimension(200, 300));
|
||||
treePanel.setMinimumSize(JBUI.size(200, 300));
|
||||
|
||||
splitter.setFirstComponent(treePanel);
|
||||
myOptionsPanel = new JPanel(new CardLayout());
|
||||
JPanel emptyCard = new JPanel();
|
||||
emptyCard.setPreferredSize(new Dimension(400, 100));
|
||||
emptyCard.setPreferredSize(JBUI.size(400, 100));
|
||||
myOptionsPanel.add(EMPTY_CARD, emptyCard);
|
||||
|
||||
splitter.setSecondComponent(myOptionsPanel);
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,6 +46,7 @@ import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.FieldPanel;
|
||||
import com.intellij.ui.InsertPathAction;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -121,7 +122,7 @@ public class ProjectConfigurable extends ProjectStructureElementConfigurable<Pro
|
||||
|
||||
private void init(final ProjectSdksModel model) {
|
||||
myPanel = new JPanel(new GridBagLayout());
|
||||
myPanel.setPreferredSize(new Dimension(700, 500));
|
||||
myPanel.setPreferredSize(JBUI.size(700, 500));
|
||||
|
||||
if (((ProjectEx)myProject).getStateStore().getStorageScheme().equals(StorageScheme.DIRECTORY_BASED)) {
|
||||
final JPanel namePanel = new JPanel(new BorderLayout());
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,6 +52,7 @@ import com.intellij.ui.navigation.ForwardAction;
|
||||
import com.intellij.ui.navigation.History;
|
||||
import com.intellij.ui.navigation.Place;
|
||||
import com.intellij.util.io.storage.HeavyProcessLatch;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -672,7 +673,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(1024, 768);
|
||||
return JBUI.size(1024, 768);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,6 +47,7 @@ import com.intellij.ui.treeStructure.SimpleTreeStructure;
|
||||
import com.intellij.ui.treeStructure.WeightBasedComparator;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -127,8 +128,8 @@ public class LayoutTreeComponent implements DnDTarget, Disposable {
|
||||
private void createPropertiesPanel() {
|
||||
myPropertiesPanel = new JPanel(new BorderLayout());
|
||||
final JPanel emptyPanel = new JPanel();
|
||||
emptyPanel.setMinimumSize(new Dimension(0, 0));
|
||||
emptyPanel.setPreferredSize(new Dimension(0, 0));
|
||||
emptyPanel.setMinimumSize(JBUI.emptySize());
|
||||
emptyPanel.setPreferredSize(JBUI.emptySize());
|
||||
|
||||
myPropertiesPanelWrapper = new JPanel(new CardLayout());
|
||||
myPropertiesPanel.setBorder(new CustomLineBorder(1, 0, 0, 0));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,6 +27,7 @@ import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -64,7 +65,7 @@ class ManageProjectTemplatesDialog extends DialogWrapper {
|
||||
}
|
||||
});
|
||||
myTemplatesList.setEmptyText("No user-defined project templates");
|
||||
myTemplatesList.setPreferredSize(new Dimension(300, 100));
|
||||
myTemplatesList.setPreferredSize(JBUI.size(300, 100));
|
||||
myTemplatesList.setCellRenderer(new ColoredListCellRenderer() {
|
||||
@Override
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
@@ -83,7 +84,7 @@ class ManageProjectTemplatesDialog extends DialogWrapper {
|
||||
myPanel.add(ToolbarDecorator.createDecorator(myTemplatesList).disableUpDownActions().createPanel());
|
||||
|
||||
myDescriptionPane = new JTextPane();
|
||||
myDescriptionPane.setPreferredSize(new Dimension(300, 50));
|
||||
myDescriptionPane.setPreferredSize(JBUI.size(300, 50));
|
||||
Messages.installHyperlinkSupport(myDescriptionPane);
|
||||
myPanel.add(ScrollPaneFactory.createScrollPane(myDescriptionPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.SOUTH);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -55,6 +55,7 @@ import com.intellij.ui.treeStructure.WeightBasedComparator;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -202,7 +203,7 @@ public abstract class ChooseLibrariesDialogBase extends DialogWrapper {
|
||||
myTree.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ENTER");
|
||||
myTree.getActionMap().put("ENTER", getOKAction());
|
||||
final JScrollPane pane = ScrollPaneFactory.createScrollPane(myTree);
|
||||
pane.setPreferredSize(new Dimension(500, 400));
|
||||
pane.setPreferredSize(JBUI.size(500, 400));
|
||||
return pane;
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -455,9 +455,11 @@ public class GenericsHighlightUtil {
|
||||
HighlightUtil.formatClass(superContainingClass),
|
||||
JavaHighlightUtil.formatMethod(superMethod),
|
||||
HighlightUtil.formatClass(superContainingClass, false));
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
.range(classIdentifier).descriptionAndTooltip(message)
|
||||
.create();
|
||||
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createImplementMethodsFix(aClass));
|
||||
return info;
|
||||
}
|
||||
|
||||
if (isDefault || !isAbstract && superMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
@@ -471,9 +473,11 @@ public class GenericsHighlightUtil {
|
||||
HighlightUtil.formatClass(containingClass) +
|
||||
" and " +
|
||||
HighlightUtil.formatClass(superContainingClass);
|
||||
return HighlightInfo
|
||||
final HighlightInfo info = HighlightInfo
|
||||
.newHighlightInfo(HighlightInfoType.ERROR).range(classIdentifier).descriptionAndTooltip(inheritUnrelatedDefaultsMessage)
|
||||
.create();
|
||||
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createImplementMethodsFix(aClass));
|
||||
return info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -171,7 +171,8 @@ public class HardcodedContracts {
|
||||
}
|
||||
|
||||
if (element instanceof PsiParameter) {
|
||||
return hasHardcodedContracts(element.getParent().getParent());
|
||||
PsiElement parent = element.getParent();
|
||||
return parent != null && hasHardcodedContracts(parent.getParent());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.jetbrains.java.generate.psi;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.JavaVersionService;
|
||||
import com.intellij.openapi.projectRoots.JdkVersionUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
@@ -670,7 +670,11 @@ public class PsiAdapter {
|
||||
}
|
||||
|
||||
public static int getJavaVersion(PsiElement element) {
|
||||
final JavaSdkVersion sdkVersion = JavaVersionService.getInstance().getJavaSdkVersion(element);
|
||||
JavaSdkVersion sdkVersion = JavaVersionService.getInstance().getJavaSdkVersion(element);
|
||||
if (sdkVersion == null) {
|
||||
sdkVersion = JavaSdkVersion.fromLanguageLevel(PsiUtil.getLanguageLevel(element));
|
||||
}
|
||||
|
||||
int version = 0;
|
||||
switch (sdkVersion) {
|
||||
case JDK_1_0:
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiClass;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -85,7 +86,7 @@ class RestoreReferencesDialog extends DialogWrapper {
|
||||
final JButton cancelButton = new JButton(CommonBundle.getCancelButtonText());
|
||||
buttonPanel.add(cancelButton);
|
||||
|
||||
panel.setPreferredSize(new Dimension(500, 400));
|
||||
panel.setPreferredSize(JBUI.size(500, 400));
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
+3
-2
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.ui.TitledSeparator;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import gnu.trove.Equality;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -147,14 +148,14 @@ public class EqualsHashCodeTemplatesPanel extends NamedItemsListEditor<Couple<Te
|
||||
final JPanel eqPanel = new JPanel(new BorderLayout());
|
||||
eqPanel.add(new TitledSeparator("Equals Template:"), BorderLayout.NORTH);
|
||||
final JComponent eqPane = equalsConfigurable.createComponent();
|
||||
eqPane.setPreferredSize(new Dimension(300, 200));
|
||||
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(new Dimension(300, 200));
|
||||
hcPane.setPreferredSize(JBUI.size(300, 200));
|
||||
hcPanel.add(hcPane, BorderLayout.CENTER);
|
||||
splitter.setSecondComponent(hcPanel);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiFormatUtilBase;
|
||||
import com.intellij.ui.DoubleClickListener;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -60,7 +61,7 @@ public class SimpleFieldChooser extends DialogWrapper {
|
||||
}
|
||||
}.installOn(myList);
|
||||
|
||||
myList.setPreferredSize(new Dimension(300, 400));
|
||||
myList.setPreferredSize(JBUI.size(300, 400));
|
||||
return myList;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,8 +22,8 @@ import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.event.*;
|
||||
import com.intellij.openapi.editor.event.DocumentAdapter;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.fileChooser.ex.FileChooserDialogImpl;
|
||||
import com.intellij.openapi.fileChooser.ex.TextFieldAction;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
@@ -40,13 +40,17 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.JavaReferenceEditorUtil;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.TreeSpeedSearch;
|
||||
import com.intellij.ui.components.labels.LinkLabel;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -135,7 +139,7 @@ public class PackageChooserDialog extends PackageChooser {
|
||||
);
|
||||
|
||||
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
|
||||
scrollPane.setPreferredSize(new Dimension(500, 300));
|
||||
scrollPane.setPreferredSize(JBUI.size(500, 300));
|
||||
|
||||
new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() {
|
||||
public String convert(TreePath path) {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.projectRoots;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
@@ -28,6 +29,7 @@ public class JavaVersionServiceImpl extends JavaVersionService {
|
||||
return JavaSdkVersionUtil.isAtLeast(element, version);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JavaSdkVersion getJavaSdkVersion(@NotNull PsiElement element) {
|
||||
return JavaSdkVersionUtil.getJavaSdkVersion(element);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,6 +41,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.ui.DialogUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -111,8 +112,8 @@ public class ExtractMethodDialog extends DialogWrapper implements AbstractExtrac
|
||||
myVariableData = inputVariables;
|
||||
myHelpId = helpId;
|
||||
mySignature = new MethodSignatureComponent("", project, JavaFileType.INSTANCE);
|
||||
mySignature.setPreferredSize(new Dimension(500, 100));
|
||||
mySignature.setMinimumSize(new Dimension(500, 100));
|
||||
mySignature.setPreferredSize(JBUI.size(500, 100));
|
||||
mySignature.setMinimumSize(JBUI.size(500, 100));
|
||||
setTitle(title);
|
||||
|
||||
myNameField = new NameSuggestionsField(suggestMethodNames(), myProject);
|
||||
@@ -456,7 +457,7 @@ public class ExtractMethodDialog extends DialogWrapper implements AbstractExtrac
|
||||
}
|
||||
|
||||
myParamTable = createParameterTableComponent();
|
||||
myParamTable.setMinimumSize(new Dimension(500, 100));
|
||||
myParamTable.setMinimumSize(JBUI.size(500, 100));
|
||||
myCenterPanel.add(myParamTable, BorderLayout.CENTER);
|
||||
final JTable table = UIUtil.findComponentOfType(myParamTable, JTable.class);
|
||||
myCenterPanel.add(SeparatorFactory.createSeparator("&Parameters", table), BorderLayout.NORTH);
|
||||
|
||||
+9
@@ -52,6 +52,7 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -272,6 +273,14 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addReferenceAtCaret(Collection<PsiReference> refs) {
|
||||
if (!isReplaceAllOccurrences() && getExpr() == null && !myReplaceSelf) {
|
||||
return;
|
||||
}
|
||||
super.addReferenceAtCaret(refs);
|
||||
}
|
||||
|
||||
private static void appendTypeCasts(List<RangeMarker> occurrenceMarkers,
|
||||
PsiFile file,
|
||||
Project project,
|
||||
|
||||
+11
-12
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
package com.intellij.refactoring.introduceVariable;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
@@ -37,6 +39,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
@@ -49,7 +52,8 @@ public class ReassignVariableUtil {
|
||||
private ReassignVariableUtil() {
|
||||
}
|
||||
|
||||
static boolean reassign(final Editor editor) {
|
||||
@VisibleForTesting
|
||||
public static boolean reassign(final Editor editor) {
|
||||
final SmartPsiElementPointer<PsiDeclarationStatement> pointer = editor.getUserData(DECLARATION_KEY);
|
||||
final PsiDeclarationStatement declaration = pointer != null ? pointer.getElement() : null;
|
||||
final PsiType type = getVariableType(declaration);
|
||||
@@ -138,18 +142,13 @@ public class ReassignVariableUtil {
|
||||
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(variable.getProject());
|
||||
final String chosenVariableName = variable.getName();
|
||||
//would generate red code for final variables
|
||||
PsiElement newDeclaration = elementFactory.createStatementFromText(chosenVariableName + " = " + initializer.getText() + ";",
|
||||
declaration);
|
||||
PsiElement newDeclaration = elementFactory.createStatementFromText(chosenVariableName + " = " + initializer.getText() + ";", declaration);
|
||||
final Collection<PsiReference> references = ReferencesSearch.search(var).findAll();
|
||||
newDeclaration = declaration.replace(newDeclaration);
|
||||
final PsiFile containingFile = newDeclaration.getContainingFile();
|
||||
final RangeMarker[] occurrenceMarkers = editor.getUserData(OCCURRENCES_KEY);
|
||||
if (occurrenceMarkers != null) {
|
||||
for (RangeMarker marker : occurrenceMarkers) {
|
||||
final PsiElement refVariableElement = containingFile.findElementAt(marker.getStartOffset());
|
||||
final PsiExpression expression = PsiTreeUtil.getParentOfType(refVariableElement, PsiReferenceExpression.class);
|
||||
if (expression != null) {
|
||||
expression.replace(elementFactory.createExpressionFromText(chosenVariableName, newDeclaration));
|
||||
}
|
||||
for (PsiReference reference : references) {
|
||||
final PsiElement element = reference.getElement();
|
||||
if (element instanceof PsiExpression) {
|
||||
element.replace(elementFactory.createExpressionFromText(chosenVariableName, newDeclaration));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -718,6 +718,7 @@ public class RefactoringUtil {
|
||||
PsiUtil.setModifierProperty(method, PsiModifier.FINAL, false);
|
||||
PsiUtil.setModifierProperty(method, PsiModifier.SYNCHRONIZED, false);
|
||||
PsiUtil.setModifierProperty(method, PsiModifier.NATIVE, false);
|
||||
PsiUtil.setModifierProperty(method, PsiModifier.PUBLIC, false);
|
||||
removeFinalParameters(method);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class JavaVersionService {
|
||||
public static JavaVersionService getInstance() {
|
||||
@@ -33,6 +34,7 @@ public class JavaVersionService {
|
||||
return PsiUtil.getLanguageLevel(element).isAtLeast(version.getMaxLanguageLevel());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JavaSdkVersion getJavaSdkVersion(@NotNull PsiElement element) {
|
||||
return JavaSdkVersion.fromLanguageLevel(PsiUtil.getLanguageLevel(element));
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
{
|
||||
Runnable r = () -> System.out.println("extrac<caret>t me");
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
{
|
||||
Runnable r = () -> {
|
||||
String expr = "extract me";
|
||||
System.out.println(expr);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
{
|
||||
String s;
|
||||
System.out.println("<caret>");
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
{
|
||||
String s;
|
||||
s = "";
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
{
|
||||
String strA = "bar";
|
||||
if (true
|
||||
) System.out.println("<caret>");
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class C {
|
||||
{
|
||||
String strA = "bar";
|
||||
if (true
|
||||
) {
|
||||
strA = "";
|
||||
System.out.println(strA);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,5 +3,5 @@ interface Bar<T> { }
|
||||
interface Base<T> { }
|
||||
|
||||
class Foo<T,U> implements Base<U> {
|
||||
void ge<caret>t(Bar<U> bar) { }
|
||||
public void ge<caret>t(Bar<U> bar) { }
|
||||
}
|
||||
+25
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.codeInsight.folding.CodeFoldingManager;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.FoldRegion;
|
||||
import com.intellij.testFramework.TestFileType;
|
||||
@@ -55,7 +56,31 @@ public class FoldingProcessingOnDocumentModificationTest extends AbstractEditorT
|
||||
assertFalse(foldRegion.isExpanded());
|
||||
}
|
||||
|
||||
public void testCollapseAllHappensBeforeFirstCodeFoldingPass() throws Exception {
|
||||
init("class Foo {\n" +
|
||||
" void m() {\n" +
|
||||
" System.out.println();\n" +
|
||||
" System.out.println();\n" +
|
||||
" }\n" +
|
||||
"}", TestFileType.JAVA);
|
||||
|
||||
buildInitialFoldRegions();
|
||||
executeAction(IdeActions.ACTION_COLLAPSE_ALL_REGIONS);
|
||||
runFoldingPass(true);
|
||||
assertEquals(1, myEditor.getFoldingModel().getAllFoldRegions().length);
|
||||
}
|
||||
|
||||
private static void buildInitialFoldRegions() {
|
||||
CodeFoldingManager.getInstance(getProject()).buildInitialFoldings(myEditor);
|
||||
}
|
||||
|
||||
private static void updateFoldRegions() {
|
||||
CodeFoldingManager.getInstance(getProject()).updateFoldRegions(myEditor);
|
||||
}
|
||||
|
||||
private static void runFoldingPass(boolean firstTime) {
|
||||
Runnable runnable = CodeFoldingManager.getInstance(getProject()).updateFoldRegionsAsync(myEditor, firstTime);
|
||||
assertNotNull(runnable);
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,15 @@ public class InplaceIntroduceVariableTest extends AbstractJavaInplaceIntroduceTe
|
||||
});
|
||||
}
|
||||
|
||||
public void testPlaceInsideLoopAndRename() throws Exception {
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer inplaceIntroduceFieldPopup) {
|
||||
type("expr");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testRanges() throws Exception {
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring;
|
||||
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.refactoring.introduceVariable.ReassignVariableUtil;
|
||||
|
||||
public class InplaceReassignVariableTest extends AbstractJavaInplaceIntroduceTest {
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
doRunTest();
|
||||
}
|
||||
|
||||
public void testReassignSimple() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testReassignWhenVariableWasPutInLoopBody() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
String name = getTestName(true);
|
||||
configureByFile(getBasePath() + name + getExtension());
|
||||
final boolean enabled = getEditor().getSettings().isVariableInplaceRenameEnabled();
|
||||
try {
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
|
||||
getEditor().getSettings().setVariableInplaceRenameEnabled(true);
|
||||
|
||||
invokeRefactoring();
|
||||
ReassignVariableUtil.reassign(getEditor());
|
||||
|
||||
TemplateState state = TemplateManagerImpl.getTemplateState(getEditor());
|
||||
assert state != null;
|
||||
state.gotoEnd(false);
|
||||
checkResultByFile(getBasePath() + name + "_after" + getExtension());
|
||||
}
|
||||
finally {
|
||||
getEditor().getSettings().setVariableInplaceRenameEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/refactoring/inplaceIntroduceVariable/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MyIntroduceHandler createIntroduceHandler() {
|
||||
return new InplaceIntroduceVariableTest.MyIntroduceVariableHandler();
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,7 @@
|
||||
package org.jetbrains.jps.incremental;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.LowMemoryWatcher;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
@@ -84,7 +81,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
public class IncProjectBuilder {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.IncProjectBuilder");
|
||||
|
||||
private static final String CLASSPATH_INDEX_FINE_NAME = "classpath.index";
|
||||
private static final String CLASSPATH_INDEX_FILE_NAME = "classpath.index";
|
||||
private static final boolean GENERATE_CLASSPATH_INDEX = Boolean.parseBoolean(System.getProperty(GlobalOptions.GENERATE_CLASSPATH_INDEX_OPTION, "false"));
|
||||
private static final boolean SYNC_DELETE = Boolean.parseBoolean(System.getProperty("jps.sync.delete", SystemInfo.isWindows ? "true" : "false"));
|
||||
private static final GlobalContextKey<Set<BuildTarget<?>>> TARGET_WITH_CLEARED_OUTPUT = GlobalContextKey.create("_targets_with_cleared_output_");
|
||||
@@ -334,7 +331,25 @@ public class IncProjectBuilder {
|
||||
BuildRunner.PARALLEL_BUILD_ENABLED);
|
||||
|
||||
context.addBuildListener(new ChainedTargetsBuildListener(context));
|
||||
|
||||
//Deletes class loader classpath index files for changed output roots
|
||||
context.addBuildListener(new BuildListener() {
|
||||
@Override
|
||||
public void filesGenerated(Collection<Pair<String, String>> paths) {
|
||||
final Set<File> outputs = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
for (Pair<String, String> pair : paths) {
|
||||
outputs.add(new File(pair.getFirst()));
|
||||
}
|
||||
for (File root : outputs) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
new File(root, CLASSPATH_INDEX_FILE_NAME).delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filesDeleted(Collection<String> paths) {
|
||||
}
|
||||
});
|
||||
for (TargetBuilder builder : myBuilderRegistry.getTargetBuilders()) {
|
||||
builder.buildStarted(context);
|
||||
}
|
||||
@@ -965,7 +980,7 @@ public class IncProjectBuilder {
|
||||
File outputDir = ((ModuleBuildTarget)target).getOutputDir();
|
||||
if (outputDir != null && outputDirs.add(outputDir)) {
|
||||
try {
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(outputDir, CLASSPATH_INDEX_FINE_NAME)));
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(outputDir, CLASSPATH_INDEX_FILE_NAME)));
|
||||
try {
|
||||
writeIndex(writer, outputDir, "");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.SystemInfoRt;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.Restarter;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -228,7 +229,7 @@ public class Main {
|
||||
textPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scrollPane.setBorder(null);
|
||||
|
||||
int maxHeight = Math.min(600, Toolkit.getDefaultToolkit().getScreenSize().height - 150);
|
||||
int maxHeight = Math.min(JBUI.scale(600), Toolkit.getDefaultToolkit().getScreenSize().height - 150);
|
||||
Dimension component = scrollPane.getPreferredSize();
|
||||
if (component.height >= maxHeight) {
|
||||
Object setting = UIManager.get("ScrollBar.width");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.actionSystem;
|
||||
|
||||
import com.intellij.ui.switcher.QuickActionProvider;
|
||||
import com.intellij.ui.switcher.SwitchProvider;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -47,9 +48,9 @@ public interface ActionToolbar extends SwitchProvider, QuickActionProvider {
|
||||
int AUTO_LAYOUT_POLICY = 2;
|
||||
|
||||
/** This is default minimum size of the toolbar button */
|
||||
Dimension DEFAULT_MINIMUM_BUTTON_SIZE = new Dimension(25, 25);
|
||||
Dimension DEFAULT_MINIMUM_BUTTON_SIZE = JBUI.size(25, 25);
|
||||
|
||||
Dimension NAVBAR_MINIMUM_BUTTON_SIZE = new Dimension(20, 20);
|
||||
Dimension NAVBAR_MINIMUM_BUTTON_SIZE = JBUI.size(20, 20);
|
||||
|
||||
/**
|
||||
* @return component which represents the tool bar on UI
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 210 B |
Binary file not shown.
|
After Width: | Height: | Size: 282 B |
@@ -49,11 +49,15 @@ import com.intellij.util.Producer;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PasteHandler extends EditorActionHandler implements EditorTextInsertHandler {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.editorActions.PasteHandler");
|
||||
@@ -73,6 +77,9 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser
|
||||
|
||||
@Override
|
||||
public void execute(final Editor editor, final DataContext dataContext, @Nullable final Producer<Transferable> producer) {
|
||||
final Transferable transferable = EditorModificationUtil.getContentsToPasteToEditor(producer);
|
||||
if (transferable == null) return;
|
||||
|
||||
if (!CodeInsightUtilBase.prepareEditorForWrite(editor)) return;
|
||||
|
||||
final Document document = editor.getDocument();
|
||||
@@ -80,15 +87,18 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser
|
||||
return;
|
||||
}
|
||||
|
||||
DataContext context = dataContext;
|
||||
if (producer != null) {
|
||||
context = new DataContext() {
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
return PasteAction.TRANSFERABLE_PROVIDER.is(dataId) ? producer : dataContext.getData(dataId);
|
||||
}
|
||||
};
|
||||
}
|
||||
DataContext context = new DataContext() {
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
return PasteAction.TRANSFERABLE_PROVIDER.is(dataId) ? new Producer<Transferable>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Transferable produce() {
|
||||
return transferable;
|
||||
}
|
||||
} : dataContext.getData(dataId);
|
||||
}
|
||||
};
|
||||
|
||||
final Project project = editor.getProject();
|
||||
if (project == null || editor.isColumnMode() || editor.getCaretModel().getCaretCount() > 1) {
|
||||
@@ -114,7 +124,7 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser
|
||||
return;
|
||||
}
|
||||
}
|
||||
doPaste(editor, project, file, document, producer);
|
||||
doPaste(editor, project, file, document, transferable);
|
||||
}
|
||||
catch (ReadOnlyFragmentModificationException e) {
|
||||
EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(document).handle(e);
|
||||
@@ -128,152 +138,137 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser
|
||||
final Project project,
|
||||
final PsiFile file,
|
||||
final Document document,
|
||||
final Producer<Transferable> producer) {
|
||||
Transferable content = null;
|
||||
@NotNull final Transferable content) {
|
||||
CopyPasteManager.getInstance().stopKillRings();
|
||||
|
||||
String text = null;
|
||||
try {
|
||||
text = (String)content.getTransferData(DataFlavor.stringFlavor);
|
||||
}
|
||||
catch (Exception e) {
|
||||
editor.getComponent().getToolkit().beep();
|
||||
}
|
||||
if (text == null) return;
|
||||
|
||||
if (producer != null) {
|
||||
content = producer.produce();
|
||||
final CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
||||
|
||||
final Map<CopyPastePostProcessor, List<? extends TextBlockTransferableData>> extraData = new HashMap<CopyPastePostProcessor, List<? extends TextBlockTransferableData>>();
|
||||
Collection<TextBlockTransferableData> allValues = new ArrayList<TextBlockTransferableData>();
|
||||
|
||||
DumbService.getInstance(project).setAlternativeResolveEnabled(true);
|
||||
try {
|
||||
for (CopyPastePostProcessor<? extends TextBlockTransferableData> processor : Extensions.getExtensions(CopyPastePostProcessor.EP_NAME)) {
|
||||
List<? extends TextBlockTransferableData> data = processor.extractTransferableData(content);
|
||||
if (!data.isEmpty()) {
|
||||
extraData.put(processor, data);
|
||||
allValues.addAll(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
DumbService.getInstance(project).setAlternativeResolveEnabled(false);
|
||||
}
|
||||
|
||||
text = TextBlockTransferable.convertLineSeparators(editor, text, allValues);
|
||||
|
||||
final CaretModel caretModel = editor.getCaretModel();
|
||||
final SelectionModel selectionModel = editor.getSelectionModel();
|
||||
final int col = caretModel.getLogicalPosition().column;
|
||||
|
||||
// There is a possible case that we want to perform paste while there is an active selection at the editor and caret is located
|
||||
// inside it (e.g. Ctrl+A is pressed while caret is not at the zero column). We want to insert the text at selection start column
|
||||
// then, hence, inserted block of text should be indented according to the selection start as well.
|
||||
final int blockIndentAnchorColumn;
|
||||
final int caretOffset = caretModel.getOffset();
|
||||
if (selectionModel.hasSelection() && caretOffset >= selectionModel.getSelectionStart()) {
|
||||
blockIndentAnchorColumn = editor.offsetToLogicalPosition(selectionModel.getSelectionStart()).column;
|
||||
}
|
||||
else {
|
||||
CopyPasteManager manager = CopyPasteManager.getInstance();
|
||||
if (manager.areDataFlavorsAvailable(DataFlavor.stringFlavor)) {
|
||||
content = manager.getContents();
|
||||
if (content != null) {
|
||||
manager.stopKillRings();
|
||||
}
|
||||
}
|
||||
blockIndentAnchorColumn = col;
|
||||
}
|
||||
|
||||
if (content != null) {
|
||||
String text = null;
|
||||
try {
|
||||
text = (String)content.getTransferData(DataFlavor.stringFlavor);
|
||||
}
|
||||
catch (Exception e) {
|
||||
editor.getComponent().getToolkit().beep();
|
||||
}
|
||||
if (text == null) return;
|
||||
// We assume that EditorModificationUtil.insertStringAtCaret() is smart enough to remove currently selected text (if any).
|
||||
|
||||
final CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
||||
RawText rawText = RawText.fromTransferable(content);
|
||||
String newText = text;
|
||||
for (CopyPastePreProcessor preProcessor : Extensions.getExtensions(CopyPastePreProcessor.EP_NAME)) {
|
||||
newText = preProcessor.preprocessOnPaste(project, file, editor, newText, rawText);
|
||||
}
|
||||
int indentOptions = text.equals(newText) ? settings.REFORMAT_ON_PASTE : CodeInsightSettings.REFORMAT_BLOCK;
|
||||
text = newText;
|
||||
|
||||
final Map<CopyPastePostProcessor, List<? extends TextBlockTransferableData>> extraData = new HashMap<CopyPastePostProcessor, List<? extends TextBlockTransferableData>>();
|
||||
Collection<TextBlockTransferableData> allValues = new ArrayList<TextBlockTransferableData>();
|
||||
|
||||
DumbService.getInstance(project).setAlternativeResolveEnabled(true);
|
||||
try {
|
||||
for (CopyPastePostProcessor<? extends TextBlockTransferableData> processor : Extensions.getExtensions(CopyPastePostProcessor.EP_NAME)) {
|
||||
List<? extends TextBlockTransferableData> data = processor.extractTransferableData(content);
|
||||
if (!data.isEmpty()) {
|
||||
extraData.put(processor, data);
|
||||
allValues.addAll(data);
|
||||
}
|
||||
if (LanguageFormatting.INSTANCE.forContext(file) == null && indentOptions != CodeInsightSettings.NO_REFORMAT) {
|
||||
indentOptions = CodeInsightSettings.INDENT_BLOCK;
|
||||
}
|
||||
|
||||
final String _text = text;
|
||||
ApplicationManager.getApplication().runWriteAction(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EditorModificationUtil.insertStringAtCaret(editor, _text, false, true);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
DumbService.getInstance(project).setAlternativeResolveEnabled(false);
|
||||
}
|
||||
);
|
||||
|
||||
text = TextBlockTransferable.convertLineSeparators(editor, text, allValues);
|
||||
int length = text.length();
|
||||
int offset = caretModel.getOffset() - length;
|
||||
if (offset < 0) {
|
||||
length += offset;
|
||||
offset = 0;
|
||||
}
|
||||
final RangeMarker bounds = document.createRangeMarker(offset, offset + length);
|
||||
|
||||
final CaretModel caretModel = editor.getCaretModel();
|
||||
final SelectionModel selectionModel = editor.getSelectionModel();
|
||||
final int col = caretModel.getLogicalPosition().column;
|
||||
caretModel.moveToOffset(bounds.getEndOffset());
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
selectionModel.removeSelection();
|
||||
|
||||
// There is a possible case that we want to perform paste while there is an active selection at the editor and caret is located
|
||||
// inside it (e.g. Ctrl+A is pressed while caret is not at the zero column). We want to insert the text at selection start column
|
||||
// then, hence, inserted block of text should be indented according to the selection start as well.
|
||||
final int blockIndentAnchorColumn;
|
||||
final int caretOffset = caretModel.getOffset();
|
||||
if (selectionModel.hasSelection() && caretOffset >= selectionModel.getSelectionStart()) {
|
||||
blockIndentAnchorColumn = editor.offsetToLogicalPosition(selectionModel.getSelectionStart()).column;
|
||||
}
|
||||
else {
|
||||
blockIndentAnchorColumn = col;
|
||||
}
|
||||
final Ref<Boolean> indented = new Ref<Boolean>(Boolean.FALSE);
|
||||
for (Map.Entry<CopyPastePostProcessor, List<? extends TextBlockTransferableData>> e : extraData.entrySet()) {
|
||||
//noinspection unchecked
|
||||
e.getKey().processTransferableData(project, editor, bounds, caretOffset, indented, e.getValue());
|
||||
}
|
||||
|
||||
// We assume that EditorModificationUtil.insertStringAtCaret() is smart enough to remove currently selected text (if any).
|
||||
boolean pastedTextContainsWhiteSpacesOnly =
|
||||
CharArrayUtil.shiftForward(document.getCharsSequence(), bounds.getStartOffset(), " \n\t") >= bounds.getEndOffset();
|
||||
|
||||
RawText rawText = RawText.fromTransferable(content);
|
||||
String newText = text;
|
||||
for (CopyPastePreProcessor preProcessor : Extensions.getExtensions(CopyPastePreProcessor.EP_NAME)) {
|
||||
newText = preProcessor.preprocessOnPaste(project, file, editor, newText, rawText);
|
||||
}
|
||||
int indentOptions = text.equals(newText) ? settings.REFORMAT_ON_PASTE : CodeInsightSettings.REFORMAT_BLOCK;
|
||||
text = newText;
|
||||
VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (!pastedTextContainsWhiteSpacesOnly && (virtualFile == null || !SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile))) {
|
||||
final int indentOptions1 = indentOptions;
|
||||
|
||||
if (LanguageFormatting.INSTANCE.forContext(file) == null && indentOptions != CodeInsightSettings.NO_REFORMAT) {
|
||||
indentOptions = CodeInsightSettings.INDENT_BLOCK;
|
||||
}
|
||||
|
||||
final String _text = text;
|
||||
ApplicationManager.getApplication().runWriteAction(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EditorModificationUtil.insertStringAtCaret(editor, _text, false, true);
|
||||
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(document);
|
||||
switch (indentOptions1) {
|
||||
case CodeInsightSettings.INDENT_BLOCK:
|
||||
if (!indented.get()) {
|
||||
indentBlock(project, editor, bounds.getStartOffset(), bounds.getEndOffset(), blockIndentAnchorColumn);
|
||||
}
|
||||
break;
|
||||
|
||||
case CodeInsightSettings.INDENT_EACH_LINE:
|
||||
if (!indented.get()) {
|
||||
indentEachLine(project, editor, bounds.getStartOffset(), bounds.getEndOffset());
|
||||
}
|
||||
break;
|
||||
|
||||
case CodeInsightSettings.REFORMAT_BLOCK:
|
||||
indentEachLine(project, editor, bounds.getStartOffset(), bounds.getEndOffset()); // this is needed for example when inserting a comment before method
|
||||
reformatBlock(project, editor, bounds.getStartOffset(), bounds.getEndOffset());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
int length = text.length();
|
||||
int offset = caretModel.getOffset() - length;
|
||||
if (offset < 0) {
|
||||
length += offset;
|
||||
offset = 0;
|
||||
}
|
||||
final RangeMarker bounds = document.createRangeMarker(offset, offset + length);
|
||||
|
||||
if (bounds.isValid()) {
|
||||
caretModel.moveToOffset(bounds.getEndOffset());
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
selectionModel.removeSelection();
|
||||
|
||||
final Ref<Boolean> indented = new Ref<Boolean>(Boolean.FALSE);
|
||||
for (Map.Entry<CopyPastePostProcessor, List<? extends TextBlockTransferableData>> e : extraData.entrySet()) {
|
||||
//noinspection unchecked
|
||||
e.getKey().processTransferableData(project, editor, bounds, caretOffset, indented, e.getValue());
|
||||
}
|
||||
|
||||
boolean pastedTextContainsWhiteSpacesOnly =
|
||||
CharArrayUtil.shiftForward(document.getCharsSequence(), bounds.getStartOffset(), " \n\t") >= bounds.getEndOffset();
|
||||
|
||||
VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (!pastedTextContainsWhiteSpacesOnly && (virtualFile == null || !SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile))) {
|
||||
final int indentOptions1 = indentOptions;
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(document);
|
||||
switch (indentOptions1) {
|
||||
case CodeInsightSettings.INDENT_BLOCK:
|
||||
if (!indented.get()) {
|
||||
indentBlock(project, editor, bounds.getStartOffset(), bounds.getEndOffset(), blockIndentAnchorColumn);
|
||||
}
|
||||
break;
|
||||
|
||||
case CodeInsightSettings.INDENT_EACH_LINE:
|
||||
if (!indented.get()) {
|
||||
indentEachLine(project, editor, bounds.getStartOffset(), bounds.getEndOffset());
|
||||
}
|
||||
break;
|
||||
|
||||
case CodeInsightSettings.REFORMAT_BLOCK:
|
||||
indentEachLine(project, editor, bounds.getStartOffset(), bounds.getEndOffset()); // this is needed for example when inserting a comment before method
|
||||
reformatBlock(project, editor, bounds.getStartOffset(), bounds.getEndOffset());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (bounds.isValid()) {
|
||||
caretModel.moveToOffset(bounds.getEndOffset());
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
selectionModel.removeSelection();
|
||||
editor.putUserData(EditorEx.LAST_PASTED_REGION, TextRange.create(bounds));
|
||||
}
|
||||
editor.putUserData(EditorEx.LAST_PASTED_REGION, TextRange.create(bounds));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -281,6 +281,13 @@ public class FoldingUpdate {
|
||||
}
|
||||
|
||||
public static class FoldingMap extends MultiMap<PsiElement, FoldingDescriptor>{
|
||||
public FoldingMap() {
|
||||
}
|
||||
|
||||
public FoldingMap(FoldingMap map) {
|
||||
super(map);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Map<PsiElement, Collection<FoldingDescriptor>> createMap() {
|
||||
|
||||
+11
-8
@@ -76,11 +76,14 @@ class UpdateFoldRegionsOperation implements Runnable {
|
||||
FoldingModelEx foldingModel = (FoldingModelEx)myEditor.getFoldingModel();
|
||||
Map<TextRange,Boolean> rangeToExpandStatusMap = newTroveMap();
|
||||
|
||||
removeInvalidRegions(info, foldingModel, rangeToExpandStatusMap);
|
||||
// FoldingUpdate caches instances of our object, so they must be immutable.
|
||||
FoldingUpdate.FoldingMap elementsToFold = new FoldingUpdate.FoldingMap(myElementsToFoldMap);
|
||||
|
||||
removeInvalidRegions(info, foldingModel, elementsToFold, rangeToExpandStatusMap);
|
||||
|
||||
Map<FoldRegion, Boolean> shouldExpand = newTroveMap();
|
||||
Map<FoldingGroup, Boolean> groupExpand = newTroveMap();
|
||||
List<FoldRegion> newRegions = addNewRegions(info, foldingModel, rangeToExpandStatusMap, shouldExpand, groupExpand);
|
||||
List<FoldRegion> newRegions = addNewRegions(info, foldingModel, elementsToFold, rangeToExpandStatusMap, shouldExpand, groupExpand);
|
||||
|
||||
applyExpandStatus(newRegions, shouldExpand, groupExpand);
|
||||
}
|
||||
@@ -100,14 +103,14 @@ class UpdateFoldRegionsOperation implements Runnable {
|
||||
|
||||
private List<FoldRegion> addNewRegions(@NotNull EditorFoldingInfo info,
|
||||
@NotNull FoldingModelEx foldingModel,
|
||||
@NotNull Map<TextRange, Boolean> rangeToExpandStatusMap,
|
||||
FoldingUpdate.FoldingMap elementsToFold, @NotNull Map<TextRange, Boolean> rangeToExpandStatusMap,
|
||||
@NotNull Map<FoldRegion, Boolean> shouldExpand,
|
||||
@NotNull Map<FoldingGroup, Boolean> groupExpand) {
|
||||
List<FoldRegion> newRegions = newArrayList();
|
||||
SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(myProject);
|
||||
for (PsiElement element : myElementsToFoldMap.keySet()) {
|
||||
for (PsiElement element : elementsToFold.keySet()) {
|
||||
ProgressManager.checkCanceled();
|
||||
final Collection<FoldingDescriptor> descriptors = myElementsToFoldMap.get(element);
|
||||
final Collection<FoldingDescriptor> descriptors = elementsToFold.get(element);
|
||||
for (FoldingDescriptor descriptor : descriptors) {
|
||||
FoldingGroup group = descriptor.getGroup();
|
||||
TextRange range = descriptor.getRange();
|
||||
@@ -165,7 +168,7 @@ class UpdateFoldRegionsOperation implements Runnable {
|
||||
|
||||
private void removeInvalidRegions(@NotNull EditorFoldingInfo info,
|
||||
@NotNull FoldingModelEx foldingModel,
|
||||
@NotNull Map<TextRange, Boolean> rangeToExpandStatusMap) {
|
||||
FoldingUpdate.FoldingMap elementsToFold, @NotNull Map<TextRange, Boolean> rangeToExpandStatusMap) {
|
||||
List<FoldRegion> toRemove = newArrayList();
|
||||
InjectedLanguageManager injectedManager = InjectedLanguageManager.getInstance(myProject);
|
||||
for (FoldRegion region : foldingModel.getAllFoldRegions()) {
|
||||
@@ -176,7 +179,7 @@ class UpdateFoldRegionsOperation implements Runnable {
|
||||
if (isInjected != myForInjected) continue;
|
||||
}
|
||||
final Collection<FoldingDescriptor> descriptors;
|
||||
if (element != null && !(descriptors = myElementsToFoldMap.get(element)).isEmpty()) {
|
||||
if (element != null && !(descriptors = elementsToFold.get(element)).isEmpty()) {
|
||||
boolean matchingDescriptorFound = false;
|
||||
FoldingDescriptor[] array = descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
|
||||
for (FoldingDescriptor descriptor : array) {
|
||||
@@ -194,7 +197,7 @@ class UpdateFoldRegionsOperation implements Runnable {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
myElementsToFoldMap.remove(element, descriptor);
|
||||
elementsToFold.remove(element, descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -61,6 +61,7 @@ import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.SideBorder;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.ui.AbstractLayoutManager;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -230,8 +231,8 @@ public class LanguageConsoleImpl implements LanguageConsole, DataProvider {
|
||||
if (SEPARATOR_THICKNESS > 0 && myShowSeparatorLine) {
|
||||
myHistoryViewer.getComponent().setBorder(new SideBorder(JBColor.LIGHT_GRAY, SideBorder.BOTTOM));
|
||||
}
|
||||
myHistoryViewer.getComponent().setMinimumSize(new Dimension(0, 0));
|
||||
myHistoryViewer.getComponent().setPreferredSize(new Dimension(0, 0));
|
||||
myHistoryViewer.getComponent().setMinimumSize(JBUI.emptySize());
|
||||
myHistoryViewer.getComponent().setPreferredSize(JBUI.emptySize());
|
||||
myHistoryViewer.setCaretEnabled(false);
|
||||
|
||||
myConsoleEditor.setHorizontalScrollbarVisible(true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -95,7 +95,7 @@ public abstract class RunTab implements DataProvider, Disposable {
|
||||
logConsoleManager = new LogConsoleManagerBase(myProject, mySearchScope) {
|
||||
@Override
|
||||
protected Icon getDefaultIcon() {
|
||||
return AllIcons.Debugger.Console;
|
||||
return AllIcons.Debugger.Console_log;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1682,10 +1682,10 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
myProgressIndicator, new Processor<Object>() {
|
||||
@Override
|
||||
public boolean process(Object o) {
|
||||
if (o instanceof PsiElement && !(((PsiElement)o).getParent() instanceof PsiFile)) {
|
||||
if (isSymbol(o)) {
|
||||
final PsiElement element = (PsiElement)o;
|
||||
final PsiFile file = element.getContainingFile();
|
||||
if (!myListModel.contains(o) &&
|
||||
if (!myListModel.contains(o) && !symbols.contains(o) &&
|
||||
//some elements are non-physical like DB columns
|
||||
(file == null || (file.getVirtualFile() != null && (includeLibs || scope.accept(file.getVirtualFile()))))) {
|
||||
symbols.add(o);
|
||||
@@ -1698,6 +1698,16 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
return symbols;
|
||||
}
|
||||
|
||||
protected boolean isSymbol(Object o) {
|
||||
if (o instanceof PsiElement) {
|
||||
final PsiElement e = (PsiElement)o;
|
||||
//todo[kb] need a better way to avoid mixing java classes with symbols. Same to other languages where
|
||||
//todo[kb] symbol provider returns classes. We need kind of suppressor API & EP here.
|
||||
return !e.getLanguage().is(Language.findLanguageByID("JAVA")) || !(e.getParent() instanceof PsiFile);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private SearchResult getClasses(String pattern, boolean includeLibs, final int max, ChooseByNamePopup chooseByNamePopup) {
|
||||
final SearchResult classes = new SearchResult();
|
||||
if (chooseByNamePopup == null) {
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.panels.VerticalLayout;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ui.ColorIcon;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -237,11 +238,11 @@ public class ScopeEditorPanel {
|
||||
myPackageTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
final boolean recursiveEnabled = isButtonEnabled(true, e.getPaths(), e);
|
||||
final boolean recursiveEnabled = isButtonEnabled(true);
|
||||
includeRec.setEnabled(recursiveEnabled);
|
||||
excludeRec.setEnabled(recursiveEnabled);
|
||||
|
||||
final boolean nonRecursiveEnabled = isButtonEnabled(false, e.getPaths(), e);
|
||||
final boolean nonRecursiveEnabled = isButtonEnabled(false);
|
||||
include.setEnabled(nonRecursiveEnabled);
|
||||
exclude.setEnabled(nonRecursiveEnabled);
|
||||
}
|
||||
@@ -281,19 +282,6 @@ public class ScopeEditorPanel {
|
||||
return buttonsPanel;
|
||||
}
|
||||
|
||||
static boolean isButtonEnabled(boolean rec, TreePath[] paths, TreeSelectionEvent e) {
|
||||
if (paths != null) {
|
||||
for (TreePath path : paths) {
|
||||
if (!e.isAddedPath(path)) continue;
|
||||
final PackageDependenciesNode node = (PackageDependenciesNode)path.getLastPathComponent();
|
||||
if (PatternDialectProvider.getInstance(DependencyUISettings.getInstance().SCOPE_TYPE).createPackageSet(node, rec) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isButtonEnabled(boolean rec) {
|
||||
final TreePath[] paths = myPackageTree.getSelectionPaths();
|
||||
if (paths != null) {
|
||||
|
||||
@@ -197,6 +197,17 @@ public class EditorModificationUtil {
|
||||
zeroWidthBlockSelectionAtCaretColumn(editor, caretLine, caretLine);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Transferable getContentsToPasteToEditor(@Nullable Producer<Transferable> producer) {
|
||||
if (producer == null) {
|
||||
CopyPasteManager manager = CopyPasteManager.getInstance();
|
||||
return manager.areDataFlavorsAvailable(DataFlavor.stringFlavor) ? manager.getContents() : null;
|
||||
}
|
||||
else {
|
||||
return producer.produce();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getStringContent(@NotNull Transferable content) {
|
||||
RawText raw = RawText.fromTransferable(content);
|
||||
|
||||
+6
-2
@@ -23,6 +23,10 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Base class for {@link EditorActionHandler} instances, which need to modify the document.
|
||||
* Implementations should override {@link #executeWriteAction(Editor, Caret, DataContext)}.
|
||||
*/
|
||||
public abstract class EditorWriteActionHandler extends EditorActionHandler {
|
||||
private boolean inExecution;
|
||||
|
||||
@@ -34,7 +38,7 @@ public abstract class EditorWriteActionHandler extends EditorActionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void doExecute(final Editor editor, @Nullable final Caret caret, final DataContext dataContext) {
|
||||
public void doExecute(final Editor editor, @Nullable final Caret caret, final DataContext dataContext) {
|
||||
if (editor.isViewer()) return;
|
||||
|
||||
if (dataContext != null) {
|
||||
@@ -63,7 +67,7 @@ public abstract class EditorWriteActionHandler extends EditorActionHandler {
|
||||
|
||||
/**
|
||||
* @deprecated Use/override
|
||||
* {@link #executeWriteAction(com.intellij.openapi.editor.Editor, com.intellij.openapi.editor.Caret, com.intellij.openapi.actionSystem.DataContext)}
|
||||
* {@link #executeWriteAction(Editor, Caret, DataContext)}
|
||||
* instead.
|
||||
*/
|
||||
public void executeWriteAction(Editor editor, DataContext dataContext) {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class TextFieldWithBrowseButton extends ComponentWithBrowseButton<JTextFi
|
||||
}
|
||||
|
||||
public TextFieldWithBrowseButton(ActionListener browseActionListener) {
|
||||
this(new JTextField(10/* to prevent field to be infinitely resized in grid-box layouts */), browseActionListener);
|
||||
this(new JBTextField(10/* to prevent field to be infinitely resized in grid-box layouts */), browseActionListener);
|
||||
}
|
||||
|
||||
public void addBrowseFolderListener(@Nullable String title, @Nullable String description, @Nullable Project project, FileChooserDescriptor fileChooserDescriptor) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.wm.IdeGlassPane;
|
||||
import com.intellij.openapi.wm.IdeGlassPaneUtil;
|
||||
import com.intellij.ui.ClickListener;
|
||||
import com.intellij.ui.UIBundle;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.update.Activatable;
|
||||
import com.intellij.util.ui.update.UiNotifyConnector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -143,9 +144,9 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable {
|
||||
public Dimension getMinimumSize() {
|
||||
if (isHonorMinimumSize()) {
|
||||
final int dividerWidth = getDividerWidth();
|
||||
final Dimension firstSize = myFirstComponent != null ? myFirstComponent.getMinimumSize() : new Dimension(0, 0);
|
||||
final Dimension lastSize = myLastComponent != null ? myLastComponent.getMinimumSize() : new Dimension(0, 0);
|
||||
final Dimension innerSize = myInnerComponent != null ? myInnerComponent.getMinimumSize() : new Dimension(0, 0);
|
||||
final Dimension firstSize = myFirstComponent != null ? myFirstComponent.getMinimumSize() : JBUI.emptySize();
|
||||
final Dimension lastSize = myLastComponent != null ? myLastComponent.getMinimumSize() : JBUI.emptySize();
|
||||
final Dimension innerSize = myInnerComponent != null ? myInnerComponent.getMinimumSize() : JBUI.emptySize();
|
||||
if (getOrientation()) {
|
||||
int width = Math.max(firstSize.width, Math.max(lastSize.width, innerSize.width));
|
||||
int height = visibleDividersCount() * dividerWidth;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,10 +18,7 @@ package com.intellij.ide.util;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.ComponentWithEmptyText;
|
||||
import com.intellij.util.ui.StatusText;
|
||||
import com.intellij.util.ui.Table;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -87,7 +84,7 @@ public class MultiStateElementsChooser<T, S> extends JPanel implements Component
|
||||
myTableModel = new MyTableModel(elementsCanBeMarked);
|
||||
myTable = new Table(myTableModel);
|
||||
myTable.setShowGrid(false);
|
||||
myTable.setIntercellSpacing(new Dimension(0, 0));
|
||||
myTable.setIntercellSpacing(JBUI.emptySize());
|
||||
myTable.setTableHeader(null);
|
||||
myTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
||||
myTable.setColumnSelectionAllowed(false);
|
||||
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -83,7 +83,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
*/
|
||||
private final List<Rectangle> myComponentBounds = new ArrayList<Rectangle>();
|
||||
|
||||
private Dimension myMinimumButtonSize = new Dimension(0, 0);
|
||||
private Dimension myMinimumButtonSize = JBUI.emptySize();
|
||||
|
||||
/**
|
||||
* @see ActionToolbar#getLayoutPolicy()
|
||||
@@ -753,7 +753,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
public Dimension getPreferredSize() {
|
||||
final ArrayList<Rectangle> bounds = new ArrayList<Rectangle>();
|
||||
calculateBounds(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE), bounds);
|
||||
if (bounds.isEmpty()) return new Dimension(0, 0);
|
||||
if (bounds.isEmpty()) return JBUI.emptySize();
|
||||
int xLeft = Integer.MAX_VALUE;
|
||||
int yTop = Integer.MAX_VALUE;
|
||||
int xRight = Integer.MIN_VALUE;
|
||||
@@ -798,10 +798,10 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
|
||||
public MySeparator() {
|
||||
if (myOrientation == SwingConstants.HORIZONTAL) {
|
||||
mySize = new Dimension(6, 24);
|
||||
mySize = JBUI.size(6, 24);
|
||||
}
|
||||
else {
|
||||
mySize = new Dimension(24, 6);
|
||||
mySize = JBUI.size(24, 6);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1247,7 +1247,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
|
||||
myMinimalMode = minimalMode;
|
||||
if (myMinimalMode) {
|
||||
setMinimumButtonSize(new Dimension(0, 0));
|
||||
setMinimumButtonSize(JBUI.emptySize());
|
||||
setLayoutPolicy(NOWRAP_LAYOUT_POLICY);
|
||||
setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
setOpaque(false);
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.editor.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorCopyPasteHelper;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
|
||||
import com.intellij.util.Producer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.datatransfer.Transferable;
|
||||
|
||||
public abstract class BasePasteHandler extends EditorWriteActionHandler {
|
||||
protected Transferable myTransferable;
|
||||
|
||||
@Override
|
||||
public void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) {
|
||||
// We capture the contents to paste here, so it that it won't be affected by possible clipboard operations later (e.g. during unlocking
|
||||
// of current file for writing)
|
||||
myTransferable = getContentsToPaste(editor, dataContext);
|
||||
try {
|
||||
super.doExecute(editor, caret, dataContext);
|
||||
}
|
||||
finally {
|
||||
myTransferable = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeWriteAction(Editor editor, @Nullable Caret caret, DataContext dataContext) {
|
||||
if (myTransferable != null) {
|
||||
EditorCopyPasteHelper.getInstance().pasteTransferable(editor, myTransferable);
|
||||
}
|
||||
}
|
||||
|
||||
protected Transferable getContentsToPaste(Editor editor, DataContext dataContext) {
|
||||
Producer<Transferable> producer = PasteAction.TRANSFERABLE_PROVIDER.getData(dataContext);
|
||||
return EditorModificationUtil.getContentsToPasteToEditor(producer);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-5
@@ -19,10 +19,9 @@ import com.intellij.ide.CopyPasteManagerEx;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.ui.UIBundle;
|
||||
|
||||
@@ -100,9 +99,6 @@ public class MultiplePasteAction extends AnAction implements DumbAware {
|
||||
|
||||
if (editor != null) {
|
||||
if (editor.isViewer()) return;
|
||||
if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)){
|
||||
return;
|
||||
}
|
||||
|
||||
final AnAction pasteAction = ActionManager.getInstance().getAction(IdeActions.ACTION_PASTE);
|
||||
AnActionEvent newEvent = new AnActionEvent(e.getInputEvent(),
|
||||
|
||||
@@ -17,10 +17,10 @@ package com.intellij.openapi.editor.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.editor.EditorCopyPasteHelper;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.util.Producer;
|
||||
@@ -38,17 +38,17 @@ public class PasteAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends EditorWriteActionHandler {
|
||||
private static class Handler extends BasePasteHandler {
|
||||
@Override
|
||||
public void executeWriteAction(Editor editor, DataContext dataContext) {
|
||||
Producer<Transferable> producer = TRANSFERABLE_PROVIDER.getData(dataContext);
|
||||
if (!editor.getCaretModel().supportsMultipleCarets() && editor.isColumnMode()) {
|
||||
EditorModificationUtil.pasteTransferableAsBlock(editor, producer);
|
||||
}
|
||||
else {
|
||||
TextRange range = EditorModificationUtil.pasteTransferable(editor, producer);
|
||||
editor.putUserData(EditorEx.LAST_PASTED_REGION, range);
|
||||
public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
|
||||
TextRange range = null;
|
||||
if (myTransferable != null) {
|
||||
TextRange[] ranges = EditorCopyPasteHelper.getInstance().pasteTransferable(editor, myTransferable);
|
||||
if (ranges != null && ranges.length == 1) {
|
||||
range = ranges[0];
|
||||
}
|
||||
}
|
||||
editor.putUserData(EditorEx.LAST_PASTED_REGION, range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-22
@@ -21,15 +21,9 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
|
||||
import com.intellij.openapi.editor.event.EditorMouseEventArea;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.util.Producer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -71,30 +65,19 @@ public class PasteFromX11Action extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler extends EditorWriteActionHandler {
|
||||
public static class Handler extends BasePasteHandler {
|
||||
@Override
|
||||
public void executeWriteAction(Editor editor, DataContext dataContext) {
|
||||
protected Transferable getContentsToPaste(Editor editor, DataContext dataContext) {
|
||||
Clipboard clip = editor.getComponent().getToolkit().getSystemSelection();
|
||||
if (clip == null) return;
|
||||
if (clip == null) return null;
|
||||
|
||||
final Transferable content;
|
||||
try {
|
||||
content = clip.getContents(null);
|
||||
return clip.getContents(null);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.info(e);
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
if (content == null) return;
|
||||
|
||||
TextRange range = EditorModificationUtil.pasteTransferable(editor, new Producer<Transferable>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Transferable produce() {
|
||||
return content;
|
||||
}
|
||||
});
|
||||
editor.putUserData(EditorEx.LAST_PASTED_REGION, range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-21
@@ -19,15 +19,10 @@ import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.util.Producer;
|
||||
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
@@ -47,21 +42,9 @@ public class SimplePasteAction extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
private static class Handler extends EditorWriteActionHandler {
|
||||
private static class Handler extends BasePasteHandler {
|
||||
@Override
|
||||
public void executeWriteAction(Editor editor, DataContext dataContext) {
|
||||
Producer<Transferable> producer = PasteAction.TRANSFERABLE_PROVIDER.getData(dataContext);
|
||||
if (!editor.getCaretModel().supportsMultipleCarets() && editor.isColumnMode()) {
|
||||
EditorModificationUtil.pasteTransferableAsBlock(editor, producer);
|
||||
}
|
||||
else {
|
||||
TextRange range = EditorModificationUtil.pasteTransferable(editor, producer);
|
||||
editor.putUserData(EditorEx.LAST_PASTED_REGION, range);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(Editor editor, DataContext dataContext) {
|
||||
public boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
|
||||
return !editor.isViewer();
|
||||
}
|
||||
}
|
||||
|
||||
+6
-12
@@ -26,12 +26,12 @@ import com.intellij.openapi.util.text.LineTokenizer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class EditorCopyPasteHelperImpl extends EditorCopyPasteHelper {
|
||||
private static final Logger LOG = Logger.getInstance(EditorCopyPasteHelperImpl.class);
|
||||
@@ -72,14 +72,8 @@ public class EditorCopyPasteHelperImpl extends EditorCopyPasteHelper {
|
||||
@Nullable
|
||||
@Override
|
||||
public TextRange[] pasteFromClipboard(@NotNull Editor editor) {
|
||||
CopyPasteManager manager = CopyPasteManager.getInstance();
|
||||
if (manager.areDataFlavorsAvailable(DataFlavor.stringFlavor)) {
|
||||
Transferable clipboardContents = manager.getContents();
|
||||
if (clipboardContents != null) {
|
||||
return pasteTransferable(editor, clipboardContents);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
Transferable transferable = EditorModificationUtil.getContentsToPasteToEditor(null);
|
||||
return transferable == null ? null : pasteTransferable(editor, transferable);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+5
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import java.awt.*;
|
||||
@@ -777,11 +779,11 @@ public class LeftHandScrollbarLayout extends ScrollPaneLayout {
|
||||
Component view = (viewport != null) ? viewport.getView() : null;
|
||||
Dimension viewPrefSize =
|
||||
(view != null) ? view.getPreferredSize()
|
||||
: new Dimension(0, 0);
|
||||
: JBUI.emptySize();
|
||||
|
||||
Dimension extentSize =
|
||||
(viewport != null) ? viewport.toViewCoordinates(availR.getSize())
|
||||
: new Dimension(0, 0);
|
||||
: JBUI.emptySize();
|
||||
|
||||
boolean viewTracksViewportWidth = false;
|
||||
boolean viewTracksViewportHeight = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Weighted;
|
||||
import com.intellij.openapi.wm.IdeGlassPane;
|
||||
import com.intellij.openapi.wm.IdeGlassPaneUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -85,7 +86,7 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
|
||||
setLayout(null);
|
||||
|
||||
myFocusProxy.setOpaque(false);
|
||||
myFocusProxy.setPreferredSize(new Dimension(0, 0));
|
||||
myFocusProxy.setPreferredSize(JBUI.emptySize());
|
||||
myFocusProxy.setFocusable(true);
|
||||
UIUtil.setFocusProxy(myFocusProxy, true);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,6 +39,7 @@ import com.intellij.ui.PopupHandler;
|
||||
import com.intellij.ui.components.JBLayeredPane;
|
||||
import com.intellij.ui.components.JBPanel;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -342,7 +343,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
|
||||
mbd = menuBar.getPreferredSize();
|
||||
}
|
||||
else {
|
||||
mbd = new Dimension(0, 0);
|
||||
mbd = JBUI.emptySize();
|
||||
}
|
||||
return new Dimension(Math.max(rd.width, mbd.width) + i.left + i.right,
|
||||
rd.height + mbd.height + i.top + i.bottom);
|
||||
@@ -361,7 +362,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
|
||||
mbd = menuBar.getMinimumSize();
|
||||
}
|
||||
else {
|
||||
mbd = new Dimension(0, 0);
|
||||
mbd = JBUI.emptySize();
|
||||
}
|
||||
return new Dimension(Math.max(rd.width, mbd.width) + i.left + i.right,
|
||||
rd.height + mbd.height + i.top + i.bottom);
|
||||
@@ -374,7 +375,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
|
||||
mbd = menuBar.getMaximumSize();
|
||||
}
|
||||
else {
|
||||
mbd = new Dimension(0, 0);
|
||||
mbd = JBUI.emptySize();
|
||||
}
|
||||
if (contentPane != null) {
|
||||
rd = contentPane.getMaximumSize();
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.awt.RelativeRectangle;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentManagerEvent;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -54,7 +55,7 @@ class ComboContentLayout extends ContentLayout {
|
||||
@Override
|
||||
public void layout() {
|
||||
Rectangle bounds = myUi.getBounds();
|
||||
Dimension idSize = isIdVisible() ? myIdLabel.getPreferredSize() : new Dimension(0, 0);
|
||||
Dimension idSize = isIdVisible() ? myIdLabel.getPreferredSize() : JBUI.emptySize();
|
||||
|
||||
int eachX = 0;
|
||||
int eachY = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -1071,7 +1071,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
|
||||
@Override
|
||||
Point getLocation(final Dimension containerSize, final Point targetPoint, final Dimension balloonSize) {
|
||||
final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, new Dimension(0, 0)), balloonSize);
|
||||
final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, JBUI.emptySize()), balloonSize);
|
||||
return new Point(center.x, targetPoint.y);
|
||||
}
|
||||
|
||||
@@ -1128,7 +1128,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
|
||||
@Override
|
||||
Point getLocation(final Dimension containerSize, final Point targetPoint, final Dimension balloonSize) {
|
||||
final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, new Dimension(0, 0)), balloonSize);
|
||||
final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, JBUI.emptySize()), balloonSize);
|
||||
return new Point(center.x, targetPoint.y - balloonSize.height);
|
||||
}
|
||||
|
||||
@@ -1186,7 +1186,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
|
||||
@Override
|
||||
Point getLocation(final Dimension containerSize, final Point targetPoint, final Dimension balloonSize) {
|
||||
final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, new Dimension(0, 0)), balloonSize);
|
||||
final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, JBUI.emptySize()), balloonSize);
|
||||
return new Point(targetPoint.x, center.y);
|
||||
}
|
||||
|
||||
@@ -1243,7 +1243,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
|
||||
@Override
|
||||
Point getLocation(final Dimension containerSize, final Point targetPoint, final Dimension balloonSize) {
|
||||
final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, new Dimension(0, 0)), balloonSize);
|
||||
final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, JBUI.emptySize()), balloonSize);
|
||||
return new Point(targetPoint.x - balloonSize.width, center.y);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.mac.MacMainFrameDecorator;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.ui.Animator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -221,6 +222,7 @@ public class SheetMessage {
|
||||
staticImage = null;
|
||||
myWindow.setContentPane(myController.getPanel(myWindow));
|
||||
|
||||
IJSwingUtilities.moveMousePointerOn(myWindow.getRootPane().getDefaultButton());
|
||||
myController.requestFocus();
|
||||
} else {
|
||||
if (restoreFullScreenButton) {
|
||||
|
||||
@@ -100,7 +100,7 @@ inspection.empty.method.delete.quickfix=Delete unnecessary method(s)
|
||||
inspection.empty.method.problem.descriptor=Method only calls its super
|
||||
inspection.empty.method.problem.descriptor1=Empty method overrides empty method
|
||||
inspection.empty.method.problem.descriptor2=The method is empty
|
||||
inspection.empty.method.problem.descriptor3=The method and all it's derivables are empty
|
||||
inspection.empty.method.problem.descriptor3=The method and all its derivables are empty
|
||||
inspection.empty.method.problem.descriptor4=All implementations of this method are empty
|
||||
|
||||
#redundant cast
|
||||
|
||||
@@ -716,9 +716,6 @@
|
||||
<action id="IntroduceParameter">
|
||||
<keyboard-shortcut first-keystroke="control alt P"/>
|
||||
</action>
|
||||
<action id="IntroduceFunctionalParameter">
|
||||
<keyboard-shortcut first-keystroke="control alt shift P"/>
|
||||
</action>
|
||||
<action id="NextOccurence">
|
||||
<keyboard-shortcut first-keystroke="control alt DOWN"/>
|
||||
</action>
|
||||
|
||||
+86
-85
@@ -1,5 +1,7 @@
|
||||
package com.intellij.structuralsearch.plugin.ui;
|
||||
|
||||
import com.intellij.ide.ui.search.SearchUtil;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.structuralsearch.SSRBundle;
|
||||
@@ -9,7 +11,9 @@ import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.*;
|
||||
@@ -90,25 +94,37 @@ public class ExistingTemplatesComponent {
|
||||
}
|
||||
|
||||
panel = ToolbarDecorator.createDecorator(patternTree)
|
||||
.setAddAction(new AnActionButtonRunnable() {
|
||||
.setRemoveAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
addSelectedTreeNodeAndClose();
|
||||
final Object selection = patternTree.getLastSelectedPathComponent();
|
||||
if (!(selection instanceof DefaultMutableTreeNode)) {
|
||||
return;
|
||||
}
|
||||
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)selection;
|
||||
if (!(node.getUserObject() instanceof Configuration)) {
|
||||
return;
|
||||
}
|
||||
final Configuration configuration = (Configuration)node.getUserObject();
|
||||
if (configuration.isPredefined()) {
|
||||
return;
|
||||
}
|
||||
patternTreeModel.removeNodeFromParent(node);
|
||||
configurationManager.removeConfiguration(configuration);
|
||||
}
|
||||
}).setRemoveAction(new AnActionButtonRunnable() {
|
||||
}).setRemoveActionUpdater(new AnActionButtonUpdater() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
Object selection = patternTree.getLastSelectedPathComponent();
|
||||
|
||||
public boolean isEnabled(AnActionEvent e) {
|
||||
final Object selection = patternTree.getLastSelectedPathComponent();
|
||||
if (selection instanceof DefaultMutableTreeNode) {
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode)selection;
|
||||
|
||||
if (node.getUserObject() instanceof Configuration) {
|
||||
Configuration configuration = (Configuration)node.getUserObject();
|
||||
patternTreeModel.removeNodeFromParent(node);
|
||||
configurationManager.removeConfiguration(configuration);
|
||||
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)selection;
|
||||
final Object userObject = node.getUserObject();
|
||||
if (userObject instanceof Configuration) {
|
||||
final Configuration configuration = (Configuration)userObject;
|
||||
return !configuration.isPredefined();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}).createPanel();
|
||||
|
||||
@@ -118,23 +134,19 @@ public class ExistingTemplatesComponent {
|
||||
|
||||
historyModel = new DefaultListModel();
|
||||
historyPanel = new JPanel(new BorderLayout());
|
||||
historyPanel.add(
|
||||
BorderLayout.NORTH,
|
||||
new JLabel(SSRBundle.message("used.templates"))
|
||||
);
|
||||
Component view = historyList = new JBList(historyModel);
|
||||
historyPanel.add(
|
||||
BorderLayout.CENTER,
|
||||
ScrollPaneFactory.createScrollPane(view)
|
||||
);
|
||||
|
||||
historyList.setCellRenderer(
|
||||
new ListCellRenderer()
|
||||
);
|
||||
historyPanel.add(BorderLayout.NORTH, new JLabel(SSRBundle.message("used.templates")));
|
||||
|
||||
historyList = new JBList(historyModel);
|
||||
historyPanel.add(BorderLayout.CENTER, ScrollPaneFactory.createScrollPane(historyList));
|
||||
historyList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
new ListSpeedSearch(historyList);
|
||||
final ListSpeedSearch speedSearch = new ListSpeedSearch(historyList, new Convertor<Object, String>() {
|
||||
@Override
|
||||
public String convert(Object o) {
|
||||
return o instanceof Configuration ? ((Configuration)o).getName() : o.toString();
|
||||
}
|
||||
});
|
||||
historyList.setCellRenderer(new ExistingTemplatesListCellRenderer(speedSearch));
|
||||
|
||||
if (configurationManager.getHistoryConfigurations() != null) {
|
||||
for (final Configuration configuration : configurationManager.getHistoryConfigurations()) {
|
||||
@@ -167,13 +179,6 @@ public class ExistingTemplatesComponent {
|
||||
}.installOn(component);
|
||||
}
|
||||
|
||||
private void addSelectedTreeNodeAndClose() {
|
||||
addConfigurationToUserTemplates(
|
||||
Configuration.getConfigurationCreator().createConfiguration()
|
||||
);
|
||||
owner.close(DialogWrapper.OK_EXIT_CODE);
|
||||
}
|
||||
|
||||
private static Tree createTree(TreeModel treeModel) {
|
||||
final Tree tree = new Tree(treeModel);
|
||||
|
||||
@@ -183,25 +188,17 @@ public class ExistingTemplatesComponent {
|
||||
tree.setEditable(false);
|
||||
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
|
||||
|
||||
tree.setCellRenderer(new TreeCellRenderer());
|
||||
|
||||
new TreeSpeedSearch(
|
||||
final TreeSpeedSearch speedSearch = new TreeSpeedSearch(
|
||||
tree,
|
||||
new Convertor<TreePath, String>() {
|
||||
public String convert(TreePath object) {
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode)object.getLastPathComponent();
|
||||
Object displayValue = node.getUserObject();
|
||||
|
||||
if (displayValue instanceof Configuration) {
|
||||
displayValue = ((Configuration)displayValue).getName();
|
||||
}
|
||||
else {
|
||||
displayValue = "";
|
||||
}
|
||||
return displayValue.toString();
|
||||
final Object userObject = ((DefaultMutableTreeNode)object.getLastPathComponent()).getUserObject();
|
||||
return (userObject instanceof Configuration) ? ((Configuration)userObject).getName() : userObject.toString();
|
||||
}
|
||||
}
|
||||
);
|
||||
tree.setCellRenderer(new ExistingTemplatesTreeCellRenderer(speedSearch));
|
||||
|
||||
return tree;
|
||||
}
|
||||
@@ -224,56 +221,60 @@ public class ExistingTemplatesComponent {
|
||||
return plugin.getExistingTemplatesComponent();
|
||||
}
|
||||
|
||||
static class ListCellRenderer extends DefaultListCellRenderer {
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
private static class ExistingTemplatesListCellRenderer extends ColoredListCellRenderer {
|
||||
|
||||
private final ListSpeedSearch mySpeedSearch;
|
||||
|
||||
public ExistingTemplatesListCellRenderer(ListSpeedSearch speedSearch) {
|
||||
mySpeedSearch = speedSearch;
|
||||
}
|
||||
@Override
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean focus) {
|
||||
if (value instanceof Configuration) {
|
||||
value = ((Configuration)value).getName();
|
||||
}
|
||||
|
||||
Component comp = super.getListCellRendererComponent(
|
||||
list,
|
||||
value,
|
||||
index,
|
||||
isSelected,
|
||||
cellHasFocus
|
||||
);
|
||||
|
||||
return comp;
|
||||
final Color background = (selected && !focus) ?
|
||||
UIUtil.getListUnfocusedSelectionBackground() : UIUtil.getListBackground(selected);
|
||||
final Color foreground = UIUtil.getListForeground(selected);
|
||||
setPaintFocusBorder(false);
|
||||
SearchUtil.appendFragments(mySpeedSearch.getEnteredPrefix(), value.toString(), SimpleTextAttributes.STYLE_PLAIN,
|
||||
foreground, background, this);
|
||||
}
|
||||
}
|
||||
|
||||
static class TreeCellRenderer extends DefaultTreeCellRenderer {
|
||||
TreeCellRenderer() {
|
||||
setOpenIcon(null);
|
||||
setLeafIcon(null);
|
||||
setClosedIcon(null);
|
||||
private static class ExistingTemplatesTreeCellRenderer extends ColoredTreeCellRenderer {
|
||||
|
||||
private final TreeSpeedSearch mySpeedSearch;
|
||||
|
||||
ExistingTemplatesTreeCellRenderer(TreeSpeedSearch speedSearch) {
|
||||
mySpeedSearch = speedSearch;
|
||||
}
|
||||
|
||||
public Component getTreeCellRendererComponent(JTree tree,
|
||||
Object value,
|
||||
boolean sel,
|
||||
boolean expanded,
|
||||
boolean leaf,
|
||||
int row,
|
||||
boolean hasFocus) {
|
||||
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)value;
|
||||
Object displayValue = treeNode.getUserObject();
|
||||
@Override
|
||||
public void customizeCellRenderer(@NotNull JTree tree,
|
||||
Object value,
|
||||
boolean selected,
|
||||
boolean expanded,
|
||||
boolean leaf,
|
||||
int row,
|
||||
boolean hasFocus) {
|
||||
final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)value;
|
||||
final Object userObject = treeNode.getUserObject();
|
||||
|
||||
if (displayValue instanceof Configuration) {
|
||||
displayValue = ((Configuration)displayValue).getName();
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground(hasFocus) : UIUtil.getTreeTextBackground();
|
||||
final Color foreground = selected && hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground();
|
||||
|
||||
final String text;
|
||||
final int style;
|
||||
if (userObject instanceof Configuration) {
|
||||
text = ((Configuration)userObject).getName();
|
||||
style = SimpleTextAttributes.STYLE_PLAIN;
|
||||
}
|
||||
|
||||
Component comp = super.getTreeCellRendererComponent(
|
||||
tree,
|
||||
displayValue,
|
||||
sel,
|
||||
expanded,
|
||||
leaf,
|
||||
row,
|
||||
hasFocus
|
||||
);
|
||||
|
||||
return comp;
|
||||
else {
|
||||
text = userObject.toString();
|
||||
style = SimpleTextAttributes.STYLE_BOLD;
|
||||
}
|
||||
SearchUtil.appendFragments(mySpeedSearch.getEnteredPrefix(), text, style, foreground, background, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ incorrect.pattern.message=Incorrect pattern
|
||||
used.templates.history.dialog.title=Used Templates History
|
||||
existing.templates.dialog.title=Existing Templates
|
||||
selecttemplate.template.preview=Template preview:
|
||||
selecttemplate.template.label.please.select.template=<html><body><center>Please select template in the tree on the left.</center></body></html>
|
||||
selecttemplate.template.label.please.select.template=<html><body><center>Please select a template in the tree on the left.</center></body></html>
|
||||
|
||||
# Replace Dialog specific titles/options
|
||||
structural.replace.title=Structural Replace
|
||||
|
||||
@@ -215,6 +215,7 @@ public class AllIcons {
|
||||
public static final Icon Class_filter = IconLoader.getIcon("/debugger/class_filter.png"); // 16x16
|
||||
public static final Icon CommandLine = IconLoader.getIcon("/debugger/commandLine.png"); // 16x16
|
||||
public static final Icon Console = IconLoader.getIcon("/debugger/console.png"); // 16x16
|
||||
public static final Icon Console_log = IconLoader.getIcon("/debugger/console_log.png"); // 16x16
|
||||
public static final Icon Db_array = IconLoader.getIcon("/debugger/db_array.png"); // 16x16
|
||||
public static final Icon Db_db_object = IconLoader.getIcon("/debugger/db_db_object.png"); // 16x16
|
||||
public static final Icon Db_dep_exception_breakpoint = IconLoader.getIcon("/debugger/db_dep_exception_breakpoint.png"); // 12x12
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.ui;
|
||||
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.intellij.lang.annotations.MagicConstant;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -139,7 +140,7 @@ public class VerticalFlowLayout extends FlowLayout implements Serializable {
|
||||
|
||||
@Override
|
||||
public Dimension minimumLayoutSize(Container container) {
|
||||
Dimension dimension = new Dimension(0, 0);
|
||||
Dimension dimension = JBUI.emptySize();
|
||||
for(int i = 0; i < container.getComponentCount(); i++){
|
||||
Component component = container.getComponent(i);
|
||||
if (!component.isVisible()) continue;
|
||||
@@ -158,7 +159,7 @@ public class VerticalFlowLayout extends FlowLayout implements Serializable {
|
||||
|
||||
@Override
|
||||
public Dimension preferredLayoutSize(Container container) {
|
||||
Dimension dimension = new Dimension(0, 0);
|
||||
Dimension dimension = JBUI.emptySize();
|
||||
for(int i = 0; i < container.getComponentCount(); i++){
|
||||
Component component = container.getComponent(i);
|
||||
if (!component.isVisible()) continue;
|
||||
|
||||
@@ -305,12 +305,13 @@ public class FileSystemUtil {
|
||||
@Override
|
||||
protected boolean clonePermissions(@NotNull String source, @NotNull String target) throws Exception {
|
||||
if (SystemInfo.isUnix) {
|
||||
Object pathObj = myGetPath.invoke(myDefaultFileSystem, source, ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
Map attributes = (Map)myReadAttributes.invoke(null, pathObj, "posix:permissions", myLinkOptions);
|
||||
Object sourcePath = myGetPath.invoke(myDefaultFileSystem, source, ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
Object targetPath = myGetPath.invoke(myDefaultFileSystem, target, ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
Map attributes = (Map)myReadAttributes.invoke(null, sourcePath, "posix:permissions", myLinkOptions);
|
||||
if (attributes != null) {
|
||||
Object permissions = attributes.get("permissions");
|
||||
if (permissions instanceof Collection) {
|
||||
mySetAttribute.invoke(null, pathObj, "posix:permissions", permissions, myLinkOptions);
|
||||
mySetAttribute.invoke(null, targetPath, "posix:permissions", permissions, myLinkOptions);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
@@ -77,12 +76,13 @@ public class TitlePanel extends CaptionPanel {
|
||||
public Dimension getPreferredSize() {
|
||||
final String text = myLabel.getText();
|
||||
if (text == null || text.trim().isEmpty()) {
|
||||
return new Dimension(0, 0);
|
||||
return JBUI.emptySize();
|
||||
}
|
||||
|
||||
final Dimension preferredSize = super.getPreferredSize();
|
||||
if (!myHtml && preferredSize.width > 350) { // do not allow caption to extend parent container
|
||||
return new Dimension(350, preferredSize.height);
|
||||
int maxWidth = JBUI.scale(350);
|
||||
if (!myHtml && preferredSize.width > maxWidth) { // do not allow caption to extend parent container
|
||||
return new Dimension(maxWidth, preferredSize.height);
|
||||
}
|
||||
|
||||
return preferredSize;
|
||||
|
||||
@@ -156,6 +156,7 @@ public class Restarter {
|
||||
public static File createTempExecutable(File executable) throws IOException {
|
||||
File executableDir = new File(System.getProperty("user.home") + "/." + System.getProperty("idea.paths.selector") + "/restart");
|
||||
File copy = new File(executableDir.getPath() + "/" + executable.getName());
|
||||
if (!FileUtilRt.createDirectory(executableDir)) throw new IOException("Cannot create dir: " + executableDir);
|
||||
if (!FileUtilRt.ensureCanCreateFile(copy) || (copy.exists() && !copy.delete())) {
|
||||
String ext = FileUtilRt.getExtension(executable.getName());
|
||||
copy = FileUtilRt.createTempFile(executableDir, FileUtilRt.getNameWithoutExtension(copy.getName()),
|
||||
|
||||
@@ -56,6 +56,10 @@ public class JBUI {
|
||||
return (EmptyIcon)EmptyIcon.create(scale(i));
|
||||
}
|
||||
|
||||
public static JBDimension emptySize() {
|
||||
return new JBDimension(0, 0);
|
||||
}
|
||||
|
||||
public static float scale(float f) {
|
||||
return f * scale(1);
|
||||
}
|
||||
|
||||
@@ -578,6 +578,10 @@
|
||||
key="non.public.clone.display.name" groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.cloning.issues" enabledByDefault="false" level="WARNING"
|
||||
implementationClass="com.siyeh.ig.cloneable.NonPublicCloneInspection"/>
|
||||
<localInspection language="JAVA" shortName="UseOfClone" bundle="com.siyeh.InspectionGadgetsBundle"
|
||||
key="use.of.clone.display.name" groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.cloning.issues" enabledByDefault="false" level="WARNING"
|
||||
implementationClass="com.siyeh.ig.cloneable.UseOfCloneInspection"/>
|
||||
|
||||
<!--group.names.control.flow.issues-->
|
||||
<localInspection language="JAVA" shortName="BreakStatement" bundle="com.siyeh.InspectionGadgetsBundle" key="break.statement.display.name"
|
||||
|
||||
+4
@@ -2140,3 +2140,7 @@ clone.returns.class.type.display.name='clone()' should have return type equal to
|
||||
clone.returns.class.type.problem.descriptor=''clone()'' should have return type ''{0}'' #loc
|
||||
clone.returns.class.type.quickfix=Change return type to ''{0}''
|
||||
clone.returns.class.type.family.quickfix=Change return type to class type
|
||||
use.of.clone.display.name=Use of 'clone()' or 'Cloneable'
|
||||
use.of.clone.call.problem.descriptor=Call to <code>#ref()</code>
|
||||
use.of.clone.call.method.problem.descriptor=Implementation of <code>#ref()</code>
|
||||
use.of.clone.reference.problem.descriptor=Use of <code>#ref</code>
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class CloneCallsConstructorsInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
final PsiClass aClass = method.getContainingClass();
|
||||
if (aClass == null || aClass.hasModifierProperty(PsiModifier.FINAL) || !CloneUtils.isCloneable(aClass)) {
|
||||
if (aClass == null || aClass.hasModifierProperty(PsiModifier.FINAL)) {
|
||||
return;
|
||||
}
|
||||
method.accept(new JavaRecursiveElementVisitor() {
|
||||
|
||||
+4
-9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -77,15 +77,10 @@ public class CloneCallsSuperCloneInspection extends BaseInspection {
|
||||
containingClass.isAnnotationType()) {
|
||||
return;
|
||||
}
|
||||
if (CloneUtils.onlyThrowsCloneNotSupportedException(method)) {
|
||||
if (method.hasModifierProperty(PsiModifier.FINAL) ||
|
||||
containingClass.hasModifierProperty(
|
||||
PsiModifier.FINAL)) {
|
||||
return;
|
||||
}
|
||||
if (CloneUtils.onlyThrowsException(method)) {
|
||||
return;
|
||||
}
|
||||
final CallToSuperCloneVisitor visitor =
|
||||
new CallToSuperCloneVisitor();
|
||||
final CallToSuperCloneVisitor visitor = new CallToSuperCloneVisitor();
|
||||
method.accept(visitor);
|
||||
if (visitor.isCallToSuperCloneFound()) {
|
||||
return;
|
||||
|
||||
+1
-4
@@ -104,10 +104,7 @@ public class CloneInNonCloneableClassInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
if (CloneUtils.isCloneable(containingClass)) {
|
||||
return;
|
||||
}
|
||||
if (method.hasModifierProperty(PsiModifier.FINAL) && CloneUtils.onlyThrowsCloneNotSupportedException(method)) {
|
||||
if (CloneUtils.isCloneable(containingClass) || CloneUtils.onlyThrowsException(method)) {
|
||||
return;
|
||||
}
|
||||
registerMethodError(method, containingClass);
|
||||
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.siyeh.ig.cloneable;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.siyeh.HardcodedMethodConstants;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.psiutils.CloneUtils;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class UseOfCloneInspection extends BaseInspection {
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return InspectionGadgetsBundle.message("use.of.clone.display.name");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String buildErrorString(Object... infos) {
|
||||
final Object errorElement = infos[0];
|
||||
if (errorElement instanceof PsiMethodCallExpression) {
|
||||
return InspectionGadgetsBundle.message("use.of.clone.call.problem.descriptor");
|
||||
}
|
||||
else if (errorElement instanceof PsiMethod) {
|
||||
return InspectionGadgetsBundle.message("use.of.clone.call.method.problem.descriptor");
|
||||
}
|
||||
else {
|
||||
return InspectionGadgetsBundle.message("use.of.clone.reference.problem.descriptor");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new UseOfCloneVisitor();
|
||||
}
|
||||
|
||||
private static class UseOfCloneVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
|
||||
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
|
||||
final String referenceName = methodExpression.getReferenceName();
|
||||
if (!HardcodedMethodConstants.CLONE.equals(referenceName)) {
|
||||
return;
|
||||
}
|
||||
final PsiExpressionList argumentList = expression.getArgumentList();
|
||||
final PsiExpression[] arguments = argumentList.getExpressions();
|
||||
if (arguments.length != 0) {
|
||||
return;
|
||||
}
|
||||
final PsiExpression qualifierExpression = methodExpression.getQualifierExpression();
|
||||
if (qualifierExpression != null) {
|
||||
final PsiType type = qualifierExpression.getType();
|
||||
if (type instanceof PsiArrayType) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
registerMethodCallError(expression, expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
|
||||
final String qualifiedName = reference.getQualifiedName();
|
||||
if (!CommonClassNames.JAVA_LANG_CLONEABLE.equals(qualifiedName)) {
|
||||
return;
|
||||
}
|
||||
registerError(reference, reference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethod(PsiMethod method) {
|
||||
if (!CloneUtils.isClone(method) || CloneUtils.onlyThrowsException(method)) {
|
||||
return;
|
||||
}
|
||||
registerMethodError(method, method);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-21
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,32 +60,22 @@ public class CloneUtils {
|
||||
HardcodedMethodConstants.CLONE, PsiType.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
public static boolean onlyThrowsCloneNotSupportedException(
|
||||
@NotNull PsiMethod method) {
|
||||
public static boolean onlyThrowsException(@NotNull PsiMethod method) {
|
||||
if (!method.hasModifierProperty(PsiModifier.FINAL)) {
|
||||
final PsiClass aClass = method.getContainingClass();
|
||||
if (aClass == null || !aClass.hasModifierProperty(PsiModifier.FINAL)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final PsiCodeBlock body = method.getBody();
|
||||
if (body == null) {
|
||||
return false;
|
||||
}
|
||||
final PsiStatement[] statements = body.getStatements();
|
||||
if (statements.length != 1) {
|
||||
if (statements.length == 0) {
|
||||
return false;
|
||||
}
|
||||
final PsiStatement statement = statements[0];
|
||||
if (!(statement instanceof PsiThrowStatement)) {
|
||||
return false;
|
||||
}
|
||||
final PsiThrowStatement throwStatement = (PsiThrowStatement)statement;
|
||||
final PsiExpression exception = ParenthesesUtils.stripParentheses(throwStatement.getException());
|
||||
if (!(exception instanceof PsiNewExpression)) {
|
||||
return false;
|
||||
}
|
||||
final PsiNewExpression newExpression = (PsiNewExpression)exception;
|
||||
final PsiJavaCodeReferenceElement classReference =
|
||||
newExpression.getClassReference();
|
||||
if (classReference == null) {
|
||||
return false;
|
||||
}
|
||||
final String qualifiedName = classReference.getQualifiedName();
|
||||
return qualifiedName.equals("java.lang.CloneNotSupportedException");
|
||||
final PsiStatement statement = statements[statements.length - 1];
|
||||
return statement instanceof PsiThrowStatement;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports calls to and implementations of the <b>clone()</b> method and uses of <b>java.lang.Cloneable</b>.
|
||||
Some coding standards prohibit <b>clone()</b> usage, and recommend using a copy constructor or <b>static</b> factory method.
|
||||
Calls to <b>clone()</b> on arrays are ignored, because that is a common, correct, efficient and compact way to copy an array.
|
||||
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
<small>New in 14.1</small>
|
||||
</body>
|
||||
</html>
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package com.siyeh.igtest.cloneable;
|
||||
|
||||
public class CloneCallsSuperCloneInspection implements Cloneable
|
||||
{
|
||||
|
||||
public void foo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@ class CloneCallsConstructors implements Cloneable {
|
||||
class One {
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return new One();
|
||||
return new <warning descr="'clone()' creates new 'One' instances">One</warning>();
|
||||
}
|
||||
}
|
||||
final class Two implements Cloneable {
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.siyeh.igtest.cloneable.clone_calls_super_clone;
|
||||
|
||||
public class CloneCallsSuperClone implements Cloneable
|
||||
{
|
||||
|
||||
public void foo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Object <warning descr="'clone()' does not call 'super.clone()'">clone</warning>()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class One {
|
||||
|
||||
public final One clone() throws CloneNotSupportedException {
|
||||
throw new CloneNotSupportedException();
|
||||
}
|
||||
}
|
||||
final class Two {
|
||||
public Two clone() throws CloneNotSupportedException {
|
||||
throw (new CloneNotSupportedException());
|
||||
}
|
||||
}
|
||||
class Three {
|
||||
public Three <warning descr="'clone()' does not call 'super.clone()'">clone</warning>() throws CloneNotSupportedException {
|
||||
throw new CloneNotSupportedException();
|
||||
}
|
||||
}
|
||||
class Four {
|
||||
public final Four clone() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package use_of_clone;
|
||||
|
||||
class UseOfClone implements <warning descr="Use of 'Cloneable'">Cloneable</warning> {
|
||||
|
||||
void f(int[] is) {
|
||||
System.out.println(is.clone()); // don't warn when cloning an array
|
||||
}
|
||||
|
||||
public UseOfClone <warning descr="Implementation of 'clone()'">clone</warning>() {
|
||||
return this;
|
||||
}
|
||||
|
||||
void g(UseOfClone o) {
|
||||
o.<warning descr="Call to 'clone()'">clone</warning>();
|
||||
}
|
||||
}
|
||||
interface I extends <warning descr="Use of 'Cloneable'">Cloneable</warning> {
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.siyeh.ig.cloneable;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers.
|
||||
*/
|
||||
public class CloneCallsSuperCloneInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void testCloneCallsSuperClone() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new CloneCallsSuperCloneInspection();
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.siyeh.ig.cloneable;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers.
|
||||
*/
|
||||
public class UseOfCloneInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void testUseOfClone() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new UseOfCloneInspection();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -229,15 +229,17 @@ public class InjectorUtils {
|
||||
public static BaseInjection findCommentInjection(@NotNull PsiElement context, @NotNull String supportId, @Nullable Ref<PsiElement> causeRef) {
|
||||
PsiElement target = CompletionUtil.getOriginalOrSelf(context);
|
||||
PsiFile file = target.getContainingFile();
|
||||
if (file == null || file.getFileType().isBinary()) return null;
|
||||
TreeMap<TextRange, BaseInjection> map = getInjectionMap(file);
|
||||
Map.Entry<TextRange, BaseInjection> entry = map == null ? null : map.lowerEntry(target.getTextRange());
|
||||
if (map == null) return null;
|
||||
Map.Entry<TextRange, BaseInjection> entry = map.lowerEntry(target.getTextRange());
|
||||
if (entry == null) return null;
|
||||
|
||||
PsiComment psiComment = PsiTreeUtil.findElementOfClassAtOffset(file, entry.getKey().getStartOffset(), PsiComment.class, false);
|
||||
if (psiComment == null) return null;
|
||||
TextRange r0 = psiComment.getTextRange();
|
||||
|
||||
// calulate topmost siblings & heights
|
||||
// calculate topmost siblings & heights
|
||||
PsiElement commonParent = PsiTreeUtil.findCommonParent(psiComment, target);
|
||||
int h1 = 0, h2 = 0;
|
||||
PsiElement e1 = psiComment, e2 = target;
|
||||
@@ -269,8 +271,7 @@ public class InjectorUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static TreeMap<TextRange, BaseInjection> getInjectionMap(@Nullable final PsiFile file) {
|
||||
if (file == null) return null; // e.g. null for synthetic groovy variables
|
||||
private static TreeMap<TextRange, BaseInjection> getInjectionMap(@NotNull final PsiFile file) {
|
||||
return CachedValuesManager.getCachedValue(file, new CachedValueProvider<TreeMap<TextRange, BaseInjection>>() {
|
||||
@Nullable
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,6 +30,7 @@ import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.TableUtil;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.idea.devkit.DevKitBundle;
|
||||
import org.jetbrains.idea.devkit.module.PluginModuleType;
|
||||
@@ -142,7 +143,7 @@ public class ChooseModulesDialog extends DialogWrapper {
|
||||
|
||||
final JScrollPane jScrollPane = ScrollPaneFactory.createScrollPane();
|
||||
jScrollPane.setViewportView(myView);
|
||||
jScrollPane.setPreferredSize(new Dimension(300, 80));
|
||||
jScrollPane.setPreferredSize(JBUI.size(300, 80));
|
||||
panel.add(jScrollPane, BorderLayout.SOUTH);
|
||||
return panel;
|
||||
}
|
||||
|
||||
+14
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.plugins.groovy.dsl;
|
||||
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import gnu.trove.THashMap;
|
||||
@@ -49,11 +50,16 @@ public class DslActivationStatus implements PersistentStateComponent<Element> {
|
||||
@Nullable
|
||||
public synchronized String getInactivityReason(VirtualFile file) {
|
||||
String status = myStatus.get(file);
|
||||
return status == null || status == ENABLED ? null : status;
|
||||
return ENABLED.equals(status) ? null : status;
|
||||
}
|
||||
|
||||
public synchronized boolean isActivated(VirtualFile file) {
|
||||
return myStatus.get(file) == ENABLED;
|
||||
final String status = myStatus.get(file);
|
||||
if (status == null) {
|
||||
myStatus.put(file, ENABLED);
|
||||
return true;
|
||||
}
|
||||
return ENABLED.equals(status);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -66,7 +72,9 @@ public class DslActivationStatus implements PersistentStateComponent<Element> {
|
||||
Element element = new Element("file");
|
||||
root.addContent(element);
|
||||
element.setAttribute("url", file.getUrl());
|
||||
element.setAttribute("status", (status == ENABLED ? "" : status));
|
||||
if (!ENABLED.equals(status)) {
|
||||
element.setAttribute("status", status);
|
||||
}
|
||||
}
|
||||
return root;
|
||||
}
|
||||
@@ -76,10 +84,10 @@ public class DslActivationStatus implements PersistentStateComponent<Element> {
|
||||
List<Element> children = state.getChildren("file");
|
||||
for (Element element : children) {
|
||||
String url = element.getAttributeValue("url", "");
|
||||
String status = element.getAttributeValue("status", ENABLED);
|
||||
String status = element.getAttributeValue("status");
|
||||
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
if (file != null) {
|
||||
myStatus.put(file, status);
|
||||
myStatus.put(file, StringUtil.isNotEmpty(status) ? status : ENABLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -74,7 +74,7 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
|
||||
private static final Key<Pair<GroovyDslExecutor, Long>> CACHED_EXECUTOR = Key.create("CachedGdslExecutor");
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.dsl.GroovyDslFileIndex");
|
||||
private static final Logger LOG = Logger.getInstance(GroovyDslFileIndex.class);
|
||||
|
||||
@NonNls public static final ID<String, Void> NAME = ID.create("GroovyDslFileIndex");
|
||||
@NonNls private static final String OUR_KEY = "ourKey";
|
||||
@@ -412,7 +412,10 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
|
||||
if (!vfile.isValid()) {
|
||||
continue;
|
||||
}
|
||||
if (!fileIndex.isInLibraryClasses(vfile) && !fileIndex.isInLibrarySource(vfile)) {
|
||||
if (fileIndex.isInLibrarySource(vfile)) {
|
||||
continue;
|
||||
}
|
||||
if (!fileIndex.isInLibraryClasses(vfile)) {
|
||||
if (!fileIndex.isInSourceContent(vfile) || !isActivated(vfile)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -183,8 +183,9 @@ public class IdeaDecompiler extends ClassFileDecompilers.Light {
|
||||
}
|
||||
decompiler.decompileContext();
|
||||
|
||||
file.putUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY,
|
||||
new ExactMatchLineNumbersMapping(saver.myMapping));
|
||||
if (saver.myMapping != null) {
|
||||
file.putUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY, new ExactMatchLineNumbersMapping(saver.myMapping));
|
||||
}
|
||||
|
||||
return saver.myResult;
|
||||
}
|
||||
@@ -344,7 +345,7 @@ public class IdeaDecompiler extends ClassFileDecompilers.Light {
|
||||
private static class ExactMatchLineNumbersMapping implements LineNumbersMapping {
|
||||
private int[] myMapping;
|
||||
|
||||
private ExactMatchLineNumbersMapping(int[] mapping) {
|
||||
private ExactMatchLineNumbersMapping(@NotNull int[] mapping) {
|
||||
myMapping = mapping;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
|
||||
private boolean myDisposed;
|
||||
private VirtualFileListener myVfsListener;
|
||||
private Editor mySelectedEditor;
|
||||
private String myPropertyToSelectWhenVisible;
|
||||
|
||||
public ResourceBundleEditor(@NotNull ResourceBundle resourceBundle) {
|
||||
myProject = resourceBundle.getProject();
|
||||
@@ -208,6 +209,9 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
|
||||
if (newEditor == this) {
|
||||
if (oldEditor instanceof TextEditor) {
|
||||
setStructureViewSelectionFromPropertiesFile(((TextEditor)oldEditor).getEditor());
|
||||
} else if (myPropertyToSelectWhenVisible != null) {
|
||||
setStructureViewSelection(myPropertyToSelectWhenVisible);
|
||||
myPropertyToSelectWhenVisible = null;
|
||||
}
|
||||
}
|
||||
else if (newEditor instanceof TextEditor) {
|
||||
@@ -239,6 +243,17 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
|
||||
|
||||
Object root = tree.getModel().getRoot();
|
||||
if (AbstractTreeUi.isLoadingChildrenFor(root)) {
|
||||
boolean isEditorVisible = false;
|
||||
for (FileEditor editor : FileEditorManager.getInstance(myProject).getSelectedEditors()) {
|
||||
if (editor == this) {
|
||||
isEditorVisible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isEditorVisible) {
|
||||
myPropertyToSelectWhenVisible = propertyName;
|
||||
return;
|
||||
}
|
||||
mySelectionChangeAlarm.cancelAllRequests();
|
||||
mySelectionChangeAlarm.addRequest(new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.ide.palette.impl;
|
||||
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -90,7 +91,7 @@ public class PaletteContentWindow extends JPanel implements Scrollable {
|
||||
}
|
||||
|
||||
public Dimension minimumLayoutSize(Container parent) {
|
||||
return new Dimension(0, 0);
|
||||
return JBUI.emptySize();
|
||||
}
|
||||
|
||||
public Dimension preferredLayoutSize(Container parent) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user