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

This commit is contained in:
Kirill Kalishev
2011-04-07 20:00:32 +04:00
27 changed files with 684 additions and 57 deletions
@@ -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);
@@ -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);
}
@@ -40,7 +40,6 @@ public class NullableNotNullManager implements PersistentStateComponent<Element>
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<Element>
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;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

@@ -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();
}
}
@@ -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);
@@ -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;
@@ -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;
}
}
});
@@ -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();
}
}
}
@@ -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();
@@ -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());
@@ -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);
@@ -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<Object, Boolean> NAVBAR_GETTER = new Function<Object, Boolean>() {
@Override
public Boolean fun(Object o) {
return UISettings.getInstance().SHOW_NAVIGATION_BAR;
}
};
public static final Function<Object, Boolean> TOOLBAR_GETTER = new Function<Object, Boolean>() {
@Override
public Boolean fun(Object o) {
return UISettings.getInstance().SHOW_MAIN_TOOLBAR;
}
};
private static Runnable CURRENT_SETTER = null;
private static Function<Object, Boolean> 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;
}
}
@@ -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=<html><body>Suggest @Nullable annotation for methods that may possibly return null.<br> Requires JDK5.0 and annotations.jar from {0} distribution</body></html>
inspection.data.flow.true.asserts.option=<html><body>Don''t report assert statements with condition statically proven to be always <code>true</code></body></html>
inspection.data.flow.true.asserts.option=<html><body>Don't report assert statements with condition statically proven to be always <code>true</code></body></html>
inspection.data.flow.redundant.instanceof.quickfix=Replace with != null
inspection.data.flow.simplify.boolean.expression.quickfix=Simplify Boolean Expression
@@ -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);
}
@@ -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");
}
@@ -46,7 +46,7 @@
</scrollpane>
</children>
</splitpane>
<grid id="bc3dc" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="bc3dc" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints border-constraint="North"/>
<properties/>
@@ -54,7 +54,7 @@
<children>
<grid id="d29c8" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -71,7 +71,7 @@
</grid>
<grid id="23086" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -86,6 +86,61 @@
</component>
</children>
</grid>
<grid id="490e0" binding="myActionsPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="6002e" binding="myActionsCenterPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="2" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints border-constraint="Center"/>
<properties/>
<border type="etched"/>
<children>
<hspacer id="d0cf4">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="b08b8" binding="myToolBarPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<grid id="97b9b" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="51b76" class="javax.swing.JComboBox" binding="myFileFilter">
<constraints border-constraint="Center"/>
<properties>
<editable value="true"/>
<model>
<item value="*.*"/>
</model>
</properties>
</component>
<component id="5d686" class="com.intellij.ui.components.JBLabel">
<constraints border-constraint="West"/>
<properties>
<labelFor value="51b76"/>
<text value="Filter:"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</children>
</grid>
</children>
</grid>
</children>
@@ -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() {
@@ -33,6 +33,10 @@ public class DirDiffTableModel extends AbstractTableModel {
private VirtualFile mySrc;
private VirtualFile myTrg;
final List<DirDiffElement> myElements = new ArrayList<DirDiffElement>();
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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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();
}
}