summaryrefslogtreecommitdiff
path: root/platform/platform-impl/src/com/intellij/ui
diff options
context:
space:
mode:
Diffstat (limited to 'platform/platform-impl/src/com/intellij/ui')
-rw-r--r--platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java1
-rw-r--r--platform/platform-impl/src/com/intellij/ui/AppUIUtil.java8
-rw-r--r--platform/platform-impl/src/com/intellij/ui/EditorComboBoxEditor.java12
-rw-r--r--platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java10
-rw-r--r--platform/platform-impl/src/com/intellij/ui/EditorTextField.java10
-rw-r--r--platform/platform-impl/src/com/intellij/ui/FocusTrackback.java10
-rw-r--r--platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java15
-rw-r--r--platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java10
-rwxr-xr-xplatform/platform-impl/src/com/intellij/ui/messages/SheetController.java4
-rwxr-xr-xplatform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java12
-rw-r--r--platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java6
11 files changed, 74 insertions, 24 deletions
diff --git a/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java b/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java
index 1fc23e5f4055..d9ebeefa7acc 100644
--- a/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java
+++ b/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java
@@ -368,6 +368,7 @@ public abstract class AbstractExpandableItemsHandler<KeyType, ComponentType exte
if (!(renderer instanceof JComponent)) return null;
myKeyItemBounds = rendererAndBounds.second;
+ myKeyItemBounds.width = Math.min(myKeyItemBounds.width, myComponent.getToolkit().getScreenSize().width);
Rectangle cellBounds = myKeyItemBounds;
Rectangle visibleRect = getVisibleRect(key);
diff --git a/platform/platform-impl/src/com/intellij/ui/AppUIUtil.java b/platform/platform-impl/src/com/intellij/ui/AppUIUtil.java
index 2a7d44d017bd..f4bf768e92a6 100644
--- a/platform/platform-impl/src/com/intellij/ui/AppUIUtil.java
+++ b/platform/platform-impl/src/com/intellij/ui/AppUIUtil.java
@@ -90,19 +90,19 @@ public class AppUIUtil {
invokeOnEdt(runnable, null);
}
- public static void invokeOnEdt(Runnable runnable, @Nullable Condition condition) {
+ public static void invokeOnEdt(Runnable runnable, @Nullable Condition expired) {
Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
//noinspection unchecked
- if (condition == null || !condition.value(null)) {
+ if (expired == null || !expired.value(null)) {
runnable.run();
}
}
- else if (condition == null) {
+ else if (expired == null) {
application.invokeLater(runnable);
}
else {
- application.invokeLater(runnable, condition);
+ application.invokeLater(runnable, expired);
}
}
diff --git a/platform/platform-impl/src/com/intellij/ui/EditorComboBoxEditor.java b/platform/platform-impl/src/com/intellij/ui/EditorComboBoxEditor.java
index f4dfb1059651..60371365f2c3 100644
--- a/platform/platform-impl/src/com/intellij/ui/EditorComboBoxEditor.java
+++ b/platform/platform-impl/src/com/intellij/ui/EditorComboBoxEditor.java
@@ -17,6 +17,7 @@ package com.intellij.ui;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NonNls;
@@ -34,10 +35,19 @@ public class EditorComboBoxEditor implements ComboBoxEditor{
@NonNls protected static final String NAME = "ComboBox.textField";
public EditorComboBoxEditor(Project project, FileType fileType) {
- myTextField = new ComboboxEditorTextField((Document)null, project, fileType);
+ myTextField = new ComboboxEditorTextField((Document)null, project, fileType) {
+ @Override
+ protected EditorEx createEditor() {
+ EditorEx editor = super.createEditor();
+ onEditorCreate(editor);
+ return editor;
+ }
+ };
myTextField.setName(NAME);
}
+ protected void onEditorCreate(EditorEx editor) {}
+
@Override
public void selectAll() {
myTextField.selectAll();
diff --git a/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java b/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java
index 5721f4af4821..4b788c80ae54 100644
--- a/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java
+++ b/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java
@@ -102,13 +102,7 @@ public class EditorNotificationsImpl extends EditorNotifications {
task.computeInReadAction(indicator);
}
else {
- final ProgressIndicator indicator1 = indicator;
- myExecutor.execute(new Runnable() {
- @Override
- public void run() {
- ProgressIndicatorUtils.runWithWriteActionPriority(indicator1, task);
- }
- });
+ ProgressIndicatorUtils.scheduleWithWriteActionPriority(indicator, myExecutor, task);
}
}
});
@@ -165,7 +159,7 @@ public class EditorNotificationsImpl extends EditorNotifications {
}
@Override
- public void onCanceled(@NotNull ProgressIndicator _) {
+ public void onCanceled(@NotNull ProgressIndicator ignored) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
diff --git a/platform/platform-impl/src/com/intellij/ui/EditorTextField.java b/platform/platform-impl/src/com/intellij/ui/EditorTextField.java
index c16f5f188cdc..27b1a2be56ae 100644
--- a/platform/platform-impl/src/com/intellij/ui/EditorTextField.java
+++ b/platform/platform-impl/src/com/intellij/ui/EditorTextField.java
@@ -278,13 +278,18 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
public void selectAll() {
if (myEditor != null) {
- myEditor.getSelectionModel().setSelection(0, myDocument.getTextLength());
+ doSelectAll(myEditor);
}
else {
myWholeTextSelected = true;
}
}
+ private static void doSelectAll(@NotNull Editor editor) {
+ editor.getCaretModel().removeSecondaryCarets();
+ editor.getCaretModel().getPrimaryCaret().setSelection(0, editor.getDocument().getTextLength(), false);
+ }
+
public void removeSelection() {
if (myEditor != null) {
myEditor.getSelectionModel().removeSelection();
@@ -514,7 +519,8 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
editor.getSelectionModel().removeSelection();
}
else if (myWholeTextSelected) {
- editor.getSelectionModel().setSelection(0, myDocument.getTextLength());
+ doSelectAll(editor);
+ myWholeTextSelected = false;
}
editor.putUserData(SUPPLEMENTARY_KEY, myIsSupplementary);
diff --git a/platform/platform-impl/src/com/intellij/ui/FocusTrackback.java b/platform/platform-impl/src/com/intellij/ui/FocusTrackback.java
index 9ad0931c85b9..5c531a7b6ae8 100644
--- a/platform/platform-impl/src/com/intellij/ui/FocusTrackback.java
+++ b/platform/platform-impl/src/com/intellij/ui/FocusTrackback.java
@@ -191,10 +191,12 @@ public class FocusTrackback {
if (app == null || wrongOS() || myConsumed || isSheduledForRestore()) return;
Project project = null;
- DataContext context =
- myParentWindow == null ? DataManager.getInstance().getDataContext() : DataManager.getInstance().getDataContext(myParentWindow);
- if (context != null) {
- project = CommonDataKeys.PROJECT.getData(context);
+ DataManager dataManager = DataManager.getInstance();
+ if (dataManager != null) {
+ DataContext context = myParentWindow == null ? dataManager.getDataContext() : dataManager.getDataContext(myParentWindow);
+ if (context != null) {
+ project = CommonDataKeys.PROJECT.getData(context);
+ }
}
mySheduledForRestore = true;
diff --git a/platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java b/platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java
index e8c6f49f8088..7e613982a406 100644
--- a/platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java
+++ b/platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java
@@ -50,6 +50,8 @@ class LibNotifyWrapper implements SystemNotificationsImpl.Notifier {
private final LibNotify myLibNotify;
private final String myIcon;
+ private final Object myLock = new Object();
+ private boolean myDisposed = false;
private LibNotifyWrapper() {
myLibNotify = (LibNotify)Native.loadLibrary("libnotify.so.4", LibNotify.class);
@@ -66,14 +68,21 @@ class LibNotifyWrapper implements SystemNotificationsImpl.Notifier {
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
@Override
public void appClosing() {
- myLibNotify.notify_uninit();
+ synchronized (myLock) {
+ myDisposed = true;
+ myLibNotify.notify_uninit();
+ }
}
});
}
@Override
public void notify(@NotNull Set<String> allNames, @NotNull String name, @NotNull String title, @NotNull String description) {
- Pointer notification = myLibNotify.notify_notification_new(title, description, myIcon);
- myLibNotify.notify_notification_show(notification, null);
+ synchronized (myLock) {
+ if (!myDisposed) {
+ Pointer notification = myLibNotify.notify_notification_new(title, description, myIcon);
+ myLibNotify.notify_notification_show(notification, null);
+ }
+ }
}
}
diff --git a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java
index cbcde2d36418..76985ad77362 100644
--- a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java
+++ b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java
@@ -298,6 +298,7 @@ public abstract class SpeedSearchBase<Comp extends JComponent> extends SpeedSear
protected void processKeyEvent(KeyEvent e) {
if (e.isAltDown()) return;
+ if (e.isShiftDown() && isNavigationKey(e.getKeyCode())) return;
if (mySearchPopup != null) {
mySearchPopup.processKeyEvent(e);
return;
@@ -499,6 +500,15 @@ public abstract class SpeedSearchBase<Comp extends JComponent> extends SpeedSear
return keyCode == KeyEvent.VK_HOME || keyCode == KeyEvent.VK_END || keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN;
}
+ private static boolean isPgUpPgDown(int keyCode) {
+ return keyCode == KeyEvent.VK_PAGE_UP || keyCode == KeyEvent.VK_PAGE_DOWN;
+ }
+
+ private static boolean isNavigationKey(int keyCode) {
+ return isPgUpPgDown(keyCode) || isUpDownHomeEnd(keyCode);
+ }
+
+
private void manageSearchPopup(@Nullable SearchPopup searchPopup) {
Project project = null;
if (ApplicationManager.getApplication() != null && !ApplicationManager.getApplication().isDisposed()) {
diff --git a/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java b/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java
index 2d76d6391ee8..bf0b37116941 100755
--- a/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java
+++ b/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java
@@ -70,6 +70,8 @@ public class SheetController {
private static int GAP_BETWEEN_BUTTONS = 5;
+ private static String SPACE_OR_LINE_SEPARATOR_PATTERN = "[\\s" + System.getProperty("line.separator") + "]+";
+
// SHEET
public int SHEET_WIDTH = 400;
@@ -289,7 +291,7 @@ public class SheetController {
int widestWordWidth = 250;
- String [] words = (message == null) ? ArrayUtil.EMPTY_STRING_ARRAY : message.split(" ");
+ String [] words = (message == null) ? ArrayUtil.EMPTY_STRING_ARRAY : message.split(SPACE_OR_LINE_SEPARATOR_PATTERN);
for (String word : words) {
widestWordWidth = Math.max(fontMetrics.stringWidth(word), widestWordWidth);
diff --git a/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java b/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java
index 446722c081e4..fee84330f0a2 100755
--- a/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java
+++ b/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java
@@ -70,6 +70,8 @@ public class SheetMessage {
final Component recentFocusOwner = activeWindow == null ? null : activeWindow.getMostRecentFocusOwner();
beforeShowFocusOwner = new WeakReference<Component>(recentFocusOwner);
+ maximizeIfNeeded(owner);
+
myWindow = new JDialog(owner, "This should not be shown", Dialog.ModalityType.APPLICATION_MODAL);
myWindow.getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE);
@@ -132,6 +134,16 @@ public class SheetMessage {
}
+ private static void maximizeIfNeeded(final Window owner) {
+ if (owner == null) return;
+ if (owner instanceof Frame) {
+ Frame f = (Frame)owner;
+ if (f.getState() == Frame.ICONIFIED) {
+ f.setState(Frame.NORMAL);
+ }
+ }
+ }
+
private void setWindowOpacity(float opacity) {
try {
Method setOpacityMethod = myWindow.getClass().getMethod("setOpacity", Float.TYPE);
diff --git a/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java b/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java
index 04c38a6cc295..1b9190f6a740 100644
--- a/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java
+++ b/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java
@@ -177,15 +177,19 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
LOG.assertTrue (!isDisposed());
Rectangle targetBounds = new Rectangle(new Point(aScreenX, aScreenY), getContent().getPreferredSize());
- ScreenUtil.moveRectangleToFitTheScreen(targetBounds);
if (getParent() != null) {
final Rectangle parentBounds = getParent().getBounds();
parentBounds.x += STEP_X_PADDING;
parentBounds.width -= STEP_X_PADDING * 2;
+ ScreenUtil.moveToFit(targetBounds, ScreenUtil.getScreenRectangle(
+ parentBounds.x + parentBounds.width / 2,
+ parentBounds.y + parentBounds.height / 2), null);
if (parentBounds.intersects(targetBounds)) {
targetBounds.x = getParent().getBounds().x - targetBounds.width - STEP_X_PADDING;
}
+ } else {
+ ScreenUtil.moveToFit(targetBounds, ScreenUtil.getScreenRectangle(aScreenX, aScreenY), null);
}
if (getParent() == null) {