diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java index 5818702ec324..89900405485b 100644 --- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java @@ -416,7 +416,6 @@ public class DataFlowInspection extends BaseLocalInspectionTool { gc.fill = GridBagConstraints.HORIZONTAL; gc.anchor = GridBagConstraints.NORTHWEST; - //mySuggestNullables = new JCheckBox("Suggest @Nullable annotation for method possibly return null.\n Requires JDK5.0 and annotations.jar from IDEA distribution"); mySuggestNullables = new JCheckBox( InspectionsBundle.message("inspection.data.flow.nullable.quickfix.option", ApplicationNamesInfo.getInstance().getProductName())); mySuggestNullables.setSelected(SUGGEST_NULLABLE_ANNOTATIONS); @@ -455,6 +454,8 @@ public class DataFlowInspection extends BaseLocalInspectionTool { gc.insets.bottom = 15; add(configureAnnotations, gc); + gc.fill = GridBagConstraints.HORIZONTAL; + gc.weighty = 1; gc.insets.left = 0; gc.gridy++; add(myDontReportTrueAsserts, gc); diff --git a/java/openapi/src/com/intellij/codeInsight/NullableNotNullDialog.java b/java/openapi/src/com/intellij/codeInsight/NullableNotNullDialog.java index e00b1d1edfab..5251a425fcbd 100644 --- a/java/openapi/src/com/intellij/codeInsight/NullableNotNullDialog.java +++ b/java/openapi/src/com/intellij/codeInsight/NullableNotNullDialog.java @@ -15,31 +15,27 @@ */ package com.intellij.codeInsight; -import com.intellij.ide.ui.ListCellRendererWrapper; import com.intellij.ide.util.ClassFilter; import com.intellij.ide.util.TreeClassChooser; import com.intellij.ide.util.TreeClassChooserFactory; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.ui.VerticalFlowLayout; +import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.IconLoader; -import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiClass; import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.ui.LayeredIcon; import com.intellij.ui.ScrollPaneFactory; +import com.intellij.ui.TitledSeparator; import com.intellij.ui.components.JBList; import com.intellij.util.ArrayUtil; -import com.intellij.util.Icons; import com.intellij.util.ui.EmptyIcon; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import javax.swing.*; import java.awt.*; -import java.util.ArrayList; import java.util.List; /** @@ -66,15 +62,16 @@ public class NullableNotNullDialog extends DialogWrapper { @Override protected JComponent createCenterPanel() { - final JPanel panel = new JPanel(new GridBagLayout()); final NullableNotNullManager manager = NullableNotNullManager.getInstance(myProject); + final Splitter splitter = new Splitter(true); myNullablePanel = new AnnoPanel("Nullable", manager.getDefaultNullable(), manager.getNullables(), NullableNotNullManager.DEFAULT_NULLABLES); - panel.add(myNullablePanel, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0, 0)); + splitter.setFirstComponent(myNullablePanel); myNotNullPanel = new AnnoPanel("NotNull", manager.getDefaultNotNull(), manager.getNotNulls(), NullableNotNullManager.DEFAULT_NOT_NULLS); - panel.add(myNotNullPanel, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0, 0)); - panel.add(Box.createVerticalBox(), new GridBagConstraints(0, 2, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0,0)); - return panel; + splitter.setSecondComponent(myNotNullPanel); + splitter.setHonorComponentsMinimumSize(true); + splitter.setPreferredSize(new Dimension(300, 400)); + return splitter; } @Override @@ -99,7 +96,6 @@ public class NullableNotNullDialog extends DialogWrapper { super(new GridBagLayout()); myDefaultAnn = defaultAnn; myDefaultAnns = defaultAnns; - setBorder(BorderFactory.createTitledBorder(title)); myList = new JBList(anns); myList.setCellRenderer(new DefaultListCellRenderer(){ @Override @@ -153,16 +149,23 @@ public class NullableNotNullDialog extends DialogWrapper { @Override public void actionPerformed(AnActionEvent e) { - myDefaultAnn = (String)myList.getSelectedValue(); + myDefaultAnn = (String)myList.getSelectedValue(); + final DefaultListModel model = (DefaultListModel)myList.getModel(); + + // to show the new default value in the ui + model.setElementAt(myList.getSelectedValue(), myList.getSelectedIndex()); } }); - GridBagConstraints gc = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0, 0); + GridBagConstraints gc = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5,0,0,0), 0, 0); + add(new TitledSeparator(title), gc); + gc.gridy++; + gc.insets.top = 0; add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent(), gc); - gc.gridy = 1; + gc.gridy++; gc.weighty = 1; gc.fill = GridBagConstraints.BOTH; final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myList); - scrollPane.setMinimumSize(new Dimension(-1, 150)); + scrollPane.setMinimumSize(new Dimension(250, 100)); add(scrollPane, gc); } diff --git a/java/openapi/src/com/intellij/codeInsight/NullableNotNullManager.java b/java/openapi/src/com/intellij/codeInsight/NullableNotNullManager.java index b1c5b0eb553a..1c20cf669ac8 100644 --- a/java/openapi/src/com/intellij/codeInsight/NullableNotNullManager.java +++ b/java/openapi/src/com/intellij/codeInsight/NullableNotNullManager.java @@ -40,7 +40,6 @@ public class NullableNotNullManager implements PersistentStateComponent private static final Logger LOG = Logger.getInstance("#" + NullableNotNullManager.class.getName()); public String myDefaultNullable = AnnotationUtil.NULLABLE; - public String myDefaultNotNull = AnnotationUtil.NOT_NULL; public JDOMExternalizableStringList myNullables = new JDOMExternalizableStringList(); public JDOMExternalizableStringList myNotNulls = new JDOMExternalizableStringList(); @@ -122,11 +121,32 @@ public class NullableNotNullManager implements PersistentStateComponent return myNotNulls; } + public boolean hasDefaultValues() { + if (DEFAULT_NULLABLES.length != myNullables.size() || DEFAULT_NOT_NULLS.length != myNotNulls.size()) { + return false; + } + if (myDefaultNotNull != AnnotationUtil.NOT_NULL || myDefaultNullable != AnnotationUtil.NULLABLE) { + return false; + } + for (int i = 0; i < DEFAULT_NULLABLES.length; i++) { + if (!myNullables.get(i).equals(DEFAULT_NULLABLES[i])) { + return false; + } + } + for (int i = 0; i < DEFAULT_NOT_NULLS.length; i++) { + if (!myNotNulls.get(i).equals(DEFAULT_NOT_NULLS[i])) { + return false; + } + } + + return true; + } + @Override public Element getState() { final Element component = new Element("component"); - if (getNullables().size() == DEFAULT_NULLABLES.length && getNotNulls().size() == DEFAULT_NOT_NULLS.length) { + if (hasDefaultValues()) { return component; } diff --git a/platform/icons/src/vcs/equal.png b/platform/icons/src/vcs/equal.png new file mode 100644 index 000000000000..8ac5c60e1a5f Binary files /dev/null and b/platform/icons/src/vcs/equal.png differ diff --git a/platform/icons/src/vcs/not_equal.png b/platform/icons/src/vcs/not_equal.png new file mode 100644 index 000000000000..b1cdcf1b1482 Binary files /dev/null and b/platform/icons/src/vcs/not_equal.png differ diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ActivateNavigationBarAction.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ActivateNavigationBarAction.java index 621e69120d07..761bcd38c1c8 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ActivateNavigationBarAction.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ActivateNavigationBarAction.java @@ -36,7 +36,7 @@ public class ActivateNavigationBarAction extends AnAction implements DumbAware { final IdeFrameImpl frame = WindowManagerEx.getInstanceEx().getFrame(project); final IdeRootPane ideRootPane = ((IdeRootPane)frame.getRootPane()); final NavBarPanel navBarPanel = (NavBarPanel)ideRootPane.findByName(NavBarRootPaneExtension.NAV_BAR).getComponent(); - navBarPanel.activatePopupOnLastElement(e.getDataContext()); + navBarPanel.selectTail(); } } diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarKeyboardCommand.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarKeyboardCommand.java index c5775f3f1b6a..d0a4d69e36a4 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarKeyboardCommand.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarKeyboardCommand.java @@ -29,6 +29,7 @@ public enum NavBarKeyboardCommand { HOME(KeyEvent.VK_HOME), END(KeyEvent.VK_END), DOWN(KeyEvent.VK_DOWN), + UP(KeyEvent.VK_UP), ENTER(KeyEvent.VK_ENTER), NAVIGATE(KeyEvent.VK_F4), ESCAPE(KeyEvent.VK_ESCAPE); diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarListener.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarListener.java index f1d1cba26af4..a20d97936c4b 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarListener.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarListener.java @@ -113,6 +113,7 @@ public class NavBarListener extends WolfTheProblemSolver.ProblemListener case HOME: myPanel.moveHome(); break; case END: myPanel.moveEnd(); break; case DOWN: myPanel.moveDown(); break; + case UP: myPanel.moveDown(); break; case ENTER: myPanel.enter(); break; case ESCAPE: myPanel.escape(); break; case NAVIGATE: myPanel.navigate(); break; diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java index 4632e9ffe9be..771cbd13dd64 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java @@ -94,6 +94,7 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup private NavBarItem myContextObject; private boolean myDisposed = false; private RelativePoint myLocationCache; + private boolean initialized = false; public NavBarPanel(final Project project) { @@ -171,8 +172,14 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup } public void moveDown() { - if (myModel.getSelectedIndex() != -1) { - ctrlClick(myModel.getSelectedIndex()); + final int index = myModel.getSelectedIndex(); + if (index != -1) { + if (myModel.size() - 1 == index) { + shiftFocus(-1); + ctrlClick(index - 1); + } else { + ctrlClick(index); + } } } @@ -719,7 +726,7 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup } }); } - activatePopupOnLastElement(); + selectTail(); } }, NavBarUpdateQueue.ID.SHOW_HINT); @@ -741,6 +748,7 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup myModel.setSelectedIndex(Math.max(myList.size() - 2, 0)); IdeFocusManager.getInstance(myProject).requestFocus(NavBarPanel.this, true); restorePopup(); + initialized = true; } } }); diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/SelectInNavBarTarget.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/SelectInNavBarTarget.java index 28a7bcceac92..c9554c88b8ba 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/SelectInNavBarTarget.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/SelectInNavBarTarget.java @@ -72,7 +72,7 @@ public class SelectInNavBarTarget extends SelectInTargetPsiWrapper implements Du if (navBarExt != null) { final JComponent c = navBarExt.getComponent(); final NavBarPanel panel = (NavBarPanel)c.getClientProperty("NavBarPanel"); - panel.activatePopupOnLastElement(); + panel.selectTail(); } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java index a06a1f455bbf..f73c690b92c5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java @@ -49,6 +49,8 @@ import com.intellij.openapi.wm.impl.status.ToggleReadOnlyAttributePanel; import com.intellij.ui.AppUIUtil; import com.intellij.ui.BalloonLayout; import com.intellij.ui.FocusTrackback; +import com.intellij.ui.mac.MacMainFrameDecorator; +import com.intellij.util.PlatformUtils; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -58,9 +60,6 @@ import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; /** * @author Anton Katilin @@ -80,6 +79,7 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider { private IdeRootPane myRootPane; private final BalloonLayout myBalloonLayout; private static boolean myUpdatingTitle; + private MacMainFrameDecorator myFrameDecorator; public IdeFrameImpl(ApplicationInfoEx applicationInfoEx, ActionManagerEx actionManager, UISettings uiSettings, DataManager dataManager, final Application application, final String[] commandLineArgs) { @@ -130,6 +130,10 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider { setFocusableWindowState(true); } }); + + if (SystemInfo.isMac && myFrameDecorator == null) { + myFrameDecorator = new MacMainFrameDecorator(this, PlatformUtils.isCidr()); + } } /** @@ -337,6 +341,10 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider { myRootPane = null; } + if (myFrameDecorator != null) { + myFrameDecorator.remove(); + } + FocusTrackback.release(this); super.dispose(); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java index 2157bcd4ed71..651451d8e77e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java @@ -552,6 +552,11 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat myProject2Frame.remove(project); if (myProject2Frame.isEmpty()) { myProject2Frame.put(null, frame); + + if (ApplicationManager.getApplication().isDisposeInProgress()) { + // disposing last frame if quitting + frame.dispose(); + } } else { Disposer.dispose((StatusBarEx) frame.getStatusBar()); diff --git a/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java b/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java index fbb40eecfd1e..effadf8b1a61 100644 --- a/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java @@ -138,30 +138,8 @@ public class MacFileChooserDialogImpl implements MacFileChooserDialog { } 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"); - final ID windowEnumerator = invoke(windows, "objectEnumerator"); - - ID focusedWindow = null; - while (true) { - // dirty hack: walks through all the windows to find a cocoa window to show sheet for - final ID window = invoke(windowEnumerator, "nextObject"); - if (0 == window.intValue()) break; - - final ID windowTitle = invoke(window, "title"); - if (windowTitle != null && windowTitle.intValue() != 0) { - final String titleString = Foundation.toStringViaUTF8(windowTitle); - if (titleString.equals(activeWindowTitle)) { - if (1 == invoke(window, "isVisible").intValue()) { - focusedWindow = window; - break; - } - } - } - } + final ID focusedWindow = MacMainFrameDecorator.findWindowForTitle(activeWindowTitle); if (focusedWindow != null) { invoke(chooser, "beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:", directory, file, null, focusedWindow, self, Foundation.createSelector("openPanelDidEnd:returnCode:contextInfo:"), null); diff --git a/platform/platform-impl/src/com/intellij/ui/mac/MacMainFrameDecorator.java b/platform/platform-impl/src/com/intellij/ui/mac/MacMainFrameDecorator.java new file mode 100644 index 000000000000..4327d36a5ba7 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ui/mac/MacMainFrameDecorator.java @@ -0,0 +1,179 @@ +/* + * Copyright 2000-2011 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.ui.mac; + +import com.intellij.ide.ui.UISettings; +import com.intellij.ide.ui.UISettingsListener; +import com.intellij.openapi.Disposable; +import com.intellij.openapi.util.Disposer; +import com.intellij.ui.mac.foundation.Foundation; +import com.intellij.ui.mac.foundation.ID; +import com.intellij.util.Function; +import com.sun.jna.Callback; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import java.awt.*; +import java.util.concurrent.atomic.AtomicInteger; + +import static com.intellij.ui.mac.foundation.Foundation.invoke; +import static com.intellij.ui.mac.foundation.Foundation.toStringViaUTF8; + +/** + * User: spLeaner + */ +public class MacMainFrameDecorator implements UISettingsListener, Disposable { + private static boolean SHOWN = false; + + private static Callback SET_VISIBLE_CALLBACK = new Callback() { + public void callback(ID caller, ID selector, ID value) { + SHOWN = value.intValue() == 1; + SwingUtilities.invokeLater(CURRENT_SETTER); + } + }; + + private static Callback IS_VISIBLE = new Callback() { + public boolean callback(ID caller) { + return SHOWN; + } + }; + + private static AtomicInteger UNIQUE_COUNTER = new AtomicInteger(0); + + public static final Runnable TOOLBAR_SETTER = new Runnable() { + @Override + public void run() { + final UISettings settings = UISettings.getInstance(); + settings.SHOW_MAIN_TOOLBAR = SHOWN; + settings.fireUISettingsChanged(); + } + }; + + public static final Runnable NAVBAR_SETTER = new Runnable() { + @Override + public void run() { + final UISettings settings = UISettings.getInstance(); + settings.SHOW_NAVIGATION_BAR = SHOWN; + settings.fireUISettingsChanged(); + } + }; + + public static final Function NAVBAR_GETTER = new Function() { + @Override + public Boolean fun(Object o) { + return UISettings.getInstance().SHOW_NAVIGATION_BAR; + } + }; + + public static final Function TOOLBAR_GETTER = new Function() { + @Override + public Boolean fun(Object o) { + return UISettings.getInstance().SHOW_MAIN_TOOLBAR; + } + }; + + private static Runnable CURRENT_SETTER = null; + private static Function CURRENT_GETTER = null; + private String myClassName; + + public MacMainFrameDecorator(@NotNull final Frame frame, final boolean navBar) { + final ID window = findWindowForTitle(frame.getTitle()); + if (window == null) return; + + if (CURRENT_SETTER == null) { + CURRENT_SETTER = navBar ? NAVBAR_SETTER : TOOLBAR_SETTER; + CURRENT_GETTER = navBar ? NAVBAR_GETTER : TOOLBAR_GETTER; + SHOWN = CURRENT_GETTER.fun(null); + } + + UISettings.getInstance().addUISettingsListener(this, this); + + final ID pool = invoke("NSAutoreleasePool", "new"); + + try { + myClassName = "IdeaToolbar" + UNIQUE_COUNTER.incrementAndGet(); + + final ID ownToolbar = Foundation.registerObjcClass(Foundation.getClass("NSToolbar"), myClassName); + Foundation.registerObjcClassPair(ownToolbar); + + ID toolbar = invoke(invoke(myClassName, "alloc"), "initWithIdentifier:", Foundation.cfString(myClassName)); + Foundation.cfRetain(toolbar); + + invoke(toolbar, "setVisible:", 0); // hide native toolbar by default + + Foundation.addMethod(ownToolbar, Foundation.createSelector("setVisible:"), SET_VISIBLE_CALLBACK, "v*"); + Foundation.addMethod(ownToolbar, Foundation.createSelector("isVisible"), IS_VISIBLE, "B*"); + + invoke(window, "setToolbar:", toolbar); + invoke(window, "setShowsToolbarButton:", 1); + } + finally { + invoke(pool, "release"); + } + } + + public void remove() { + // TODO: clean up? + Disposer.dispose(this); + } + + @Override + public void uiSettingsChanged(final UISettings source) { + if (CURRENT_GETTER != null) { + SHOWN = CURRENT_GETTER.fun(null); + } + } + + @Override + public void dispose() { + } + + @Nullable + public static ID findWindowForTitle(final String title) { + if (title == null || title.length() == 0) return null; + final ID pool = invoke("NSAutoreleasePool", "new"); + + ID focusedWindow = null; + try { + final ID sharedApplication = invoke("NSApplication", "sharedApplication"); + final ID windows = invoke(sharedApplication, "windows"); + final ID windowEnumerator = invoke(windows, "objectEnumerator"); + + while (true) { + // dirty hack: walks through all the windows to find a cocoa window to show sheet for + final ID window = invoke(windowEnumerator, "nextObject"); + if (0 == window.intValue()) break; + + final ID windowTitle = invoke(window, "title"); + if (windowTitle != null && windowTitle.intValue() != 0) { + final String titleString = toStringViaUTF8(windowTitle); + if (titleString.equals(title)) { + if (1 == invoke(window, "isVisible").intValue()) { + focusedWindow = window; + break; + } + } + } + } + } + finally { + invoke(pool, "release"); + } + + return focusedWindow; + } +} diff --git a/platform/platform-resources-en/src/messages/InspectionsBundle.properties b/platform/platform-resources-en/src/messages/InspectionsBundle.properties index 71f683b74152..903cb930eff6 100644 --- a/platform/platform-resources-en/src/messages/InspectionsBundle.properties +++ b/platform/platform-resources-en/src/messages/InspectionsBundle.properties @@ -36,7 +36,7 @@ inspection.annotate.method.quickfix.name=Annotate method as @{0} #dataflow inspection.data.flow.display.name=Constant conditions \\& exceptions inspection.data.flow.nullable.quickfix.option=Suggest @Nullable annotation for methods that may possibly return null.
Requires JDK5.0 and annotations.jar from {0} distribution -inspection.data.flow.true.asserts.option=Don''t report assert statements with condition statically proven to be always true +inspection.data.flow.true.asserts.option=Don't report assert statements with condition statically proven to be always true inspection.data.flow.redundant.instanceof.quickfix=Replace with != null inspection.data.flow.simplify.boolean.expression.quickfix=Simplify Boolean Expression 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 227f9fd3b0f4..85dd878aa3f5 100644 --- a/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java +++ b/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java @@ -67,6 +67,10 @@ public class Foundation { return invoke(getClass(cls), createSelector(selector), args); } + public static ID invoke(final ID id, final String selector, Object... args) { + return invoke(id, createSelector(selector), args); + } + public static ID registerObjcClass(ID superCls, String name) { return myFoundationLibrary.objc_allocateClassPair(superCls, name, 0); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffIcons.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffIcons.java new file mode 100644 index 000000000000..b36f529eb1a2 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffIcons.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2011 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.diff.impl.dir; + +import com.intellij.openapi.util.IconLoader; +import com.intellij.util.Icons; + +import javax.swing.*; + +/** + * @author Konstantin Bulenkov + */ +public interface DirDiffIcons { + Icon FOLDER = Icons.FOLDER_ICON; + Icon MOVE_RIGHT = IconLoader.getIcon("/vcs/arrow_right.png"); + Icon MOVE_LEFT = IconLoader.getIcon("/vcs/arrow_left.png"); + Icon EQUAL = IconLoader.getIcon("/vcs/equal.png"); + Icon NOT_EQUAL = IconLoader.getIcon("/vcs/not_equal.png"); +} diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.form b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.form index 354d8a890393..dde268b4b3e9 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.form +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.form @@ -46,7 +46,7 @@ - + @@ -54,7 +54,7 @@ - + @@ -71,7 +71,7 @@ - + @@ -86,6 +86,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java index 294a0e69766d..5e675f1e7b2c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java @@ -15,11 +15,14 @@ */ package com.intellij.openapi.diff.impl.dir; +import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.diff.DiffManager; import com.intellij.openapi.diff.DiffPanel; import com.intellij.openapi.diff.DiffRequest; import com.intellij.openapi.diff.SimpleDiffRequest; import com.intellij.openapi.diff.impl.DiffPanelImpl; +import com.intellij.openapi.diff.impl.dir.actions.DirDiffToolbarActions; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.ex.EditorEx; @@ -44,6 +47,7 @@ import java.awt.event.KeyEvent; * @author Konstantin Bulenkov */ public class DirDiffPanel { + public static final JBLabel CANT_OPEN_LABEL = new JBLabel("Can't open file content", SwingConstants.CENTER); private JPanel myDiffPanel; private JBTable myTable; private JPanel myComponent; @@ -52,6 +56,10 @@ public class DirDiffPanel { private TextFieldWithBrowseButton myTargetDirField; private JBLabel myTargetDirLabel; private JBLabel mySourceDirLabel; + private JPanel myActionsPanel; + private JPanel myActionsCenterPanel; + private JComboBox myFileFilter; + private JPanel myToolBarPanel; private final DirDiffTableModel myModel; private final DirDiffDialog myDialog; private DiffPanel myDiffPanelComponent; @@ -97,9 +105,13 @@ public class DirDiffPanel { final VirtualFile file = element.isSource() ? element.getSource() : element.getTarget(); final Document document = FileDocumentManager.getInstance().getDocument(file); - myEditor = (EditorEx)EditorFactory.getInstance().createEditor(document, project, file, true); - myEditor.getSettings().setFoldingOutlineShown(false); - myDiffPanel.add(myEditor.getComponent(), BorderLayout.CENTER); + if (document != null) { + myEditor = (EditorEx)EditorFactory.getInstance().createEditor(document, project, file, true); + myEditor.getSettings().setFoldingOutlineShown(false); + myDiffPanel.add(myEditor.getComponent(), BorderLayout.CENTER); + } else { + myDiffPanel.add(CANT_OPEN_LABEL, BorderLayout.CENTER); + } myDiffPanel.revalidate(); } } @@ -134,6 +146,8 @@ public class DirDiffPanel { final TableColumn operationColumn = myTable.getColumnModel().getColumn(3); operationColumn.setMaxWidth(25); operationColumn.setMinWidth(25); + final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("DirDiff", new DirDiffToolbarActions(myModel), true); + myToolBarPanel.add(toolbar.getComponent(), BorderLayout.CENTER); } private void clearDiffPanel() { @@ -147,6 +161,7 @@ public class DirDiffPanel { EditorFactory.getInstance().releaseEditor(myEditor); myEditor = null; } + myDiffPanel.remove(CANT_OPEN_LABEL); } private void createUIComponents() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java index 3a35ed77747f..b8fd370c984f 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java @@ -33,6 +33,10 @@ public class DirDiffTableModel extends AbstractTableModel { private VirtualFile mySrc; private VirtualFile myTrg; final List myElements = new ArrayList(); + private boolean showEqual = false; + private boolean showDifferent = true; + private boolean showNewOnSource = true; + private boolean showNewOnTarget = true; public DirDiffTableModel(Project project, VirtualFile src, VirtualFile trg, ProgressIndicator indicator) { myProject = project; @@ -198,4 +202,36 @@ public class DirDiffTableModel extends AbstractTableModel { public Project getProject() { return myProject; } + + public boolean isShowEqual() { + return showEqual; + } + + public void setShowEqual(boolean show) { + this.showEqual = show; + } + + public boolean isShowDifferent() { + return showDifferent; + } + + public void setShowDifferent(boolean show) { + this.showDifferent = show; + } + + public boolean isShowNewOnSource() { + return showNewOnSource; + } + + public void setShowNewOnSource(boolean show) { + this.showNewOnSource = show; + } + + public boolean isShowNewOnTarget() { + return showNewOnTarget; + } + + public void setShowNewOnTarget(boolean show) { + this.showNewOnTarget = show; + } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/DirDiffAction.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/DirDiffAction.java new file mode 100644 index 000000000000..399a60f39a70 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/DirDiffAction.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2011 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.diff.impl.dir.actions; + +import com.intellij.openapi.actionSystem.ToggleAction; +import com.intellij.openapi.diff.impl.dir.DirDiffIcons; +import com.intellij.openapi.diff.impl.dir.DirDiffTableModel; + +import javax.swing.*; + +/** + * @author Konstantin Bulenkov + */ +public abstract class DirDiffAction extends ToggleAction implements DirDiffIcons { + private final DirDiffTableModel myModel; + + protected DirDiffAction(DirDiffTableModel model, String name, Icon icon) { + super(name, name, icon); + myModel = model; + } + + public DirDiffTableModel getModel() { + return myModel; + } +} diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/DirDiffToolbarActions.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/DirDiffToolbarActions.java new file mode 100644 index 000000000000..6c5d2057ea6f --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/DirDiffToolbarActions.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2011 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.diff.impl.dir.actions; + +import com.intellij.openapi.actionSystem.ActionGroup; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.Separator; +import com.intellij.openapi.diff.impl.dir.DirDiffTableModel; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Konstantin Bulenkov + */ +public class DirDiffToolbarActions extends ActionGroup { + private final AnAction[] myActions; + private final DirDiffTableModel myModel; + + public DirDiffToolbarActions(DirDiffTableModel model) { + super("Directory Diff Actions", false); + myModel = model; + myActions = new AnAction[] { + new RefreshDirDiffAction(myModel), + Separator.getInstance(), + new EnableLeft(myModel), + new EnableNotEqual(myModel), + new EnableEqual(myModel), + new EnableRight(myModel), + Separator.getInstance() + }; + } + + @NotNull + @Override + public AnAction[] getChildren(@Nullable AnActionEvent e) { + return myActions; + } +} diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/EnableEqual.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/EnableEqual.java new file mode 100644 index 000000000000..80ff1350c238 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/EnableEqual.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2011 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.diff.impl.dir.actions; + +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.diff.impl.dir.DirDiffTableModel; + +/** + * @author Konstantin Bulenkov + */ +public class EnableEqual extends DirDiffAction { + public EnableEqual(DirDiffTableModel model) { + super(model, "Show equal files", EQUAL); + } + + @Override + public boolean isSelected(AnActionEvent e) { + return getModel().isShowEqual(); + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + getModel().setShowEqual(state); + } +} diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/EnableLeft.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/EnableLeft.java new file mode 100644 index 000000000000..7731b26d86e4 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/EnableLeft.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2011 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.diff.impl.dir.actions; + +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.diff.impl.dir.DirDiffTableModel; + +/** + * @author Konstantin Bulenkov + */ +public class EnableLeft extends DirDiffAction { + protected EnableLeft(DirDiffTableModel model) { + super(model, "Show new files on left side", MOVE_RIGHT); + } + + @Override + public boolean isSelected(AnActionEvent e) { + return getModel().isShowNewOnSource(); + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + getModel().setShowNewOnSource(state); + } +} diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/EnableNotEqual.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/EnableNotEqual.java new file mode 100644 index 000000000000..50a462897c37 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/EnableNotEqual.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2011 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.diff.impl.dir.actions; + +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.diff.impl.dir.DirDiffTableModel; + +/** + * @author Konstantin Bulenkov + */ +public class EnableNotEqual extends DirDiffAction { + protected EnableNotEqual(DirDiffTableModel model) { + super(model, "Show difference", NOT_EQUAL); + } + + @Override + public boolean isSelected(AnActionEvent e) { + return getModel().isShowDifferent(); + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + getModel().setShowDifferent(state); + } +} diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/EnableRight.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/EnableRight.java new file mode 100644 index 000000000000..c58043b2856b --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/EnableRight.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2011 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.diff.impl.dir.actions; + +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.diff.impl.dir.DirDiffTableModel; + +/** + * @author Konstantin Bulenkov + */ +public class EnableRight extends DirDiffAction { + protected EnableRight(DirDiffTableModel model) { + super(model, "Show new files on right side", MOVE_LEFT); + } + + @Override + public boolean isSelected(AnActionEvent e) { + return getModel().isShowNewOnTarget(); + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + getModel().setShowNewOnTarget(state); + } +} diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/RefreshDirDiffAction.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/RefreshDirDiffAction.java new file mode 100644 index 000000000000..99cfc9d2dea0 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/RefreshDirDiffAction.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2011 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.diff.impl.dir.actions; + +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.diff.impl.dir.DirDiffTableModel; +import com.intellij.util.Icons; + +/** + * @author Konstantin Bulenkov + */ +public class RefreshDirDiffAction extends DirDiffAction { + public RefreshDirDiffAction(DirDiffTableModel model) { + super(model, "Refresh", Icons.SYNCHRONIZE_ICON); + } + + @Override + public boolean isSelected(AnActionEvent e) { + return false; + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + //TODO getModel().refresh(); + } +}