Merge commit 'origin/master'

This commit is contained in:
Maxim Medvedev
2011-01-31 00:33:24 +03:00
11 changed files with 95 additions and 13 deletions
@@ -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();
@@ -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));
}
}
});
@@ -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);
@@ -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);
}
@@ -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);
@@ -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.<br>" +
"You may reduce memory, used by IntelliJ IDEA, by running it in 32-bit mode. " +
"<a href=\"http://devnet.jetbrains.net/docs/DOC-1232\">Click for details</a>", 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() {
@@ -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() {
@@ -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
@@ -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.
* <p/>
@@ -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);
@@ -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);
}
}
}
});
}
}