Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
irengrig
2010-08-17 18:56:33 +04:00
7 changed files with 39 additions and 23 deletions
@@ -30,6 +30,7 @@ import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.UIBundle;
import com.intellij.util.Consumer;
import com.intellij.util.ui.update.LazyUiDisposable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -204,10 +205,15 @@ public class ComponentWithBrowseButton<Comp extends JComponent> extends JPanel i
fileChooserDescriptor.setDescription(myDescription);
}
VirtualFile initialFile = getInitialFile();
VirtualFile[] files = doChoose(fileChooserDescriptor, initialFile);
if (files != null && files.length != 0) {
onFileChoosen(files[0]);
}
FileChooser.chooseFilesWithSlideEffect(fileChooserDescriptor, myProject, initialFile, new Consumer<VirtualFile[]>() {
@Override
public void consume(VirtualFile[] virtualFiles) {
if (virtualFiles != null && virtualFiles.length > 0) {
onFileChoosen(virtualFiles[0]);
}
}
});
}
@Nullable
@@ -233,14 +239,6 @@ public class ComponentWithBrowseButton<Comp extends JComponent> extends JPanel i
myAccessor.setText(myTextComponent.getChildComponent(), chosenFile.getPresentableUrl());
}
private VirtualFile[] doChoose(FileChooserDescriptor fileChooserDescriptor, VirtualFile initialFile) {
if (myProject == null) {
return FileChooser.chooseFiles(myTextComponent, fileChooserDescriptor, initialFile);
}
else {
return FileChooser.chooseFiles(myProject, fileChooserDescriptor, initialFile);
}
}
}
public final void requestFocus() {
@@ -24,7 +24,6 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
@@ -36,14 +35,19 @@ import java.util.Enumeration;
*/
public class TreeComboBox extends JComboBox {
final static int INDENT = UIManager.getInt("Tree.leftChildIndent");
private TreeModel myTreeModel;
public TreeComboBox(@NotNull final TreeModel model) {
setModel(new TreeModelWrapper(model));
myTreeModel = model;
setModel(new TreeModelWrapper(myTreeModel));
setRenderer(new TreeListCellRenderer(this, model));
setSelectedIndex(0);
if (SystemInfo.isMac) setMaximumRowCount(25);
}
public TreeModel getTreeModel() {
return myTreeModel;
}
private static class TreeListCellRenderer extends JLabel implements ListCellRenderer {
private static final Border SELECTION_PAINTER = (Border)UIManager.get("MenuItem.selectedBackgroundPainter");
@@ -17,9 +17,14 @@ package com.intellij.openapi.project.ex;
import com.intellij.openapi.components.impl.stores.IProjectStore;
import com.intellij.openapi.project.Project;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
public interface ProjectEx extends Project {
interface ProjectSaved {
Topic<ProjectSaved> TOPIC = Topic.create("SaveProjectTopic", ProjectSaved.class, Topic.BroadcastDirection.NONE);
void saved(@NotNull final Project project);
}
@NotNull
IProjectStore getStateStore();
@@ -55,7 +55,6 @@ import org.picocontainer.defaults.CachingComponentAdapter;
import org.picocontainer.defaults.ConstructorInjectionComponentAdapter;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -267,6 +266,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
LOG.info("Error saving project", e);
} finally {
mySavingInProgress.set(false);
ApplicationManager.getApplication().getMessageBus().syncPublisher(ProjectSaved.TOPIC).saved(this);
}
}
}
@@ -115,8 +115,14 @@ public class MacFileChooserDialogImpl implements MacFileChooserDialog {
if (mySheetCallback != null) {
final Window activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
if (activeWindow != null && activeWindow instanceof Frame) {
final String frameTitle = ((Frame)activeWindow).getTitle();
if (activeWindow != null) {
String activeWindowTitle = null;
if (activeWindow instanceof Frame) {
activeWindowTitle = ((Frame)activeWindow).getTitle();
} else if (activeWindow instanceof JDialog) {
activeWindowTitle = ((JDialog)activeWindow).getTitle();
}
if (activeWindowTitle == null || activeWindowTitle.length() == 0) return;
final ID sharedApplication = invoke("NSApplication", "sharedApplication");
final ID windows = invoke(sharedApplication, "windows");
@@ -130,7 +136,10 @@ public class MacFileChooserDialogImpl implements MacFileChooserDialog {
final ID windowTitle = invoke(window, "title");
final String titleString = Foundation.toStringViaUTF8(windowTitle);
if (titleString.equals(frameTitle)) focusedWindow = window;
if (titleString.equals(activeWindowTitle)) {
focusedWindow = window;
break;
}
}
if (focusedWindow != null) {
@@ -430,8 +430,11 @@
text="Add Test Notification"/>
<action id="TestMessageBoxAction" internal="true" class="com.intellij.diagnostic.TestMessageBoxAction" text="Show Test Dialog"/>
<separator/>
<action id="FocusDebugger" internal="true" class="com.intellij.internal.focus.FocusDebuggerAction" text="Start Focus Debugger"/>
<action id="UiInspector" internal="true" class="com.intellij.internal.inspector.UiInspectorAction" text="UI Inspector"/>
<separator/>
<reference ref="MaintenanceGroup"/>
<add-to-group group-id="ToolsMenu" anchor="last"/>
</group>
-3
View File
@@ -255,9 +255,6 @@
<separator/>
<action id="GenerateVisitorByHierarchy" internal="true" class="com.intellij.internal.GenerateVisitorByHierarchyAction" text="Generate Hierarchy Visitor"/>
<separator/>
<action id="FocusDebugger" internal="true" class="com.intellij.internal.focus.FocusDebuggerAction" text="Start Focus Debugger"/>
<action id="UiInspector" internal="true" class="com.intellij.internal.inspector.UiInspectorAction" text="UI Inspector"/>
<separator/>
<action id="DumpLookupElementWeights" internal="true" class="com.intellij.internal.DumpLookupElementWeights" text="Dump lookup element weights"/>
<action id="CheckVfsSanity" internal="true" class="com.intellij.openapi.vfs.newvfs.persistent.CheckSanityAction" text="Check VFS sanity"/>