From a647ccaa1d64e490158670ca2716a548004cea73 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Wed, 26 Jan 2011 16:00:24 +0300 Subject: [PATCH 1/4] [10.0.2] IDEA-63034 Cant cancel IDEA 6.0 style incremental search in same way as before rev=pegov --- .../codeInsight/navigation/IncrementalSearchHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java index fd6f4e6be567..3b2da4750a33 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java @@ -39,6 +39,7 @@ import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; +import com.intellij.ui.HintHint; import com.intellij.ui.LightweightHint; import com.intellij.util.text.StringSearcher; import com.intellij.util.ui.UIUtil; @@ -177,7 +178,7 @@ public class IncrementalSearchHandler { int y = - hint.getComponent().getPreferredSize().height; Point p = SwingUtilities.convertPoint(component,x,y,component.getRootPane().getLayeredPane()); - HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, p, HintManagerImpl.HIDE_BY_ESCAPE | HintManagerImpl.HIDE_BY_TEXT_CHANGE, 0, false); + HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, p, HintManagerImpl.HIDE_BY_ESCAPE | HintManagerImpl.HIDE_BY_TEXT_CHANGE, 0, false, new HintHint(editor, p).setAwtTooltip(false)); PerHintSearchData hintData = new PerHintSearchData(project, label2); hintData.searchStart = editor.getCaretModel().getOffset(); From 268927bca8280949f19955b801a646108c352b0c Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Thu, 27 Jan 2011 13:55:41 +0300 Subject: [PATCH 2/4] IDEA-53707 Toolwindow tabs - > react on mouse down --- .../intellij/util/ui/BaseButtonBehavior.java | 40 ++++++++++++++----- .../wm/impl/content/ContentTabLabel.java | 4 +- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/platform/platform-api/src/com/intellij/util/ui/BaseButtonBehavior.java b/platform/platform-api/src/com/intellij/util/ui/BaseButtonBehavior.java index f31c72ced0b8..04449de5a3ba 100644 --- a/platform/platform-api/src/com/intellij/util/ui/BaseButtonBehavior.java +++ b/platform/platform-api/src/com/intellij/util/ui/BaseButtonBehavior.java @@ -33,9 +33,10 @@ public abstract class BaseButtonBehavior { private boolean myPressedByMouse; private boolean mySelected; - private TimedDeadzone myMouseDeadzone; + private int myActionTrigger; + public BaseButtonBehavior(JComponent component) { this(component, TimedDeadzone.DEFAULT); } @@ -45,6 +46,12 @@ public abstract class BaseButtonBehavior { myMouseDeadzone = new TimedDeadzone(mouseDeadzoneTime, Alarm.ThreadToUse.SWING_THREAD); myComponent.addMouseListener(new MyMouseListener()); myComponent.addMouseMotionListener(new MyMouseMotionListener()); + setActionTrigger(MouseEvent.MOUSE_RELEASED); + } + + public void setActionTrigger(int trigger) { + assert trigger == MouseEvent.MOUSE_PRESSED || trigger == MouseEvent.MOUSE_RELEASED; + myActionTrigger = trigger; } public final boolean isHovered() { @@ -111,7 +118,11 @@ public abstract class BaseButtonBehavior { setPressedByMouse(true); - repaintComponent(); + if (myActionTrigger == MouseEvent.MOUSE_PRESSED) { + if (execute(e)) return; + } else { + repaintComponent(); + } } @@ -121,21 +132,30 @@ public abstract class BaseButtonBehavior { setPressedByMouse(false); - Point point = e.getPoint(); - if (point.x < 0 || point.x > myComponent.getWidth()) return; - if (point.y < 0 || point.y > myComponent.getHeight()) return; - - repaintComponent(); - - execute(e); + if (myActionTrigger == MouseEvent.MOUSE_RELEASED) { + if (execute(e)) return; + } else { + repaintComponent(); + } } finally { myWasPressedOnFocusTransfer = false; } } + private boolean execute(MouseEvent e) { + Point point = e.getPoint(); + if (point.x < 0 || point.x > myComponent.getWidth()) return true; + if (point.y < 0 || point.y > myComponent.getHeight()) return true; + + repaintComponent(); + + BaseButtonBehavior.this.execute(e); + return false; + } + private boolean passIfNeeded(final MouseEvent e, boolean considerDeadzone) { - final boolean actionClick = UIUtil.isActionClick(e, MouseEvent.MOUSE_RELEASED) || UIUtil.isActionClick(e, MouseEvent.MOUSE_PRESSED); + final boolean actionClick = UIUtil.isActionClick(e, myActionTrigger); if (!actionClick || (considerDeadzone && myMouseDeadzone.isWithin())) { pass(e); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java index e9412b21e285..f47bec52c7ec 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java @@ -18,6 +18,7 @@ package com.intellij.openapi.wm.impl.content; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentManager; import com.intellij.util.ui.BaseButtonBehavior; +import com.intellij.util.ui.TimedDeadzone; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -44,7 +45,8 @@ class ContentTabLabel extends BaseLabel { } } }; - + myBehavior.setActionTrigger(MouseEvent.MOUSE_PRESSED); + myBehavior.setMouseDeadzone(TimedDeadzone.NULL); } public void update() { From 26b5dd6a8c1afa2245ecd1acc60d11082902bae5 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Sun, 30 Jan 2011 17:10:25 +0300 Subject: [PATCH 3/4] notifciation about 64-bit mode on Mac --- .../ide/startup/impl/StartupManagerImpl.java | 21 +++++++++++++++++++ .../src/misc/registry.properties | 1 + 2 files changed, 22 insertions(+) diff --git a/platform/platform-impl/src/com/intellij/ide/startup/impl/StartupManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/startup/impl/StartupManagerImpl.java index 31f5fb82b90e..93d26be1f868 100644 --- a/platform/platform-impl/src/com/intellij/ide/startup/impl/StartupManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/startup/impl/StartupManagerImpl.java @@ -15,8 +15,10 @@ */ package com.intellij.ide.startup.impl; +import com.intellij.ide.BrowserUtil; import com.intellij.ide.caches.CacheUpdater; import com.intellij.ide.startup.StartupManagerEx; +import com.intellij.notification.*; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; @@ -27,12 +29,15 @@ import com.intellij.openapi.project.DumbAwareRunnable; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.DumbServiceImpl; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.util.io.storage.HeavyProcessLatch; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; +import javax.swing.event.HyperlinkEvent; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; @@ -144,6 +149,22 @@ public class StartupManagerImpl extends StartupManagerEx { if (!app.isUnitTestMode()) { VirtualFileManager.getInstance().refresh(!app.isHeadlessEnvironment()); } + + if (SystemInfo.isMac && SystemInfo.is64Bit && "10.6".compareTo(SystemInfo.OS_VERSION) <= 0) { + if (Registry.is("ide.firstStartup")) { + Notification n = + new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "64-bit System Information", "You IntelliJ IDEA now running in 64-bit mode.
" + + "You may reduce memory, used by IntelliJ IDEA, by running it in 32-bit mode. " + + "Click for details", NotificationType.INFORMATION, new NotificationListener() { + @Override + public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) { + BrowserUtil.launchBrowser(event.getURL().toString()); + } + }); + Notifications.Bus.notify(n, NotificationDisplayType.STICKY_BALLOON, null); + Registry.get("ide.firstStartup").setValue(false); + } + } } private void startCacheUpdate() { diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index 925c8f2003d3..0367c55c0f9a 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -30,6 +30,7 @@ actionSystem.quickAccessModifiers= actionSystem.quickAccessShowSpotsTime=1500 actionSystem.win.supressAlt=true +ide.firstStartup=true ide.debugMode=false ide.debugMode.description=Record additonal information to make bug reports more informative ide.forcedShowTooltip=alt From 82ac812746920ceea7098000cbd885ba5bd421cd Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Sun, 30 Jan 2011 17:25:32 +0300 Subject: [PATCH 4/4] create new Xcode project (Xcode 3 only) --- .../intellij/ide/util/BrowseFilesListener.java | 7 ++++++- .../intellij/ide/util/PropertiesComponent.java | 6 ++++++ .../src/com/intellij/openapi/ui/Messages.java | 4 ++++ .../intellij/ui/mac/foundation/Foundation.java | 4 ++++ .../ui/mac/foundation/FoundationLibrary.java | 2 ++ .../util/src/com/intellij/util/ui/UIUtil.java | 16 ++++++++++++++++ 6 files changed, 38 insertions(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/ide/util/BrowseFilesListener.java b/platform/platform-api/src/com/intellij/ide/util/BrowseFilesListener.java index e0fd2f392cb1..e25f96811077 100644 --- a/platform/platform-api/src/com/intellij/ide/util/BrowseFilesListener.java +++ b/platform/platform-api/src/com/intellij/ide/util/BrowseFilesListener.java @@ -21,6 +21,7 @@ import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Consumer; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.event.ActionEvent; @@ -60,6 +61,10 @@ public class BrowseFilesListener implements ActionListener { return null; } + protected void doSetText(@NotNull final String path) { + myTextField.setText(path); + } + public void actionPerformed( ActionEvent e ) { final VirtualFile fileToSelect = getFileToSelect(); myChooserDescriptor.setTitle(myTitle); // important to set title and description here because a shared descriptor instance can be used @@ -69,7 +74,7 @@ public class BrowseFilesListener implements ActionListener { @Override public void consume(final VirtualFile[] files) { if (files != null && files.length > 0) { - myTextField.setText(files[0].getPath().replace('/', File.separatorChar)); + doSetText(files[0].getPath().replace('/', File.separatorChar)); } } }); diff --git a/platform/platform-api/src/com/intellij/ide/util/PropertiesComponent.java b/platform/platform-api/src/com/intellij/ide/util/PropertiesComponent.java index 52272fe91fef..b737d7583ceb 100644 --- a/platform/platform-api/src/com/intellij/ide/util/PropertiesComponent.java +++ b/platform/platform-api/src/com/intellij/ide/util/PropertiesComponent.java @@ -18,6 +18,7 @@ package com.intellij.ide.util; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public abstract class PropertiesComponent { public abstract void unsetValue(String name); @@ -42,6 +43,11 @@ public abstract class PropertiesComponent { public abstract String getValue(@NonNls String name); + @NotNull + public String getValue(@NonNls String name, @NotNull String defaultValue) { + return isValueSet(name) ? getValue(name) : defaultValue; + } + public String getOrInit(@NonNls String name, String defaultValue) { if (!isValueSet(name)) { setValue(name, defaultValue); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index 8542f7b9d161..f4796f4d1141 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -238,6 +238,10 @@ public class Messages { return showDialog(project, message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, 0, icon); } + public static int showOkCancelDialog(Component parent, String message, String title, int defaultOptionIndex, int focusedOptionIndex, Icon icon) { + return showDialog(parent, message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, defaultOptionIndex, focusedOptionIndex, icon); + } + public static int showOkCancelDialog(Component parent, String message, String title, Icon icon) { return showDialog(parent, message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, 0, icon); } diff --git a/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java b/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java index 104f9ca5f0a1..b090176309ef 100644 --- a/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java +++ b/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java @@ -85,6 +85,10 @@ public class Foundation { return myFoundationLibrary.objc_getClass(clazz); } + public static String fullUserName() { + return toStringViaUTF8(myFoundationLibrary.NSFullUserName()); + } + /** * Return a CFString as an ID, toll-free bridged to NSString. *

diff --git a/platform/util/src/com/intellij/ui/mac/foundation/FoundationLibrary.java b/platform/util/src/com/intellij/ui/mac/foundation/FoundationLibrary.java index f4a887cd1da0..4b1bcaff5786 100644 --- a/platform/util/src/com/intellij/ui/mac/foundation/FoundationLibrary.java +++ b/platform/util/src/com/intellij/ui/mac/foundation/FoundationLibrary.java @@ -25,6 +25,8 @@ import com.sun.jna.Pointer; public interface FoundationLibrary extends Library { void NSLog(Pointer pString, Object thing); + ID NSFullUserName(); + ID objc_allocateClassPair(ID supercls, String name, int extraBytes); void objc_registerClassPair(ID cls); diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index cad2e46b6d72..403b1089820e 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -1762,5 +1762,21 @@ public class UIUtil { return null; } + public static void scrollListToVisibleIfNeeded(@NotNull final JList list) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + final int selectedIndex = list.getSelectedIndex(); + if (selectedIndex >= 0) { + final Rectangle visibleRect = list.getVisibleRect(); + final Rectangle cellBounds = list.getCellBounds(selectedIndex, selectedIndex); + if (!visibleRect.contains(cellBounds)) { + list.scrollRectToVisible(cellBounds); + } + } + } + }); + } + }