summaryrefslogtreecommitdiff
path: root/platform/platform-api/src/com/intellij/openapi
diff options
context:
space:
mode:
Diffstat (limited to 'platform/platform-api/src/com/intellij/openapi')
-rw-r--r--platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java3
-rw-r--r--platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java7
-rw-r--r--platform/platform-api/src/com/intellij/openapi/editor/CaretStateTransferableData.java56
-rw-r--r--platform/platform-api/src/com/intellij/openapi/editor/ClipboardTextPerCaretSplitter.java18
-rw-r--r--platform/platform-api/src/com/intellij/openapi/editor/CopyPasteSupport.java212
-rw-r--r--platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java155
-rw-r--r--platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java5
-rw-r--r--platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java4
-rw-r--r--platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java10
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java12
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java6
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java6
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java6
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/ThreeComponentsSplitter.java17
-rw-r--r--platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java61
15 files changed, 379 insertions, 199 deletions
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java
index d4ac053e994e..1d4fea4c01de 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java
@@ -50,6 +50,8 @@ public interface IdeActions {
@NonNls String ACTION_EDITOR_COMPLETE_STATEMENT = "EditorCompleteStatement";
@NonNls String ACTION_EDITOR_USE_SOFT_WRAPS = "EditorToggleUseSoftWraps";
@NonNls String ACTION_EDITOR_ADD_OR_REMOVE_CARET= "EditorAddOrRemoveCaret";
+ @NonNls String ACTION_EDITOR_CLONE_CARET_BELOW= "EditorCloneCaretBelow";
+ @NonNls String ACTION_EDITOR_CLONE_CARET_ABOVE= "EditorCloneCaretAbove";
@NonNls String ACTION_EDITOR_NEXT_TEMPLATE_VARIABLE = "NextTemplateVariable";
@NonNls String ACTION_EDITOR_PREVIOUS_TEMPLATE_VARIABLE = "PreviousTemplateVariable";
@@ -267,6 +269,7 @@ public interface IdeActions {
String ACTION_UNDO = "$Undo";
String ACTION_REDO = "$Redo";
String GROUP_REFACTOR = "RefactoringMenu";
+ String SELECTED_CHANGES_ROLLBACK = "RollbackLineStatusChanges";
String CHANGES_VIEW_ROLLBACK = "ChangesView.Rollback";
String CONSOLE_CLEAR_ALL = "ConsoleView.ClearAll";
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java
index e72428804ee4..92a1d9c8b42c 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java
@@ -47,6 +47,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
private static final Icon DISABLED_ARROW_ICON = IconLoader.getDisabledIcon(ARROW_ICON);
private boolean mySmallVariant = true;
+ private String myPopupTitle;
private DataContext myDataContext;
protected ComboBoxAction() {
@@ -77,6 +78,10 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
mySmallVariant = smallVariant;
}
+ public void setPopupTitle(String popupTitle) {
+ myPopupTitle = popupTitle;
+ }
+
@Override
public void update(AnActionEvent e) {
super.update(e);
@@ -247,7 +252,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
DataContext context = getDataContext();
myDataContext = null;
final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
- null, group, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false, onDispose, getMaxRows());
+ myPopupTitle, group, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false, onDispose, getMaxRows());
popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight()));
return popup;
}
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/CaretStateTransferableData.java b/platform/platform-api/src/com/intellij/openapi/editor/CaretStateTransferableData.java
new file mode 100644
index 000000000000..f0d2085cbb6b
--- /dev/null
+++ b/platform/platform-api/src/com/intellij/openapi/editor/CaretStateTransferableData.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2000-2014 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;
+
+import com.intellij.codeInsight.editorActions.TextBlockTransferableData;
+
+import java.awt.datatransfer.DataFlavor;
+
+public class CaretStateTransferableData implements TextBlockTransferableData {
+ public static final DataFlavor FLAVOR = new DataFlavor(CaretStateTransferableData.class, "Caret state");
+
+ public final int[] startOffsets;
+ public final int[] endOffsets;
+
+ public CaretStateTransferableData(int[] startOffsets, int[] endOffsets) {
+ this.startOffsets = startOffsets;
+ this.endOffsets = endOffsets;
+ }
+
+ @Override
+ public DataFlavor getFlavor() {
+ return FLAVOR;
+ }
+
+ @Override
+ public int getOffsetCount() {
+ return startOffsets.length + endOffsets.length;
+ }
+
+ @Override
+ public int getOffsets(int[] offsets, int index) {
+ System.arraycopy(startOffsets, 0, offsets, index, startOffsets.length);
+ System.arraycopy(endOffsets, 0, offsets, index + startOffsets.length, endOffsets.length);
+ return index + getOffsetCount();
+ }
+
+ @Override
+ public int setOffsets(int[] offsets, int index) {
+ System.arraycopy(offsets, index, startOffsets, 0, startOffsets.length);
+ System.arraycopy(offsets, index + startOffsets.length, endOffsets, 0, endOffsets.length);
+ return index + getOffsetCount();
+ }
+}
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/ClipboardTextPerCaretSplitter.java b/platform/platform-api/src/com/intellij/openapi/editor/ClipboardTextPerCaretSplitter.java
index afc58b818bce..a3e62412f4a4 100644
--- a/platform/platform-api/src/com/intellij/openapi/editor/ClipboardTextPerCaretSplitter.java
+++ b/platform/platform-api/src/com/intellij/openapi/editor/ClipboardTextPerCaretSplitter.java
@@ -15,12 +15,16 @@
*/
package com.intellij.openapi.editor;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ClipboardTextPerCaretSplitter {
- public List<String> split(String input, int caretCount) {
+ @NotNull
+ public List<String> split(@NotNull String input, @Nullable CaretStateTransferableData caretData, int caretCount) {
if (caretCount <= 0) {
throw new IllegalArgumentException("Caret count must be positive");
}
@@ -28,9 +32,17 @@ public class ClipboardTextPerCaretSplitter {
return Collections.singletonList(input);
}
List<String> result = new ArrayList<String>(caretCount);
- String[] lines = input.split("\n", -1);
+ int sourceCaretCount = caretData == null ? -1 : caretData.startOffsets.length;
+ String[] lines = sourceCaretCount == 1 || sourceCaretCount == caretCount ? null : input.split("\n", -1);
for (int i = 0; i < caretCount; i++) {
- if (lines.length == 0) {
+ if (sourceCaretCount == 1) {
+ result.add(input);
+ }
+ else if (sourceCaretCount == caretCount) {
+ //noinspection ConstantConditions
+ result.add(new String(input.substring(caretData.startOffsets[i], caretData.endOffsets[i])));
+ }
+ else if (lines.length == 0) {
result.add("");
}
else if (lines.length == 1) {
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/CopyPasteSupport.java b/platform/platform-api/src/com/intellij/openapi/editor/CopyPasteSupport.java
new file mode 100644
index 000000000000..7095080aa13d
--- /dev/null
+++ b/platform/platform-api/src/com/intellij/openapi/editor/CopyPasteSupport.java
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2000-2014 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;
+
+import com.intellij.codeInsight.editorActions.TextBlockTransferable;
+import com.intellij.codeInsight.editorActions.TextBlockTransferableData;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.ide.CopyPasteManager;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.text.LineTokenizer;
+import com.intellij.util.Producer;
+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.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+public class CopyPasteSupport {
+ private static final Logger LOG = Logger.getInstance(CopyPasteSupport.class);
+
+ private CopyPasteSupport() { }
+
+ public static void copySelectionToClipboard(@NotNull Editor editor) {
+ ApplicationManager.getApplication().assertIsDispatchThread();
+ List<TextBlockTransferableData> extraData = new ArrayList<TextBlockTransferableData>();
+ String s = editor.getCaretModel().supportsMultipleCarets() ? getSelectedTextForClipboard(editor, extraData)
+ : editor.getSelectionModel().getSelectedText();
+ if (s == null) return;
+
+ s = TextBlockTransferable.convertLineSeparators(s, "\n", extraData);
+ Transferable contents = editor.getCaretModel().supportsMultipleCarets() ? new TextBlockTransferable(s, extraData, null) : new StringSelection(s);
+ CopyPasteManager.getInstance().setContents(contents);
+ }
+
+ public static String getSelectedTextForClipboard(@NotNull Editor editor, @NotNull Collection<TextBlockTransferableData> extraDataCollector) {
+ final StringBuilder buf = new StringBuilder();
+ String separator = "";
+ List<Caret> carets = editor.getCaretModel().getAllCarets();
+ int[] startOffsets = new int[carets.size()];
+ int[] endOffsets = new int[carets.size()];
+ for (int i = 0; i < carets.size(); i++) {
+ buf.append(separator);
+ String caretSelectedText = carets.get(i).getSelectedText();
+ startOffsets[i] = buf.length();
+ if (caretSelectedText != null) {
+ buf.append(caretSelectedText);
+ }
+ endOffsets[i] = buf.length();
+ separator = "\n";
+ }
+ extraDataCollector.add(new CaretStateTransferableData(startOffsets, endOffsets));
+ return buf.toString();
+ }
+
+
+ public static TextRange pasteFromClipboard(Editor editor) {
+ return pasteTransferable(editor, (Producer<Transferable>)null);
+ }
+
+ public static TextRange pasteTransferable(Editor editor, final Transferable content) {
+ return pasteTransferable(editor, new Producer<Transferable>() {
+ @Nullable
+ @Override
+ public Transferable produce() {
+ return content;
+ }
+ });
+ }
+
+ @Nullable
+ public static TextRange pasteTransferable(final Editor editor, @Nullable Producer<Transferable> producer) {
+ Transferable content = getTransferable(producer);
+ if (content == null) return null;
+ String text = getStringContent(content);
+ if (text == null) return null;
+
+ if (editor.getCaretModel().supportsMultipleCarets()) {
+ int caretCount = editor.getCaretModel().getCaretCount();
+ if (caretCount == 1 && editor.isColumnMode()) {
+ int pastedLineCount = LineTokenizer.calcLineCount(text, true);
+ EditorModificationUtil.deleteSelectedText(editor);
+ Caret caret = editor.getCaretModel().getPrimaryCaret();
+ for (int i = 0; i < pastedLineCount - 1; i++) {
+ caret = caret.clone(false);
+ if (caret == null) {
+ break;
+ }
+ }
+ caretCount = editor.getCaretModel().getCaretCount();
+ }
+ CaretStateTransferableData caretData = null;
+ try {
+ caretData = content.isDataFlavorSupported(CaretStateTransferableData.FLAVOR)
+ ? (CaretStateTransferableData)content.getTransferData(CaretStateTransferableData.FLAVOR) : null;
+ }
+ catch (Exception e) {
+ LOG.error(e);
+ }
+ final Iterator<String> segments = new ClipboardTextPerCaretSplitter().split(text, caretData, caretCount).iterator();
+ editor.getCaretModel().runForEachCaret(new CaretAction() {
+ @Override
+ public void perform(Caret caret) {
+ EditorModificationUtil.insertStringAtCaret(editor, segments.next(), false, true);
+ }
+ });
+ return null;
+ }
+ else {
+ int caretOffset = editor.getCaretModel().getOffset();
+ EditorModificationUtil.insertStringAtCaret(editor, text, false, true);
+ return new TextRange(caretOffset, caretOffset + text.length());
+ }
+ }
+
+ public static void pasteTransferableAsBlock(Editor editor, @Nullable Producer<Transferable> producer) {
+ Transferable content = getTransferable(producer);
+ if (content == null) return;
+ String text = getStringContent(content);
+ if (text == null) return;
+
+ int caretLine = editor.getCaretModel().getLogicalPosition().line;
+ int originalCaretLine = caretLine;
+ int selectedLinesCount = 0;
+
+ final SelectionModel selectionModel = editor.getSelectionModel();
+ if (selectionModel.hasBlockSelection()) {
+ final LogicalPosition start = selectionModel.getBlockStart();
+ final LogicalPosition end = selectionModel.getBlockEnd();
+ assert start != null;
+ assert end != null;
+ LogicalPosition caret = new LogicalPosition(Math.min(start.line, end.line), Math.min(start.column, end.column));
+ selectedLinesCount = Math.abs(end.line - start.line);
+ caretLine = caret.line;
+
+ EditorModificationUtil.deleteSelectedText(editor);
+ editor.getCaretModel().moveToLogicalPosition(caret);
+ }
+
+ LogicalPosition caretToRestore = editor.getCaretModel().getLogicalPosition();
+
+ String[] lines = LineTokenizer.tokenize(text.toCharArray(), false);
+ if (lines.length > 1 || selectedLinesCount == 0) {
+ int longestLineLength = 0;
+ for (int i = 0; i < lines.length; i++) {
+ String line = lines[i];
+ longestLineLength = Math.max(longestLineLength, line.length());
+ editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(caretLine + i, caretToRestore.column));
+ EditorModificationUtil.insertStringAtCaret(editor, line, false, true);
+ }
+ caretToRestore = new LogicalPosition(originalCaretLine, caretToRestore.column + longestLineLength);
+ }
+ else {
+ for (int i = 0; i <= selectedLinesCount; i++) {
+ editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(caretLine + i, caretToRestore.column));
+ EditorModificationUtil.insertStringAtCaret(editor, text, false, true);
+ }
+ caretToRestore = new LogicalPosition(originalCaretLine, caretToRestore.column + text.length());
+ }
+
+ editor.getCaretModel().moveToLogicalPosition(caretToRestore);
+ EditorModificationUtil.zeroWidthBlockSelectionAtCaretColumn(editor, caretLine, caretLine + selectedLinesCount);
+ }
+
+ @Nullable
+ private static String getStringContent(@NotNull Transferable content) {
+ RawText raw = RawText.fromTransferable(content);
+ if (raw != null) return raw.rawText;
+
+ try {
+ return (String)content.getTransferData(DataFlavor.stringFlavor);
+ }
+ catch (UnsupportedFlavorException ignore) { }
+ catch (IOException ignore) { }
+
+ return null;
+ }
+
+ private static Transferable getTransferable(Producer<Transferable> producer) {
+ Transferable content = null;
+ if (producer != null) {
+ content = producer.produce();
+ }
+ else {
+ CopyPasteManager manager = CopyPasteManager.getInstance();
+ if (manager.areDataFlavorsAvailable(DataFlavor.stringFlavor)) {
+ content = manager.getContents();
+ }
+ }
+ return content;
+ }
+}
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java b/platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java
index 3fddbc344585..ee5527967440 100644
--- a/platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java
+++ b/platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java
@@ -19,20 +19,14 @@ import com.intellij.codeStyle.CodeStyleFacade;
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.editor.event.MockDocumentEvent;
-import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
-import com.intellij.openapi.util.text.LineTokenizer;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.util.Producer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
-import java.awt.datatransfer.UnsupportedFlavorException;
-import java.io.IOException;
-import java.util.Iterator;
import java.util.List;
public class EditorModificationUtil {
@@ -99,7 +93,7 @@ public class EditorModificationUtil {
zeroWidthBlockSelectionAtCaretColumn(editor, startLine, endLine);
}
- private static void zeroWidthBlockSelectionAtCaretColumn(final Editor editor, final int startLine, final int endLine) {
+ public static void zeroWidthBlockSelectionAtCaretColumn(final Editor editor, final int startLine, final int endLine) {
int caretColumn = editor.getCaretModel().getLogicalPosition().column;
editor.getSelectionModel().setBlockSelection(new LogicalPosition(startLine, caretColumn), new LogicalPosition(endLine, caretColumn));
}
@@ -181,112 +175,21 @@ public class EditorModificationUtil {
return offset;
}
+ /**
+ * @deprecated Use {@link com.intellij.openapi.editor.CopyPasteSupport#pasteTransferable(Editor, com.intellij.util.Producer)} instead.
+ * (to remove in IDEA 15)
+ */
@Nullable
public static TextRange pasteTransferable(final Editor editor, @Nullable Producer<Transferable> producer) {
- String text = getStringContent(producer);
- if (text == null) return null;
-
- if (editor.getCaretModel().supportsMultipleCarets()) {
- int caretCount = editor.getCaretModel().getCaretCount();
- if (caretCount == 1 && editor.isColumnMode()) {
- int pastedLineCount = LineTokenizer.calcLineCount(text, true);
- deleteSelectedText(editor);
- Caret caret = editor.getCaretModel().getPrimaryCaret();
- for (int i = 0; i < pastedLineCount - 1; i++) {
- caret = caret.clone(false);
- if (caret == null) {
- break;
- }
- }
- caretCount = editor.getCaretModel().getCaretCount();
- }
- final Iterator<String> segments = new ClipboardTextPerCaretSplitter().split(text, caretCount).iterator();
- editor.getCaretModel().runForEachCaret(new CaretAction() {
- @Override
- public void perform(Caret caret) {
- insertStringAtCaret(editor, segments.next(), false, true);
- }
- });
- return null;
- }
- else {
- int caretOffset = editor.getCaretModel().getOffset();
- insertStringAtCaret(editor, text, false, true);
- return new TextRange(caretOffset, caretOffset + text.length());
- }
+ return CopyPasteSupport.pasteTransferable(editor, producer);
}
+ /**
+ * @deprecated Use {@link com.intellij.openapi.editor.CopyPasteSupport#pasteTransferableAsBlock(Editor, com.intellij.util.Producer)} instead.
+ * (to remove in IDEA 15)
+ */
public static void pasteTransferableAsBlock(Editor editor, @Nullable Producer<Transferable> producer) {
- String text = getStringContent(producer);
- if (text == null) return;
-
- int caretLine = editor.getCaretModel().getLogicalPosition().line;
- int originalCaretLine = caretLine;
- int selectedLinesCount = 0;
-
- final SelectionModel selectionModel = editor.getSelectionModel();
- if (selectionModel.hasBlockSelection()) {
- final LogicalPosition start = selectionModel.getBlockStart();
- final LogicalPosition end = selectionModel.getBlockEnd();
- assert start != null;
- assert end != null;
- LogicalPosition caret = new LogicalPosition(Math.min(start.line, end.line), Math.min(start.column, end.column));
- selectedLinesCount = Math.abs(end.line - start.line);
- caretLine = caret.line;
-
- deleteSelectedText(editor);
- editor.getCaretModel().moveToLogicalPosition(caret);
- }
-
- LogicalPosition caretToRestore = editor.getCaretModel().getLogicalPosition();
-
- String[] lines = LineTokenizer.tokenize(text.toCharArray(), false);
- if (lines.length > 1 || selectedLinesCount == 0) {
- int longestLineLength = 0;
- for (int i = 0; i < lines.length; i++) {
- String line = lines[i];
- longestLineLength = Math.max(longestLineLength, line.length());
- editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(caretLine + i, caretToRestore.column));
- insertStringAtCaret(editor, line, false, true);
- }
- caretToRestore = new LogicalPosition(originalCaretLine, caretToRestore.column + longestLineLength);
- }
- else {
- for (int i = 0; i <= selectedLinesCount; i++) {
- editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(caretLine + i, caretToRestore.column));
- insertStringAtCaret(editor, text, false, true);
- }
- caretToRestore = new LogicalPosition(originalCaretLine, caretToRestore.column + text.length());
- }
-
- editor.getCaretModel().moveToLogicalPosition(caretToRestore);
- zeroWidthBlockSelectionAtCaretColumn(editor, caretLine, caretLine + selectedLinesCount);
- }
-
- @Nullable
- private static String getStringContent(@Nullable Producer<Transferable> producer) {
- Transferable content = null;
- if (producer != null) {
- content = producer.produce();
- }
- else {
- CopyPasteManager manager = CopyPasteManager.getInstance();
- if (manager.areDataFlavorsAvailable(DataFlavor.stringFlavor)) {
- content = manager.getContents();
- }
- }
- if (content == null) return null;
-
- RawText raw = RawText.fromTransferable(content);
- if (raw != null) return raw.rawText;
-
- try {
- return (String)content.getTransferData(DataFlavor.stringFlavor);
- }
- catch (UnsupportedFlavorException ignore) { }
- catch (IOException ignore) { }
-
- return null;
+ CopyPasteSupport.pasteTransferableAsBlock(editor, producer);
}
/**
@@ -494,40 +397,4 @@ public class EditorModificationUtil {
CaretModel caretModel = editor.getCaretModel();
caretModel.moveToOffset(caretModel.getOffset() + caretShift);
}
-
- /** @deprecated use {@link #pasteTransferable(Editor, Producer)} (to remove in IDEA 14) */
- @SuppressWarnings("UnusedDeclaration")
- public static TextRange pasteFromClipboard(Editor editor) {
- return pasteTransferable(editor, null);
- }
-
- /** @deprecated use {@link #pasteTransferable(Editor, Producer)} (to remove in IDEA 14) */
- @SuppressWarnings("SpellCheckingInspection,UnusedDeclaration")
- public static TextRange pasteFromTransferrable(final Transferable content, Editor editor) {
- return pasteTransferable(editor, new Producer<Transferable>() {
- @Nullable
- @Override
- public Transferable produce() {
- return content;
- }
- });
- }
-
- @SuppressWarnings("UnusedDeclaration")
- /** @deprecated use {@link #pasteTransferableAsBlock(Editor, Producer)} (to remove in IDEA 14) */
- public static void pasteFromClipboardAsBlock(Editor editor) {
- pasteTransferableAsBlock(editor, (Producer<Transferable>)null);
- }
-
- @SuppressWarnings("UnusedDeclaration")
- /** @deprecated use {@link #pasteTransferableAsBlock(Editor, Producer)} (to remove in IDEA 14) */
- public static void pasteTransferableAsBlock(Editor editor, @Nullable final Transferable content) {
- pasteTransferableAsBlock(editor, new Producer<Transferable>() {
- @Nullable
- @Override
- public Transferable produce() {
- return content;
- }
- });
- }
}
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java b/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java
index 13b2c43faa7b..9cd9ab29f4cd 100644
--- a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java
+++ b/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java
@@ -19,6 +19,7 @@ import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.editor.markup.TextAttributes;
+import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
@@ -74,8 +75,8 @@ public class FragmentedEditorHighlighter implements EditorHighlighter {
if (myMergeByTextAttributes && !myPieces.isEmpty()) {
Element element = myPieces.get(myPieces.size() - 1);
if (element.getEnd() >= offset + relativeStart &&
- element.getAttributes().equals(iterator.getTextAttributes()) &&
- element.getElementType().equals(iterator.getTokenType())) {
+ Comparing.equal(element.getAttributes(), iterator.getTextAttributes()) &&
+ Comparing.equal(element.getElementType(), iterator.getTokenType())) {
merged = true;
myPieces.add(new Element(element.getStart(),
offset + relativeEnd,
diff --git a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java
index 07430ddbad8b..11c8bdd90052 100644
--- a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java
+++ b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -90,6 +90,8 @@ public class ConfigurableEP<T extends UnnamedConfigurable> extends AbstractExten
@Attribute("id")
public String id;
+ @Attribute("groupId")
+ public String groupId;
/** Marks project level configurables that do not apply to the default project. */
@Attribute("nonDefaultProject")
diff --git a/platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java b/platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java
index 634144817fa7..e98bb05aba99 100644
--- a/platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java
+++ b/platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java
@@ -36,41 +36,49 @@ public interface SearchableConfigurable extends Configurable {
boolean hasOwnContent();
boolean isVisible();
-
abstract class Abstract implements Parent {
private Configurable[] myKids;
+ @Override
public JComponent createComponent() {
return null;
}
+ @Override
public boolean hasOwnContent() {
return false;
}
+ @Override
public boolean isModified() {
return false;
}
+ @Override
public void apply() throws ConfigurationException {
}
+ @Override
public void reset() {
}
+ @Override
public void disposeUIResources() {
myKids = null;
}
+ @Override
public Runnable enableSearch(final String option) {
return null;
}
+ @Override
public boolean isVisible() {
return true;
}
+ @Override
public final Configurable[] getConfigurables() {
if (myKids != null) return myKids;
myKids = buildConfigurables();
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java b/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java
index 9e6c0aa1b965..5d2ecafb1b7e 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java
@@ -76,6 +76,10 @@ public class ComboBoxTableRenderer<T> extends JLabel implements TableCellRendere
return value.toString();
}
+ protected Icon getIconFor(@NotNull T value) {
+ return null;
+ }
+
protected Runnable onChosen(@NotNull final T value) {
stopCellEditing(value);
@@ -137,6 +141,11 @@ public class ComboBoxTableRenderer<T> extends JLabel implements TableCellRendere
return ComboBoxTableRenderer.this.getTextFor(value);
}
+ @Override
+ public Icon getIconFor(T value) {
+ return ComboBoxTableRenderer.this.getIconFor(value);
+ }
+
public PopupStep onChosen(T selectedValue, boolean finalChoice) {
myFinalRunnable = ComboBoxTableRenderer.this.onChosen(selectedValue);
return FINAL_CHOICE;
@@ -169,6 +178,9 @@ public class ComboBoxTableRenderer<T> extends JLabel implements TableCellRendere
protected void customizeComponent(final T value, final JTable table, final boolean isSelected) {
setOpaque(true);
setText(value == null ? "" : getTextFor(value));
+ if (value != null) {
+ setIcon(getIconFor(value));
+ }
setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
}
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java
index 5bbd3d12da6a..34aaa93d2741 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java
@@ -170,11 +170,7 @@ public class DetailsComponent {
myContent.setBorder(new EmptyBorder(UIUtil.PANEL_REGULAR_INSETS));
}
else {
- if (Registry.is("ide.new.project.settings")) {
- myContent.setBorder(new EmptyBorder(16, 10, 16, 10));
- } else {
- myContent.setBorder(null);
- }
+ myContent.setBorder(null);
}
}
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java b/platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java
index 6f38d9a96356..101444a9d649 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java
@@ -87,7 +87,7 @@ public class FixedSizeButton extends JButton {
public Dimension getPreferredSize() {
if (myComponent != null) {
int size = myComponent.getPreferredSize().height;
- if (myComponent instanceof ComboBox && (UIUtil.isUnderIntelliJLaF() || UIUtil.isUnderDarcula())) {
+ if (myComponent instanceof JComboBox && (UIUtil.isUnderIntelliJLaF() || UIUtil.isUnderDarcula())) {
size -= 2; // decrement to match JTextField's preferred height
}
return new Dimension(size, size);
@@ -120,9 +120,7 @@ public class FixedSizeButton extends JButton {
public void setBounds(Rectangle r) {
if (r.width != r.height) {
int size = Math.min(r.width, r.height);
- r = new Rectangle(r);
- r.width = size;
- r.height = size;
+ r = new Rectangle(r.x, r.y, size, size);
}
super.setBounds(r);
}
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
index 35e81b032ba5..816349ed1c37 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
@@ -135,11 +135,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
mySplitter.setSplitterProportionKey("ProjectStructure.SecondLevelElements");
mySplitter.setHonorComponentsMinimumSize(true);
if (Registry.is("ide.new.project.settings")) {
- mySplitter.setDividerWidth(1);
- mySplitter.setShowDividerIcon(false);
- mySplitter.getDivider().setBackground(Gray._153.withAlpha(128));
- mySplitter.setShowDividerControls(false);
- mySplitter.setOrientation(mySplitter.getOrientation());
+ mySplitter.setOnePixelMode();
}
installAutoScroll();
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ThreeComponentsSplitter.java b/platform/platform-api/src/com/intellij/openapi/ui/ThreeComponentsSplitter.java
index faa26e2415b8..62864d01b91a 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/ThreeComponentsSplitter.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/ThreeComponentsSplitter.java
@@ -26,6 +26,7 @@ import com.intellij.ui.UIBundle;
import com.intellij.util.ui.update.Activatable;
import com.intellij.util.ui.update.UiNotifyConnector;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
@@ -56,9 +57,9 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable {
private final Divider myFirstDivider;
private final Divider myLastDivider;
- private JComponent myFirstComponent;
- private JComponent myInnerComponent;
- private JComponent myLastComponent;
+ @Nullable private JComponent myFirstComponent;
+ @Nullable private JComponent myInnerComponent;
+ @Nullable private JComponent myLastComponent;
private int myFirstSize = 10;
private int myLastSize = 10;
@@ -303,6 +304,7 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable {
repaint();
}
+ @Nullable
public JComponent getFirstComponent() {
return myFirstComponent;
}
@@ -312,7 +314,7 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable {
* repaint the splitter. If there is already
*
*/
- public void setFirstComponent(JComponent component) {
+ public void setFirstComponent(@Nullable JComponent component) {
if (myFirstComponent != component) {
if (myFirstComponent != null) {
remove(myFirstComponent);
@@ -325,6 +327,7 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable {
}
}
+ @Nullable
public JComponent getLastComponent() {
return myLastComponent;
}
@@ -335,7 +338,7 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable {
* repaint the splitter.
*
*/
- public void setLastComponent(JComponent component) {
+ public void setLastComponent(@Nullable JComponent component) {
if (myLastComponent != component) {
if (myLastComponent != null) {
remove(myLastComponent);
@@ -348,7 +351,7 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable {
}
}
-
+ @Nullable
public JComponent getInnerComponent() {
return myInnerComponent;
}
@@ -359,7 +362,7 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable {
* repaint the splitter.
*
*/
- public void setInnerComponent(JComponent component) {
+ public void setInnerComponent(@Nullable JComponent component) {
if (myInnerComponent != component) {
if (myInnerComponent != null) {
remove(myInnerComponent);
diff --git a/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java b/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java
index 6584184a1bb2..fc9eec268ece 100644
--- a/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java
+++ b/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.wm;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.popup.util.PopupUtil;
import com.intellij.openapi.util.ActionCallback;
@@ -22,12 +23,13 @@ import com.intellij.openapi.util.ActiveRunnable;
import com.intellij.openapi.util.Expirable;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.registry.Registry;
-import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
import java.util.Arrays;
/**
@@ -41,6 +43,8 @@ public abstract class FocusCommand extends ActiveRunnable implements Expirable {
private boolean myInvalidatesPendingFurtherRequestors = true;
private Expirable myExpirable;
+ public static final Logger LOG = Logger.getInstance("#com.intellij.openapi.wm.FocusCommand");
+
public boolean isForced() {
return myForced;
}
@@ -154,46 +158,51 @@ public abstract class FocusCommand extends ActiveRunnable implements Expirable {
public static class ByComponent extends FocusCommand {
private Component myToFocus;
+ private Throwable myAllocation;
- public ByComponent(@Nullable Component toFocus) {
- this(toFocus, toFocus);
+ public ByComponent(@Nullable Component toFocus, @NotNull Throwable allocation) {
+ this(toFocus, toFocus, allocation);
}
- public ByComponent(@Nullable Component toFocus, @Nullable Component dominationComponent) {
+ public ByComponent(@Nullable Component toFocus, @Nullable Component dominationComponent, @NotNull Throwable allocation) {
super(toFocus, dominationComponent);
+ myAllocation = allocation;
myToFocus = toFocus;
}
@NotNull
public final ActionCallback run() {
- if (myToFocus != null) {
- if (Registry.is("actionSystem.doNotStealFocus")) {
- Window topWindow = SwingUtilities.windowForComponent(myToFocus);
- UIUtil.setAutoRequestFocus(topWindow, topWindow.isActive());
- while (topWindow.getOwner() != null) {
- topWindow = SwingUtilities.windowForComponent(topWindow);
- UIUtil.setAutoRequestFocus(topWindow, topWindow.isActive());
- }
- if (topWindow.isActive()) {
- if (!myToFocus.requestFocusInWindow()) {
- myToFocus.requestFocus();
- }
- } else {
- myToFocus.requestFocusInWindow();
+ boolean shouldLogFocuses = Registry.is("ide.log.focuses");
+
+ if (shouldLogFocuses) {
+ myToFocus.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ if (isExpired()) return;
+ super.focusGained(e);
+ LOG.info("Focus gained on " + myToFocus.getClass().getName());
+ myToFocus.removeFocusListener(this);
}
+ });
+ }
- } else {
- // This change seems reasonable to me. But as far as some implementations
- // can ignore the "forced" parameter we can get bad focus behaviour.
- // So let's start from mac.
- if (!(myToFocus.requestFocusInWindow())) {
- if (!SystemInfo.isMac || isForced() ) {
- myToFocus.requestFocus();
- }
+ if (!(myToFocus.requestFocusInWindow())) {
+ if (shouldLogFocuses) {
+ LOG.info("We could not request focus in window on " + myToFocus.getClass().getName());
+ LOG.info(myAllocation);
+ }
+ if (!SystemInfo.isMac || isForced() ) {
+ myToFocus.requestFocus();
+ if (shouldLogFocuses) {
+ LOG.info("Force request focus on " + myToFocus.getClass().getName());
}
}
+ } else if (shouldLogFocuses) {
+ LOG.info("We have successfully requested focus in window on " + myToFocus.getClass().getName());
+ LOG.info(myAllocation);
}
+
clear();
return new ActionCallback.Done();
}