diff --git a/colorSchemes/src/colorSchemes/WarmNeon.xml b/colorSchemes/src/colorSchemes/WarmNeon.xml index 2b3c50da9f6c..0c1ba8e0b170 100644 --- a/colorSchemes/src/colorSchemes/WarmNeon.xml +++ b/colorSchemes/src/colorSchemes/WarmNeon.xml @@ -1416,7 +1416,7 @@ - + - + - + diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDetector.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDetector.java index ef910af186cf..a73b88c837fa 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDetector.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDetector.java @@ -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; } diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageSearcher.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageSearcher.java index bb9ae51d0988..e3ef59852ea5 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageSearcher.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageSearcher.java @@ -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); } } diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java index 87fd082a8aa5..4efda00c354d 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java @@ -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) { diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/VariableInplaceIntroducer.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/VariableInplaceIntroducer.java index 313616745d37..5e5f82afaed2 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/VariableInplaceIntroducer.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/VariableInplaceIntroducer.java @@ -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); diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/ClassTypeArgumentMigrationProcessor.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/ClassTypeArgumentMigrationProcessor.java index 8cdc18f48a0c..b3a8846658cc 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/ClassTypeArgumentMigrationProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/ClassTypeArgumentMigrationProcessor.java @@ -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); } diff --git a/platform/lang-api/src/com/intellij/execution/actions/ConfigurationContext.java b/platform/lang-api/src/com/intellij/execution/actions/ConfigurationContext.java index 277aa95423db..f04003dd4a0f 100644 --- a/platform/lang-api/src/com/intellij/execution/actions/ConfigurationContext.java +++ b/platform/lang-api/src/com/intellij/execution/actions/ConfigurationContext.java @@ -124,6 +124,11 @@ public class ConfigurationContext { return null; } + final PsiElement psiElement = myLocation.getPsiElement(); + if (!psiElement.isValid()) { + return null; + } + final List producers = findPreferredProducers(); if (producers == null) return null; if (myRuntimeConfiguration != null) { diff --git a/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java b/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java index 2ce07c7525c7..61d6b12fa1b0 100644 --- a/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java +++ b/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java @@ -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; } diff --git a/platform/lang-impl/src/com/intellij/ide/actions/ViewStructureAction.java b/platform/lang-impl/src/com/intellij/ide/actions/ViewStructureAction.java index acdbebe9b7d7..68cd485b6798 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/ViewStructureAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/ViewStructureAction.java @@ -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(); } diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarBorder.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarBorder.java index f1540ae676e6..0d0087997a85 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarBorder.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarBorder.java @@ -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; } } diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarItem.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarItem.java index b1f4e9b0d7de..39727daf380a 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarItem.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarItem.java @@ -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) { diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java index 345b684ab5ac..7e4ada9e0f22 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java @@ -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(); diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java index d9618a801814..d4118201f437 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java @@ -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); + } } } diff --git a/platform/lang-impl/src/com/intellij/ide/todo/nodes/TodoDirNode.java b/platform/lang-impl/src/com/intellij/ide/todo/nodes/TodoDirNode.java index ff13c6547aee..0c92beec5f5b 100644 --- a/platform/lang-impl/src/com/intellij/ide/todo/nodes/TodoDirNode.java +++ b/platform/lang-impl/src/com/intellij/ide/todo/nodes/TodoDirNode.java @@ -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 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; } diff --git a/platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java b/platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java index 2852cd8b1d6e..e1913f9b3c8c 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java +++ b/platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java @@ -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 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 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 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 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 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 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 extends DialogWrapper implemen return myTree; } - public JCheckBox[] getCheckboxes() { - return myCheckboxes; + public JComponent[] getOptionControls() { + return myOptionControls; } @Nullable diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManager.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManager.java index 7402fe037efa..6789471004b1 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManager.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManager.java @@ -174,7 +174,7 @@ public class InspectionProjectProfileManager extends DefaultProjectProfileManage public void run() { DaemonCodeAnalyzer.getInstance(myProject).restart(); } - }); + }, myProject.getDisposed()); } }; if (app.isUnitTestMode() || app.isHeadlessEnvironment()) { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index 24c1dd29f7a9..ff979ac6e478 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -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() { @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 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 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 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 diff --git a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java index b902ca5b6711..9b8725ea98b7 100644 --- a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java +++ b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java @@ -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); } diff --git a/platform/platform-api/src/com/intellij/ui/components/panels/OpaquePanel.java b/platform/platform-api/src/com/intellij/ui/components/panels/OpaquePanel.java index 28bbeec0a948..b2df6c441c72 100644 --- a/platform/platform-api/src/com/intellij/ui/components/panels/OpaquePanel.java +++ b/platform/platform-api/src/com/intellij/ui/components/panels/OpaquePanel.java @@ -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(); diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java index 3c9c317ff016..8812374245bf 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java @@ -65,6 +65,9 @@ public class JBTabsImpl extends JComponent implements JBTabs, PropertyChangeListener, TimerListener, DataProvider, PopupMenuListener, Disposable, JBTabsPresentation, Queryable, QuickActionProvider { static DataKey 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 myVisibleInfos = new ArrayList(); @@ -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); diff --git a/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java b/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java index fa9782512905..a53c4ad6f00b 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java @@ -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 diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java index 21d4fa906c8a..66e8172d3e42 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java @@ -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) { diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ShowLogAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ShowLogAction.java index 8ec0b7223f10..a9af13d51712 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ShowLogAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowLogAction.java @@ -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; } } diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java index 9fce3ad8b39b..0082e15efd11 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java @@ -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); + } } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/IdeaActionButtonLook.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/IdeaActionButtonLook.java index dbfc86afbc31..7b17a35f9209 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/IdeaActionButtonLook.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/IdeaActionButtonLook.java @@ -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++; } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java index 326a3c55e67b..448cff59f843 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java @@ -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() { public ActionGroup get() { return (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_EDITOR_TAB_POPUP); diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java index 2cfad4dccfb5..b35f926523e5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java @@ -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>() { + @Override + public Pair 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) { diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java index a318df753510..e54564474b6d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java @@ -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 diff --git a/platform/platform-impl/src/com/intellij/ui/docking/impl/DockManagerImpl.java b/platform/platform-impl/src/com/intellij/ui/docking/impl/DockManagerImpl.java index 49ca4f9f0aab..0c6429ae9edc 100644 --- a/platform/platform-impl/src/com/intellij/ui/docking/impl/DockManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/docking/impl/DockManagerImpl.java @@ -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()); diff --git a/platform/platform-resources/src/idea/Keymap_Default.xml b/platform/platform-resources/src/idea/Keymap_Default.xml index c3fe8be6cc4e..25b7bc6ecd36 100644 --- a/platform/platform-resources/src/idea/Keymap_Default.xml +++ b/platform/platform-resources/src/idea/Keymap_Default.xml @@ -917,12 +917,10 @@ - - diff --git a/platform/platform-resources/src/idea/Keymap_XWin.xml b/platform/platform-resources/src/idea/Keymap_XWin.xml index 9a69d5080fca..c921a3fcf8b1 100644 --- a/platform/platform-resources/src/idea/Keymap_XWin.xml +++ b/platform/platform-resources/src/idea/Keymap_XWin.xml @@ -25,8 +25,5 @@ - - - diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java index 04a0391b79d0..8373539c4eb5 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java @@ -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); diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java index 2229b44c48ce..3eb4bd59da90 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java @@ -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); diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java index d693a18d28cb..cfdf4eb36c80 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java @@ -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 locations = myLocator.getLocation(protocolId, path, project); + if (!locations.isEmpty()) { + return locations.iterator().next(); + } + } for (TestLocationProvider provider : Extensions.getExtensions(TestLocationProvider.EP_NAME)) { final List locations = provider.getLocation(protocolId, path, project); if (!locations.isEmpty()) { diff --git a/platform/util/src/com/intellij/openapi/util/SystemInfo.java b/platform/util/src/com/intellij/openapi/util/SystemInfo.java index 00fda6c7b079..1e8a6340baa7 100644 --- a/platform/util/src/com/intellij/openapi/util/SystemInfo.java +++ b/platform/util/src/com/intellij/openapi/util/SystemInfo.java @@ -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. * diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 9153810760d2..b6c64766db4a 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -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> myLines = new ArrayList>(); + 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> _position) { + final int[] maxWidth = new int[] {0}; + final int[] height = new int[] {0}; + ContainerUtil.process(myLines, new Processor>() { + @Override + public boolean process(final Pair 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 position = _position.fun(maxWidth[0], height[0]); + assert position != null; + + final int[] yOffset = new int[] {position.getSecond()}; + ContainerUtil.process(myLines, new Processor>() { + @Override + public boolean process(final Pair 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); diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java b/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java index 1bb9f22c9f01..0da2de7917da 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java @@ -221,6 +221,7 @@ public abstract class ProjectLevelVcsManager { */ public abstract boolean isBackgroundVcsOperationRunning(); + public abstract List getRootsUnderVcsWithoutFiltering(final AbstractVcs vcs); public abstract VirtualFile[] getRootsUnderVcs(AbstractVcs vcs); /** diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/DateChangeListGroupingStrategy.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/DateChangeListGroupingStrategy.java index 1805c9ae399d..91d3c4fb3983 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/DateChangeListGroupingStrategy.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/DateChangeListGroupingStrategy.java @@ -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 myCache; + + private MonthsCache(final Calendar calendarForInit) { + myCache = new HashMap(); + 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 myCache; + + private WeekDayFormatCache(final Calendar calendarForInit) { + myCache = new HashMap(); + 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); + } + } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java index abaca260592d..49eadd1a22eb 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java @@ -557,6 +557,10 @@ public void addMessageToConsoleWindow(final String message, final TextAttributes return myBackgroundOperationCounter > 0; } + public List getRootsUnderVcsWithoutFiltering(final AbstractVcs vcs) { + return myMappings.getMappingsAsFilesUnderVcs(vcs); + } + public VirtualFile[] getRootsUnderVcs(AbstractVcs vcs) { return myMappingsToRoots.getRootsUnderVcs(vcs); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java index e7e9c3bb4bde..734dabf27d8a 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java @@ -70,11 +70,6 @@ public class MappingsToRoots { // same as above, but no compression List 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 directoryMappings = myMappings.getDirectoryMappings(vcsName); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java index 633eba307147..e52d3cc9e1fd 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java @@ -253,7 +253,7 @@ public class NewMappings { return FileUtil.startsWith(systemIndependPath, mapping.systemIndependentPath()); } - List getMappingsAsFilesUnderVcs(final AbstractVcs vcs) { + public List getMappingsAsFilesUnderVcs(final AbstractVcs vcs) { final List result = new ArrayList(); final String vcsName = vcs.getName(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyPropertyUtils.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyPropertyUtils.java index b06c0c7a0a7f..34b0eca24cc2 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyPropertyUtils.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyPropertyUtils.java @@ -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) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java index 6ceec3a59d85..7163f06b3f54 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java @@ -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); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/ConstructorAnnotationsProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/ConstructorAnnotationsProcessor.java index e4ccb4ca76b6..f290dc2a17f9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/ConstructorAnnotationsProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/ConstructorAnnotationsProcessor.java @@ -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, diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java index 2220e3cc0e74..277dc14a0570 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java @@ -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()); } diff --git a/plugins/groovy/testdata/highlighting/CanonicalConstructorApplicability.groovy b/plugins/groovy/testdata/highlighting/CanonicalConstructorApplicability.groovy new file mode 100644 index 000000000000..8176be755a28 --- /dev/null +++ b/plugins/groovy/testdata/highlighting/CanonicalConstructorApplicability.groovy @@ -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('mrhaki', ['Groovy', 'Java'], true) \ No newline at end of file