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

This commit is contained in:
Kirill Kalishev
2011-05-05 11:24:29 +04:00
48 changed files with 834 additions and 203 deletions
+10 -8
View File
@@ -1416,7 +1416,7 @@
</option>
<option name="PY.DOC_COMMENT">
<value>
<option name="FOREGROUND" value="99cc00" />
<option name="FOREGROUND" value="d2c200" />
<option name="BACKGROUND" />
<option name="FONT_TYPE" value="1" />
<option name="EFFECT_COLOR" />
@@ -1524,14 +1524,16 @@
<option name="ERROR_STRIPE_COLOR" />
</value>
</option>
<option name="PY.STRING">
<option name="PY.STRING.B">
<value>
<option name="FOREGROUND" value="b501" />
<option name="BACKGROUND" />
<option name="FONT_TYPE" value="1" />
<option name="EFFECT_COLOR" />
<option name="EFFECT_TYPE" value="0" />
<option name="ERROR_STRIPE_COLOR" />
<option name="FOREGROUND" value="85cd00" />
<option name="FONT_TYPE" value="1" />
</value>
</option>
<option name="PY.STRING.U">
<value>
<option name="FOREGROUND" value="b580" />
<option name="FONT_TYPE" value="1" />
</value>
</option>
<option name="PY.VALID_STRING_ESCAPE">
+8 -3
View File
@@ -388,9 +388,14 @@
<option name="FOREGROUND" value="F92672" />
</value>
</option>
<option name="PY.STRING">
<option name="PY.STRING.B">
<value>
<option name="FOREGROUND" value="E6DB74" />
<option name="FOREGROUND" value="e6a774" />
</value>
</option>
<option name="PY.STRING.U">
<value>
<option name="FOREGROUND" value="e6db74" />
</value>
</option>
<option name="PY.NUMBER">
@@ -425,7 +430,7 @@
</option>
<option name="PY.DOC_COMMENT">
<value>
<option name="FOREGROUND" value="75715E" />
<option name="FOREGROUND" value="a19b81" />
</value>
</option>
<option name="PY.DECORATOR">
+8 -3
View File
@@ -395,9 +395,14 @@
<option name="FOREGROUND" value="CDA869" />
</value>
</option>
<option name="PY.STRING">
<option name="PY.STRING.B">
<value>
<option name="FOREGROUND" value="8F9D6A" />
<option name="FOREGROUND" value="979d6a" />
</value>
</option>
<option name="PY.STRING.U">
<value>
<option name="FOREGROUND" value="6a9d7c" />
</value>
</option>
<option name="PY.NUMBER">
@@ -433,7 +438,7 @@
</option>
<option name="PY.DOC_COMMENT">
<value>
<option name="FOREGROUND" value="5F5A60" />
<option name="FOREGROUND" value="89a19d" />
<option name="FONT_TYPE" value="2" />
</value>
</option>
@@ -95,27 +95,32 @@ public class JavaChangeSignatureDetector implements LanguageChangeSignatureDetec
return null;
}
}
final MyJavaChangeInfo javaChangeInfo =
new MyJavaChangeInfo(newVisibility, method, newReturnType, parameterInfos, info.getNewExceptions(), method.getName(), info.getOldName()) {
@Override
protected void fillOldParams(PsiMethod method) {
oldParameterNames = info.getOldParameterNames();
oldParameterTypes = info.getOldParameterTypes();
if (!method.isConstructor()) {
try {
isReturnTypeChanged = info.isReturnTypeChanged ||
(info.getNewReturnType() != null
? !Comparing.strEqual(info.getNewReturnType().getTypeText(), newReturnType.getTypeText())
: newReturnType != null);
}
catch (IncorrectOperationException e) {
isReturnTypeChanged = true;
try {
final MyJavaChangeInfo javaChangeInfo =
new MyJavaChangeInfo(newVisibility, method, newReturnType, parameterInfos, info.getNewExceptions(), method.getName(), info.getOldName()) {
@Override
protected void fillOldParams(PsiMethod method) {
oldParameterNames = info.getOldParameterNames();
oldParameterTypes = info.getOldParameterTypes();
if (!method.isConstructor()) {
try {
isReturnTypeChanged = info.isReturnTypeChanged ||
(info.getNewReturnType() != null
? !Comparing.strEqual(info.getNewReturnType().getTypeText(), newReturnType.getTypeText())
: newReturnType != null);
}
catch (IncorrectOperationException e) {
isReturnTypeChanged = true;
}
}
}
}
};
javaChangeInfo.setSuperMethod(info.getSuperMethod());
return javaChangeInfo;
};
javaChangeInfo.setSuperMethod(info.getSuperMethod());
return javaChangeInfo;
}
catch (IncorrectOperationException e) {
return null;
}
}
return changeInfo;
}
@@ -157,7 +157,7 @@ class JavaChangeSignatureUsageSearcher {
for (PsiMethod overrider : overriders) {
PsiParameter parameter1 = overrider.getParameterList().getParameters()[info.getOldIndex()];
if (parameter.getName().equals(parameter1.getName())) {
if (parameter1 != null && Comparing.strEqual(parameter.getName(), parameter1.getName())) {
addParameterUsages(parameter1, result, info);
}
}
@@ -124,7 +124,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
if (psiField != null && psiField.getParent() == aClass) break;
aClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class, true);
}
if (classes.size() == 1 || ApplicationManager.getApplication().isUnitTestMode()) {
if (classes.size() == 1 || editor == null || ApplicationManager.getApplication().isUnitTestMode()) {
return !convertExpressionToField(selectedExpr, editor, file, project, tempType);
}
else {
@@ -143,7 +143,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
}
private boolean convertExpressionToField(PsiExpression selectedExpr,
Editor editor,
@Nullable Editor editor,
PsiFile file,
final Project project,
PsiType tempType) {
@@ -48,6 +48,7 @@ import com.intellij.refactoring.JavaRefactoringSettings;
import com.intellij.refactoring.rename.NameSuggestionProvider;
import com.intellij.refactoring.rename.inplace.VariableInplaceRenamer;
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
import com.intellij.refactoring.util.InlineUtil;
import com.intellij.ui.NonFocusableCheckBox;
import com.intellij.ui.TitlePanel;
import com.intellij.ui.awt.RelativePoint;
@@ -207,6 +208,25 @@ public class VariableInplaceIntroducer extends VariableInplaceRenamer {
});
}
} else {
final PsiVariable variable = getVariable();
if (variable != null) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
final PsiFile containingFile = variable.getContainingFile();
for (RangeMarker occurrenceMarker : myOccurrenceMarkers) {
final PsiElement refVariableElement = containingFile.findElementAt(occurrenceMarker.getStartOffset());
final PsiExpression expression = PsiTreeUtil.getParentOfType(refVariableElement, PsiReferenceExpression.class);
if (expression instanceof PsiReferenceExpression &&
(((PsiReferenceExpression)expression).resolve() == variable ||
Comparing.strEqual(variable.getName(), ((PsiReferenceExpression)expression).getReferenceName()))) {
InlineUtil.inlineVariable(variable, variable.getInitializer(), (PsiJavaCodeReferenceElement)expression);
}
}
variable.delete();
}
});
}
if (myExprMarker != null) {
myEditor.getCaretModel().moveToOffset(myExprMarker.getStartOffset());
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
@@ -151,14 +151,14 @@ public class ClassTypeArgumentMigrationProcessor {
private void prepareMethodsChangeSignature(final PsiClass currentClass, final PsiElement memberToChangeSignature, final PsiType memberType) {
if (memberToChangeSignature instanceof PsiMethod) {
final PsiMethod method = MethodSignatureUtil.findMethodBySuperMethod(currentClass, (PsiMethod)memberToChangeSignature, true);
if (method.getContainingClass() == currentClass) {
if (method != null && method.getContainingClass() == currentClass) {
myLabeler.addRoot(new TypeMigrationUsageInfo(method), memberType, method, false);
}
} else if (memberToChangeSignature instanceof PsiParameter && ((PsiParameter)memberToChangeSignature).getDeclarationScope() instanceof PsiMethod) {
final PsiMethod superMethod = (PsiMethod)((PsiParameter)memberToChangeSignature).getDeclarationScope();
final int parameterIndex = superMethod.getParameterList().getParameterIndex((PsiParameter)memberToChangeSignature);
final PsiMethod method = MethodSignatureUtil.findMethodBySuperMethod(currentClass, superMethod, true);
if (method.getContainingClass() == currentClass) {
if (method != null && method.getContainingClass() == currentClass) {
final PsiParameter parameter = method.getParameterList().getParameters()[parameterIndex];
myLabeler.addRoot(new TypeMigrationUsageInfo(parameter), memberType, parameter, false);
}
@@ -124,6 +124,11 @@ public class ConfigurationContext {
return null;
}
final PsiElement psiElement = myLocation.getPsiElement();
if (!psiElement.isValid()) {
return null;
}
final List<RuntimeConfigurationProducer> producers = findPreferredProducers();
if (producers == null) return null;
if (myRuntimeConfiguration != null) {
@@ -16,7 +16,10 @@
package com.intellij.execution.actions;
import com.intellij.execution.*;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.RunManager;
import com.intellij.execution.RunManagerEx;
import com.intellij.execution.RunnerAndConfigurationSettings;
import com.intellij.execution.configurations.ConfigurationType;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.ide.DataManager;
@@ -30,8 +33,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.wm.IdeFrame;
import com.intellij.openapi.wm.impl.IdeFrameImpl;
import com.intellij.util.IJSwingUtilities;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -76,6 +77,7 @@ public class RunConfigurationAction extends ComboBoxAction implements DumbAware
else {
if (DumbService.getInstance(project).isDumb()) {
presentation.setEnabled(false);
presentation.setText("");
}
else {
final RunManagerEx runManager = RunManagerEx.getInstanceEx(project);
@@ -111,7 +113,7 @@ public class RunConfigurationAction extends ComboBoxAction implements DumbAware
}
public JComponent createCustomComponent(final Presentation presentation) {
return new ComboBoxButton(presentation) {
final ComboBoxButton comboBoxButton = new ComboBoxButton(presentation) {
public void addNotify() {
super.addNotify(); //To change body of overriden methods use Options | File Templates.;
final IdeFrame frame = findFrame(this);
@@ -119,6 +121,12 @@ public class RunConfigurationAction extends ComboBoxAction implements DumbAware
frame.getComponent().getRootPane().putClientProperty(BUTTON_KEY, this);
}
};
final JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
panel.add(comboBoxButton);
panel.setOpaque(false);
return panel;
}
@@ -62,7 +62,7 @@ public class ViewStructureAction extends AnAction {
if (dialog != null) {
final VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile != null) {
dialog.setTitle(virtualFile.getPresentableUrl());
dialog.setTitle(virtualFile.getName());
}
dialog.show();
}
@@ -52,6 +52,8 @@ class NavBarBorder implements Border {
else {
if (drawTopBorder) {
g.drawLine(0, 0, width - myRightOffset + 3, 0);
} else {
g.drawLine(width - 1, 0, width - 1, height);
}
}
g.drawLine(0, height - 1, width, height - 1);
@@ -67,6 +69,6 @@ class NavBarBorder implements Border {
}
public boolean isBorderOpaque() {
return true;
return false;
}
}
@@ -60,6 +60,9 @@ class NavBarItem extends SimpleColoredComponent {
myAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
}
setOpaque(false);
setFont(UIUtil.isUnderAquaLookAndFeel() ? UIUtil.getLabelFont().deriveFont(11.0f) : getFont());
setIpad(new Insets(1, 2, 1, 2));
update();
}
@@ -85,12 +88,10 @@ class NavBarItem extends SimpleColoredComponent {
clear();
setIcon(myIcon);
final Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
final boolean focused = isPopupElement || (focusOwner == myPanel && !myPanel.isNodePopupShowing());
final boolean focused = isFocused();
final NavBarModel model = myPanel.getModel();
final boolean selected = isPopupElement ? myPanel.isSelectedInPopup(myObject)
: model.getSelectedIndex() == myIndex;
final boolean selected = isSelected();
setPaintFocusBorder(!focused && selected && !isPopupElement);
setFocusBorderAroundIcon(false);
@@ -106,12 +107,36 @@ class NavBarItem extends SimpleColoredComponent {
: myAttributes.getFgColor();
final Color bg = selected && focused ? UIUtil.getListSelectionBackground() : myAttributes.getBgColor();
append(myText, new SimpleTextAttributes(bg, fg, myAttributes.getWaveColor(), myAttributes.getStyle()));
repaint();
}
private boolean isFocused() {
final Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
return isPopupElement || (focusOwner == myPanel && !myPanel.isNodePopupShowing());
}
private boolean isSelected() {
final NavBarModel model = myPanel.getModel();
return isPopupElement ? myPanel.isSelectedInPopup(myObject) : model.getSelectedIndex() == myIndex;
}
@Override
protected boolean shouldDrawBackground() {
return isSelected() && isFocused();
}
@Override
protected boolean shouldDrawMacShadow() {
return UIUtil.isUnderAquaLookAndFeel() && !isSelected();
}
@Override
public boolean isIconOpaque() {
return false;
}
private Icon wrapIcon(final Icon openIcon, final Icon closedIcon, final int idx) {
return new Icon() {
public void paintIcon(Component c, Graphics g, int x, int y) {
@@ -50,7 +50,6 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFileSystemItem;
import com.intellij.ui.*;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.components.panels.OpaquePanel;
import com.intellij.ui.popup.AbstractPopup;
import com.intellij.ui.popup.PopupOwner;
import com.intellij.ui.popup.list.ListPopupImpl;
@@ -69,7 +68,7 @@ import java.util.Set;
* @author Konstantin Bulenkov
* @author Anna Kozlova
*/
public class NavBarPanel extends OpaquePanel.List implements DataProvider, PopupOwner, Disposable {
public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Disposable {
private final NavBarModel myModel;
@@ -96,9 +95,8 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup
private RelativePoint myLocationCache;
private boolean initialized = false;
public NavBarPanel(final Project project) {
super(new FlowLayout(FlowLayout.LEFT, 5, 0), UIUtil.isUnderGTKLookAndFeel() ? Color.WHITE : UIUtil.getListBackground());
super(new FlowLayout(FlowLayout.LEFT, 5, 0));
myProject = project;
myModel = new NavBarModel(myProject);
myIdeView = new NavBarIdeView(this);
@@ -108,6 +106,7 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup
PopupHandler.installPopupHandler(this, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.NAVIGATION_BAR);
setBorder(new NavBarBorder(false, -1));
setOpaque(false);
myCopyPasteDelegator = new CopyPasteDelegator(myProject, NavBarPanel.this) {
@NotNull
@@ -690,7 +689,12 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup
@Override
public void run() {
if (myModel.isEmpty()) return;
myHint = new LightweightHint(NavBarPanel.this) {
final JPanel panel = new JPanel(new BorderLayout());
panel.add(NavBarPanel.this);
panel.setOpaque(true);
panel.setBackground(UIUtil.isUnderGTKLookAndFeel() ? Color.WHITE : UIUtil.getListBackground());
myHint = new LightweightHint(panel) {
public void hide() {
super.hide();
cancelPopup();
@@ -26,9 +26,10 @@ import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.wm.IdeRootPaneNorthExtension;
import com.intellij.openapi.wm.impl.IdeFrameImpl;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.components.panels.OpaquePanel;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
@@ -65,7 +66,48 @@ public class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
public JComponent getComponent() {
if (myWrapperPanel == null) {
myWrapperPanel = new JPanel(new BorderLayout());
myWrapperPanel = new JPanel(new BorderLayout()) {
@Override
protected void paintChildren(Graphics g) {
super.paintChildren(g);
if (UIUtil.isUnderAquaLookAndFeel() && !UISettings.getInstance().SHOW_MAIN_TOOLBAR) {
final Rectangle r = getBounds();
g.setColor(new Color(255, 255, 255, 90));
g.drawLine(0, r.height - 4, r.width, r.height - 4);
g.setColor(new Color(0, 0, 0, 90));
g.drawLine(0, r.height - 3, r.width, r.height - 3);
g.setColor(new Color(0, 0, 0, 20));
g.drawLine(0, r.height - 2, r.width, r.height - 2);
}
}
@Override
protected void paintComponent(Graphics g) {
if (!UIUtil.isUnderAquaLookAndFeel()) {
super.paintComponent(g);
return;
}
final Rectangle r = getBounds();
if (UISettings.getInstance().SHOW_MAIN_TOOLBAR) {
g.setColor(new Color(200, 200, 200));
g.fillRect(0, 0, r.width, r.height);
}
else {
UIUtil.drawGradientHToolbarBackground(g, r.width, r.height);
}
}
@Override
public Insets getInsets() {
final Insets i = super.getInsets();
if (!UIUtil.isUnderAquaLookAndFeel()) {
return i;
}
return new Insets(i.top, i.left, i.bottom + 3, i.right);
}
};
myWrapperPanel.add(buildNavBarPanel(), BorderLayout.CENTER);
myWrapperPanel.putClientProperty("NavBarPanel", myNavigationBar);
toggleRunPanel(!UISettings.getInstance().SHOW_MAIN_TOOLBAR);
@@ -82,14 +124,14 @@ public class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
final DefaultActionGroup group = (DefaultActionGroup)toolbarRunGroup;
final boolean needGap = isNeedGap(group);
final ActionToolbar actionToolbar = manager.createActionToolbar(ActionPlaces.UNKNOWN, group, true);
actionToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
final JComponent component = actionToolbar.getComponent();
component.setBackground(Color.WHITE);
component.setOpaque(false);
myRunPanel = new JPanel(new BorderLayout());
final Color color = myRunPanel.getBackground() != null ? myRunPanel.getBackground().darker() : Color.darkGray;
myRunPanel.setBackground(Color.WHITE);
myRunPanel.add(component);
myRunPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 1, 1, 0, color),
BorderFactory.createEmptyBorder(1, needGap ? 5 : 1, 0, 0)));
myRunPanel.setOpaque(false);
myRunPanel.add(component, BorderLayout.CENTER);
myRunPanel.setBorder(BorderFactory.createEmptyBorder(0, needGap ? 5 : 1, 0, 0));
myWrapperPanel.add(myRunPanel, BorderLayout.EAST);
}
}
@@ -99,6 +141,11 @@ public class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
}
}
private boolean isUndocked() {
final Window ancestor = SwingUtilities.getWindowAncestor(myWrapperPanel);
return ancestor != null && !(ancestor instanceof IdeFrameImpl);
}
private static boolean isNeedGap(final DefaultActionGroup group) {
final AnAction firstAction = getFirstAction(group);
return firstAction instanceof ComboBoxAction;
@@ -124,31 +171,101 @@ public class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
}
private JComponent buildNavBarPanel() {
final JComponent result = new OpaquePanel.List(new BorderLayout());
final JComponent result = new JPanel(new BorderLayout()) {
@Override
protected void paintComponent(Graphics g) {
if (UIUtil.isUnderAquaLookAndFeel()) {
final Rectangle r = getBounds();
final Graphics2D g2d = (Graphics2D)g;
if (!UISettings.getInstance().SHOW_MAIN_TOOLBAR) {
//UIUtil.drawGradientHToolbarBackground(g, r.width, r.height);
final Dimension d = getPreferredSize();
final int topOffset = (r.height - d.height) / 2 + 2;
//
//g2d.setPaint(new GradientPaint(0, 0, new Color(240, 240, 240), 0, d.height, new Color(210, 210, 210)));
//g.fillRect(0, topOffset, r.width, d.height);
//
//g.setColor(new Color(0, 0, 0, 90));
//g.drawLine(0, topOffset, r.width, topOffset);
//g.drawLine(0, topOffset + d.height, r.width - 1, topOffset + d.height);
UIUtil.drawDoubleSpaceDottedLine(g2d, topOffset, topOffset + d.height - 1, r.width - 1, Color.GRAY, false);
}
else {
final boolean undocked = isUndocked();
g2d.setPaint(new GradientPaint(0, 0, new Color(240, 240, 240), 0, r.height, new Color(210, 210, 210)));
g.fillRect(0, 0, r.width, r.height);
if (!undocked) {
g.setColor(new Color(255, 255, 255, 220));
g.drawLine(0, 1, r.width, 1);
}
g.setColor(new Color(0, 0, 0, 80));
if (!undocked) g.drawLine(0, 0, r.width, 0);
g.drawLine(0, r.height - 1, r.width - 1, r.height - 1);
}
} else {
super.paintComponent(g);
}
}
@Override
public void doLayout() {
// align vertically
final Rectangle r = getBounds();
final Insets insets = getInsets();
int x = insets.left;
final Component navBar = getComponent(0);
final Component closeLabel = getComponentCount() == 2 ? getComponent(1) : null;
final Dimension preferredSize = navBar.getPreferredSize();
final Dimension closePreferredSize = closeLabel == null ? new Dimension() : closeLabel.getPreferredSize();
navBar.setBounds(x, insets.top + ((r.height - preferredSize.height - insets.top - insets.bottom) / 2),
r.width - insets.left - insets.right - closePreferredSize.width, preferredSize.height);
if(closeLabel != null) {
closeLabel.setBounds(x + r.width - insets.left - insets.right - closePreferredSize.width,
insets.top + ((r.height - closePreferredSize.height - insets.top - insets.bottom) / 2),
closePreferredSize.width, closePreferredSize.height);
}
}
};
result.setBackground(UIUtil.isUnderGTKLookAndFeel() ? Color.WHITE : UIUtil.getListBackground());
result.setOpaque(!UIUtil.isUnderAquaLookAndFeel() || UISettings.getInstance().SHOW_MAIN_TOOLBAR);
myNavigationBar = new NavBarPanel(myProject);
myNavigationBar.getModel().setFixedComponent(true);
JScrollPane scroller = ScrollPaneFactory.createScrollPane(myNavigationBar);
scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scroller.setHorizontalScrollBar(null);
scroller.setBorder(null);
scroller.setOpaque(false);
scroller.getViewport().setOpaque(false);
result.add(scroller, BorderLayout.CENTER);
JLabel closeLabel = new JLabel(CROSS_ICON);
if (!SystemInfo.isMac) {
JLabel closeLabel = new JLabel(CROSS_ICON);
closeLabel.addMouseListener(new MouseAdapter() {
public void mouseClicked(final MouseEvent e) {
UISettings.getInstance().SHOW_NAVIGATION_BAR = false;
uiSettingsChanged(UISettings.getInstance());
}
});
result.add(closeLabel, BorderLayout.EAST);
}
closeLabel.addMouseListener(new MouseAdapter() {
public void mouseClicked(final MouseEvent e) {
UISettings.getInstance().SHOW_NAVIGATION_BAR = false;
uiSettingsChanged(UISettings.getInstance());
}
});
result.add(closeLabel, BorderLayout.EAST);
myNavigationBar.setBorder(new NavBarBorder(true, 0));
result.setBorder(myNavigationBar.getBorder());
result.setBorder(UIUtil.isUnderAquaLookAndFeel() ? BorderFactory.createEmptyBorder(2, 0, 2, 4) : new NavBarBorder(true, 0));
myNavigationBar.setBorder(null);
return result;
}
@@ -156,6 +273,12 @@ public class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
if (myNavigationBar != null) {
myNavigationBar.updateState(settings.SHOW_NAVIGATION_BAR);
myWrapperPanel.setVisible(settings.SHOW_NAVIGATION_BAR);
if (myWrapperPanel.getComponentCount() > 0) {
final Component c = myWrapperPanel.getComponent(0);
if (c instanceof JComponent) ((JComponent)c).setOpaque(
!UIUtil.isUnderAquaLookAndFeel() || UISettings.getInstance().SHOW_MAIN_TOOLBAR);
}
}
}
@@ -27,6 +27,7 @@ import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vcs.FileStatusManager;
@@ -104,12 +105,17 @@ public final class TodoDirNode extends PsiDirectoryNode implements HighlightedRe
public int getFileCount(PsiDirectory directory) {
Iterator<PsiFile> iterator = myBuilder.getFiles(directory);
int count = 0;
while (iterator.hasNext()) {
PsiFile psiFile = iterator.next();
if (getStructure().accept(psiFile)) {
count++;
try {
while (iterator.hasNext()) {
PsiFile psiFile = iterator.next();
if (getStructure().accept(psiFile)) {
count++;
}
}
}
catch (IndexNotReadyException e) {
return count;
}
return count;
}
@@ -32,7 +32,6 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.ui.*;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.Icons;
import com.intellij.util.SmartList;
import com.intellij.util.containers.Convertor;
import com.intellij.util.containers.FactoryMap;
import com.intellij.util.containers.HashMap;
@@ -59,7 +58,7 @@ import java.util.List;
public class MemberChooser<T extends ClassMember> extends DialogWrapper implements TypeSafeDataProvider {
protected Tree myTree;
private DefaultTreeModel myTreeModel;
protected JCheckBox[] myCheckboxes;
protected JComponent[] myOptionControls;
private JCheckBox myCopyJavadocCheckbox;
private JCheckBox myInsertOverrideAnnotationCheckbox;
@@ -94,8 +93,8 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
boolean allowEmptySelection,
boolean allowMultiSelection,
@NotNull Project project,
JCheckBox[] checkboxes) {
this(elements, allowEmptySelection, allowMultiSelection, project, false, null, checkboxes);
JComponent[] optionControls) {
this(elements, allowEmptySelection, allowMultiSelection, project, false, null, optionControls);
}
public MemberChooser(T[] elements,
@@ -122,7 +121,7 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
@NotNull Project project,
boolean isInsertOverrideVisible,
JComponent headerPanel,
@Nullable JCheckBox[] checkboxes
@Nullable JComponent[] optionControls
) {
super(project, true);
myAllowEmptySelection = allowEmptySelection;
@@ -131,7 +130,7 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
myIsInsertOverrideVisible = isInsertOverrideVisible;
myHeaderPanel = headerPanel;
myTree = new Tree(new DefaultTreeModel(new DefaultMutableTreeNode()));
myCheckboxes = checkboxes;
myOptionControls = optionControls;
resetElements(elements);
init();
}
@@ -156,14 +155,14 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
TreeUtil.expandAll(myTree);
if (myCheckboxes == null) {
if (myOptionControls == null) {
myCopyJavadocCheckbox = new NonFocusableCheckBox(IdeBundle.message("checkbox.copy.javadoc"));
if (myIsInsertOverrideVisible) {
myInsertOverrideAnnotationCheckbox = new NonFocusableCheckBox(IdeBundle.message("checkbox.insert.at.override"));
myCheckboxes = new JCheckBox[] {myCopyJavadocCheckbox, myInsertOverrideAnnotationCheckbox};
myOptionControls = new JCheckBox[] {myCopyJavadocCheckbox, myInsertOverrideAnnotationCheckbox};
}
else {
myCheckboxes = new JCheckBox[] {myCopyJavadocCheckbox};
myOptionControls = new JCheckBox[] {myCopyJavadocCheckbox};
}
}
@@ -240,7 +239,7 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
customizeOptionsPanel();
JPanel optionsPanel = new JPanel(new VerticalFlowLayout());
for (final JComponent component : myCheckboxes) {
for (final JComponent component : myOptionControls) {
optionsPanel.add(component);
}
@@ -377,8 +376,8 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
return myTree;
}
public JCheckBox[] getCheckboxes() {
return myCheckboxes;
public JComponent[] getOptionControls() {
return myOptionControls;
}
@Nullable
@@ -174,7 +174,7 @@ public class InspectionProjectProfileManager extends DefaultProjectProfileManage
public void run() {
DaemonCodeAnalyzer.getInstance(myProject).restart();
}
});
}, myProject.getDisposed());
}
};
if (app.isUnitTestMode() || app.isHeadlessEnvironment()) {
@@ -247,7 +247,7 @@ public class Messages {
public static int showCheckboxOkCancelDialog(String message, String title, String checkboxText, final boolean checked,
final int defaultOptionIndex, final int focusedOptionIndex, Icon icon) {
return showCheckboxMessageDialog(message, title, checkboxText, checked, defaultOptionIndex, focusedOptionIndex, icon,
return showCheckboxMessageDialog(message, title, new String[] {OK_BUTTON, CANCEL_BUTTON}, checkboxText, checked, defaultOptionIndex, focusedOptionIndex, icon,
new PairFunction<Integer, JCheckBox, Integer>() {
@Override
public Integer fun(final Integer exitCode, final JCheckBox cb) {
@@ -256,14 +256,14 @@ public class Messages {
});
}
public static int showCheckboxMessageDialog(String message, String title, String checkboxText, final boolean checked,
public static int showCheckboxMessageDialog(String message, String title, String[] options, String checkboxText, final boolean checked,
final int defaultOptionIndex, final int focusedOptionIndex, Icon icon,
@Nullable final PairFunction<Integer, JCheckBox, Integer> exitFunc) {
if (isApplicationInUnitTestOrHeadless()) {
return ourTestImplementation.show(message);
}
else {
TwoStepConfirmationDialog dialog = new TwoStepConfirmationDialog(message, title, checkboxText, checked, defaultOptionIndex,
TwoStepConfirmationDialog dialog = new TwoStepConfirmationDialog(message, title, options, checkboxText, checked, defaultOptionIndex,
focusedOptionIndex, icon, exitFunc);
dialog.show();
return dialog.getExitCode();
@@ -272,7 +272,7 @@ public class Messages {
public static int showTwoStepConfirmationDialog(String message, String title, String checkboxText, Icon icon) {
return showCheckboxMessageDialog(message, title, checkboxText, true, -1, -1, icon, null);
return showCheckboxMessageDialog(message, title, new String[] {OK_BUTTON, CANCEL_BUTTON}, checkboxText, true, -1, -1, icon, null);
}
public static void showErrorDialog(Project project, @Nls String message, @Nls String title) {
@@ -801,13 +801,13 @@ public class Messages {
private boolean myChecked;
private PairFunction<Integer, JCheckBox, Integer> myExitFunc;
public TwoStepConfirmationDialog(String message, String title, String checkboxText, boolean checked, final int defaultOptionInxed,
public TwoStepConfirmationDialog(String message, String title, String[] options, String checkboxText, boolean checked, final int defaultOptionInxed,
final int focusedOptionIndex, Icon icon, @Nullable final PairFunction<Integer, JCheckBox, Integer> exitFunc) {
myCheckboxText = checkboxText;
myChecked = checked;
myExitFunc = exitFunc;
_init(title, message, new String[] {OK_BUTTON, CANCEL_BUTTON}, defaultOptionInxed, focusedOptionIndex, icon, null);
_init(title, message, options, defaultOptionInxed, focusedOptionIndex, icon, null);
}
@Override
@@ -370,7 +370,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible {
if (icon != null) {
final Container parent = getParent();
Color iconBackgroundColor = null;
if (isIconOpaque()) {
if (isOpaque() || isIconOpaque()) {
if (parent != null && !myFocusBorderAroundIcon && !UIUtil.isFullRowSelectionLAF()) {
iconBackgroundColor = parent.getBackground();
}
@@ -389,7 +389,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible {
xOffset += myIpad.left + icon.getIconWidth() + myIconTextGap;
}
if (isOpaque()) {
if (isOpaque() || shouldDrawBackground()) {
// Paint text background
g.setColor(getBackground());
g.fillRect(xOffset, 0, getWidth() - xOffset, getHeight());
@@ -437,7 +437,15 @@ public class SimpleColoredComponent extends JComponent implements Accessible {
final int textBaseline = getTextBaseLine(metrics, getHeight());
if (!attributes.isSearchMatch()) g.drawString(fragment, xOffset, textBaseline);
if (!attributes.isSearchMatch()) {
if (shouldDrawMacShadow()) {
g.setColor(new Color(250, 250, 250, 140));
g.drawString(fragment, xOffset, textBaseline + 1);
}
g.setColor(color);
g.drawString(fragment, xOffset, textBaseline);
}
// 1. Strikeout effect
if (attributes.isStrikeout()) {
@@ -494,11 +502,25 @@ public class SimpleColoredComponent extends JComponent implements Accessible {
for (final Object[] info: searchMatches) {
UIUtil.drawSearchMatch((Graphics2D)g, (Integer) info[0], (Integer) info[1], getHeight());
g.setFont((Font) info[4]);
if (shouldDrawMacShadow()) {
g.setColor(new Color(250, 250, 250, 140));
g.drawString((String) info[3], (Integer) info[0], (Integer) info[2] + 1);
}
g.setColor(new Color(50, 50, 50));
g.drawString((String) info[3], (Integer) info[0], (Integer) info[2]);
}
}
protected boolean shouldDrawMacShadow() {
return false;
}
protected boolean shouldDrawBackground() {
return false;
}
protected void paintIcon(Graphics g, Icon icon) {
icon.paintIcon(this, g, myIpad.left, (getHeight() - icon.getIconHeight()) / 2);
}
@@ -15,8 +15,6 @@
*/
package com.intellij.ui.components.panels;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
import java.awt.*;
@@ -44,7 +42,7 @@ public class OpaquePanel extends JPanel {
}
protected void paintComponent(Graphics g) {
if (myOpaqueActive) {
if (isOpaqueActive()) {
final Color bg = getBackground();
g.setColor(bg);
final Dimension size = getSize();
@@ -65,6 +65,9 @@ public class JBTabsImpl extends JComponent
implements JBTabs, PropertyChangeListener, TimerListener, DataProvider, PopupMenuListener, Disposable, JBTabsPresentation, Queryable, QuickActionProvider {
static DataKey<JBTabsImpl> NAVIGATION_ACTIONS_KEY = DataKey.create("JBTabs");
public static final String EDITOR_TABS = "main.editor.tabs";
public static final Color MAC_AQUA_BG_COLOR = new Color(200, 200, 200);
ActionManager myActionManager;
private final List<TabInfo> myVisibleInfos = new ArrayList<TabInfo>();
@@ -1455,7 +1458,11 @@ public class JBTabsImpl extends JComponent
config.setAntialiasing(true);
g2d.setColor(getBackground());
if (getClientProperty(EDITOR_TABS) != null && UIUtil.isUnderAquaLookAndFeel()) {
g2d.setColor(MAC_AQUA_BG_COLOR);
} else {
g2d.setColor(getBackground());
}
final Rectangle clip = g2d.getClipBounds();
g2d.fillRect(clip.x, clip.y, clip.width, clip.height);
@@ -45,7 +45,7 @@ public class RevealFileAction extends AnAction {
@NotNull
public static String getActionName() {
return SystemInfo.isMac ? "Reveal in Finder" : "Show in " + ShowFilePathAction.getFileExplorerName();
return SystemInfo.isMac ? "Reveal in Finder" : "Show in " + SystemInfo.nativeFileManagerName;
}
@Override
@@ -168,13 +168,6 @@ public class ShowFilePathAction extends AnAction {
return SystemInfo.isWindows || SystemInfo.isMac || SystemInfo.isGnome || SystemInfo.isKDE || Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.OPEN);
}
public static String getFileExplorerName() {
if (SystemInfo.isMac) return "Finder";
if (SystemInfo.isGnome) return "Nautilus";
if (SystemInfo.isKDE) return "Konqueror";
return "Explorer";
}
public static void open(final File ioFile, File toSelect) {
try {
if (SystemInfo.isWindows || SystemInfo.isMac) {
@@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.util.SystemInfo;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -44,7 +45,7 @@ public class ShowLogAction extends AnAction implements DumbAware {
@NotNull
public static String getActionName() {
return "Reveal Log in " + ShowFilePathAction.getFileExplorerName();
return "Reveal Log in " + SystemInfo.nativeFileManagerName;
}
}
@@ -33,10 +33,7 @@ import com.intellij.openapi.keymap.ex.KeymapManagerEx;
import com.intellij.openapi.keymap.ex.WeakKeymapManagerListener;
import com.intellij.openapi.project.DumbAwareRunnable;
import com.intellij.openapi.ui.popup.*;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.*;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.ex.WindowManagerEx;
@@ -123,10 +120,10 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
super(null);
myActionManager = actionManager;
myKeymapManager = keymapManager;
myPlace = place;
setMinimumButtonSize(DEFAULT_MINIMUM_BUTTON_SIZE);
setLayoutPolicy(AUTO_LAYOUT_POLICY);
setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
myPlace = place;
myActionGroup = actionGroup;
myPresentationFactory = new PresentationFactory();
myKeymapManagerListener = new MyKeymapManagerListener();
@@ -158,6 +155,10 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
myActionManager.addTimerListener(500, myWeakTimerListener);
myActionManager.addTransparrentTimerListener(500, myWeakTimerListener);
}
private boolean doMacEnhancementsForMainToolbar() {
return UIUtil.isUnderAquaLookAndFeel() && ActionPlaces.MAIN_TOOLBAR.equals(myPlace);
}
@Override
public void removeNotify() {
@@ -182,7 +183,12 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
protected void paintComponent(final Graphics g) {
super.paintComponent(g);
if (doMacEnhancementsForMainToolbar()) {
final Rectangle r = getBounds();
UIUtil.drawGradientHToolbarBackground(g, r.width, r.height);
} else {
super.paintComponent(g);
}
if (myLayoutPolicy == AUTO_LAYOUT_POLICY) {
if (myAutoPopupRec != null) {
@@ -298,12 +304,14 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
final int width = getWidth();
final int height = getHeight();
final Insets insets = getInsets();
if (myAdjustTheSameSize) {
final int maxWidth = getMaxButtonWidth();
final int maxHeight = getMaxButtonHeight();
if (myOrientation == SwingConstants.HORIZONTAL) {
int xOffset = 0;
int xOffset = insets.left;
for (int i = 0; i < componentCount; i++) {
final Rectangle r = bounds.get(i);
r.setBounds(xOffset, (height - maxHeight) / 2, maxWidth, maxHeight);
@@ -311,7 +319,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
}
else {
int yOffset = 0;
int yOffset = insets.top;
for (int i = 0; i < componentCount; i++) {
final Rectangle r = bounds.get(i);
r.setBounds((width - maxWidth) / 2, yOffset, maxWidth, maxHeight);
@@ -322,8 +330,9 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
else {
if (myOrientation == SwingConstants.HORIZONTAL) {
final int maxHeight = getMaxButtonHeight();
int xOffset = 0;
final int yOffset = 0;
int xOffset = insets.left;
final int yOffset = insets.top;
for (int i = 0; i < componentCount; i++) {
final Component component = getComponent(i);
final Dimension d = component.getPreferredSize();
@@ -334,8 +343,8 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
else {
final int maxWidth = getMaxButtonWidth();
final int xOffset = 0;
int yOffset = 0;
final int xOffset = insets.left;
int yOffset = insets.top;
for (int i = 0; i < componentCount; i++) {
final Component component = getComponent(i);
final Dimension d = component.getPreferredSize();
@@ -360,9 +369,11 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
int autoButtonSize = myAutoPopupIcon.getIconWidth();
boolean full = false;
final Insets insets = getInsets();
if (myOrientation == SwingConstants.HORIZONTAL) {
int eachX = 0;
int eachY = 0;
int eachX = insets.left;
int eachY = insets.top;
int maxHeight = 0;
for (int i = 0; i < componentCount; i++) {
final Component eachComp = getComponent(i);
@@ -420,8 +431,8 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
else {
int eachX = 0;
int eachY = 0;
int eachX = insets.left;
int eachY = insets.top;
for (int i = 0; i < componentCount; i++) {
final Rectangle eachBound = new Rectangle(getComponent(i).getPreferredSize());
if (!full) {
@@ -475,19 +486,21 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
final int componentCount = getComponentCount();
LOG.assertTrue(componentCount <= bounds.size());
final Insets insets = getInsets();
if (myAdjustTheSameSize) {
if (myOrientation == SwingConstants.HORIZONTAL) {
final int maxWidth = getMaxButtonWidth();
final int maxHeight = getMaxButtonHeight();
// Lay components out
int xOffset = 0;
int yOffset = 0;
int xOffset = insets.left;
int yOffset = insets.top;
// Calculate max size of a row. It's not possible to make more then 3 row toolbar
final int maxRowWidth = Math.max(sizeToFit.width, componentCount * maxWidth / 3);
for (int i = 0; i < componentCount; i++) {
if (xOffset + maxWidth > maxRowWidth) { // place component at new row
xOffset = 0;
xOffset = insets.left;
yOffset += maxHeight;
}
@@ -502,13 +515,13 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
final int maxHeight = getMaxButtonHeight();
// Lay components out
int xOffset = 0;
int yOffset = 0;
int xOffset = insets.left;
int yOffset = insets.top;
// Calculate max size of a row. It's not possible to make more then 3 column toolbar
final int maxRowHeight = Math.max(sizeToFit.height, componentCount * myMinimumButtonSize.height / 3);
for (int i = 0; i < componentCount; i++) {
if (yOffset + maxHeight > maxRowHeight) { // place component at new row
yOffset = 0;
yOffset = insets.top;
xOffset += maxWidth;
}
@@ -531,14 +544,14 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
// Lay components out
int xOffset = 0;
int yOffset = 0;
int xOffset = insets.left;
int yOffset = insets.top;
// Calculate max size of a row. It's not possible to make more then 3 row toolbar
final int maxRowWidth = Math.max(getWidth(), componentCount * myMinimumButtonSize.width / 3);
for (int i = 0; i < componentCount; i++) {
final Dimension d = dims[i];
if (xOffset + d.width > maxRowWidth) { // place component at new row
xOffset = 0;
xOffset = insets.left;
yOffset += rowHeight;
}
@@ -559,14 +572,14 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
// Lay components out
int xOffset = 0;
int yOffset = 0;
int xOffset = insets.left;
int yOffset = insets.top;
// Calculate max size of a row. It's not possible to make more then 3 column toolbar
final int maxRowHeight = Math.max(getHeight(), componentCount * myMinimumButtonSize.height / 3);
for (int i = 0; i < componentCount; i++) {
final Dimension d = dims[i];
if (yOffset + d.height > maxRowHeight) { // place component at new row
yOffset = 0;
yOffset = insets.top;
xOffset += rowWidth;
}
@@ -629,7 +642,9 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
}
return dimension;
final Insets i = getInsets();
return new Dimension(dimension.width + i.left + i.right, dimension.height + i.top + i.bottom);
}
public Dimension getMinimumSize() {
@@ -658,13 +673,25 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
protected void paintComponent(final Graphics g) {
g.setColor(UIUtil.getSeparatorShadow());
if (getParent() != null) {
if (myOrientation == SwingConstants.HORIZONTAL) {
UIUtil.drawLine(g, 3, 2, 3, getParent().getSize().height - 2);
final Insets insets = getInsets();
if (UIUtil.isUnderAquaLookAndFeel()) {
if (getParent() != null) {
if (myOrientation == SwingConstants.HORIZONTAL) {
UIUtil.drawDoubleSpaceDottedLine((Graphics2D)g, insets.top + 2, getParent().getSize().height - 2 - insets.top - insets.bottom, 3, Color.GRAY, false);
} else {
UIUtil.drawDoubleSpaceDottedLine((Graphics2D)g, insets.left + 2, getParent().getSize().width - 2 - insets.left - insets.right, 3, Color.GRAY, true);
}
}
else {
UIUtil.drawLine(g, 2, 3, getParent().getSize().width - 2, 3);
}
else {
g.setColor(UIUtil.getSeparatorShadow());
if (getParent() != null) {
if (myOrientation == SwingConstants.HORIZONTAL) {
UIUtil.drawLine(g, 3, 2, 3, getParent().getSize().height - 2);
}
else {
UIUtil.drawLine(g, 2, 3, getParent().getSize().width - 2, 3);
}
}
}
}
@@ -29,22 +29,59 @@ public class IdeaActionButtonLook extends ActionButtonLook {
public void paintBackground(Graphics g, JComponent component, int state) {
Dimension dimension = component.getSize();
if (state != ActionButtonComponent.NORMAL) {
if (state == ActionButtonComponent.POPPED) {
g.setColor(new Color(181, 190, 214));
g.fillRect(0, 0, dimension.width, dimension.height);
if (!UIUtil.isUnderAquaLookAndFeel()) {
if (state == ActionButtonComponent.POPPED) {
g.setColor(new Color(181, 190, 214));
g.fillRect(0, 0, dimension.width, dimension.height);
}
else {
g.setColor(new Color(130, 146, 185));
g.fillRect(0, 0, dimension.width, dimension.height);
}
}
}
if (state == ActionButtonComponent.PUSHED) {
if (UIUtil.isUnderAquaLookAndFeel()) {
((Graphics2D)g).setPaint(new GradientPaint(0, 0, new Color(0, 0, 0, 40), dimension.width, dimension.height, new Color(0, 0, 0, 20)));
g.fillRect(0, 0, dimension.width - 1, dimension.height - 1);
g.setColor(new Color(0, 0, 0, 120));
g.drawLine(0, 0, 0, dimension.height - 2);
g.drawLine(1, 0, dimension.width - 2, 0);
g.setColor(new Color(0, 0, 0, 30));
g.drawRect(1, 1, dimension.width - 3, dimension.height - 3);
/*
final Graphics2D g2d = (Graphics2D)g;
final int x = 1;
g2d.setPaint(new LinearGradientPaint(0, 0, 0, dimension.height, new float[] {0f, 0.5f, 1.0f},
new Color[] {new Color(0, 0, 0, 0), new Color(0, 0, 0, 40), new Color(0, 0, 0, 0)}));
g2d.fillRect(x, 0, dimension.width - 2, dimension.height);
g2d.setPaint(new LinearGradientPaint(0, 0, 0, dimension.height, new float[] {0f, 0.5f, 1.0f},
new Color[] {new Color(0, 0, 0, 40), new Color(0, 0, 0, 150), new Color(0, 0, 0, 40)}));
g2d.drawLine(x, 0, x, dimension.height);
g2d.drawLine(dimension.width - 2, 0, dimension.width - 2, dimension.height);
g2d.setPaint(new LinearGradientPaint(0, 0, 0, dimension.height, new float[] {0f, 0.5f, 1.0f},
new Color[] {new Color(0, 0, 0, 0), new Color(0, 0, 0, 60), new Color(0, 0, 0, 0)}));
g2d.drawLine(x + 1, 0, x + 1, dimension.height);
g2d.drawLine(dimension.width - 3, 0, dimension.width - 3, dimension.height);
*/
}
else {
g.setColor(new Color(130, 146, 185));
g.fillRect(0, 0, dimension.width, dimension.height);
}
}
if (state == ActionButtonComponent.PUSHED) {
g.setColor(new Color(130, 146, 185));
g.fillRect(0, 0, dimension.width, dimension.height);
}
}
public void paintBorder(Graphics g, JComponent component, int state) {
if (UIUtil.isUnderAquaLookAndFeel()) return;
if (state == ActionButtonComponent.NORMAL) return;
Rectangle rectangle = new Rectangle(component.getWidth(), component.getHeight());
Color color = new Color(8, 36, 107);
@@ -66,7 +103,7 @@ public class IdeaActionButtonLook extends ActionButtonLook {
}
public void paintIconAt(Graphics g, ActionButtonComponent button, Icon icon, int x, int y) {
if (button.getPopState() == ActionButtonComponent.PUSHED) {
if (button.getPopState() == ActionButtonComponent.PUSHED && !UIUtil.isUnderAquaLookAndFeel()) {
x++;
y++;
}
@@ -24,7 +24,6 @@ import com.intellij.ide.ui.customization.CustomActionsSchema;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.CommandProcessorEx;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileEditor.FileEditor;
@@ -81,6 +80,7 @@ final class EditorTabbedContainer implements Disposable, CloseAction.CloseTarget
myDockManager = dockManager;
final ActionManager actionManager = ActionManager.getInstance();
myTabs = new JBTabsImpl(project, actionManager, IdeFocusManager.getInstance(project), this);
((JBTabsImpl)myTabs).putClientProperty(JBTabsImpl.EDITOR_TABS, Boolean.TRUE);
myTabs.setDataProvider(new MyDataProvider()).setPopupGroup(new Getter<ActionGroup>() {
public ActionGroup get() {
return (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_EDITOR_TAB_POPUP);
@@ -15,6 +15,8 @@
*/
package com.intellij.openapi.fileEditor.impl;
import com.intellij.openapi.actionSystem.KeyboardShortcut;
import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileEditor.FileEditor;
@@ -22,15 +24,14 @@ import com.intellij.openapi.fileEditor.FileEditorProvider;
import com.intellij.openapi.fileEditor.FileEditorState;
import com.intellij.openapi.fileEditor.FileEditorStateLevel;
import com.intellij.openapi.fileEditor.impl.text.FileDropHandler;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.*;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.FocusWatcher;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.IdeFrame;
import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy;
import com.intellij.openapi.wm.ex.WindowManagerEx;
@@ -38,10 +39,13 @@ import com.intellij.openapi.wm.impl.FrameTitleBuilder;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.docking.DockManager;
import com.intellij.ui.tabs.JBTabs;
import com.intellij.ui.tabs.impl.JBTabsImpl;
import com.intellij.util.Alarm;
import com.intellij.util.ArrayUtil;
import com.intellij.util.PairFunction;
import com.intellij.util.containers.ArrayListSet;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -72,7 +76,7 @@ public class EditorsSplitters extends JPanel {
public EditorsSplitters(final FileEditorManagerImpl manager, DockManager dockManager, boolean createOwnDockableContainer) {
super(new BorderLayout());
setOpaque(true);
setBackground(Color.GRAY);
setBackground(UIUtil.isUnderAquaLookAndFeel() ? JBTabsImpl.MAC_AQUA_BG_COLOR : Color.GRAY);
myManager = manager;
myFocusWatcher = new MyFocusWatcher();
setFocusTraversalPolicy(new MyFocusTraversalPolicy());
@@ -119,6 +123,48 @@ public class EditorsSplitters extends JPanel {
return null;
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (myCurrentWindow == null || myCurrentWindow.getFiles().length == 0) {
final boolean aquaLookAndFeel = UIUtil.isUnderAquaLookAndFeel();
UIUtil.applyRenderingHints(g);
g.setColor(aquaLookAndFeel ? new Color(100, 100, 100) : Color.LIGHT_GRAY);
g.setFont(UIUtil.getLabelFont().deriveFont(aquaLookAndFeel ? 17f : 19f));
final UIUtil.TextPainter painter = new UIUtil.TextPainter(1.3f);
painter.appendLine("No files are open").underlined(aquaLookAndFeel ? new Color(150, 150, 150) : Color.LIGHT_GRAY)
.appendLine("\u2022 Open Project Navigator with " +
KeymapUtil.getShortcutText(new KeyboardShortcut(KeyStroke.getKeyStroke("meta 1"), null))).smaller()
.appendLine("\u2022 Open Recent files with " + getActionShortcutText("RecentFiles")).smaller()
.appendLine("\u2022 Open NavBar with " + getActionShortcutText("ShowNavBar")).smaller()
.appendLine("\u2022 Drag'n'Drop file(s) here from " + SystemInfo.nativeFileManagerName).smaller().draw(g,
new PairFunction<Integer, Integer, Pair<Integer, Integer>>() {
@Override
public Pair<Integer, Integer> fun(
Integer width,
Integer height) {
final Dimension s = getSize();
return Pair.create((s.width - width) / 2,
(s.height - height) / 5);
}
});
}
}
private static String getActionShortcutText(final String actionId) {
final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionId);
String shortcutText = "";
for (final Shortcut shortcut : shortcuts) {
if (shortcut instanceof KeyboardShortcut) {
shortcutText = KeymapUtil.getShortcutText(shortcut);
break;
}
}
return shortcutText;
}
public void writeExternal(final Element element) {
if (getComponentCount() != 0) {
@@ -60,6 +60,7 @@ import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.ex.StatusBarEx;
import com.intellij.ui.docking.DockContainer;
import com.intellij.ui.docking.DockManager;
import com.intellij.ui.tabs.impl.JBTabsImpl;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.messages.impl.MessageListenerList;
@@ -221,6 +222,13 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
private class MyBorder implements Border {
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
if (UIUtil.isUnderAquaLookAndFeel()) {
g.setColor(JBTabsImpl.MAC_AQUA_BG_COLOR);
final Insets insets = getBorderInsets(c);
if (insets.top > 0) {
g.fillRect(x, y, width, height + insets.top);
}
}
}
@Override
@@ -42,6 +42,7 @@ import com.intellij.ui.awt.RelativeRectangle;
import com.intellij.ui.components.panels.NonOpaquePanel;
import com.intellij.ui.components.panels.VerticalBox;
import com.intellij.ui.docking.*;
import com.intellij.ui.tabs.impl.JBTabsImpl;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.update.UiNotifyConnector;
import org.jdom.Element;
@@ -416,6 +417,11 @@ public class DockManagerImpl extends DockManager implements PersistentStateCompo
myUiContainer = new NonOpaquePanel(new BorderLayout());
NonOpaquePanel center = new NonOpaquePanel(new BorderLayout(0, 2));
if (UIUtil.isUnderAquaLookAndFeel()) {
center.setOpaque(true);
center.setBackground(JBTabsImpl.MAC_AQUA_BG_COLOR);
}
center.add(myNorthPanel, BorderLayout.NORTH);
myDockContentUiContainer = new NonOpaquePanel(new BorderLayout());
@@ -917,12 +917,10 @@
<action id="Console.Hibernate.GenerateSql"><keyboard-shortcut first-keystroke="control shift ENTER"/></action>
<action id="Console.Hibernate.GenerateDDL"><keyboard-shortcut first-keystroke="control alt shift ENTER"/></action>
<action id="Console.Hibernate.Properties"><keyboard-shortcut first-keystroke="control alt ENTER"/></action>
<action id="Console.Hibernate.Close"><keyboard-shortcut first-keystroke="control alt shift F4"/></action>
<action id="Console.Hibernate.Terminate"><keyboard-shortcut first-keystroke="control alt shift DELETE"/></action>
<action id="Console.Jpa.Execute"><keyboard-shortcut first-keystroke="control ENTER"/></action>
<action id="Console.Jpa.Properties"><keyboard-shortcut first-keystroke="control alt ENTER"/></action>
<action id="Console.Jpa.Close"><keyboard-shortcut first-keystroke="control alt shift F4"/></action>
<action id="Console.Jpa.Terminate"><keyboard-shortcut first-keystroke="control alt shift DELETE"/></action>
<action id="Jdbc.RunSqlScript"><keyboard-shortcut first-keystroke="control shift F10"/></action>
@@ -25,8 +25,5 @@
<action id="RunAPT">
<keyboard-shortcut first-keystroke="control alt shift 9"/>
</action>
<action id="Console.Hibernate.Close"/>
<action id="Console.Jpa.Close"/>
</keymap>
</component>
@@ -37,7 +37,9 @@ import com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.testIntegration.TestLocationProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Roman Chernyatchik
@@ -80,11 +82,11 @@ public class SMTestRunnerConnectionUtil {
return console;
}
public static BaseTestsOutputConsoleView createConsole(@NotNull final String testFrameworkName,
@NotNull final TestConsoleProperties consoleProperties,
final RunnerSettings runnerSettings,
final ConfigurationPerRunnerSettings configurationSettings) {
public static BaseTestsOutputConsoleView createConsoleWithCustomLocator(@NotNull final String testFrameworkName,
@NotNull final TestConsoleProperties consoleProperties,
final RunnerSettings runnerSettings,
final ConfigurationPerRunnerSettings configurationSettings,
@Nullable final TestLocationProvider locator) {
// Console
final String splitterPropertyName = testFrameworkName + ".Splitter.Proportion";
final SMTRunnerConsoleView console =
@@ -95,13 +97,20 @@ public class SMTestRunnerConnectionUtil {
super.attachToProcess(processHandler);
attachEventsProcessors(consoleProperties, getResultsViewer(),
getResultsViewer().getStatisticsPane(),
processHandler, testFrameworkName);
processHandler, testFrameworkName, locator);
}
};
console.setHelpId("reference.runToolWindow.testResultsTab");
console.initUI();
return console;
}
public static BaseTestsOutputConsoleView createConsole(@NotNull final String testFrameworkName,
@NotNull final TestConsoleProperties consoleProperties,
final RunnerSettings runnerSettings,
final ConfigurationPerRunnerSettings configurationSettings) {
return createConsoleWithCustomLocator(testFrameworkName, consoleProperties, runnerSettings, configurationSettings, null);
}
/**
* Creates Test Runner console component with test tree, console, statistics tabs
@@ -176,7 +185,8 @@ public class SMTestRunnerConnectionUtil {
final SMTestRunnerResultsForm resultsViewer,
final StatisticsPanel statisticsPane,
final ProcessHandler processHandler,
@NotNull final String testFrameworkName) {
@NotNull final String testFrameworkName,
@Nullable final TestLocationProvider locator) {
//build messages consumer
final OutputToGeneralTestEventsConverter outputConsumer = consoleProperties instanceof SMCustomMessagesParsing
? ((SMCustomMessagesParsing)consoleProperties).createTestEventsConverter(testFrameworkName, consoleProperties)
@@ -185,6 +195,9 @@ public class SMTestRunnerConnectionUtil {
//events processor
final GeneralToSMTRunnerEventsConvertor eventsProcessor = new GeneralToSMTRunnerEventsConvertor(resultsViewer.getTestsRootNode(),
testFrameworkName);
if (locator != null) {
eventsProcessor.setLocator(locator);
}
// ui actions
final SMTRunnerUIActionsHandler uiActionsHandler = new SMTRunnerUIActionsHandler(consoleProperties);
@@ -23,6 +23,7 @@ import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Key;
import com.intellij.testIntegration.TestLocationProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
@@ -46,6 +47,7 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
private final SMTestProxy.SMRootTestProxy myTestsRootNode;
private final String myTestFrameworkName;
private boolean myIsTestingFinished;
private TestLocationProvider myLocator = null;
public GeneralToSMTRunnerEventsConvertor(@NotNull final SMTestProxy.SMRootTestProxy testsRootNode,
@NotNull final String testFrameworkName) {
@@ -53,6 +55,10 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
myTestFrameworkName = testFrameworkName;
}
public void setLocator(TestLocationProvider customLocator) {
myLocator = customLocator;
}
public void addEventsListener(final SMTRunnerEventsListener listener) {
myEventsListeners.add(listener);
}
@@ -124,6 +130,9 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
// creates test
final SMTestProxy testProxy = new SMTestProxy(testName, false, locationUrl);
if (myLocator != null) {
testProxy.setLocator(myLocator);
}
parentSuite.addChild(testProxy);
// adds to running tests map
myRunningTestsFullNameToProxy.put(fullName, testProxy);
@@ -143,6 +152,9 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce
final SMTestProxy parentSuite = getCurrentSuite();
//new suite
final SMTestProxy newSuite = new SMTestProxy(suiteName, true, locationUrl);
if (myLocator != null) {
newSuite.setLocator(myLocator);
}
parentSuite.addChild(newSuite);
mySuitesStack.pushSuite(newSuite);
@@ -16,7 +16,10 @@
package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.Location;
import com.intellij.execution.testframework.*;
import com.intellij.execution.testframework.AbstractTestProxy;
import com.intellij.execution.testframework.Filter;
import com.intellij.execution.testframework.Printable;
import com.intellij.execution.testframework.Printer;
import com.intellij.execution.testframework.sm.TestsLocationProviderUtil;
import com.intellij.execution.testframework.sm.runner.states.*;
import com.intellij.execution.testframework.sm.runner.ui.TestsPresentationUtil;
@@ -55,6 +58,7 @@ public class SMTestProxy extends AbstractTestProxy {
private final boolean myIsSuite;
private boolean myIsEmptyIsCached = false; // is used for separating unknown and unset values
private boolean myIsEmpty = true;
TestLocationProvider myLocator = null;
public SMTestProxy(final String testName, final boolean isSuite,
@Nullable final String locationUrl) {
@@ -63,6 +67,10 @@ public class SMTestProxy extends AbstractTestProxy {
myLocationUrl = locationUrl;
}
public void setLocator(@NotNull TestLocationProvider locator) {
myLocator = locator;
}
public boolean isInProgress() {
//final SMTestProxy parent = getParent();
@@ -172,6 +180,12 @@ public class SMTestProxy extends AbstractTestProxy {
final String path = TestsLocationProviderUtil.extractPath(myLocationUrl);
if (protocolId != null && path != null) {
if (myLocator != null) {
List<Location> locations = myLocator.getLocation(protocolId, path, project);
if (!locations.isEmpty()) {
return locations.iterator().next();
}
}
for (TestLocationProvider provider : Extensions.getExtensions(TestLocationProvider.EP_NAME)) {
final List<Location> locations = provider.getLocation(protocolId, path, project);
if (!locations.isEmpty()) {
@@ -55,6 +55,8 @@ public class SystemInfo {
public static final boolean isMacIntel64 = isMac && "x86_64".equals(OS_ARCH);
public static final String nativeFileManagerName = isMac ? "Finder" : isGnome ? "Nautilus" : isKDE ? "Konqueror" : "Explorer";
/**
* Whether IDEA is running under MacOS X version 10.4 or later.
*
@@ -17,15 +17,15 @@ package com.intellij.util.ui;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.ColorUtil;
import com.intellij.ui.SideBorder;
import com.intellij.util.ArrayUtil;
import com.intellij.util.PairFunction;
import com.intellij.util.Processor;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.containers.ContainerUtil;
import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -877,6 +877,31 @@ public class UIUtil {
// restore color
g.setColor(oldColor);
}
public static void drawGradientHToolbarBackground(final Graphics g, final int width, final int height) {
final Graphics2D g2d = (Graphics2D)g;
final GradientPaint gradientPaint = new GradientPaint(0, 0, new Color(220, 220, 220), 0, height, new Color(200, 200, 200));
g2d.setPaint(gradientPaint);
g2d.fillRect(0, 0, width, height);
}
public static void drawDoubleSpaceDottedLine(final Graphics2D g,
final int start,
final int end,
final int xOrY,
final Color fgColor,
boolean horizontal) {
g.setColor(fgColor);
for (int dot = start; dot < end; dot+=3) {
if (horizontal) {
g.drawLine(dot, xOrY, dot, xOrY);
} else {
g.drawLine(xOrY, dot, xOrY, dot);
}
}
}
private static void drawAppleDottedLine(final Graphics2D g,
final int startX,
@@ -1923,6 +1948,168 @@ public class UIUtil {
}
return null;
}
public static class TextPainter {
private List<Pair<String, LineInfo>> myLines = new ArrayList<Pair<String, LineInfo>>();
private boolean myDrawMacShadow;
private Color myMacShadowColor;
private float myLineSpacing;
public TextPainter() {
this(true, new Color(220, 220, 220), 1.0f);
}
public TextPainter(final float lineSpacing) {
this(true, new Color(220, 220, 220), lineSpacing);
}
public TextPainter(final boolean drawMacShadow, final Color shadowColor, final float lineSpacing) {
myDrawMacShadow = drawMacShadow;
myMacShadowColor = shadowColor;
myLineSpacing = lineSpacing;
}
public TextPainter appendLine(final String text) {
if (text == null || text.length() == 0) return this;
myLines.add(Pair.create(text, new LineInfo()));
return this;
}
public TextPainter underlined(final Color color) {
if (myLines.size() > 0) {
final LineInfo info = myLines.get(myLines.size() - 1).getSecond();
info.underlined = true;
info.underlineColor = color;
}
return this;
}
public TextPainter underlined() {
if (myLines.size() > 0) {
myLines.get(myLines.size() - 1).getSecond().underlined = true;
}
return this;
}
public TextPainter smaller() {
if (myLines.size() > 0) {
myLines.get(myLines.size() - 1).getSecond().smaller = true;
}
return this;
}
public TextPainter center() {
if (myLines.size() > 0) {
myLines.get(myLines.size() - 1).getSecond().center = true;
}
return this;
}
/**
* _position(block width, block height) => (x, y) of the block
*/
public void draw(@NotNull final Graphics g, final PairFunction<Integer, Integer, Pair<Integer, Integer>> _position) {
final int[] maxWidth = new int[] {0};
final int[] height = new int[] {0};
ContainerUtil.process(myLines, new Processor<Pair<String, LineInfo>>() {
@Override
public boolean process(final Pair<String, LineInfo> pair) {
final LineInfo info = pair.getSecond();
Font old = null;
if (info.smaller) {
old = g.getFont();
g.setFont(old.deriveFont(old.getSize() * 0.75f));
}
final FontMetrics fm = g.getFontMetrics();
maxWidth[0] = Math.max(fm.stringWidth(pair.getFirst()), maxWidth[0]);
height[0] += (fm.getHeight() + fm.getLeading()) * myLineSpacing;
if (old != null) {
g.setFont(old);
}
return true;
}
});
final Pair<Integer, Integer> position = _position.fun(maxWidth[0], height[0]);
assert position != null;
final int[] yOffset = new int[] {position.getSecond()};
ContainerUtil.process(myLines, new Processor<Pair<String, LineInfo>>() {
@Override
public boolean process(final Pair<String, LineInfo> pair) {
final LineInfo info = pair.getSecond();
Font old = null;
if (info.smaller) {
old = g.getFont();
g.setFont(old.deriveFont(old.getSize() * 0.75f));
}
final int x = position.getFirst();
final FontMetrics fm = g.getFontMetrics();
int xOffset = x;
if (info.center) {
xOffset = x + (maxWidth[0] - fm.stringWidth(pair.getFirst())) / 2;
}
if (myDrawMacShadow && UIUtil.isUnderAquaLookAndFeel()) {
final Color oldColor = g.getColor();
g.setColor(myMacShadowColor);
g.drawString(pair.getFirst(), xOffset, yOffset[0] + 1);
g.setColor(oldColor);
}
g.drawString(pair.getFirst(), xOffset, yOffset[0]);
Color c = null;
if (info.underlined) {
if (info.underlineColor != null) {
c = g.getColor();
g.setColor(info.underlineColor);
}
g.drawLine(x, yOffset[0] + fm.getDescent(), x + maxWidth[0], yOffset[0] + fm.getDescent());
if (c != null) {
g.setColor(c);
c = null;
}
if (myDrawMacShadow && UIUtil.isUnderAquaLookAndFeel()) {
c = g.getColor();
g.setColor(myMacShadowColor);
g.drawLine(x, yOffset[0] + fm.getDescent() + 1, x + maxWidth[0], yOffset[0] + fm.getDescent() + 1);
g.setColor(c);
c = null;
}
}
yOffset[0] += (fm.getHeight() + fm.getLeading()) * myLineSpacing;
if (old != null) {
g.setFont(old);
}
return true;
}
});
}
private static class LineInfo {
boolean underlined;
Color underlineColor;
boolean smaller;
public boolean center;
}
}
public static JRootPane getRootPane(Component c) {
JRootPane root = getParentOfType(JRootPane.class, c);
@@ -221,6 +221,7 @@ public abstract class ProjectLevelVcsManager {
*/
public abstract boolean isBackgroundVcsOperationRunning();
public abstract List<VirtualFile> getRootsUnderVcsWithoutFiltering(final AbstractVcs vcs);
public abstract VirtualFile[] getRootsUnderVcs(AbstractVcs vcs);
/**
@@ -17,21 +17,18 @@ import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
import org.jetbrains.annotations.NonNls;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.Locale;
import java.util.*;
/**
* @author irengrig
*/
public class DateChangeListGroupingStrategy implements ChangeListGroupingStrategy {
@NonNls private final SimpleDateFormat myWeekdayFormat = new SimpleDateFormat("EEEE", Locale.ENGLISH);
@NonNls private final SimpleDateFormat myMonthFormat = new SimpleDateFormat("MMMM", Locale.ENGLISH);
@NonNls private final SimpleDateFormat myMonthYearFormat = new SimpleDateFormat("MMMM yyyy", Locale.ENGLISH);
private long myTimeToRecalculateAfter;
private Calendar myCurrentCalendar;
private Calendar myCalendar;
private final WeekDayFormatCache myWeekDayFormatCache;
private final MonthsCache myMonthsCache;
public String toString() {
return VcsBundle.message("date.group.title");
@@ -41,9 +38,15 @@ public class DateChangeListGroupingStrategy implements ChangeListGroupingStrateg
return System.currentTimeMillis() > myTimeToRecalculateAfter;
}
public DateChangeListGroupingStrategy() {
myCalendar = Calendar.getInstance();
myWeekDayFormatCache = new WeekDayFormatCache(myCalendar);
myMonthsCache = new MonthsCache(myCalendar);
}
public void beforeStart() {
myCurrentCalendar = Calendar.getInstance();
myCalendar = Calendar.getInstance();
myCurrentCalendar.setTimeInMillis(0);
// +- seconds etc
myCurrentCalendar.set(Calendar.HOUR, 0);
myCurrentCalendar.set(Calendar.MINUTE, 0);
@@ -64,12 +67,12 @@ public class DateChangeListGroupingStrategy implements ChangeListGroupingStrateg
return VcsBundle.message("date.group.today");
}
if (myCurrentCalendar.get(Calendar.WEEK_OF_YEAR) == myCalendar.get(Calendar.WEEK_OF_YEAR)) {
return myWeekdayFormat.format(date);
return myWeekDayFormatCache.get(myCalendar.get(Calendar.DAY_OF_WEEK));
}
if (myCurrentCalendar.get(Calendar.WEEK_OF_YEAR) == myCalendar.get(Calendar.WEEK_OF_YEAR)+1) {
return VcsBundle.message("date.group.last.week");
}
return myMonthFormat.format(date);
return myMonthsCache.get(myCalendar.get(Calendar.MONTH));
}
return myMonthYearFormat.format(date);
}
@@ -81,4 +84,38 @@ public class DateChangeListGroupingStrategy implements ChangeListGroupingStrateg
}
};
}
private static class MonthsCache {
@NonNls private final SimpleDateFormat myMonthFormat = new SimpleDateFormat("MMMM", Locale.ENGLISH);
private final Map<Integer, String> myCache;
private MonthsCache(final Calendar calendarForInit) {
myCache = new HashMap<Integer, String>();
for (int i = 0; i < 12; i++) {
calendarForInit.set(Calendar.MONTH, i);
myCache.put(i, myMonthFormat.format(calendarForInit.getTime()));
}
}
public String get(final int month) {
return myCache.get(month);
}
}
private static class WeekDayFormatCache {
@NonNls private final SimpleDateFormat myWeekdayFormat = new SimpleDateFormat("EEEE", Locale.ENGLISH);
private final Map<Integer, String> myCache;
private WeekDayFormatCache(final Calendar calendarForInit) {
myCache = new HashMap<Integer, String>();
for (int i = 1; i < 8; i++) {
calendarForInit.set(Calendar.DAY_OF_WEEK, i);
myCache.put(i, myWeekdayFormat.format(calendarForInit.getTime()));
}
}
public String get(final int dayOfWeek) {
return myCache.get(dayOfWeek);
}
}
}
@@ -557,6 +557,10 @@ public void addMessageToConsoleWindow(final String message, final TextAttributes
return myBackgroundOperationCounter > 0;
}
public List<VirtualFile> getRootsUnderVcsWithoutFiltering(final AbstractVcs vcs) {
return myMappings.getMappingsAsFilesUnderVcs(vcs);
}
public VirtualFile[] getRootsUnderVcs(AbstractVcs vcs) {
return myMappingsToRoots.getRootsUnderVcs(vcs);
}
@@ -70,11 +70,6 @@ public class MappingsToRoots {
// same as above, but no compression
List<VirtualFile> result = myMappings.getMappingsAsFilesUnderVcs(vcs);
final AbstractVcs.RootsConvertor convertor = vcs.getCustomConvertor();
if (convertor != null) {
result = convertor.convertRoots(result);
}
boolean addInnerModules = true;
final String vcsName = vcs.getName();
final List<VcsDirectoryMapping> directoryMappings = myMappings.getDirectoryMappings(vcsName);
@@ -253,7 +253,7 @@ public class NewMappings {
return FileUtil.startsWith(systemIndependPath, mapping.systemIndependentPath());
}
List<VirtualFile> getMappingsAsFilesUnderVcs(final AbstractVcs vcs) {
public List<VirtualFile> getMappingsAsFilesUnderVcs(final AbstractVcs vcs) {
final List<VirtualFile> result = new ArrayList<VirtualFile>();
final String vcsName = vcs.getName();
@@ -140,7 +140,7 @@ public class GroovyPropertyUtils {
}
@NotNull
public static PsiMethod[] getAllSetters(PsiClass aClass, String propertyName, boolean isStatic, boolean checkSuperClasses) {
public static PsiMethod[] getAllSetters(PsiClass aClass, @NotNull String propertyName, boolean isStatic, boolean checkSuperClasses) {
if (aClass == null) return PsiMethod.EMPTY_ARRAY;
PsiMethod[] methods;
if (checkSuperClasses) {
@@ -1193,7 +1193,7 @@ public class PsiUtil {
return context;
}
public static String getAnnoAttributeValue(PsiAnnotation annotation, final String attributeName, String defaultValue) {
public static String getAnnoAttributeValue(@NotNull PsiAnnotation annotation, final String attributeName, String defaultValue) {
PsiAnnotationMemberValue value = annotation.findAttributeValue(attributeName);
if (value instanceof GrExpression) {
Object o = GroovyConstantExpressionEvaluator.evaluate((GrExpression)value);
@@ -1204,7 +1204,7 @@ public class PsiUtil {
return defaultValue;
}
public static boolean getAnnoAttributeValue(PsiAnnotation annotation, final String attributeName, boolean defaultValue) {
public static boolean getAnnoAttributeValue(@NotNull PsiAnnotation annotation, final String attributeName, boolean defaultValue) {
PsiAnnotationMemberValue value = annotation.findAttributeValue(attributeName);
if (value instanceof GrExpression) {
Object o = GroovyConstantExpressionEvaluator.evaluate((GrExpression)value);
@@ -56,7 +56,8 @@ public class ConstructorAnnotationsProcessor extends NonCodeMembersContributor {
final PsiAnnotation tupleConstructor = modifierList.findAnnotation(GroovyCommonClassNames.GROOVY_TRANSFORM_TUPLE_CONSTRUCTOR);
final boolean immutable = modifierList.findAnnotation(GroovyImmutableAnnotationInspection.IMMUTABLE) != null ||
modifierList.findAnnotation(GroovyCommonClassNames.GROOVY_TRANSFORM_IMMUTABLE) != null;
if (!immutable && modifierList.findAnnotation(GroovyCommonClassNames.GROOVY_TRANSFORM_CANONICAL) == null && tupleConstructor == null) {
final PsiAnnotation canonical = modifierList.findAnnotation(GroovyCommonClassNames.GROOVY_TRANSFORM_CANONICAL);
if (!immutable && canonical == null && tupleConstructor == null) {
return;
}
@@ -92,15 +93,15 @@ public class ConstructorAnnotationsProcessor extends NonCodeMembersContributor {
addParameters(typeDefinition, fieldsConstructor,
tupleConstructor == null || PsiUtil.getAnnoAttributeValue(tupleConstructor, "includeProperties", true),
tupleConstructor == null || PsiUtil.getAnnoAttributeValue(tupleConstructor, "includeFields", false),
tupleConstructor != null ? PsiUtil.getAnnoAttributeValue(tupleConstructor, "includeFields", false) : canonical == null,
!immutable, excludes);
if (!processor.execute(fieldsConstructor, ResolveState.initial())) return;
if (!processor.execute(fieldsConstructor, state)) return;
final LightMethodBuilder defaultConstructor = new LightMethodBuilder(psiClass, GroovyFileType.GROOVY_LANGUAGE);
defaultConstructor.setConstructor(true);
processor.execute(defaultConstructor, ResolveState.initial());
processor.execute(defaultConstructor, state);
}
private static void addParametersForSuper(@NotNull PsiClass typeDefinition,
@@ -390,6 +390,11 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase {
doTest(new GroovyAssignabilityCheckInspection());
}
public void testCanonicalConstructorApplicability() throws Exception {
myFixture.addClass("package groovy.transform; public @interface Canonical {}");
doTest(new GroovyAssignabilityCheckInspection());
}
public void testUnusedDefsForArgs() {
doTest(new UnusedDefInspection());
}
@@ -0,0 +1,11 @@
import groovy.transform.Canonical
@Canonical
class Person4 {
String name
List likes
private boolean active = false
}
println new Person4('mrhaki', ['Groovy', 'Java'])
println new Person4<warning descr="Ambiguous constructor call"><warning descr="'Person4' in 'Person4' cannot be applied to '(java.lang.String, [java.lang.String, java.lang.String], java.lang.Boolean)'">('mrhaki', ['Groovy', 'Java'], true)</warning></warning>