diff --git a/build/conf/mac/Contents/MacOS/idea b/build/conf/mac/Contents/MacOS/idea index 228b1f89009f..fb9b268404fb 100755 Binary files a/build/conf/mac/Contents/MacOS/idea and b/build/conf/mac/Contents/MacOS/idea differ diff --git a/build/conf/mac/Contents/MacOS/idea_appLauncher b/build/conf/mac/Contents/MacOS/idea_appLauncher new file mode 100755 index 000000000000..228b1f89009f Binary files /dev/null and b/build/conf/mac/Contents/MacOS/idea_appLauncher differ diff --git a/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java b/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java index 805cfba2b772..dc2e1afdc547 100644 --- a/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java +++ b/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java @@ -26,6 +26,7 @@ import com.intellij.execution.runners.ProgramRunner; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.psi.search.GlobalSearchScope; +import org.jetbrains.annotations.NotNull; import java.util.List; @@ -60,6 +61,7 @@ public class DefaultDebugEnvironment implements DebugEnvironment { mySearchScope = createSearchScope(project, runProfile); } + @NotNull public static GlobalSearchScope createSearchScope(Project project, RunProfile runProfile) { Module[] modules = null; if (runProfile instanceof ModuleRunProfile) { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java index 6996d7ebda82..f515f94e4f5b 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java @@ -37,6 +37,7 @@ import com.intellij.util.text.StringTokenizer; import com.intellij.util.ui.GeometryUtil; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -53,7 +54,6 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { private DebuggerTreeNodeImpl myCurrentTooltipNode; private JComponent myCurrentTooltip; - private Point myCurrentPosition; protected final TipManager myTipManager; @@ -62,14 +62,17 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { myProject = project; myTipManager = new TipManager(this, new TipManager.TipFactory() { + @Override public JComponent createToolTip(MouseEvent e) { return DebuggerTreeBase.this.createToolTip(e); } + @Override public MouseEvent createTooltipEvent(MouseEvent candidateEvent) { return DebuggerTreeBase.this.createTooltipEvent(candidateEvent); } + @Override public boolean isFocusOwner() { return DebuggerTreeBase.this.isFocusOwner(); } @@ -85,23 +88,6 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { TreeUtil.installActions(this); } - private static int getMaximumChars(final String s, final FontMetrics metrics, final int maxWidth) { - int minChar = 0; - int maxChar = s.length(); - int chars; - while (minChar < maxChar) { - chars = (minChar + maxChar + 1) / 2; - final int width = metrics.stringWidth(s.substring(0, chars)); - if (width <= maxWidth) { - minChar = chars; - } - else { - maxChar = chars - 1; - } - } - return minChar; - } - private JComponent createTipContent(String tipText, DebuggerTreeNodeImpl node) { final JToolTip tooltip = new JToolTip(); @@ -114,35 +100,30 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { rootSize.width -= (borderInsets.left + borderInsets.right) * 2; rootSize.height -= (borderInsets.top + borderInsets.bottom) * 2; - //noinspection HardCodedStringLiteral - final StringBuilder tipBuilder = new StringBuilder(); - try { - final String markupText = node.getMarkupTooltipText(); - if (markupText != null) { - tipBuilder.append(markupText); - } + @NonNls StringBuilder tipBuilder = new StringBuilder(); + final String markupText = node.getMarkupTooltipText(); + if (markupText != null) { + tipBuilder.append(markupText); + } - if (tipText.length() > 0) { - final StringTokenizer tokenizer = new StringTokenizer(tipText, "\n ", true); + if (!tipText.isEmpty()) { + final StringTokenizer tokenizer = new StringTokenizer(tipText, "\n ", true); - while (tokenizer.hasMoreElements()) { - final String each = tokenizer.nextElement(); - if ("\n".equals(each)) { - tipBuilder.append("
"); - } - else if (" ".equals(each)) { - tipBuilder.append("  "); - } - else { - tipBuilder.append(JDOMUtil.legalizeText(each)); - } + while (tokenizer.hasMoreElements()) { + final String each = tokenizer.nextElement(); + if ("\n".equals(each)) { + tipBuilder.append("
"); + } + else if (" ".equals(each)) { + tipBuilder.append("  "); + } + else { + tipBuilder.append(JDOMUtil.legalizeText(each)); } } + } - tooltip.setTipText(UIUtil.toHtml(tipBuilder.toString(), 0)); - } - finally { - } + tooltip.setTipText(UIUtil.toHtml(tipBuilder.toString(), 0)); } tooltip.setBorder(null); @@ -174,7 +155,7 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { final Rectangle bounds = getRowBounds(row); return new MouseEvent(this, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, bounds.x, - bounds.y + bounds.height - (bounds.height / 4), 0, false); + bounds.y + bounds.height - bounds.height / 4, 0, false); } @Nullable @@ -198,8 +179,8 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { final JComponent tipContent = createTipContent(toolTipText, node); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(tipContent); scrollPane.setBorder(null); - scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); final Point point = e.getPoint(); SwingUtilities.convertPointToScreen(point, e.getComponent()); @@ -209,17 +190,7 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { final JToolTip toolTip = new JToolTip(); - tipContent.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - if (UIUtil.isActionClick(e)) { - final Window wnd = SwingUtilities.getWindowAncestor(toolTip); - if (wnd instanceof JWindow) { - wnd.setVisible(false); - } - } - } - }); + tipContent.addMouseListener(new HideTooltip(toolTip)); final Border tooltipBorder = toolTip.getBorder(); if (tooltipBorder != null) { @@ -228,16 +199,12 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { .setSize(tipRectangle.width + borderInsets.left + borderInsets.right, tipRectangle.height + borderInsets.top + borderInsets.bottom); } - boolean addScrollers = true; - toolTip.setLayout(new BorderLayout()); toolTip.add(scrollPane, BorderLayout.CENTER); - if (addScrollers) { - tipRectangle.height += scrollPane.getHorizontalScrollBar().getPreferredSize().height; - tipRectangle.width += scrollPane.getVerticalScrollBar().getPreferredSize().width; - } + tipRectangle.height += scrollPane.getHorizontalScrollBar().getPreferredSize().height; + tipRectangle.width += scrollPane.getVerticalScrollBar().getPreferredSize().width; final int maxWidth = (int)(screen.width - screen.width * .25); @@ -264,7 +231,6 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { toolTip.setPreferredSize(tipRectangle.getSize()); myCurrentTooltip = toolTip; - myCurrentPosition = tipRectangle.getLocation(); return myCurrentTooltip; } @@ -287,7 +253,7 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { } final String tipText = prepareToolTipText(text); - if (tipText.length() > 0 && + if (!tipText.isEmpty() && (tipText.indexOf('\n') >= 0 || !getVisibleRect().contains(getRowBounds(getRowForPath(new TreePath(node.getPath())))))) { return tipText; } @@ -309,42 +275,6 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { return null; } - private Rectangle getTipBounds(final Point point, Dimension tipContentSize) { - Rectangle nodeBounds = new Rectangle(point); - TreePath pathForLocation = getPathForLocation(point.x, point.y); - if (pathForLocation != null) { - nodeBounds = getPathBounds(pathForLocation); - } - - Rectangle contentRect = getVisibleRect(); - System.out.println("contentRect = " + contentRect); - - int vgap = nodeBounds.height; - int width = Math.min(tipContentSize.width, contentRect.width); - int height; - int y; - if (point.y > contentRect.y + contentRect.height / 2) { - y = Math.max(contentRect.y, nodeBounds.y - tipContentSize.height - vgap); - height = Math.min(tipContentSize.height, nodeBounds.y - contentRect.y - vgap); - } - else { - y = nodeBounds.y + nodeBounds.height + vgap; - height = Math.min(tipContentSize.height, contentRect.height - y); - } - - final Dimension tipSize = new Dimension(width, height); - - int x = point.x - width / 2; - if (x < contentRect.x) { - x = contentRect.x; - } - if (x + width > contentRect.x + contentRect.width) { - x = contentRect.x + contentRect.width - width; - } - - return new Rectangle(new Point(x, y), tipSize); - } - private String prepareToolTipText(String text) { int tabSize = CodeStyleSettingsManager.getSettings(myProject).getTabSize(StdFileTypes.JAVA); if (tabSize < 0) { @@ -383,6 +313,7 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { return buf.toString(); } + @Override public void dispose() { final JComponent tooltip = myCurrentTooltip; if (tooltip != null) { @@ -391,4 +322,26 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { myCurrentTooltip = null; myCurrentTooltipNode = null; } + + public Project getProject() { + return myProject; + } + + private static class HideTooltip extends MouseAdapter { + private final JToolTip myToolTip; + + public HideTooltip(JToolTip toolTip) { + myToolTip = toolTip; + } + + @Override + public void mouseReleased(MouseEvent e) { + if (UIUtil.isActionClick(e)) { + final Window wnd = SwingUtilities.getWindowAncestor(myToolTip); + if (wnd instanceof JWindow) { + wnd.setVisible(false); + } + } + } + } } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java index 9f26238aefda..b655148002db 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java @@ -71,7 +71,6 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi public static final DataKey DATA_KEY = DataKey.create("DebuggerTree"); - private final Project myProject; protected final NodeManagerImpl myNodeManager; private DebuggerContextImpl myDebuggerContext = DebuggerContextImpl.EMPTY_CONTEXT; @@ -117,7 +116,6 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi setModel(model); - myProject = project; final TreeSpeedSearch search = new TreeSpeedSearch(this); search.setComparator(new SpeedSearchComparator(false)); } @@ -310,10 +308,6 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi } } - public Project getProject() { - return myProject; - } - protected abstract void build(DebuggerContextImpl context); protected final void buildWhenPaused(DebuggerContextImpl context, RefreshDebuggerTreeCommand command) { diff --git a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilterFactory.java b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilterFactory.java index fd57dfe7cf89..5fb91ddee70d 100644 --- a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilterFactory.java +++ b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilterFactory.java @@ -17,6 +17,7 @@ package com.intellij.execution.filters; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.psi.search.GlobalSearchScope; +import org.jetbrains.annotations.NotNull; /** * Created by IntelliJ IDEA. @@ -26,6 +27,7 @@ import com.intellij.psi.search.GlobalSearchScope; */ public interface ExceptionFilterFactory { ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.exceptionFilter"); - - Filter create(final GlobalSearchScope searchScope); + + @NotNull + Filter create(@NotNull GlobalSearchScope searchScope); } diff --git a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilters.java b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilters.java index 2c79ed095130..1c3bd1ca4e13 100644 --- a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilters.java +++ b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilters.java @@ -16,6 +16,7 @@ package com.intellij.execution.filters; import com.intellij.psi.search.GlobalSearchScope; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -30,9 +31,10 @@ public class ExceptionFilters { private ExceptionFilters() { } - public static List getFilters(final GlobalSearchScope searchScope) { - List filters = new ArrayList(); + @NotNull + public static List getFilters(@NotNull GlobalSearchScope searchScope) { ExceptionFilterFactory[] extensions = ExceptionFilterFactory.EP_NAME.getExtensions(); + List filters = new ArrayList(extensions.length); for (ExceptionFilterFactory extension : extensions) { filters.add(extension.create(searchScope)); } diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameStep.java index 73d91d0f7ab4..d04f8d12f079 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameStep.java @@ -28,7 +28,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.text.StringUtil; import com.intellij.projectImport.ProjectFormatPanel; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -39,7 +38,7 @@ import java.io.File; * @author Eugene Zhuravlev * Date: Jul 17, 2007 */ -public class ProjectNameStep extends SettingsStep { +public class ProjectNameStep extends ModuleWizardStep { private final JPanel myPanel; protected final JPanel myAdditionalContentPanel; protected NamePathComponent myNamePathComponent; @@ -64,6 +63,7 @@ public class ProjectNameStep extends SettingsStep { myNamePathComponent.setPath(projectName == null ? (baseDir + File.separator + initialProjectName) : baseDir); myNamePathComponent.setNameValue(initialProjectName); myNamePathComponent.getNameComponent().select(0, initialProjectName.length()); + myPanel = new JPanel(new GridBagLayout()); myPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); myPanel.add(myNamePathComponent, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 20, 0), 0, 0)); @@ -170,25 +170,4 @@ public class ProjectNameStep extends SettingsStep { return shouldContinue; } - - @NotNull - @Override - public JComponent getSettingsPanel() { - return getComponent(); - } - - @Override - public JComponent getExpertSettingsPanel() { - return null; - } - - @Override - public SettingsStep addField(String label, JComponent field) { - return this; - } - - @Override - public SettingsStep addExpertPanel(JComponent panel) { - return this; - } } diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectSettingsStep.form b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectSettingsStep.form deleted file mode 100644 index 2d88360d12eb..000000000000 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectSettingsStep.form +++ /dev/null @@ -1,93 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectSettingsStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectSettingsStep.java deleted file mode 100644 index dbf9eeffc737..000000000000 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectSettingsStep.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.ide.util.newProjectWizard; - -import com.intellij.ide.IdeBundle; -import com.intellij.ide.highlighter.ModuleFileType; -import com.intellij.ide.util.BrowseFilesListener; -import com.intellij.ide.util.newProjectWizard.modes.CreateFromTemplateMode; -import com.intellij.ide.util.projectWizard.ModuleBuilder; -import com.intellij.ide.util.projectWizard.ProjectWizardUtil; -import com.intellij.ide.util.projectWizard.SettingsStep; -import com.intellij.ide.util.projectWizard.WizardContext; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleManager; -import com.intellij.openapi.options.ConfigurationException; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectBundle; -import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.ui.TextFieldWithBrowseButton; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.ui.DocumentAdapter; -import com.intellij.ui.components.JBLabel; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import javax.swing.event.DocumentEvent; -import java.awt.*; -import java.io.File; - -public class ProjectSettingsStep extends ProjectNameStep { - private JPanel myModulePanel; - private JTextField myModuleName; - private TextFieldWithBrowseButton myModuleContentRoot; - private TextFieldWithBrowseButton myModuleFileLocation; - private JPanel myHeader; - private JPanel myExpertPanel; - - private boolean myModuleNameChangedByUser = false; - private boolean myModuleNameDocListenerEnabled = true; - - private boolean myContentRootChangedByUser = false; - private boolean myContentRootDocListenerEnabled = true; - - private boolean myImlLocationChangedByUser = false; - private boolean myImlLocationDocListenerEnabled = true; - - - public ProjectSettingsStep(final WizardContext wizardContext) { - super(wizardContext, null); - myAdditionalContentPanel.add(myModulePanel, - new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, - GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); - myHeader.setVisible(myWizardContext.isCreatingNewProject() && !isCreateFromTemplateMode()); - myNamePathComponent.getNameComponent().getDocument().addDocumentListener(new DocumentAdapter() { - protected void textChanged(final DocumentEvent e) { - if (!myModuleNameChangedByUser) { - setModuleName(myNamePathComponent.getNameValue()); - } - } - }); - - myModuleContentRoot.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.content.root.chooser.title"), ProjectBundle.message("project.new.wizard.module.content.root.chooser.description"), - myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR); - - myNamePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() { - protected void textChanged(final DocumentEvent e) { - if (!myContentRootChangedByUser) { - setModuleContentRoot(myNamePathComponent.getPath()); - } - } - }); - myModuleName.getDocument().addDocumentListener(new DocumentAdapter() { - protected void textChanged(final DocumentEvent e) { - if (myModuleNameDocListenerEnabled) { - myModuleNameChangedByUser = true; - } - String path = getDefaultBaseDir(wizardContext); - final String moduleName = getModuleName(); - if (path.length() > 0 && !Comparing.strEqual(moduleName, myNamePathComponent.getNameValue())) { - path += "/" + moduleName; - } - if (!myContentRootChangedByUser) { - final boolean f = myModuleNameChangedByUser; - myModuleNameChangedByUser = true; - setModuleContentRoot(path); - myModuleNameChangedByUser = f; - } - if (!myImlLocationChangedByUser) { - setImlFileLocation(path); - } - } - }); - myModuleContentRoot.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { - protected void textChanged(final DocumentEvent e) { - if (myContentRootDocListenerEnabled) { - myContentRootChangedByUser = true; - } - if (!myImlLocationChangedByUser) { - setImlFileLocation(getModuleContentRoot()); - } - if (!myModuleNameChangedByUser) { - final String path = FileUtil.toSystemIndependentName(getModuleContentRoot()); - final int idx = path.lastIndexOf("/"); - - boolean f = myContentRootChangedByUser; - myContentRootChangedByUser = true; - - boolean i = myImlLocationChangedByUser; - myImlLocationChangedByUser = true; - - setModuleName(idx >= 0 ? path.substring(idx + 1) : ""); - - myContentRootChangedByUser = f; - myImlLocationChangedByUser = i; - } - } - }); - - myModuleFileLocation.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.file.chooser.title"), ProjectBundle.message("project.new.wizard.module.file.description"), - myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR); - myModuleFileLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { - protected void textChanged(final DocumentEvent e) { - if (myImlLocationDocListenerEnabled) { - myImlLocationChangedByUser = true; - } - } - }); - myNamePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() { - protected void textChanged(final DocumentEvent e) { - if (!myImlLocationChangedByUser) { - setImlFileLocation(myNamePathComponent.getPath()); - } - } - }); - if (wizardContext.isCreatingNewProject()) { - setModuleName(myNamePathComponent.getNameValue()); - setModuleContentRoot(myNamePathComponent.getPath()); - setImlFileLocation(myNamePathComponent.getPath()); - } else { - final Project project = wizardContext.getProject(); - assert project != null; - VirtualFile baseDir = project.getBaseDir(); - if (baseDir != null) { //e.g. was deleted - final String baseDirPath = baseDir.getPath(); - String moduleName = ProjectWizardUtil.findNonExistingFileName(baseDirPath, "untitled", ""); - String contentRoot = baseDirPath + "/" + moduleName; - if (!Comparing.strEqual(project.getName(), wizardContext.getProjectName()) && !wizardContext.isCreatingNewProject() && wizardContext.getProjectName() != null) { - moduleName = ProjectWizardUtil.findNonExistingFileName(wizardContext.getProjectFileDirectory(), wizardContext.getProjectName(), ""); - contentRoot = wizardContext.getProjectFileDirectory(); - } - setModuleName(moduleName); - setModuleContentRoot(contentRoot); - setImlFileLocation(contentRoot); - myModuleName.select(0, moduleName.length()); - } - } - } - - protected String getModuleContentRoot() { - return myModuleContentRoot.getText(); - } - - private boolean isCreateFromTemplateMode() { - return myMode instanceof CreateFromTemplateMode; - } - - private String getDefaultBaseDir(WizardContext wizardContext) { - if (wizardContext.isCreatingNewProject()) { - return myNamePathComponent.getPath(); - } else { - final Project project = wizardContext.getProject(); - assert project != null; - final VirtualFile baseDir = project.getBaseDir(); - if (baseDir != null) { - return baseDir.getPath(); - } - return ""; - } - } - - public JComponent getPreferredFocusedComponent() { - return myWizardContext.isCreatingNewProject() ? super.getPreferredFocusedComponent() : myModuleName; - } - - private void setImlFileLocation(final String path) { - myImlLocationDocListenerEnabled = false; - myModuleFileLocation.setText(FileUtil.toSystemDependentName(path)); - myImlLocationDocListenerEnabled = true; - } - - private void setModuleContentRoot(final String path) { - myContentRootDocListenerEnabled = false; - myModuleContentRoot.setText(FileUtil.toSystemDependentName(path)); - myContentRootDocListenerEnabled = true; - } - - private void setModuleName(String moduleName) { - myModuleNameDocListenerEnabled = false; - myModuleName.setText(moduleName); - myModuleNameDocListenerEnabled = true; - } - - public void updateDataModel() { - - super.updateDataModel(); - - final ModuleBuilder builder = (ModuleBuilder)myWizardContext.getProjectBuilder(); - assert builder != null; - final String moduleName = getModuleName(); - builder.setName(moduleName); - builder.setModuleFilePath( - FileUtil.toSystemIndependentName(myModuleFileLocation.getText()) + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION); - builder.setContentEntryPath(FileUtil.toSystemIndependentName(getModuleContentRoot())); - } - - public boolean validate() throws ConfigurationException { - final String moduleName = getModuleName(); - if (!myWizardContext.isCreatingNewProject()) { - final String moduleFileDirectory = myModuleFileLocation.getText(); - if (moduleFileDirectory.length() == 0) { - throw new ConfigurationException("Enter module file location"); - } - if (moduleName.length() == 0) { - throw new ConfigurationException("Enter a module name"); - } - - if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.module.file"), moduleFileDirectory, - myImlLocationChangedByUser)) { - return false; - } - if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.module.content.root"), getModuleContentRoot(), - myContentRootChangedByUser)) { - return false; - } - - File moduleFile = new File(moduleFileDirectory, moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION); - if (moduleFile.exists()) { - int answer = Messages.showYesNoDialog(IdeBundle.message("prompt.overwrite.project.file", moduleFile.getAbsolutePath(), IdeBundle.message("project.new.wizard.module.identification")), - IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon()); - if (answer != 0) { - return false; - } - } - } - Project project = myWizardContext.getProject(); - if (project != null) { - final Module module; - final ProjectStructureConfigurable fromConfigurable = ProjectStructureConfigurable.getInstance(project); - if (fromConfigurable != null) { - module = fromConfigurable.getModulesConfig().getModule(moduleName); - } - else { - module = ModuleManager.getInstance(project).findModuleByName(moduleName); - } - if (module != null) { - throw new ConfigurationException("Module \'" + moduleName + "\' already exist in project. Please, specify another name."); - } - } - return !myWizardContext.isCreatingNewProject() || super.validate(); - } - - protected String getModuleName() { - return myModuleName.getText().trim(); - } - - @NotNull - @Override - public JComponent getSettingsPanel() { - return myWizardContext.isCreatingNewProject() ? myNamePathComponent : myModulePanel; - } - - @Override - public JComponent getExpertSettingsPanel() { - return myWizardContext.isCreatingNewProject() ? myModulePanel : myExpertPanel.getComponentCount() == 0 ? null : myExpertPanel; - } - - @Override - public SettingsStep addField(String label, JComponent field) { - JComponent settingsPanel = getSettingsPanel(); - - JLabel jLabel = new JBLabel(label); - jLabel.setLabelFor(field); - settingsPanel.add(jLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.WEST, - GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - settingsPanel.add(field, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - return this; - } - - @Override - public SettingsStep addExpertPanel(JComponent panel) { - JComponent settingsPanel = myExpertPanel; - settingsPanel.add(panel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0, GridBagConstraints.NORTHWEST, - GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - return this; - } -} diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.form b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.form index d5d1b4f15b64..e1ee5c05740a 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.form +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.form @@ -3,14 +3,16 @@ - + - + + + @@ -60,7 +62,15 @@ - + + + + + + + + + @@ -93,7 +103,70 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java index b3ac5e7b6719..770b946aabcc 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java @@ -15,6 +15,9 @@ */ package com.intellij.ide.util.newProjectWizard; +import com.intellij.ide.IdeBundle; +import com.intellij.ide.highlighter.ModuleFileType; +import com.intellij.ide.util.BrowseFilesListener; import com.intellij.ide.util.projectWizard.*; import com.intellij.ide.util.treeView.AlphaComparator; import com.intellij.ide.util.treeView.NodeDescriptor; @@ -23,12 +26,18 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CustomShortcutSet; import com.intellij.openapi.options.ConfigurationException; +import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.ui.TextFieldWithBrowseButton; +import com.intellij.openapi.ui.ValidationInfo; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.ProjectTemplatesFactory; import com.intellij.platform.templates.ArchivedTemplatesFactory; @@ -36,6 +45,7 @@ import com.intellij.platform.templates.EmptyModuleTemplatesFactory; import com.intellij.psi.codeStyle.MinusculeMatcher; import com.intellij.psi.codeStyle.NameUtil; import com.intellij.ui.*; +import com.intellij.ui.components.JBLabel; import com.intellij.ui.speedSearch.ElementFilter; import com.intellij.ui.treeStructure.*; import com.intellij.ui.treeStructure.filtered.FilteringTreeBuilder; @@ -55,6 +65,7 @@ import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; +import java.io.File; import java.util.*; import java.util.List; @@ -62,7 +73,7 @@ import java.util.List; * @author Dmitry Avdeev * Date: 9/26/12 */ -public class SelectTemplateStep extends ModuleWizardStep { +public class SelectTemplateStep extends ModuleWizardStep implements SettingsStep { private JPanel myPanel; private SimpleTree myTemplatesTree; @@ -70,24 +81,49 @@ public class SelectTemplateStep extends ModuleWizardStep { private SearchTextField mySearchField; private JTextPane myDescriptionPane; private JPanel myDescriptionPanel; - private JPanel myExpertPlaceholder; - private HideableTitledPanel myExpertPanel = new HideableTitledPanel("E&xpert Settings", false); - private final WizardContext myContext; + private JPanel myExpertPlaceholder; + private JPanel myExpertPanel; + private final HideableDecorator myExpertDecorator; + + private final NamePathComponent myNamePathComponent; + private JTextField myModuleName; + private TextFieldWithBrowseButton myModuleContentRoot; + private TextFieldWithBrowseButton myModuleFileLocation; + + private boolean myModuleNameChangedByUser = false; + private boolean myModuleNameDocListenerEnabled = true; + + private boolean myContentRootChangedByUser = false; + private boolean myContentRootDocListenerEnabled = true; + + private boolean myImlLocationChangedByUser = false; + private boolean myImlLocationDocListenerEnabled = true; + + private final WizardContext myWizardContext; private final StepSequence mySequence; - private SettingsStep mySettingsStep; + @Nullable + private ModuleWizardStep mySettingsCallback; private final ElementFilter.Active.Impl myFilter; private final FilteringTreeBuilder myBuilder; private MinusculeMatcher[] myMatchers; + @Nullable private ModuleBuilder myModuleBuilder; public SelectTemplateStep(WizardContext context, StepSequence sequence) { - myContext = context; + myWizardContext = context; mySequence = sequence; Messages.installHyperlinkSupport(myDescriptionPane); - myExpertPlaceholder.add(myExpertPanel, BorderLayout.CENTER); + + myNamePathComponent = initNamePathComponent(context); + mySettingsPanel.add(myNamePathComponent, BorderLayout.NORTH); + bindModuleSettings(); + + myExpertDecorator = new HideableDecorator(myExpertPlaceholder, "Mor&e settings", false); + myExpertPanel.setBorder(IdeBorderFactory.createEmptyBorder(0, IdeBorderFactory.TITLED_BORDER_INDENT, 5, 0)); + myExpertDecorator.setContentComponent(myExpertPanel); ProjectTemplatesFactory[] factories = ProjectTemplatesFactory.EP_NAME.getExtensions(); final MultiMap groups = new MultiMap(); @@ -184,13 +220,9 @@ public class SelectTemplateStep extends ModuleWizardStep { public void valueChanged(TreeSelectionEvent e) { ProjectTemplate template = getSelectedTemplate(); myModuleBuilder = template == null ? null : template.createModuleBuilder(); - mySettingsStep = myModuleBuilder == null ? null : myModuleBuilder.createSettingsStep(myContext); - if (mySettingsStep == null) { - mySettingsStep = ProjectWizardStepFactory.getInstance().createSettingsStep(myContext); - } setupPanels(template); mySequence.setType(myModuleBuilder == null ? null : myModuleBuilder.getBuilderId()); - myContext.requestWizardButtonsUpdate(); + myWizardContext.requestWizardButtonsUpdate(); } }); @@ -225,6 +257,7 @@ public class SelectTemplateStep extends ModuleWizardStep { } }.registerCustomShortcutSet(new CustomShortcutSet(KeyEvent.VK_UP, KeyEvent.VK_DOWN), mySearchField); + //noinspection SSBasedInspection SwingUtilities.invokeLater(new Runnable() { @Override public void run() { @@ -239,22 +272,33 @@ public class SelectTemplateStep extends ModuleWizardStep { }); } + private static NamePathComponent initNamePathComponent(WizardContext context) { + NamePathComponent component = new NamePathComponent( + IdeBundle.message("label.project.name"), + IdeBundle.message("label.project.files.location"), + IdeBundle.message("title.select.project.file.directory", IdeBundle.message("project.new.wizard.project.identification")), + IdeBundle.message("description.select.project.file.directory", StringUtil + .capitalize(IdeBundle.message("project.new.wizard.project.identification"))), + true, false + ); + final String baseDir = context.getProjectFileDirectory(); + final String projectName = context.getProjectName(); + final String initialProjectName = projectName != null ? projectName : ProjectWizardUtil.findNonExistingFileName(baseDir, "untitled", ""); + component.setPath(projectName == null ? (baseDir + File.separator + initialProjectName) : baseDir); + component.setNameValue(initialProjectName); + component.getNameComponent().select(0, initialProjectName.length()); + return component; + } + private void setupPanels(@Nullable ProjectTemplate template) { - if (mySettingsPanel.getComponentCount() > 0) { - mySettingsPanel.remove(0); - } - myExpertPanel.setContentComponent(null); - JComponent expertSettingsPanel = null; + + restorePanel(myNamePathComponent, 4); + restorePanel(myExpertPanel, 6); + + mySettingsCallback = myModuleBuilder == null ? null : myModuleBuilder.modifySettingsStep(this); + String description = null; if (template != null) { - if (mySettingsStep != null) { - mySettingsPanel.add(mySettingsStep.getSettingsPanel(), BorderLayout.NORTH); - expertSettingsPanel = mySettingsStep.getExpertSettingsPanel(); - if (expertSettingsPanel != null) { - expertSettingsPanel.setBorder(IdeBorderFactory.createEmptyBorder(5, IdeBorderFactory.TITLED_BORDER_INDENT, 5, 0)); - myExpertPanel.setContentComponent(expertSettingsPanel); - } - } description = template.getDescription(); if (StringUtil.isNotEmpty(description)) { StringBuilder sb = new StringBuilder(" i) { + component.remove(component.getComponentCount() - 1); + } + } + @Override public void updateStep() { myBuilder.queueUpdate(); - myExpertPanel.setOn(SelectTemplateSettings.getInstance().EXPERT_MODE); + myExpertDecorator.setOn(SelectTemplateSettings.getInstance().EXPERT_MODE); } @Override @@ -283,17 +334,21 @@ public class SelectTemplateStep extends ModuleWizardStep { TreeState state = TreeState.createOn(myTemplatesTree, (DefaultMutableTreeNode)myTemplatesTree.getModel().getRoot()); SelectTemplateSettings settings = SelectTemplateSettings.getInstance(); settings.setTreeState(state); - settings.EXPERT_MODE = myExpertPanel.isExpanded(); + settings.EXPERT_MODE = myExpertDecorator.isExpanded(); } @Override public boolean validate() throws ConfigurationException { ProjectTemplate template = getSelectedTemplate(); if (template == null) { - throw new ConfigurationException(ProjectBundle.message("project.new.wizard.from.template.error", myContext.getPresentationName())); + throw new ConfigurationException(ProjectBundle.message("project.new.wizard.from.template.error", myWizardContext.getPresentationName()), "Error"); } - if (mySettingsStep != null) { - return mySettingsStep.validate(); + ValidationInfo info = template.validateSettings(); + if (info != null) { + throw new ConfigurationException(info.message, "Error"); + } + if (mySettingsCallback != null) { + return mySettingsCallback.validate(); } return true; } @@ -377,9 +432,21 @@ public class SelectTemplateStep extends ModuleWizardStep { @Override public void updateDataModel() { - myContext.setProjectBuilder(myModuleBuilder); - if (mySettingsStep != null) { - mySettingsStep.updateDataModel(); + + myWizardContext.setProjectBuilder(myModuleBuilder); + myWizardContext.setProjectName(myNamePathComponent.getNameValue()); + myWizardContext.setProjectFileDirectory(myNamePathComponent.getPath()); + + if (myModuleBuilder != null) { + final String moduleName = getModuleName(); + myModuleBuilder.setName(moduleName); + myModuleBuilder.setModuleFilePath( + FileUtil.toSystemIndependentName(myModuleFileLocation.getText()) + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION); + myModuleBuilder.setContentEntryPath(FileUtil.toSystemIndependentName(getModuleContentRoot())); + } + + if (mySettingsCallback != null) { + mySettingsCallback.updateDataModel(); } } @@ -397,6 +464,34 @@ public class SelectTemplateStep extends ModuleWizardStep { mySearchField = new SearchTextField(false); } + @Override + public WizardContext getContext() { + return myWizardContext; + } + + @Override + public void addSettingsField(String label, JComponent field) { + + JLabel jLabel = new JBLabel(label); + jLabel.setLabelFor(field); + myNamePathComponent.add(jLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.WEST, + GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); + myNamePathComponent.add(field, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0, GridBagConstraints.NORTHWEST, + GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); + } + + @Override + public void addSettingsComponent(JComponent component) { + myNamePathComponent.add(component, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0, GridBagConstraints.NORTHWEST, + GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); + } + + @Override + public void addExpertPanel(JComponent panel) { + myExpertPanel.add(panel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0, GridBagConstraints.NORTHWEST, + GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); + } + private static class GroupNode extends SimpleNode { private final String myGroup; private final Collection myTemplates; @@ -434,4 +529,151 @@ public class SelectTemplateStep extends ModuleWizardStep { return myTemplate.getName(); } } + + public void bindModuleSettings() { + + myNamePathComponent.getNameComponent().getDocument().addDocumentListener(new DocumentAdapter() { + protected void textChanged(final DocumentEvent e) { + if (!myModuleNameChangedByUser) { + setModuleName(myNamePathComponent.getNameValue()); + } + } + }); + + myModuleContentRoot.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.content.root.chooser.title"), ProjectBundle.message("project.new.wizard.module.content.root.chooser.description"), + myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR); + + myNamePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() { + protected void textChanged(final DocumentEvent e) { + if (!myContentRootChangedByUser) { + setModuleContentRoot(myNamePathComponent.getPath()); + } + } + }); + myModuleName.getDocument().addDocumentListener(new DocumentAdapter() { + protected void textChanged(final DocumentEvent e) { + if (myModuleNameDocListenerEnabled) { + myModuleNameChangedByUser = true; + } + String path = getDefaultBaseDir(myWizardContext); + final String moduleName = getModuleName(); + if (path.length() > 0 && !Comparing.strEqual(moduleName, myNamePathComponent.getNameValue())) { + path += "/" + moduleName; + } + if (!myContentRootChangedByUser) { + final boolean f = myModuleNameChangedByUser; + myModuleNameChangedByUser = true; + setModuleContentRoot(path); + myModuleNameChangedByUser = f; + } + if (!myImlLocationChangedByUser) { + setImlFileLocation(path); + } + } + }); + myModuleContentRoot.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { + protected void textChanged(final DocumentEvent e) { + if (myContentRootDocListenerEnabled) { + myContentRootChangedByUser = true; + } + if (!myImlLocationChangedByUser) { + setImlFileLocation(getModuleContentRoot()); + } + if (!myModuleNameChangedByUser) { + final String path = FileUtil.toSystemIndependentName(getModuleContentRoot()); + final int idx = path.lastIndexOf("/"); + + boolean f = myContentRootChangedByUser; + myContentRootChangedByUser = true; + + boolean i = myImlLocationChangedByUser; + myImlLocationChangedByUser = true; + + setModuleName(idx >= 0 ? path.substring(idx + 1) : ""); + + myContentRootChangedByUser = f; + myImlLocationChangedByUser = i; + } + } + }); + + myModuleFileLocation.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.file.chooser.title"), ProjectBundle.message("project.new.wizard.module.file.description"), + myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR); + myModuleFileLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { + protected void textChanged(final DocumentEvent e) { + if (myImlLocationDocListenerEnabled) { + myImlLocationChangedByUser = true; + } + } + }); + myNamePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() { + protected void textChanged(final DocumentEvent e) { + if (!myImlLocationChangedByUser) { + setImlFileLocation(myNamePathComponent.getPath()); + } + } + }); + if (myWizardContext.isCreatingNewProject()) { + setModuleName(myNamePathComponent.getNameValue()); + setModuleContentRoot(myNamePathComponent.getPath()); + setImlFileLocation(myNamePathComponent.getPath()); + } else { + final Project project = myWizardContext.getProject(); + assert project != null; + VirtualFile baseDir = project.getBaseDir(); + if (baseDir != null) { //e.g. was deleted + final String baseDirPath = baseDir.getPath(); + String moduleName = ProjectWizardUtil.findNonExistingFileName(baseDirPath, "untitled", ""); + String contentRoot = baseDirPath + "/" + moduleName; + if (!Comparing.strEqual(project.getName(), myWizardContext.getProjectName()) && !myWizardContext.isCreatingNewProject() && myWizardContext.getProjectName() != null) { + moduleName = ProjectWizardUtil.findNonExistingFileName(myWizardContext.getProjectFileDirectory(), myWizardContext.getProjectName(), ""); + contentRoot = myWizardContext.getProjectFileDirectory(); + } + setModuleName(moduleName); + setModuleContentRoot(contentRoot); + setImlFileLocation(contentRoot); + myModuleName.select(0, moduleName.length()); + } + } + } + + protected String getModuleContentRoot() { + return myModuleContentRoot.getText(); + } + + private String getDefaultBaseDir(WizardContext wizardContext) { + if (wizardContext.isCreatingNewProject()) { + return myNamePathComponent.getPath(); + } else { + final Project project = wizardContext.getProject(); + assert project != null; + final VirtualFile baseDir = project.getBaseDir(); + if (baseDir != null) { + return baseDir.getPath(); + } + return ""; + } + } + + private void setImlFileLocation(final String path) { + myImlLocationDocListenerEnabled = false; + myModuleFileLocation.setText(FileUtil.toSystemDependentName(path)); + myImlLocationDocListenerEnabled = true; + } + + private void setModuleContentRoot(final String path) { + myContentRootDocListenerEnabled = false; + myModuleContentRoot.setText(FileUtil.toSystemDependentName(path)); + myContentRootDocListenerEnabled = true; + } + + private void setModuleName(String moduleName) { + myModuleNameDocListenerEnabled = false; + myModuleName.setText(moduleName); + myModuleNameDocListenerEnabled = true; + } + + protected String getModuleName() { + return myModuleName.getText().trim(); + } } diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.form b/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.form index d2cc59b2b237..efd9ed6f918c 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.form +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.form @@ -1,7 +1,7 @@
- + diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.java index 434c2e9bc5ba..1dd2fffd6689 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.java @@ -17,24 +17,18 @@ package com.intellij.ide.util.projectWizard; import com.intellij.ide.IdeBundle; import com.intellij.ide.util.BrowseFilesListener; -import com.intellij.ide.util.newProjectWizard.ProjectSettingsStep; import com.intellij.openapi.project.Project; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.SdkType; -import com.intellij.openapi.roots.ui.configuration.JdkComboBox; -import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; import com.intellij.openapi.ui.ComponentWithBrowseButton; import com.intellij.openapi.ui.TextComponentAccessor; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.components.JBCheckBox; import javax.swing.*; -import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; @@ -44,33 +38,19 @@ import java.util.Collections; * @author Dmitry Avdeev * Date: 10/23/12 */ -public class JavaSettingsStep extends ProjectSettingsStep { +public class JavaSettingsStep extends SdkSettingsStep { private final ModuleBuilder myModuleBuilder; private JBCheckBox myCreateSourceRoot; private TextFieldWithBrowseButton mySourcePath; private JPanel myPanel; - private final JdkComboBox myJdkComboBox; - public JavaSettingsStep(WizardContext wizardContext, ModuleBuilder moduleBuilder, Condition sdkFilter) { - super(wizardContext); + public JavaSettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder, Condition sdkFilter) { + super(settingsStep, sdkFilter); myModuleBuilder = moduleBuilder; - ProjectSdksModel model = new ProjectSdksModel(); - Project project = wizardContext.getProject(); - model.reset(project, sdkFilter); - myJdkComboBox = new JdkComboBox(model, sdkFilter); - JButton button = new JButton("\u001BNew..."); - myJdkComboBox.setSetupButton(button, project, model, - project == null ? new JdkComboBox.NoneJdkComboBoxItem() : new JdkComboBox.ProjectJdkComboBoxItem(), - null, - false); - JPanel jdkPanel = new JPanel(new BorderLayout(SystemInfo.isMac? 0 : 2, 0)); - jdkPanel.add(myJdkComboBox); - jdkPanel.add(button, BorderLayout.EAST); - addField("Project \u001BSDK:", jdkPanel); - if (moduleBuilder instanceof JavaModuleBuilder) { + Project project = settingsStep.getContext().getProject(); ComponentWithBrowseButton.BrowseFolderActionListener listener = new ComponentWithBrowseButton.BrowseFolderActionListener( IdeBundle.message("prompt.select.source.directory"), null, mySourcePath, project, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR, @@ -96,16 +76,13 @@ public class JavaSettingsStep extends ProjectSettingsStep { mySourcePath.setEnabled(myCreateSourceRoot.isSelected()); } }); - addExpertPanel(myPanel); + settingsStep.addExpertPanel(myPanel); } - } @Override public void updateDataModel() { super.updateDataModel(); - Sdk jdk = myJdkComboBox.getSelectedJdk(); - myWizardContext.setProjectJdk(jdk); if (myModuleBuilder instanceof JavaModuleBuilder && myCreateSourceRoot.isSelected()) { String contentEntryPath = myModuleBuilder.getContentEntryPath(); if (contentEntryPath != null) { diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactoryImpl.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactoryImpl.java index 57641db4cb8b..b7da81b9ad80 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactoryImpl.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactoryImpl.java @@ -139,12 +139,7 @@ public class ProjectWizardStepFactoryImpl extends ProjectWizardStepFactory { } @Override - public SettingsStep createSettingsStep(WizardContext context) { - return new ProjectSettingsStep(context); - } - - @Override - public SettingsStep createJavaSettingsStep(final WizardContext context, final ModuleBuilder moduleBuilder, Condition sdkFilter) { - return new JavaSettingsStep(context, moduleBuilder, sdkFilter); + public ModuleWizardStep createJavaSettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder, Condition sdkFilter) { + return new JavaSettingsStep(settingsStep, moduleBuilder, sdkFilter); } } diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java new file mode 100644 index 000000000000..e9050e2a69a8 --- /dev/null +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java @@ -0,0 +1,75 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ide.util.projectWizard; + +import com.intellij.openapi.options.ConfigurationException; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.projectRoots.SdkType; +import com.intellij.openapi.roots.ui.configuration.JdkComboBox; +import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; +import com.intellij.openapi.util.Condition; + +import javax.swing.*; +import java.awt.*; + +/** + * @author Dmitry Avdeev + * Date: 10/26/12 + */ +public class SdkSettingsStep extends ModuleWizardStep { + protected final JdkComboBox myJdkComboBox; + protected final WizardContext myWizardContext; + protected final ProjectSdksModel myModel; + + public SdkSettingsStep(SettingsStep settingsStep, Condition sdkFilter) { + + myWizardContext = settingsStep.getContext(); + myModel = new ProjectSdksModel(); + Project project = myWizardContext.getProject(); + myModel.reset(project, sdkFilter); + + myJdkComboBox = new JdkComboBox(myModel, sdkFilter); + + JButton button = new JButton("\u001BNew..."); + myJdkComboBox.setSetupButton(button, project, myModel, + project == null ? new JdkComboBox.NoneJdkComboBoxItem() : new JdkComboBox.ProjectJdkComboBoxItem(), + null, + false); + JPanel jdkPanel = new JPanel(new BorderLayout(4, 0)); + jdkPanel.add(myJdkComboBox); + jdkPanel.add(button, BorderLayout.EAST); + settingsStep.addSettingsField("Project \u001BSDK:", jdkPanel); + + } + + @Override + public JComponent getComponent() { + return null; + } + + @Override + public void updateDataModel() { + Sdk jdk = myJdkComboBox.getSelectedJdk(); + myWizardContext.setProjectJdk(jdk); + } + + @Override + public boolean validate() throws ConfigurationException { + myModel.apply(); + return true; + } +} diff --git a/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java b/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java index 282f6a7b3709..e5467003d04d 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java +++ b/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java @@ -61,6 +61,11 @@ class TemplateModuleBuilder extends ModuleBuilder { return myType; } + @Override + public boolean isTemplateBased() { + return true; + } + @NotNull @Override public Module createModule(@NotNull ModifiableModuleModel moduleModel) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightNamesUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightNamesUtil.java index 7eaa8c8889ae..f67f1cc2bacc 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightNamesUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightNamesUtil.java @@ -37,6 +37,7 @@ import com.intellij.psi.impl.source.tree.TreeUtil; import com.intellij.psi.search.scope.packageSet.NamedScope; import com.intellij.psi.search.scope.packageSet.NamedScopesHolder; import com.intellij.psi.search.scope.packageSet.PackageSet; +import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,7 +49,16 @@ public class HighlightNamesUtil { final PsiElement elementToHighlight, final boolean isDeclaration, @NotNull EditorColorsScheme colorsScheme) { - HighlightInfoType type = getMethodNameHighlightType(method, isDeclaration); + boolean isInherited = false; + + if (!isDeclaration) { + if (isCalledOnThis(elementToHighlight)) { + PsiClass enclosingClass = PsiTreeUtil.getParentOfType(elementToHighlight, PsiClass.class); + isInherited = enclosingClass.isInheritor(method.getContainingClass(), true); + } + } + + HighlightInfoType type = getMethodNameHighlightType(method, isDeclaration, isInherited); if (type != null && elementToHighlight != null) { TextAttributes attributes = mergeWithScopeAttributes(method, type, colorsScheme); HighlightInfo info = HighlightInfo.createHighlightInfo(type, elementToHighlight.getTextRange(), null, null, attributes); @@ -57,6 +67,17 @@ public class HighlightNamesUtil { return null; } + private static boolean isCalledOnThis(PsiElement elementToHighlight) { + PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(elementToHighlight, PsiMethodCallExpression.class); + if (methodCallExpression != null) { + PsiElement qualifier = methodCallExpression.getMethodExpression().getQualifier(); + if (qualifier == null || qualifier instanceof PsiThisExpression) { + return true; + } + } + return false; + } + private static TextAttributes mergeWithScopeAttributes(final PsiElement element, final HighlightInfoType type, @NotNull EditorColorsScheme colorsScheme) { @@ -126,14 +147,18 @@ public class HighlightNamesUtil { return null; } - private static HighlightInfoType getMethodNameHighlightType(PsiMethod method, boolean isDeclaration) { + private static HighlightInfoType getMethodNameHighlightType(PsiMethod method, boolean isDeclaration, boolean isInheritedMethod) { if (method.isConstructor()) { return isDeclaration ? HighlightInfoType.CONSTRUCTOR_DECLARATION : HighlightInfoType.CONSTRUCTOR_CALL; } + if (isInheritedMethod) return HighlightInfoType.INHERITED_METHOD; if (isDeclaration) return HighlightInfoType.METHOD_DECLARATION; if (method.hasModifierProperty(PsiModifier.STATIC)) { return HighlightInfoType.STATIC_METHOD; } + if(method.hasModifierProperty(PsiModifier.ABSTRACT)) { + return HighlightInfoType.ABSTRACT_METHOD; + } return HighlightInfoType.METHOD_CALL; } @@ -144,9 +169,9 @@ public class HighlightNamesUtil { return HighlightInfoType.LOCAL_VARIABLE; } if (var instanceof PsiField) { - return var.hasModifierProperty(PsiModifier.STATIC) - ? HighlightInfoType.STATIC_FIELD - : HighlightInfoType.INSTANCE_FIELD; + return var.hasModifierProperty(PsiModifier.STATIC) ? (var.hasModifierProperty(PsiModifier.FINAL) + ? HighlightInfoType.STATIC_FINAL_FIELD + : HighlightInfoType.STATIC_FIELD) : HighlightInfoType.INSTANCE_FIELD; } if (var instanceof PsiParameter) { return HighlightInfoType.PARAMETER; @@ -162,6 +187,7 @@ public class HighlightNamesUtil { if (aClass != null) { if (aClass.isAnnotationType()) return HighlightInfoType.ANNOTATION_NAME; if (aClass.isInterface()) return HighlightInfoType.INTERFACE_NAME; + if (aClass.isEnum()) return HighlightInfoType.ENUM_NAME; if (aClass instanceof PsiTypeParameter) return HighlightInfoType.TYPE_PARAMETER_NAME; final PsiModifierList modList = aClass.getModifierList(); if (modList != null && modList.hasModifierProperty(PsiModifier.ABSTRACT)) return HighlightInfoType.ABSTRACT_CLASS_NAME; diff --git a/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java b/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java index 82c4264b8e5c..e2006bc691d1 100644 --- a/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java @@ -92,12 +92,16 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaLocalInspectionTool @Override public void visitThisExpression(PsiThisExpression expression) { - bodyContainsForbiddenRefs[0] = true; + if (expression.getQualifier() == null) { + bodyContainsForbiddenRefs[0] = true; + } } @Override public void visitSuperExpression(PsiSuperExpression expression) { - bodyContainsForbiddenRefs[0] = true; + if (expression.getQualifier() == null) { + bodyContainsForbiddenRefs[0] = true; + } } }); if (!bodyContainsForbiddenRefs[0]) { diff --git a/java/java-impl/src/com/intellij/codeInspection/LambdaCanBeMethReferenceInspection.java b/java/java-impl/src/com/intellij/codeInspection/LambdaCanBeMethReferenceInspection.java index 4cacb741f178..399757132ed6 100644 --- a/java/java-impl/src/com/intellij/codeInspection/LambdaCanBeMethReferenceInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/LambdaCanBeMethReferenceInspection.java @@ -176,6 +176,12 @@ public class LambdaCanBeMethReferenceInspection extends BaseJavaLocalInspectionT } super.visitReferenceExpression(expression); } + + @Override + public void visitMethodCallExpression(PsiMethodCallExpression expression) { + usedInQualifier.set(true); + super.visitMethodCallExpression(expression); + } }); if (usedInQualifier.get()) return null; } diff --git a/java/java-impl/src/com/intellij/ide/hierarchy/type/TypeHierarchyBrowser.java b/java/java-impl/src/com/intellij/ide/hierarchy/type/TypeHierarchyBrowser.java index 36ade8fff70b..f13f4010eac2 100644 --- a/java/java-impl/src/com/intellij/ide/hierarchy/type/TypeHierarchyBrowser.java +++ b/java/java-impl/src/com/intellij/ide/hierarchy/type/TypeHierarchyBrowser.java @@ -129,7 +129,7 @@ public final class TypeHierarchyBrowser extends TypeHierarchyBrowserBase { } public static class BaseOnThisTypeAction extends TypeHierarchyBrowserBase.BaseOnThisTypeAction { - protected boolean isEnabled(final HierarchyBrowserBaseEx browser, final PsiElement psiElement) { + protected boolean isEnabled(@NotNull final HierarchyBrowserBaseEx browser, @NotNull final PsiElement psiElement) { return super.isEnabled(browser, psiElement) && !CommonClassNames.JAVA_LANG_OBJECT.equals(((PsiClass)psiElement).getQualifiedName()); } } diff --git a/java/java-impl/src/com/intellij/openapi/module/JavaModuleType.java b/java/java-impl/src/com/intellij/openapi/module/JavaModuleType.java index 2c4149946054..96416c2d3f5d 100644 --- a/java/java-impl/src/com/intellij/openapi/module/JavaModuleType.java +++ b/java/java-impl/src/com/intellij/openapi/module/JavaModuleType.java @@ -103,8 +103,8 @@ public class JavaModuleType extends ModuleType { @Nullable @Override - public SettingsStep createSettingsStep(WizardContext context, ModuleBuilder moduleBuilder) { - return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(context, moduleBuilder, new Condition() { + public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder) { + return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, moduleBuilder, new Condition() { @Override public boolean value(SdkType sdk) { return sdk instanceof JavaSdkType; diff --git a/java/java-impl/src/com/intellij/openapi/options/colors/pages/JavaColorSettingsPage.java b/java/java-impl/src/com/intellij/openapi/options/colors/pages/JavaColorSettingsPage.java index 9ec9109d9db7..96956e40e65d 100644 --- a/java/java-impl/src/com/intellij/openapi/options/colors/pages/JavaColorSettingsPage.java +++ b/java/java-impl/src/com/intellij/openapi/options/colors/pages/JavaColorSettingsPage.java @@ -66,18 +66,22 @@ public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColor new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.type.parameter"), CodeInsightColors.TYPE_PARAMETER_NAME_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.abstract.class"), CodeInsightColors.ABSTRACT_CLASS_NAME_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.interface"), CodeInsightColors.INTERFACE_NAME_ATTRIBUTES), + new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.enum"), CodeInsightColors.ENUM_NAME_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.local.variable"), CodeInsightColors.LOCAL_VARIABLE_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.reassigned.local.variable"), CodeInsightColors.REASSIGNED_LOCAL_VARIABLE_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.reassigned.parameter"), CodeInsightColors.REASSIGNED_PARAMETER_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.implicit.anonymous.parameter"), CodeInsightColors.IMPLICIT_ANONYMOUS_CLASS_PARAMETER_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.instance.field"), CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.static.field"), CodeInsightColors.STATIC_FIELD_ATTRIBUTES), + new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.static.final.field"), CodeInsightColors.STATIC_FINAL_FIELD_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.parameter"), CodeInsightColors.PARAMETER_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.method.call"), CodeInsightColors.METHOD_CALL_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.method.declaration"), CodeInsightColors.METHOD_DECLARATION_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.constructor.call"), CodeInsightColors.CONSTRUCTOR_CALL_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.constructor.declaration"), CodeInsightColors.CONSTRUCTOR_DECLARATION_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.static.method"), CodeInsightColors.STATIC_METHOD_ATTRIBUTES), + new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.abstract.method"), CodeInsightColors.ABSTRACT_METHOD_ATTRIBUTES), + new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.inherited.method"), CodeInsightColors.INHERITED_METHOD_ATTRIBUTES), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.bad.character"), HighlighterColors.BAD_CHARACTER), @@ -100,18 +104,22 @@ public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColor ourTags.put("reassignedParameter", CodeInsightColors.REASSIGNED_PARAMETER_ATTRIBUTES); ourTags.put("implicitAnonymousParameter", CodeInsightColors.IMPLICIT_ANONYMOUS_CLASS_PARAMETER_ATTRIBUTES); ourTags.put("static", CodeInsightColors.STATIC_FIELD_ATTRIBUTES); + ourTags.put("static_final", CodeInsightColors.STATIC_FINAL_FIELD_ATTRIBUTES); ourTags.put("deprecated", CodeInsightColors.DEPRECATED_ATTRIBUTES); ourTags.put("constructorCall", CodeInsightColors.CONSTRUCTOR_CALL_ATTRIBUTES); ourTags.put("constructorDeclaration", CodeInsightColors.CONSTRUCTOR_DECLARATION_ATTRIBUTES); ourTags.put("methodCall", CodeInsightColors.METHOD_CALL_ATTRIBUTES); ourTags.put("methodDeclaration", CodeInsightColors.METHOD_DECLARATION_ATTRIBUTES); ourTags.put("static_method", CodeInsightColors.STATIC_METHOD_ATTRIBUTES); + ourTags.put("abstract_method", CodeInsightColors.ABSTRACT_METHOD_ATTRIBUTES); + ourTags.put("inherited_method", CodeInsightColors.INHERITED_METHOD_ATTRIBUTES); ourTags.put("param", CodeInsightColors.PARAMETER_ATTRIBUTES); ourTags.put("class", CodeInsightColors.CLASS_NAME_ATTRIBUTES); ourTags.put("anonymousClass", CodeInsightColors.ANONYMOUS_CLASS_NAME_ATTRIBUTES); ourTags.put("typeParameter", CodeInsightColors.TYPE_PARAMETER_NAME_ATTRIBUTES); ourTags.put("abstractClass", CodeInsightColors.ABSTRACT_CLASS_NAME_ATTRIBUTES); ourTags.put("interface", CodeInsightColors.INTERFACE_NAME_ATTRIBUTES); + ourTags.put("enum", CodeInsightColors.ENUM_NAME_ATTRIBUTES); ourTags.put("annotationName", CodeInsightColors.ANNOTATION_NAME_ATTRIBUTES); ourTags.put("annotationAttributeName", CodeInsightColors.ANNOTATION_ATTRIBUTE_NAME_ATTRIBUTES); } @@ -165,10 +173,11 @@ public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColor "\n" + " public SomeClass(AnInterface param, int[] reassignedParam) {\n" + " int localVar = \"IntelliJ\"; // Error, incompatible types\n" + - " System.out.println(anotherString + field + localVar);\n" + + " System.out.println(anotherString + toString() + localVar);\n" + " long time = Date.parse(\"1.2.3\"); // Method is deprecated\n" + " int reassignedValue = this.staticField; \n" + " reassignedValue ++; \n" + + " field.run(); \n" + " new SomeClass() {\n" + " {\n" + " int a = localVar;\n" + @@ -177,8 +186,9 @@ public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColor " reassignedParam = new int[2];\n" + " }\n" + "}\n" + + "enum AnEnum { CONST1, CONST2 }\n"+ "interface AnInterface {\n" + - " int CONSTANT = 2;\n" + + " int CONSTANT = 2;\n" + " void method();\n" + "}\n" + "abstract class SomeAbstractClass {\n" + diff --git a/java/java-impl/src/com/intellij/openapi/vcs/contentAnnotation/VcsContentAnnotationExceptionFilter.java b/java/java-impl/src/com/intellij/openapi/vcs/contentAnnotation/VcsContentAnnotationExceptionFilter.java index 9a49434b2ce2..b52273b0ecbe 100644 --- a/java/java-impl/src/com/intellij/openapi/vcs/contentAnnotation/VcsContentAnnotationExceptionFilter.java +++ b/java/java-impl/src/com/intellij/openapi/vcs/contentAnnotation/VcsContentAnnotationExceptionFilter.java @@ -40,6 +40,7 @@ import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.Consumer; import com.intellij.util.SmartList; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; @@ -57,7 +58,7 @@ public class VcsContentAnnotationExceptionFilter implements Filter, FilterMixin private final VcsContentAnnotationSettings mySettings; private Map myRevNumbersCache; - public VcsContentAnnotationExceptionFilter(GlobalSearchScope scope) { + public VcsContentAnnotationExceptionFilter(@NotNull GlobalSearchScope scope) { myScope = scope; myProject = scope.getProject(); mySettings = VcsContentAnnotationSettings.getInstance(myProject); diff --git a/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java index a1dda59afe63..0b5b3f463993 100644 --- a/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java +++ b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java @@ -17,6 +17,12 @@ package com.intellij.psi.codeStyle.arrangement; import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.SyntaxHighlighterColors; +import com.intellij.openapi.editor.colors.CodeInsightColors; +import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsScheme; +import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.TextRange; @@ -31,6 +37,7 @@ import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher; import com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule; import com.intellij.psi.codeStyle.arrangement.model.*; import com.intellij.psi.codeStyle.arrangement.order.ArrangementEntryOrderType; +import com.intellij.psi.codeStyle.arrangement.settings.ArrangementColorsAware; import com.intellij.psi.codeStyle.arrangement.settings.ArrangementConditionsGrouper; import com.intellij.psi.codeStyle.arrangement.settings.ArrangementStandardSettingsAware; import com.intellij.util.Function; @@ -39,7 +46,9 @@ import com.intellij.util.containers.ContainerUtilRt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.awt.*; import java.util.*; +import java.util.List; import static com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType.*; import static com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier.*; @@ -49,7 +58,7 @@ import static com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier.* * @since 7/20/12 2:31 PM */ public class JavaRearranger implements Rearranger, ArrangementStandardSettingsAware, - ArrangementConditionsGrouper + ArrangementConditionsGrouper, ArrangementColorsAware { // Type @@ -201,6 +210,7 @@ public class JavaRearranger implements Rearranger, break; case OVERRIDDEN_METHODS: setupOverriddenMethods(parseInfo); + default: assert false; } } } @@ -374,4 +384,66 @@ public class JavaRearranger implements Rearranger, } return orderType == null || orderTypes.contains(orderType); } + + @Nullable + @Override + public TextAttributes getTextAttributes(@NotNull EditorColorsScheme scheme, @NotNull ArrangementSettingType type, boolean selected) { + if (selected) { + TextAttributes attributes = new TextAttributes(); + attributes.setForegroundColor(scheme.getColor(EditorColors.SELECTION_FOREGROUND_COLOR)); + attributes.setBackgroundColor(scheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR)); + return attributes; + } + if (type == ArrangementSettingType.MODIFIER) { + return getAttributes(scheme, SyntaxHighlighterColors.KEYWORD); + } + else if (type == ArrangementSettingType.TYPE) { + return getAttributes(scheme, CodeInsightColors.CLASS_NAME_ATTRIBUTES, CodeInsightColors.INTERFACE_NAME_ATTRIBUTES); + } + return null; + } + + @Nullable + private static TextAttributes getAttributes(@NotNull EditorColorsScheme scheme, @NotNull TextAttributesKey ... keys) { + TextAttributes result = null; + for (TextAttributesKey key : keys) { + TextAttributes attributes = scheme.getAttributes(key); + if (attributes == null) { + continue; + } + + if (result == null) { + result = attributes; + } + + Color currentForegroundColor = result.getForegroundColor(); + if (currentForegroundColor == null) { + result.setForegroundColor(attributes.getForegroundColor()); + } + + Color currentBackgroundColor = result.getBackgroundColor(); + if (currentBackgroundColor == null) { + result.setBackgroundColor(attributes.getBackgroundColor()); + } + + if (result.getForegroundColor() != null && result.getBackgroundColor() != null) { + return result; + } + } + + if (result != null && result.getForegroundColor() == null) { + return null; + } + + if (result != null && result.getBackgroundColor() == null) { + result.setBackgroundColor(scheme.getDefaultBackground()); + } + return result; + } + + @Nullable + @Override + public Color getBorderColor(boolean selected) { + return null; + } } diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationConflictsPanel.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationConflictsPanel.java index 2121000558bf..bfb07f1d0e64 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationConflictsPanel.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationConflictsPanel.java @@ -19,6 +19,7 @@ import com.intellij.openapi.project.Project; import com.intellij.packageDependencies.ui.UsagesPanel; import com.intellij.usageView.UsageInfo; import com.intellij.usages.UsageInfoToUsageConverter; +import org.jetbrains.annotations.NotNull; /** * @author anna @@ -38,7 +39,7 @@ public class MigrationConflictsPanel extends UsagesPanel{ } @Override - public void showUsages(final UsageInfoToUsageConverter.TargetElementsDescriptor descriptor, final UsageInfo[] usageInfos) { + public void showUsages(@NotNull final UsageInfoToUsageConverter.TargetElementsDescriptor descriptor, @NotNull final UsageInfo[] usageInfos) { super.showUsages(descriptor, usageInfos); } } \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java index 164b8961182c..8ec16d824eb2 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java @@ -238,7 +238,12 @@ public class RefactoringUtil { if (importList != null) { final PsiImportStaticStatement[] importStaticStatements = importList.getImportStaticStatements(); for(PsiImportStaticStatement stmt: importStaticStatements) { - if (!stmt.isOnDemand() && stmt.resolveTargetClass() == member.getContainingClass() && Comparing.strEqual(stmt.getReferenceName(), member.getName())) { + final PsiClass containingClass = member.getContainingClass(); + final String referenceName = stmt.getReferenceName(); + if (!stmt.isOnDemand() && stmt.resolveTargetClass() == containingClass && Comparing.strEqual(referenceName, member.getName())) { + if (member instanceof PsiMethod) { + return containingClass.findMethodsByName(referenceName, false).length == 1; + } return true; } } diff --git a/java/java-impl/src/com/intellij/slicer/CanItBeNullAction.java b/java/java-impl/src/com/intellij/slicer/CanItBeNullAction.java index 1f2c28ccca4a..fed418df6862 100644 --- a/java/java-impl/src/com/intellij/slicer/CanItBeNullAction.java +++ b/java/java-impl/src/com/intellij/slicer/CanItBeNullAction.java @@ -25,7 +25,7 @@ import com.intellij.psi.*; */ public class CanItBeNullAction extends AnAction { private final SliceTreeBuilder myTreeBuilder; - private static final String TEXT = "Can it be null?"; + private static final String TEXT = "Group by leaf expression nullness"; public CanItBeNullAction(SliceTreeBuilder treeBuilder) { super(TEXT, "Determine whether null can flow into this expression", AllIcons.Debugger.Db_disabled_breakpoint_process); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java index 4893956ab198..3c06961feca4 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java @@ -273,8 +273,8 @@ public class PsiResolveHelperImpl implements PsiResolveHelper { } } - if (lowerBound != PsiType.NULL) return new Pair(lowerBound, ConstraintType.EQUALS); if (rawInference != null) return rawInference; + if (lowerBound != PsiType.NULL) return new Pair(lowerBound, ConstraintType.EQUALS); if (parent != null) { final Pair constraint = diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DoNotAcceptLowerBoundIfRaw.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DoNotAcceptLowerBoundIfRaw.java new file mode 100644 index 000000000000..b9bbcbe05069 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DoNotAcceptLowerBoundIfRaw.java @@ -0,0 +1,17 @@ +import java.util.*; + +class Test { + interface Condition {} + class IOC implements Condition {} + + static List filter(T[] c, Condition con) { + return null; + } + + interface OE {} + interface LOE extends OE {} + + void foo(OE[] es, IOC con) { + List l = filter(es, con); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterQualifiedThis.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterQualifiedThis.java new file mode 100644 index 000000000000..2b40ee0dc77c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterQualifiedThis.java @@ -0,0 +1,14 @@ +// "Replace with lambda" "true" +class Test { + interface Eff { + B f(A a); + } + + interface InOut { + A run() throws IOException; + + InOut bind(final Eff> f) default { + return () -> f.f(InOut.this.run()).run(); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeQualifiedThis.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeQualifiedThis.java new file mode 100644 index 000000000000..a23bd4099c2e --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeQualifiedThis.java @@ -0,0 +1,19 @@ +// "Replace with lambda" "true" +class Test { + interface Eff { + B f(A a); + } + + interface InOut { + A run() throws IOException; + + InOut bind(final Eff> f) default { + return new InOut() { + @Override + public B run() throws IOException { + return f.f(InOut.this.run()).run(); + } + }; + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2methodReference/afterQualifierDoesntUseParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2methodReference/afterQualifierDoesntUseParams.java deleted file mode 100644 index 02d8ad5ed0fd..000000000000 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2methodReference/afterQualifierDoesntUseParams.java +++ /dev/null @@ -1,12 +0,0 @@ -// "Replace with method reference" "true" -interface Foo { - B f(A a); -} - -interface DeeBee { - A run(Void c) throws SQLException; - - DeeBee bind(final Foo> f) default { - return f.f(null)::run; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2methodReference/beforeQualifierDoesntUseParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2methodReference/beforeQualifierDoesntUseParams.java index 6aa032f10471..7449a3be34cf 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2methodReference/beforeQualifierDoesntUseParams.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2methodReference/beforeQualifierDoesntUseParams.java @@ -1,4 +1,4 @@ -// "Replace with method reference" "true" +// "Replace with method reference" "false" interface Foo { B f(A a); } diff --git a/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/after/bar/A.java b/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/after/bar/A.java new file mode 100644 index 000000000000..dc0831b5628e --- /dev/null +++ b/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/after/bar/A.java @@ -0,0 +1,5 @@ +package bar; + +public class A { + public static void foo() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/after/bar/B.java b/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/after/bar/B.java new file mode 100644 index 000000000000..010f00c50a4d --- /dev/null +++ b/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/after/bar/B.java @@ -0,0 +1,5 @@ +package bar; + +public class B { + public static void foo(String s) {} +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/after/bar/U.java b/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/after/bar/U.java new file mode 100644 index 000000000000..ba41fd861b7c --- /dev/null +++ b/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/after/bar/U.java @@ -0,0 +1,7 @@ +import bar.A; + +class Usage { + void bar() { + A.foo(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/before/bar/A.java b/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/before/bar/A.java new file mode 100644 index 000000000000..e1731470a60f --- /dev/null +++ b/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/before/bar/A.java @@ -0,0 +1,4 @@ +package bar; + +public class A { +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/before/bar/B.java b/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/before/bar/B.java new file mode 100644 index 000000000000..b5ff307bf5b5 --- /dev/null +++ b/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/before/bar/B.java @@ -0,0 +1,6 @@ +package bar; + +public class B { + public static void foo() {} + public static void foo(String s) {} +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/before/bar/U.java b/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/before/bar/U.java new file mode 100644 index 000000000000..b7caf738654f --- /dev/null +++ b/java/java-tests/testData/refactoring/moveMembers/staticImportAndOverridenMethods/before/bar/U.java @@ -0,0 +1,7 @@ +import static bar.B.foo; + +class Usage { + void bar() { + foo(); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index 4cd4def05a2e..aed5600e8fe2 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -183,6 +183,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testInconvertibleTypes() throws Exception { doTest(false); } public void testIncompatibleReturnType() throws Exception { doTest(false); } public void testContinueInferenceAfterFirstRawResult() throws Exception { doTest(false); } + public void testDoNotAcceptLowerBoundIfRaw() throws Exception { doTest(false); } public void testStaticOverride() throws Exception { doTest(false); } public void testTypeArgumentsGivenOnRawType() throws Exception { doTest(false); } public void testTypeArgumentsGivenOnAnonymousClassCreation() throws Exception { doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/TypeInferenceTest.java b/java/java-tests/testSrc/com/intellij/psi/resolve/TypeInferenceTest.java index 32b2beac3263..cfa1c9348144 100644 --- a/java/java-tests/testSrc/com/intellij/psi/resolve/TypeInferenceTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/TypeInferenceTest.java @@ -144,7 +144,7 @@ public class TypeInferenceTest extends Resolve15TestCase { } public void testInferUnchecked () throws Exception { - checkResolvesTo(CommonClassNames.JAVA_LANG_STRING); + checkResolvesTo(CommonClassNames.JAVA_LANG_OBJECT); } public void testInferNotNull () throws Exception { diff --git a/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java b/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java index fbb83329f740..bc0349b1de9b 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java @@ -105,6 +105,10 @@ public class MoveMembersTest extends MultiFileTestCase { doTest("B", "A", 0); } + public void testStaticImportAndOverridenMethods() throws Exception { + doTest("bar.B", "bar.A", 0); + } + public void testWritableField() throws Exception { try { doTest("B", "A", 0); diff --git a/java/openapi/src/com/intellij/execution/filters/ExceptionWorker.java b/java/openapi/src/com/intellij/execution/filters/ExceptionWorker.java index 803e69d6bcfa..16c129f53e98 100644 --- a/java/openapi/src/com/intellij/execution/filters/ExceptionWorker.java +++ b/java/openapi/src/com/intellij/execution/filters/ExceptionWorker.java @@ -30,6 +30,7 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.PsiShortNamesCache; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.awt.*; @@ -44,8 +45,7 @@ public class ExceptionWorker { private static final String AT_PREFIX = AT + " "; private static final String STANDALONE_AT = " " + AT + " "; - private static final TextAttributes HYPERLINK_ATTRIBUTES = EditorColorsManager - .getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES); + private static final TextAttributes HYPERLINK_ATTRIBUTES = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES); private final Project myProject; private final GlobalSearchScope mySearchScope; @@ -55,7 +55,7 @@ public class ExceptionWorker { private String myMethod; private Trinity myInfo; - public ExceptionWorker(Project project, final GlobalSearchScope searchScope) { + public ExceptionWorker(@NotNull Project project, @NotNull GlobalSearchScope searchScope) { myProject = project; mySearchScope = searchScope; } @@ -104,35 +104,7 @@ public class ExceptionWorker { final int highlightEndOffset = textStartOffset + rparenthIndex; final VirtualFile virtualFile = myFile.getVirtualFile(); - HyperlinkInfo linkInfo = new HyperlinkInfo() { - @Override - public void navigate(Project project) { - VirtualFile currentVirtualFile = null; - - AccessToken accessToken = ReadAction.start(); - - try { - if (!virtualFile.isValid()) return; - - PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile); - if (psiFile != null) { - PsiElement navigationElement = psiFile.getNavigationElement(); // Sources may be downloaded. - if (navigationElement instanceof PsiFile) { - currentVirtualFile = ((PsiFile)navigationElement).getVirtualFile(); - } - } - - if (currentVirtualFile == null) { - currentVirtualFile = virtualFile; - } - } - finally { - accessToken.finish(); - } - - new OpenFileHyperlinkInfo(myProject, currentVirtualFile, lineNumber - 1).navigate(project); - } - }; + HyperlinkInfo linkInfo = new MyHyperlinkInfo(myProject, virtualFile, lineNumber); TextAttributes attributes = HYPERLINK_ATTRIBUTES.clone(); if (!ProjectRootManager.getInstance(myProject).getFileIndex().isInContent(virtualFile)) { @@ -226,4 +198,44 @@ public class ExceptionWorker { } return pos; } + + private static class MyHyperlinkInfo implements HyperlinkInfo { + private final VirtualFile myVirtualFile; + private final int myLineNumber; + private final Project myProject; + + public MyHyperlinkInfo(@NotNull Project project, @NotNull VirtualFile virtualFile, int lineNumber) { + myProject = project; + myVirtualFile = virtualFile; + myLineNumber = lineNumber; + } + + @Override + public void navigate(Project project) { + VirtualFile currentVirtualFile = null; + + AccessToken accessToken = ReadAction.start(); + + try { + if (!myVirtualFile.isValid()) return; + + PsiFile psiFile = PsiManager.getInstance(project).findFile(myVirtualFile); + if (psiFile != null) { + PsiElement navigationElement = psiFile.getNavigationElement(); // Sources may be downloaded. + if (navigationElement instanceof PsiFile) { + currentVirtualFile = ((PsiFile)navigationElement).getVirtualFile(); + } + } + + if (currentVirtualFile == null) { + currentVirtualFile = myVirtualFile; + } + } + finally { + accessToken.finish(); + } + + new OpenFileHyperlinkInfo(myProject, currentVirtualFile, myLineNumber - 1).navigate(project); + } + } } diff --git a/java/openapi/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactory.java b/java/openapi/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactory.java index 923b1e15e494..4a904f4e566a 100644 --- a/java/openapi/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactory.java +++ b/java/openapi/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactory.java @@ -72,7 +72,5 @@ public abstract class ProjectWizardStepFactory { @Nullable public abstract ModuleWizardStep createSupportForFrameworksStep(WizardContext context, ModuleBuilder builder, ModulesProvider modulesProvider); - public abstract SettingsStep createSettingsStep(WizardContext context); - - public abstract SettingsStep createJavaSettingsStep(WizardContext context, ModuleBuilder moduleBuilder, Condition sdkFilter); + public abstract ModuleWizardStep createJavaSettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder, Condition sdkFilter); } diff --git a/platform/core-api/src/com/intellij/ide/FileIconProvider.java b/platform/core-api/src/com/intellij/ide/FileIconProvider.java index 9caacdeea1b7..5deb6a486a54 100644 --- a/platform/core-api/src/com/intellij/ide/FileIconProvider.java +++ b/platform/core-api/src/com/intellij/ide/FileIconProvider.java @@ -23,6 +23,7 @@ import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Iconable; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -31,5 +32,5 @@ public interface FileIconProvider { ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.fileIconProvider"); @Nullable - Icon getIcon(VirtualFile file, @Iconable.IconFlags int flags, @Nullable Project project); + Icon getIcon(@NotNull VirtualFile file, @Iconable.IconFlags int flags, @Nullable Project project); } \ No newline at end of file diff --git a/platform/core-api/src/com/intellij/lang/ASTNode.java b/platform/core-api/src/com/intellij/lang/ASTNode.java index 16c3ca54e89c..fe603470ad3a 100644 --- a/platform/core-api/src/com/intellij/lang/ASTNode.java +++ b/platform/core-api/src/com/intellij/lang/ASTNode.java @@ -153,7 +153,7 @@ public interface ASTNode extends UserDataHolder { * @param anchorBefore the node before which the child node is inserted. * @since 7.0 */ - void addLeaf(@NotNull IElementType leafType, CharSequence leafText, ASTNode anchorBefore); + void addLeaf(@NotNull IElementType leafType, CharSequence leafText, @Nullable ASTNode anchorBefore); /** * Removes the specified node from the list of children of this node. diff --git a/platform/core-api/src/com/intellij/openapi/editor/colors/CodeInsightColors.java b/platform/core-api/src/com/intellij/openapi/editor/colors/CodeInsightColors.java index 823769f0eed8..f17d13146a61 100644 --- a/platform/core-api/src/com/intellij/openapi/editor/colors/CodeInsightColors.java +++ b/platform/core-api/src/com/intellij/openapi/editor/colors/CodeInsightColors.java @@ -37,15 +37,19 @@ public interface CodeInsightColors { TextAttributesKey IMPLICIT_ANONYMOUS_CLASS_PARAMETER_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("IMPLICIT_ANONYMOUS_CLASS_PARAMETER_ATTRIBUTES"); TextAttributesKey INSTANCE_FIELD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("INSTANCE_FIELD_ATTRIBUTES"); TextAttributesKey STATIC_FIELD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("STATIC_FIELD_ATTRIBUTES"); + TextAttributesKey STATIC_FINAL_FIELD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("STATIC_FINAL_FIELD_ATTRIBUTES"); TextAttributesKey PARAMETER_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("PARAMETER_ATTRIBUTES"); TextAttributesKey CLASS_NAME_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("CLASS_NAME_ATTRIBUTES"); TextAttributesKey ANONYMOUS_CLASS_NAME_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("ANONYMOUS_CLASS_NAME_ATTRIBUTES"); TextAttributesKey TYPE_PARAMETER_NAME_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("TYPE_PARAMETER_NAME_ATTRIBUTES"); TextAttributesKey INTERFACE_NAME_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("INTERFACE_NAME_ATTRIBUTES"); + TextAttributesKey ENUM_NAME_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("ENUM_NAME_ATTRIBUTES"); TextAttributesKey ABSTRACT_CLASS_NAME_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("ABSTRACT_CLASS_NAME_ATTRIBUTES"); TextAttributesKey METHOD_CALL_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("METHOD_CALL_ATTRIBUTES"); TextAttributesKey METHOD_DECLARATION_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("METHOD_DECLARATION_ATTRIBUTES"); TextAttributesKey STATIC_METHOD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("STATIC_METHOD_ATTRIBUTES"); + TextAttributesKey ABSTRACT_METHOD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("ABSTRACT_METHOD_ATTRIBUTES"); + TextAttributesKey INHERITED_METHOD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("INHERITED_METHOD_ATTRIBUTES"); TextAttributesKey CONSTRUCTOR_CALL_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("CONSTRUCTOR_CALL_ATTRIBUTES"); TextAttributesKey CONSTRUCTOR_DECLARATION_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("CONSTRUCTOR_DECLARATION_ATTRIBUTES"); TextAttributesKey ANNOTATION_NAME_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("ANNOTATION_NAME_ATTRIBUTES"); diff --git a/platform/core-api/src/com/intellij/util/FileIconKey.java b/platform/core-api/src/com/intellij/util/FileIconKey.java index 7124c5ccca65..286a6147d832 100644 --- a/platform/core-api/src/com/intellij/util/FileIconKey.java +++ b/platform/core-api/src/com/intellij/util/FileIconKey.java @@ -18,6 +18,7 @@ package com.intellij.util; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Iconable; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; /** * @author Konstantin Bulenkov @@ -27,7 +28,7 @@ class FileIconKey { private final Project myProject; @Iconable.IconFlags private final int myFlags; - FileIconKey(final VirtualFile file, final Project project, @Iconable.IconFlags int flags) { + FileIconKey(@NotNull VirtualFile file, final Project project, @Iconable.IconFlags int flags) { myFile = file; myProject = project; myFlags = flags; diff --git a/platform/core-api/src/com/intellij/util/IconUtil.java b/platform/core-api/src/com/intellij/util/IconUtil.java index 7ff53d502f13..30f5ee6b7517 100644 --- a/platform/core-api/src/com/intellij/util/IconUtil.java +++ b/platform/core-api/src/com/intellij/util/IconUtil.java @@ -46,7 +46,7 @@ import java.awt.image.BufferedImage; public class IconUtil { private static final Key PROJECT_WAS_EVER_INITIALIZED = Key.create("iconDeferrer:projectWasEverInitialized"); - private static boolean wasEverInitialized(Project project) { + private static boolean wasEverInitialized(@NotNull Project project) { Boolean was = project.getUserData(PROJECT_WAS_EVER_INITIALIZED); if (was == null) { if (project.isInitialized()) { @@ -61,7 +61,8 @@ public class IconUtil { return was.booleanValue(); } - public static Icon cropIcon(Icon icon, int maxWidth, int maxHeight) { + @NotNull + public static Icon cropIcon(@NotNull Icon icon, int maxWidth, int maxHeight) { if (icon.getIconHeight() <= maxHeight && icon.getIconWidth() <= maxWidth) { return icon; } @@ -90,6 +91,7 @@ public class IconUtil { return new ImageIcon(img); } + @NotNull public static Icon flip(@NotNull Icon icon, boolean horizontal) { int w = icon.getIconWidth(); int h = icon.getIconHeight(); @@ -109,8 +111,8 @@ public class IconUtil { g.dispose(); return new ImageIcon(second); } - - public static Icon getIcon(final VirtualFile file, @Iconable.IconFlags final int flags, @Nullable final Project project) { + + public static Icon getIcon(@NotNull final VirtualFile file, @Iconable.IconFlags final int flags, @Nullable final Project project) { Icon lastIcon = Iconable.LastComputedIcon.get(file, flags); final Icon base = lastIcon != null ? lastIcon : VirtualFilePresentation.getIcon(file); @@ -151,7 +153,7 @@ public class IconUtil { } @Nullable - private static Icon getProvidersIcon(VirtualFile file, @Iconable.IconFlags int flags, Project project) { + private static Icon getProvidersIcon(@NotNull VirtualFile file, @Iconable.IconFlags int flags, Project project) { for (FileIconProvider provider : getProviders()) { final Icon icon = provider.getIcon(file, flags, project); if (icon != null) return icon; @@ -159,6 +161,7 @@ public class IconUtil { return null; } + @NotNull public static Icon getEmptyIcon(boolean showVisibility) { RowIcon baseIcon = new RowIcon(2); baseIcon.setIcon(createEmptyIconLike(PlatformIcons.CLASS_ICON_PATH), 0); @@ -168,8 +171,8 @@ public class IconUtil { return baseIcon; } - @Nullable - private static Icon createEmptyIconLike(final String baseIconPath) { + @NotNull + private static Icon createEmptyIconLike(@NotNull String baseIconPath) { Icon baseIcon = IconLoader.findIcon(baseIconPath); if (baseIcon == null) { return EmptyIcon.ICON_16; @@ -265,7 +268,7 @@ public class IconUtil { return getToolbarDecoratorIcon("analyze.png"); } - public static void paintInCenterOf(Component c, Graphics g, Icon icon) { + public static void paintInCenterOf(@NotNull Component c, Graphics g, Icon icon) { final int x = (c.getWidth() - icon.getIconWidth()) / 2; final int y = (c.getHeight() - icon.getIconHeight()) / 2; icon.paintIcon(c, g, x, y); @@ -282,6 +285,7 @@ public class IconUtil { /** * Result icons look like original but have equal (maximum) size */ + @NotNull public static Icon[] getEqualSizedIcons(@NotNull Icon... icons) { Icon[] result = new Icon[icons.length]; int width = 0; @@ -301,7 +305,7 @@ public class IconUtil { private final int myWidth; private final int myHeight; - private IconSizeWrapper(Icon icon, int width, int height) { + private IconSizeWrapper(@NotNull Icon icon, int width, int height) { myIcon = icon; myWidth = width; myHeight = height; diff --git a/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionPointImpl.java b/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionPointImpl.java index a3489c92c53c..cc7b6442d2d3 100644 --- a/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionPointImpl.java +++ b/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionPointImpl.java @@ -110,6 +110,9 @@ public class ExtensionPointImpl implements ExtensionPoint { public synchronized void registerExtension(@NotNull T extension, @NotNull LoadingOrder order) { assert myExtensions.size() == myLoadedAdapters.size(); + ObjectComponentAdapter adapter = new ObjectComponentAdapter(extension, order); + assertClass(extension.getClass()); + if (LoadingOrder.ANY == order) { int index = myLoadedAdapters.size(); if (index > 0) { @@ -118,10 +121,10 @@ public class ExtensionPointImpl implements ExtensionPoint { index--; } } - internalRegisterExtension(extension, new ObjectComponentAdapter(extension, order), index, true); + internalRegisterExtension(extension, adapter, index, true); } else { - myExtensionAdapters.add(new ObjectComponentAdapter(extension, order)); + myExtensionAdapters.add(adapter); processAdapters(); } clearCache(); @@ -177,10 +180,10 @@ public class ExtensionPointImpl implements ExtensionPoint { T t = result[i]; if (i > 0 && result[i] == result[i - 1]) { LOG.error("Duplicate extension found: " + t + "; " + - " Result: "+ Arrays.asList(result)+";\n" + - " extensions: "+ myExtensions+";\n" + - " getExtensionClass(): "+ extensionClass +";\n" + - " size:"+myExtensions.size()+";"+result.length); + " Result: " + Arrays.asList(result) + ";\n" + + " extensions: " + myExtensions + ";\n" + + " getExtensionClass(): " + extensionClass + ";\n" + + " size:" + myExtensions.size() + ";" + result.length); } if (!extensionClass.isAssignableFrom(t.getClass())) { @@ -216,13 +219,17 @@ public class ExtensionPointImpl implements ExtensionPoint { allAdapters.addAll(myLoadedAdapters); myExtensions.clear(); - ExtensionComponentAdapter[] loadedAdapters = myLoadedAdapters.isEmpty() ? ExtensionComponentAdapter.EMPTY_ARRAY : myLoadedAdapters.toArray(new ExtensionComponentAdapter[myLoadedAdapters.size()]); + ExtensionComponentAdapter[] loadedAdapters = myLoadedAdapters.isEmpty() + ? ExtensionComponentAdapter.EMPTY_ARRAY + : myLoadedAdapters.toArray(new ExtensionComponentAdapter[myLoadedAdapters.size()]); myLoadedAdapters.clear(); ExtensionComponentAdapter[] adapters = allAdapters.toArray(new ExtensionComponentAdapter[myExtensionAdapters.size()]); LoadingOrder.sort(adapters); for (ExtensionComponentAdapter adapter : adapters) { //noinspection unchecked T extension = (T)adapter.getExtension(); + assertClass(extension.getClass()); + internalRegisterExtension(extension, adapter, myExtensions.size(), ArrayUtil.find(loadedAdapters, adapter) == -1); } myExtensionAdapters.clear(); @@ -318,7 +325,8 @@ public class ExtensionPointImpl implements ExtensionPoint { try { //noinspection unchecked listener.extensionAdded((T)componentAdapter.getExtension(), componentAdapter.getPluginDescriptor()); - } catch (Throwable e) { + } + catch (Throwable e) { myLogger.error(e); } } @@ -375,11 +383,16 @@ public class ExtensionPointImpl implements ExtensionPoint { return getName(); } - synchronized void registerExtensionAdapter(ExtensionComponentAdapter adapter) { + synchronized void registerExtensionAdapter(@NotNull ExtensionComponentAdapter adapter) { myExtensionAdapters.add(adapter); clearCache(); } + private void assertClass(@NotNull Class extensionClass) { + Class expectedClass = getExtensionClass(); + assert expectedClass.isAssignableFrom(extensionClass) : "Expected: "+ expectedClass +"; Actual: "+ extensionClass; + } + private void clearCache() { myExtensionsCache = null; } @@ -421,7 +434,7 @@ public class ExtensionPointImpl implements ExtensionPoint { private final Object myExtension; private final LoadingOrder myLoadingOrder; - private ObjectComponentAdapter(Object extension, LoadingOrder loadingOrder) { + private ObjectComponentAdapter(@NotNull Object extension, @NotNull LoadingOrder loadingOrder) { super(Object.class.getName(), null, null, null, false); myExtension = extension; myLoadingOrder = loadingOrder; diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java index 8dbb852aa1a7..3d8280155b7e 100644 --- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java +++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java @@ -91,9 +91,13 @@ public abstract class ModuleBuilder extends ProjectBuilder{ } @Nullable - public SettingsStep createSettingsStep(WizardContext wizardContext) { + public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep) { ModuleType type = getModuleType(); - return type == null ? null : type.createSettingsStep(wizardContext, this); + return type == null ? null : type.modifySettingsStep(settingsStep, this); + } + + public boolean isTemplateBased() { + return false; } public void setName(String name) { diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java index 3a1cefe23e5e..7d84d0e1d40a 100644 --- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java +++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java @@ -15,24 +15,19 @@ */ package com.intellij.ide.util.projectWizard; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import javax.swing.*; /** * @author Dmitry Avdeev * Date: 10/23/12 */ -public abstract class SettingsStep extends ModuleWizardStep { +public interface SettingsStep { - @NotNull - public abstract JComponent getSettingsPanel(); + WizardContext getContext(); - @Nullable - public abstract JComponent getExpertSettingsPanel(); + void addSettingsField(String label, JComponent field); - public abstract SettingsStep addField(String label, JComponent field); + void addSettingsComponent(JComponent component); - public abstract SettingsStep addExpertPanel(JComponent panel); + void addExpertPanel(JComponent panel); } diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java index c99f0fdfdff8..8486e306f989 100644 --- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java +++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java @@ -171,7 +171,7 @@ public class WizardContext { return myProjectBuilder; } - public void setProjectBuilder(final ProjectBuilder projectBuilder) { + public void setProjectBuilder(@Nullable final ProjectBuilder projectBuilder) { myProjectBuilder = projectBuilder; } diff --git a/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java b/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java index b378069698da..05bb5b25181a 100644 --- a/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java +++ b/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java @@ -50,7 +50,7 @@ public abstract class ModuleType { } @Nullable - public SettingsStep createSettingsStep(WizardContext context, ModuleBuilder moduleBuilder) { + public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder) { return null; } diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/settings/ArrangementColorsAware.java b/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/settings/ArrangementColorsAware.java index 8884a845a6d3..6c4365f631e9 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/settings/ArrangementColorsAware.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/settings/ArrangementColorsAware.java @@ -15,7 +15,8 @@ */ package com.intellij.psi.codeStyle.arrangement.settings; -import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.editor.colors.EditorColorsScheme; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.psi.codeStyle.arrangement.model.ArrangementSettingType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -24,6 +25,8 @@ import java.awt.*; /** * Callback which allows to customize colors used at the arrangement UI on the basis of existing coloring scheme. + *

+ * It's save to return 'null' from all color retrieval services - default values will be used then. * * @author Denis Zhdanov * @since 10/23/12 11:53 PM @@ -31,10 +34,7 @@ import java.awt.*; public interface ArrangementColorsAware { @Nullable - TextAttributesKey getTextKey(@NotNull ArrangementSettingType type, boolean selected); - - @Nullable - TextAttributesKey getTextBackgroundKey(@NotNull ArrangementSettingType type, boolean selected); + TextAttributes getTextAttributes(@NotNull EditorColorsScheme scheme, @NotNull ArrangementSettingType type, boolean selected); @Nullable Color getBorderColor(boolean selected); diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProvider.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProvider.java index 117bc1b8c409..9b467962a46d 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProvider.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProvider.java @@ -15,6 +15,7 @@ */ package com.intellij.application.options.codeStyle.arrangement; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.psi.codeStyle.arrangement.model.ArrangementSettingType; import org.jetbrains.annotations.NotNull; @@ -28,10 +29,7 @@ public interface ArrangementColorsProvider { @NotNull Color getBorderColor(boolean selected); - + @NotNull - Color getTextColor(@NotNull ArrangementSettingType type, boolean selected); - - @NotNull - Color getTextBackgroundColor(@NotNull ArrangementSettingType type, boolean selected); + TextAttributes getTextAttributes(@NotNull ArrangementSettingType type, boolean selected); } diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProviderImpl.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProviderImpl.java index 9b1858692ae3..a1807f8f59ee 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProviderImpl.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsProviderImpl.java @@ -17,7 +17,6 @@ package com.intellij.application.options.codeStyle.arrangement; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; -import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.psi.codeStyle.arrangement.model.ArrangementSettingType; import com.intellij.psi.codeStyle.arrangement.settings.ArrangementColorsAware; @@ -38,14 +37,10 @@ public class ArrangementColorsProviderImpl implements ArrangementColorsProvider @Nullable private final ArrangementColorsAware myColorsAware; - @NotNull private final Map myTextColors - = new EnumMap(ArrangementSettingType.class); - @NotNull private final Map myBackgroundColors - = new EnumMap(ArrangementSettingType.class); - @NotNull private final Map mySelectedTextColors - = new EnumMap(ArrangementSettingType.class); - @NotNull private final Map mySelectedBackgroundColors - = new EnumMap(ArrangementSettingType.class); + @NotNull private final Map myTextAttributes + = new EnumMap(ArrangementSettingType.class); + @NotNull private final Map mySelectedTextAttributes + = new EnumMap(ArrangementSettingType.class); @NotNull private Color myBorderColor; @NotNull private Color mySelectedBorderColor; @@ -57,7 +52,7 @@ public class ArrangementColorsProviderImpl implements ArrangementColorsProvider applyCustomColors(colorsAware); } } - + @NotNull @Override public Color getBorderColor(boolean selected) { @@ -66,14 +61,8 @@ public class ArrangementColorsProviderImpl implements ArrangementColorsProvider @NotNull @Override - public Color getTextColor(@NotNull ArrangementSettingType type, boolean selected) { - return selected ? mySelectedTextColors.get(type) : myTextColors.get(type); - } - - @NotNull - @Override - public Color getTextBackgroundColor(@NotNull ArrangementSettingType type, boolean selected) { - return selected ? mySelectedBackgroundColors.get(type) : myBackgroundColors.get(type); + public TextAttributes getTextAttributes(@NotNull ArrangementSettingType type, boolean selected) { + return selected ? mySelectedTextAttributes.get(type) : myTextAttributes.get(type); } /** @@ -87,25 +76,25 @@ public class ArrangementColorsProviderImpl implements ArrangementColorsProvider return; } - myTextColors.clear(); - myBackgroundColors.clear(); - mySelectedTextColors.clear(); - mySelectedBackgroundColors.clear(); + myTextAttributes.clear(); + mySelectedTextAttributes.clear(); applyDefaultColors(); applyCustomColors(myColorsAware); } private void applyDefaultColors() { - Color textColor = UIUtil.getTreeTextForeground(); - Color selectedTextColor = UIUtil.getTreeSelectionForeground(); - Color backgroundColor = UIUtil.getPanelBackground(); - Color selectedBackgroundColor = UIUtil.getTreeSelectionBackground(); + TextAttributes normalTextAttributes = new TextAttributes(); + normalTextAttributes.setForegroundColor(UIUtil.getTreeTextForeground()); + normalTextAttributes.setBackgroundColor(UIUtil.getPanelBackground()); + + TextAttributes selectedTextAttributes = new TextAttributes(); + selectedTextAttributes.setForegroundColor(UIUtil.getTreeSelectionForeground()); + selectedTextAttributes.setBackgroundColor(UIUtil.getTreeSelectionBackground()); + for (ArrangementSettingType type : ArrangementSettingType.values()) { - myTextColors.put(type, textColor); - mySelectedTextColors.put(type, selectedTextColor); - myBackgroundColors.put(type, backgroundColor); - mySelectedBackgroundColors.put(type, selectedBackgroundColor); + myTextAttributes.put(type, normalTextAttributes); + mySelectedTextAttributes.put(type, selectedTextAttributes); } myBorderColor = UIUtil.getBorderColor(); @@ -119,10 +108,15 @@ public class ArrangementColorsProviderImpl implements ArrangementColorsProvider private void applyCustomColors(@NotNull ArrangementColorsAware colorsAware) { EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); for (ArrangementSettingType type : ArrangementSettingType.values()) { - applyColorIfPossible(scheme, colorsAware.getTextKey(type, false), type, myTextColors); - applyColorIfPossible(scheme, colorsAware.getTextKey(type, true), type, mySelectedTextColors); - applyColorIfPossible(scheme, colorsAware.getTextBackgroundKey(type, false), type, myBackgroundColors); - applyColorIfPossible(scheme, colorsAware.getTextBackgroundKey(type, true), type, mySelectedBackgroundColors); + TextAttributes textAttributes = colorsAware.getTextAttributes(scheme, type, false); + if (textAttributes != null) { + myTextAttributes.put(type, textAttributes); + } + + TextAttributes selectedTextAttributes = colorsAware.getTextAttributes(scheme, type, true); + if (selectedTextAttributes != null) { + mySelectedTextAttributes.put(type, selectedTextAttributes); + } } Color borderColor = colorsAware.getBorderColor(false); @@ -134,22 +128,4 @@ public class ArrangementColorsProviderImpl implements ArrangementColorsProvider mySelectedBorderColor = selectedBorderColor; } } - - private static void applyColorIfPossible(@NotNull EditorColorsScheme scheme, - @Nullable TextAttributesKey key, - @NotNull ArrangementSettingType type, - @NotNull Map holder) - { - if (key == null) { - return; - } - TextAttributes attributes = scheme.getAttributes(key); - if (attributes == null) { - return; - } - Color color = attributes.getForegroundColor(); - if (color != null) { - holder.put(type, color); - } - } } diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementNodeDisplayManager.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementNodeDisplayManager.java index db7c47ddca9d..bef05441123b 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementNodeDisplayManager.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementNodeDisplayManager.java @@ -16,23 +16,22 @@ package com.intellij.application.options.codeStyle.arrangement; import com.intellij.openapi.application.ApplicationBundle; -import com.intellij.psi.codeStyle.arrangement.ArrangementUtil; import com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingType; import com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType; import com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier; import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition; -import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition; import com.intellij.psi.codeStyle.arrangement.model.ArrangementSettingType; import com.intellij.psi.codeStyle.arrangement.order.ArrangementEntryOrderType; import com.intellij.psi.codeStyle.arrangement.settings.ArrangementStandardSettingsAware; import com.intellij.psi.codeStyle.arrangement.settings.ArrangementStandardSettingsRepresentationAware; +import com.intellij.ui.SimpleColoredComponent; +import com.intellij.ui.SimpleTextAttributes; import gnu.trove.TObjectIntHashMap; import org.jetbrains.annotations.NotNull; -import javax.swing.*; -import java.awt.*; -import java.util.*; +import java.util.Collection; import java.util.List; +import java.util.Map; /** * Encapsulates various functionality related to showing arrangement nodes to end-users. @@ -46,32 +45,43 @@ import java.util.List; public class ArrangementNodeDisplayManager { @NotNull private final TObjectIntHashMap myMaxWidths = new TObjectIntHashMap(); + @NotNull private final ArrangementStandardSettingsAware myFilter; + @NotNull private final ArrangementColorsProvider myColorsProvider; @NotNull private ArrangementStandardSettingsRepresentationAware myRepresentationManager; - private final int myMaxGroupTextWidth; public ArrangementNodeDisplayManager(@NotNull ArrangementStandardSettingsAware filter, - @NotNull ArrangementStandardSettingsRepresentationAware representationManager, - @NotNull List> groupingRules) + @NotNull ArrangementColorsProvider colorsProvider, + @NotNull ArrangementStandardSettingsRepresentationAware representationManager) { + myFilter = filter; + myColorsProvider = colorsProvider; myRepresentationManager = representationManager; - Map> map = ArrangementConfigUtil.buildAvailableConditions(filter, null); - for (Map.Entry> entry : map.entrySet()) { - myMaxWidths.put(entry.getKey(), maxWidth(entry.getValue())); - } - myMaxGroupTextWidth = maxWidth(ArrangementUtil.flatten(groupingRules)); + refreshMaxWidths(); } - private int maxWidth(Collection values) { - JLabel label = new JLabel(); - FontMetrics metrics = label.getFontMetrics(label.getFont()); + private void refreshMaxWidths() { + Map> map = ArrangementConfigUtil.buildAvailableConditions(myFilter, null); + for (Map.Entry> entry : map.entrySet()) { + myMaxWidths.put(entry.getKey(), maxWidth(entry.getKey(), entry.getValue())); + } + } + + private int maxWidth(@NotNull ArrangementSettingType type, @NotNull Collection values) { + SimpleColoredComponent renderer = new SimpleColoredComponent(); int result = 0; for (Object value : values) { - result = Math.max(result, metrics.stringWidth(getDisplayValue(value))); + renderer.clear(); + renderer.append(getDisplayValue(value), SimpleTextAttributes.fromTextAttributes(myColorsProvider.getTextAttributes(type, true))); + result = Math.max(result, renderer.getPreferredSize().width); + + renderer.clear(); + renderer.append(getDisplayValue(value), SimpleTextAttributes.fromTextAttributes(myColorsProvider.getTextAttributes(type, false))); + result = Math.max(result, renderer.getPreferredSize().width); } return result; } - + @NotNull public String getDisplayValue(@NotNull ArrangementAtomMatchCondition setting) { return getDisplayValue(setting.getValue()); @@ -111,10 +121,6 @@ public class ArrangementNodeDisplayManager { return myMaxWidths.get(type); } - public int getMaxGroupTextWidth() { - return myMaxGroupTextWidth; - } - /** * Asks current manager to sort in-place given arrangement condition ids ('field', 'class', 'method', 'public', 'static', 'final' etc). * diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementSettingsPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementSettingsPanel.java index e72d642e24a0..cabba8f12284 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementSettingsPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementSettingsPanel.java @@ -88,9 +88,6 @@ public abstract class ArrangementSettingsPanel extends CodeStyleAbstractPanel { groupingRules = ((ArrangementConditionsGrouper)mySettingsAware).getGroupingConditions(); } - final ArrangementNodeDisplayManager displayManager = new ArrangementNodeDisplayManager( - mySettingsAware, representationManager, groupingRules - ); final ArrangementColorsProvider colorsProvider; if (rearranger instanceof ArrangementColorsAware) { colorsProvider = new ArrangementColorsProviderImpl((ArrangementColorsAware)rearranger); @@ -98,6 +95,10 @@ public abstract class ArrangementSettingsPanel extends CodeStyleAbstractPanel { else { colorsProvider = new ArrangementColorsProviderImpl(null); } + + final ArrangementNodeDisplayManager displayManager = new ArrangementNodeDisplayManager( + mySettingsAware, colorsProvider, representationManager + ); final ActionManager actionManager = ActionManager.getInstance(); final ActionGroup actionGroup = (ActionGroup)actionManager.getAction(ArrangementConstants.ACTION_GROUP_RULE_EDITOR_TOOL_WINDOW); diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementAtomMatchNodeComponent.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementAtomMatchNodeComponent.java index ca55456b1b61..eaeba3c23d81 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementAtomMatchNodeComponent.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementAtomMatchNodeComponent.java @@ -17,10 +17,12 @@ package com.intellij.application.options.codeStyle.arrangement.node.match; import com.intellij.application.options.codeStyle.arrangement.*; import com.intellij.openapi.actionSystem.impl.ActionButton; -import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.RoundedLineBorder; +import com.intellij.ui.SimpleColoredComponent; +import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.awt.RelativePoint; import com.intellij.util.ui.GridBag; import org.jetbrains.annotations.NotNull; @@ -59,7 +61,7 @@ public class ArrangementAtomMatchNodeComponent implements ArrangementMatchNodeCo }; @NotNull - private final JLabel myLabel = new JLabel() { + private final SimpleColoredComponent myTextControl = new SimpleColoredComponent() { @Override public Dimension getMinimumSize() { return getPreferredSize(); @@ -72,10 +74,11 @@ public class ArrangementAtomMatchNodeComponent implements ArrangementMatchNodeCo @Override public Dimension getPreferredSize() { - return myLabelSize == null ? super.getPreferredSize() : myLabelSize; + return myTextControlSize == null ? super.getPreferredSize() : myTextControlSize; } }; - + + @NotNull private final String myText; @NotNull private final ArrangementColorsProvider myColorsProvider; @NotNull private final RoundedLineBorder myBorder; @NotNull private final ArrangementAtomMatchCondition myCondition; @@ -85,7 +88,7 @@ public class ArrangementAtomMatchNodeComponent implements ArrangementMatchNodeCo @NotNull private Color myBackgroundColor; - @Nullable private Dimension myLabelSize; + @Nullable private Dimension myTextControlSize; @Nullable private Rectangle myScreenBounds; private boolean myEnabled = true; @@ -100,9 +103,11 @@ public class ArrangementAtomMatchNodeComponent implements ArrangementMatchNodeCo myColorsProvider = colorsProvider; myCondition = condition; myCloseCallback = closeCallback; - myLabel.setHorizontalAlignment(SwingConstants.CENTER); - myLabel.setText(manager.getDisplayValue(condition)); - myLabelSize = new Dimension(manager.getMaxWidth(condition.getType()), myLabel.getPreferredSize().height); + //myLabel.setHorizontalAlignment(SwingConstants.CENTER); + myText = manager.getDisplayValue(condition); + myTextControl.setTextAlign(SwingConstants.CENTER); + myTextControl.append(myText, SimpleTextAttributes.fromTextAttributes(colorsProvider.getTextAttributes(condition.getType(), false))); + myTextControlSize = new Dimension(manager.getMaxWidth(condition.getType()), myTextControl.getPreferredSize().height); final ArrangementRemoveConditionAction action = new ArrangementRemoveConditionAction(); Icon buttonIcon = action.getTemplatePresentation().getIcon(); @@ -117,11 +122,11 @@ public class ArrangementAtomMatchNodeComponent implements ArrangementMatchNodeCo GridBagConstraints constraints = new GridBag().anchor(GridBagConstraints.CENTER).insets(0, 0, 0, 0); JPanel labelPanel = new JPanel(new GridBagLayout()); - labelPanel.add(myLabel, constraints); + labelPanel.add(myTextControl, constraints); labelPanel.setBorder(IdeBorderFactory.createEmptyBorder(VERTICAL_PADDING, HORIZONTAL_PADDING, VERTICAL_PADDING, HORIZONTAL_PADDING)); labelPanel.setOpaque(false); - final int arcSize = myLabel.getFont().getSize(); + final int arcSize = myTextControl.getFont().getSize(); JPanel roundBorderPanel = new JPanel(new GridBagLayout()) { @Override public void paint(Graphics g) { @@ -188,9 +193,12 @@ public class ArrangementAtomMatchNodeComponent implements ArrangementMatchNodeCo * @param selected flag that indicates if current component should be drawn as 'selected' */ public void setSelected(boolean selected) { - myLabel.setForeground(myColorsProvider.getTextColor(myCondition.getType(), selected)); + myTextControl.clear(); + TextAttributes attributes = myColorsProvider.getTextAttributes(myCondition.getType(), selected); + myTextControl.append(myText, SimpleTextAttributes.fromTextAttributes(attributes)); myBorder.setColor(myColorsProvider.getBorderColor(selected)); - myBackgroundColor = myColorsProvider.getTextBackgroundColor(myCondition.getType(), selected); + myBackgroundColor = attributes.getBackgroundColor(); + myTextControl.setBackground(myBackgroundColor); } public boolean isEnabled() { @@ -251,6 +259,6 @@ public class ArrangementAtomMatchNodeComponent implements ArrangementMatchNodeCo @Override public String toString() { - return myLabel.getText(); + return myText; } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java index 04b794608721..8e8953a402d1 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java @@ -286,14 +286,18 @@ public class HighlightInfo implements Segment { if (type == HighlightInfoType.LOCAL_VARIABLE) return false; if (type == HighlightInfoType.INSTANCE_FIELD) return false; if (type == HighlightInfoType.STATIC_FIELD) return false; + if (type == HighlightInfoType.STATIC_FINAL_FIELD) return false; if (type == HighlightInfoType.PARAMETER) return false; if (type == HighlightInfoType.METHOD_CALL) return false; if (type == HighlightInfoType.METHOD_DECLARATION) return false; if (type == HighlightInfoType.STATIC_METHOD) return false; + if (type == HighlightInfoType.ABSTRACT_METHOD) return false; + if (type == HighlightInfoType.INHERITED_METHOD) return false; if (type == HighlightInfoType.CONSTRUCTOR_CALL) return false; if (type == HighlightInfoType.CONSTRUCTOR_DECLARATION) return false; if (type == HighlightInfoType.INTERFACE_NAME) return false; if (type == HighlightInfoType.ABSTRACT_CLASS_NAME) return false; + if (type == HighlightInfoType.ENUM_NAME) return false; if (type == HighlightInfoType.CLASS_NAME) return false; if (type == HighlightInfoType.ANONYMOUS_CLASS_NAME) return false; return true; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java index 48b65e3391e5..5b75fb5d86f0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java @@ -70,15 +70,19 @@ public interface HighlightInfoType { HighlightInfoType LOCAL_VARIABLE = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.LOCAL_VARIABLE_ATTRIBUTES); HighlightInfoType INSTANCE_FIELD = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES); HighlightInfoType STATIC_FIELD = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.STATIC_FIELD_ATTRIBUTES); + HighlightInfoType STATIC_FINAL_FIELD = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.STATIC_FINAL_FIELD_ATTRIBUTES); HighlightInfoType PARAMETER = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.PARAMETER_ATTRIBUTES); HighlightInfoType METHOD_CALL = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.METHOD_CALL_ATTRIBUTES); HighlightInfoType METHOD_DECLARATION = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.METHOD_DECLARATION_ATTRIBUTES); HighlightInfoType CONSTRUCTOR_CALL = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.CONSTRUCTOR_CALL_ATTRIBUTES); HighlightInfoType CONSTRUCTOR_DECLARATION = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.CONSTRUCTOR_DECLARATION_ATTRIBUTES); HighlightInfoType STATIC_METHOD = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.STATIC_METHOD_ATTRIBUTES); + HighlightInfoType ABSTRACT_METHOD = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.ABSTRACT_METHOD_ATTRIBUTES); + HighlightInfoType INHERITED_METHOD = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.INHERITED_METHOD_ATTRIBUTES); HighlightInfoType CLASS_NAME = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.CLASS_NAME_ATTRIBUTES); HighlightInfoType ANONYMOUS_CLASS_NAME = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.ANONYMOUS_CLASS_NAME_ATTRIBUTES); HighlightInfoType INTERFACE_NAME = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.INTERFACE_NAME_ATTRIBUTES); + HighlightInfoType ENUM_NAME = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.ENUM_NAME_ATTRIBUTES); HighlightInfoType TYPE_PARAMETER_NAME = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.TYPE_PARAMETER_NAME_ATTRIBUTES); HighlightInfoType ABSTRACT_CLASS_NAME = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.ABSTRACT_CLASS_NAME_ATTRIBUTES); HighlightInfoType ANNOTATION_NAME = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.ANNOTATION_NAME_ATTRIBUTES); diff --git a/platform/lang-impl/src/com/intellij/find/impl/livePreview/SearchResults.java b/platform/lang-impl/src/com/intellij/find/impl/livePreview/SearchResults.java index 8207fcc5a430..04057d78047e 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/livePreview/SearchResults.java +++ b/platform/lang-impl/src/com/intellij/find/impl/livePreview/SearchResults.java @@ -307,8 +307,7 @@ public class SearchResults implements DocumentListener { FindManager findManager = FindManager.getInstance(getProject()); FindResult result; try { - StringUtil.BombedCharSequence - bombedCharSequence = new StringUtil.BombedCharSequence(editor.getDocument().getCharsSequence(), 3000); + CharSequence bombedCharSequence = StringUtil.newBombedCharSequence(editor.getDocument().getCharsSequence(), 3000); result = findManager.findString(bombedCharSequence, offset, findModel, virtualFile); } catch(PatternSyntaxException e) { result = null; diff --git a/platform/lang-impl/src/com/intellij/ide/FileIconPatcherImpl.java b/platform/lang-impl/src/com/intellij/ide/FileIconPatcherImpl.java index bde75373c53a..145ce4f4b521 100644 --- a/platform/lang-impl/src/com/intellij/ide/FileIconPatcherImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/FileIconPatcherImpl.java @@ -24,13 +24,14 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.util.PsiIconUtil; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; public class FileIconPatcherImpl implements FileIconProvider { @Nullable - public Icon getIcon(final VirtualFile file, final int flags, final Project project) { + public Icon getIcon(@NotNull final VirtualFile file, final int flags, final Project project) { if(project == null) return null; final PsiFile psiFile = PsiManager.getInstance(project).findFile(file); diff --git a/platform/lang-impl/src/com/intellij/ide/hierarchy/CallHierarchyBrowserBase.java b/platform/lang-impl/src/com/intellij/ide/hierarchy/CallHierarchyBrowserBase.java index d5909847af1c..17fcd5280216 100644 --- a/platform/lang-impl/src/com/intellij/ide/hierarchy/CallHierarchyBrowserBase.java +++ b/platform/lang-impl/src/com/intellij/ide/hierarchy/CallHierarchyBrowserBase.java @@ -28,7 +28,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; public abstract class CallHierarchyBrowserBase extends HierarchyBrowserBaseEx { - @SuppressWarnings({"UnresolvedPropertyKey"}) public static final String CALLEE_TYPE = IdeBundle.message("title.hierarchy.callees.of"); @SuppressWarnings({"UnresolvedPropertyKey"}) @@ -36,22 +35,23 @@ public abstract class CallHierarchyBrowserBase extends HierarchyBrowserBaseEx { private static final String CALL_HIERARCHY_BROWSER_DATA_KEY = "com.intellij.ide.hierarchy.CallHierarchyBrowserBase"; - public CallHierarchyBrowserBase(final Project project, final PsiElement method) { + public CallHierarchyBrowserBase(@NotNull Project project, @NotNull PsiElement method) { super(project, method); - - } + @Override @Nullable protected JPanel createLegendPanel() { return null; } + @Override @NotNull protected String getBrowserDataKey() { return CALL_HIERARCHY_BROWSER_DATA_KEY; } + @Override protected void prependActions(@NotNull DefaultActionGroup actionGroup) { actionGroup.add(new ChangeViewTypeActionBase(IdeBundle.message("action.caller.methods.hierarchy"), IdeBundle.message("action.caller.methods.hierarchy"), @@ -63,16 +63,19 @@ public abstract class CallHierarchyBrowserBase extends HierarchyBrowserBaseEx { actionGroup.add(new ChangeScopeAction()); } + @Override @NotNull protected String getActionPlace() { return ActionPlaces.CALL_HIERARCHY_VIEW_TOOLBAR; } + @Override @NotNull protected String getPrevOccurenceActionNameImpl() { return IdeBundle.message("hierarchy.call.prev.occurence.name"); } + @Override @NotNull protected String getNextOccurenceActionNameImpl() { return IdeBundle.message("hierarchy.call.next.occurence.name"); @@ -86,15 +89,18 @@ public abstract class CallHierarchyBrowserBase extends HierarchyBrowserBaseEx { myTypeName = typeName; } + @Override public final boolean isSelected(final AnActionEvent event) { return myTypeName.equals(myCurrentViewType); } + @Override public final void setSelected(final AnActionEvent event, final boolean flag) { if (flag) { // setWaitCursor(); // invokeLater is called to update state of button before long tree building operation ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { changeView(myTypeName); } @@ -102,6 +108,7 @@ public abstract class CallHierarchyBrowserBase extends HierarchyBrowserBaseEx { } } + @Override public final void update(final AnActionEvent event) { super.update(event); setEnabled(isValidBase()); diff --git a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserBaseEx.java b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserBaseEx.java index aa6d3628191d..56b691187abd 100644 --- a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserBaseEx.java +++ b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserBaseEx.java @@ -44,7 +44,7 @@ import com.intellij.pom.Navigatable; import com.intellij.psi.*; import com.intellij.psi.search.scope.packageSet.NamedScope; import com.intellij.psi.search.scope.packageSet.NamedScopesHolder; -import com.intellij.psi.util.PsiUtilBase; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.treeStructure.Tree; import com.intellij.util.Alarm; @@ -85,26 +85,32 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem private final HashMap myOccurrenceNavigators = new HashMap(); private static final OccurenceNavigator EMPTY_NAVIGATOR = new OccurenceNavigator() { + @Override public boolean hasNextOccurence() { return false; } + @Override public boolean hasPreviousOccurence() { return false; } + @Override public OccurenceInfo goNextOccurence() { return null; } + @Override public OccurenceInfo goPreviousOccurence() { return null; } + @Override public String getNextOccurenceActionName() { return ""; } + @Override public String getPreviousOccurenceActionName() { return ""; } @@ -115,7 +121,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem public static final String SCOPE_CLASS = IdeBundle.message("hierarchy.scope.this.class"); protected final Map myType2ScopeMap = new HashMap(); - public HierarchyBrowserBaseEx(final Project project, final PsiElement element) { + public HierarchyBrowserBaseEx(@NotNull Project project, @NotNull PsiElement element) { super(project); setHierarchyBase(element); @@ -135,6 +141,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem final String key = keys.nextElement(); final JTree tree = myType2TreeMap.get(key); myOccurrenceNavigators.put(key, new OccurenceNavigatorSupport(tree) { + @Override @Nullable protected Navigatable createDescriptorForNode(DefaultMutableTreeNode node) { final HierarchyNodeDescriptor descriptor = getDescriptor(node); @@ -146,12 +153,14 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem return new OpenFileDescriptor(psiElement.getProject(), virtualFile, psiElement.getTextOffset()); } + @Override public String getNextOccurenceActionName() { - return HierarchyBrowserBaseEx.this.getNextOccurenceActionNameImpl(); + return getNextOccurenceActionNameImpl(); } + @Override public String getPreviousOccurenceActionName() { - return HierarchyBrowserBaseEx.this.getPrevOccurenceActionNameImpl(); + return getPrevOccurenceActionNameImpl(); } }); myTreePanel.add(ScrollPaneFactory.createScrollPane(tree), key); @@ -175,6 +184,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem return getElementFromDescriptor(descriptor); } + @Override @Nullable protected abstract PsiElement getElementFromDescriptor(@NotNull HierarchyNodeDescriptor descriptor); @@ -236,16 +246,20 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { DnDManager.getInstance().registerSource(new DnDSource() { + @Override public boolean canStartDragging(final DnDAction action, final Point dragOrigin) { return getSelectedElements().length > 0; } + @Override public DnDDragStartBean startDragging(final DnDAction action, final Point dragOrigin) { return new DnDDragStartBean(new TransferableWrapper() { + @Override public TreeNode[] getTreeNodes() { return tree.getSelectedNodes(TreeNode.class, null); } + @Override public PsiElement[] getPsiElements() { return getSelectedElements(); } @@ -257,13 +271,16 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem }); } + @Override public Pair createDraggedImage(final DnDAction action, final Point dragOrigin) { return null; } + @Override public void dragDropEnd() { } + @Override public void dropActionChanged(final int gestureModifiers) { } }, tree); @@ -295,7 +312,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem return tree; } - protected void setHierarchyBase(final PsiElement element) { + protected void setHierarchyBase(@NotNull PsiElement element) { mySmartPsiElementPointer = SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(element); } @@ -306,6 +323,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem private void setWaitCursor() { myAlarm.addRequest(new Runnable() { + @Override public void run() { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } @@ -349,6 +367,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem final HierarchyNodeDescriptor descriptor = structure.getBaseDescriptor(); builder.select(descriptor, new Runnable() { + @Override public void run() { builder.expand(descriptor, null); } @@ -367,9 +386,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem if (element instanceof PsiNamedElement) { return MessageFormat.format(typeName, ((PsiNamedElement)element).getName()); } - else { - return null; - } + return null; } @Override @@ -382,6 +399,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem protected void prependActions(final DefaultActionGroup actionGroup) { } + @Override public boolean hasNextOccurence() { return getOccurrenceNavigator().hasNextOccurence(); } @@ -394,26 +412,32 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem return navigator != null ? navigator : EMPTY_NAVIGATOR; } + @Override public boolean hasPreviousOccurence() { return getOccurrenceNavigator().hasPreviousOccurence(); } + @Override public OccurenceInfo goNextOccurence() { return getOccurrenceNavigator().goNextOccurence(); } + @Override public OccurenceInfo goPreviousOccurence() { return getOccurrenceNavigator().goPreviousOccurence(); } + @Override public String getNextOccurenceActionName() { return getOccurrenceNavigator().getNextOccurenceActionName(); } + @Override public String getPreviousOccurenceActionName() { return getOccurrenceNavigator().getPreviousOccurenceActionName(); } + @Override protected HierarchyTreeBuilder getCurrentBuilder() { return myBuilders.get(myCurrentViewType); } @@ -428,6 +452,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem return myCachedIsValidBase; } + @Override protected JTree getCurrentTree() { if (myCurrentViewType == null) return null; return myType2TreeMap.get(myCurrentViewType); @@ -444,19 +469,21 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem PsiElement element = getElementFromDescriptor(descriptor); if (element != null) elements.add(element); } - return PsiUtilBase.toPsiElementArray(elements); + return PsiUtilCore.toPsiElementArray(elements); } + @Override public Object getData(final String dataId) { if (getBrowserDataKey().equals(dataId)) { return this; } - else if (PlatformDataKeys.HELP_ID.is(dataId)) { + if (PlatformDataKeys.HELP_ID.is(dataId)) { return HELP_ID; } return super.getData(dataId); } + @Override public void dispose() { final Collection builders = myBuilders.values(); for (final HierarchyTreeBuilder builder : builders) { @@ -472,7 +499,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem if (getCurrentBuilder() == null) return; // seems like we are in the middle of refresh already - final Ref storedInfo = new Ref(); + final Ref, ArrayList>> storedInfo = new Ref, ArrayList>>(); if (myCurrentViewType != null) { final HierarchyTreeBuilder builder = getCurrentBuilder(); storedInfo.set(builder.storeExpandedAndSelectedInfo()); @@ -494,12 +521,11 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem setHierarchyBase(element); validate(); ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { changeView(currentViewType); - if (storedInfo != null) { - final HierarchyTreeBuilder builder = getCurrentBuilder(); - builder.restoreExpandedAndSelectedInfo(storedInfo.get()); - } + final HierarchyTreeBuilder builder = getCurrentBuilder(); + builder.restoreExpandedAndSelectedInfo(storedInfo.get()); } }); } @@ -515,10 +541,12 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem AllIcons.ObjectBrowser.Sorted); } + @Override public final boolean isSelected(final AnActionEvent event) { return HierarchyBrowserManager.getInstance(myProject).getState().SORT_ALPHABETICALLY; } + @Override public final void setSelected(final AnActionEvent event, final boolean flag) { final HierarchyBrowserManager hierarchyBrowserManager = HierarchyBrowserManager.getInstance(myProject); hierarchyBrowserManager.getState().SORT_ALPHABETICALLY = flag; @@ -529,6 +557,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem } } + @Override public final void update(final AnActionEvent event) { super.update(event); final Presentation presentation = event.getPresentation(); @@ -546,6 +575,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem myBrowserDataKey = browserDataKey; } + @Override public final void actionPerformed(final AnActionEvent event) { final DataContext dataContext = event.getDataContext(); final HierarchyBrowserBaseEx browser = (HierarchyBrowserBaseEx)dataContext.getData(myBrowserDataKey); @@ -559,6 +589,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem browser.setHierarchyBase(selectedElement); browser.validate(); ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { browser.changeView(correctViewType(browser, currentViewType)); } @@ -569,6 +600,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem return viewType; } + @Override public final void update(final AnActionEvent event) { final Presentation presentation = event.getPresentation(); @@ -613,10 +645,12 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem super(IdeBundle.message("action.refresh"), IdeBundle.message("action.refresh"), AllIcons.Actions.Refresh); } + @Override public final void actionPerformed(final AnActionEvent e) { doRefresh(false); } + @Override public final void update(final AnActionEvent event) { final Presentation presentation = event.getPresentation(); presentation.setEnabled(isValidBase()); @@ -624,6 +658,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem } public class ChangeScopeAction extends ComboBoxAction { + @Override public final void update(final AnActionEvent e) { final Presentation presentation = e.getPresentation(); final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); @@ -636,6 +671,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem return true; } + @Override @NotNull protected final DefaultActionGroup createPopupActionGroup(final JComponent button) { final DefaultActionGroup group = new DefaultActionGroup(); @@ -672,12 +708,14 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem // invokeLater is called to update state of button before long tree building operation ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { doRefresh(true); // scope is kept per type so other builders doesn't need to be refreshed } }); } + @Override public final JComponent createCustomComponent(final Presentation presentation) { final JPanel panel = new JPanel(new GridBagLayout()); panel.add(new JLabel(IdeBundle.message("label.scope")), @@ -695,6 +733,7 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem myScopeType = scopeType; } + @Override public final void actionPerformed(final AnActionEvent e) { selectScope(myScopeType); diff --git a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserManager.java b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserManager.java index f690b338d76b..c0f156fedd28 100644 --- a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserManager.java +++ b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserManager.java @@ -57,10 +57,12 @@ public final class HierarchyBrowserManager implements PersistentStateComponent comparator ) { super(tree, treeModel, treeStructure, comparator); - myProject = project; - - myPsiTreeChangeListener = new MyPsiTreeChangeListener(); - myFileStatusListener = new MyFileStatusListener(); initRootNode(); - PsiManager.getInstance(myProject).addPsiTreeChangeListener(myPsiTreeChangeListener); - FileStatusManager.getInstance(myProject).addFileStatusListener(myFileStatusListener); + PsiManager.getInstance(project).addPsiTreeChangeListener(new MyPsiTreeChangeListener(), this); + FileStatusManager.getInstance(project).addFileStatusListener(new MyFileStatusListener(), this); - Disposer.register(myProject, this); + Disposer.register(project, this); } - public final Object storeExpandedAndSelectedInfo() { + @NotNull + public Pair, ArrayList> storeExpandedAndSelectedInfo() { final ArrayList pathsToExpand = new ArrayList(); final ArrayList selectionPaths = new ArrayList(); TreeBuilderUtil.storePaths(this, getRootNode(), pathsToExpand, selectionPaths, true); return new Pair, ArrayList>(pathsToExpand, selectionPaths); } - public final void restoreExpandedAndSelectedInfo(final Object info) { - final Pair pair = (Pair)info; - TreeBuilderUtil.restorePaths(this, (ArrayList)pair.first, (ArrayList)pair.second, true); + public final void restoreExpandedAndSelectedInfo(@NotNull Pair, ArrayList> pair) { + TreeBuilderUtil.restorePaths(this, pair.first, pair.second, true); } + @Override protected boolean isAlwaysShowPlus(final NodeDescriptor nodeDescriptor) { return ((HierarchyTreeStructure) getTreeStructure()).isAlwaysShowPlus(); } + @Override protected boolean isAutoExpandNode(final NodeDescriptor nodeDescriptor) { if (getTreeStructure().getRootElement().equals(nodeDescriptor.getElement())) return true; - if (nodeDescriptor instanceof HierarchyNodeDescriptor) { - return false; - } - return true; + return !(nodeDescriptor instanceof HierarchyNodeDescriptor); } + @Override protected final boolean isSmartExpand() { return false; } + @Override protected final boolean isDisposeOnCollapsing(final NodeDescriptor nodeDescriptor) { return false; // prevents problems with building descriptors for invalidated elements } - public final void dispose() { - if (!isDisposed()) { // because can be called both externally and via my ProjectManagerListener, don't know what will happen earlier - super.dispose(); - PsiManager.getInstance(myProject).removePsiTreeChangeListener(myPsiTreeChangeListener); - FileStatusManager.getInstance(myProject).removeFileStatusListener(myFileStatusListener); - } - } - + @Override @NotNull protected ProgressIndicator createProgressIndicator() { return new StatusBarProgress(); } private final class MyPsiTreeChangeListener extends PsiTreeChangeAdapter { + @Override public final void childAdded(@NotNull final PsiTreeChangeEvent event) { getUpdater().addSubtreeToUpdate(getRootNode()); } + @Override public final void childRemoved(@NotNull final PsiTreeChangeEvent event) { getUpdater().addSubtreeToUpdate(getRootNode()); } + @Override public final void childReplaced(@NotNull final PsiTreeChangeEvent event) { getUpdater().addSubtreeToUpdate(getRootNode()); } + @Override public final void childMoved(@NotNull final PsiTreeChangeEvent event) { getUpdater().addSubtreeToUpdate(getRootNode()); } + @Override public final void childrenChanged(@NotNull final PsiTreeChangeEvent event) { getUpdater().addSubtreeToUpdate(getRootNode()); } + @Override public final void propertyChanged(@NotNull final PsiTreeChangeEvent event) { getUpdater().addSubtreeToUpdate(getRootNode()); } } private final class MyFileStatusListener implements FileStatusListener { + @Override public final void fileStatusesChanged() { getUpdater().addSubtreeToUpdate(getRootNode()); } + @Override public final void fileStatusChanged(@NotNull final VirtualFile virtualFile) { getUpdater().addSubtreeToUpdate(getRootNode()); } diff --git a/platform/lang-impl/src/com/intellij/ide/hierarchy/TypeHierarchyBrowserBase.java b/platform/lang-impl/src/com/intellij/ide/hierarchy/TypeHierarchyBrowserBase.java index dde30d8e31ca..9e79760df77b 100644 --- a/platform/lang-impl/src/com/intellij/ide/hierarchy/TypeHierarchyBrowserBase.java +++ b/platform/lang-impl/src/com/intellij/ide/hierarchy/TypeHierarchyBrowserBase.java @@ -57,7 +57,7 @@ public abstract class TypeHierarchyBrowserBase extends HierarchyBrowserBaseEx { } @Override - protected void setHierarchyBase(PsiElement element) { + protected void setHierarchyBase(@NotNull PsiElement element) { super.setHierarchyBase(element); myIsInterface = isInterface(element); } diff --git a/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebModuleGenerationStep.java b/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebModuleGenerationStep.java index ad52821d9e56..057c3bbfc274 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebModuleGenerationStep.java +++ b/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebModuleGenerationStep.java @@ -22,6 +22,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ValidationInfo; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.platform.DirectoryProjectGenerator; @@ -281,6 +282,12 @@ public class WebModuleGenerationStep extends ModuleWizardStep { return new JLabel("No extra files will be created."); } + @Nullable + @Override + public Pair getSettingsField() { + return null; + } + @NotNull @Override public Object getSettings() { diff --git a/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebProjectTemplate.java b/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebProjectTemplate.java index 8c65f28eeaa5..9d21f78e8871 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebProjectTemplate.java +++ b/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebProjectTemplate.java @@ -25,11 +25,13 @@ import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ui.configuration.ModulesProvider; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.openapi.util.NotNullLazyValue; +import com.intellij.openapi.util.Pair; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.WebProjectGenerator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.util.List; /** @@ -61,6 +63,11 @@ public abstract class WebProjectTemplate extends WebProjectGenerator imple return builder.getModuleType(); } + @Override + public boolean isTemplateBased() { + return true; + } + @Override public List commit(Project project, ModifiableModuleModel model, ModulesProvider modulesProvider) { List modules = builder.commit(project, model, modulesProvider); @@ -70,6 +77,25 @@ public abstract class WebProjectTemplate extends WebProjectGenerator imple } return modules; } + + @Nullable + @Override + public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep) { + Pair pair = myPeer.getValue().getSettingsField(); + if (pair != null) { + settingsStep.addSettingsField(pair.first, pair.second); + } + return new ModuleWizardStep() { + @Override + public JComponent getComponent() { + return null; + } + + @Override + public void updateDataModel() { + } + }; + } }; } diff --git a/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.form b/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.form index b29515f113e6..ad2eb05b53f0 100644 --- a/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.form +++ b/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.form @@ -1,13 +1,59 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -17,42 +63,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.java b/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.java index 475fc679a7cc..17e76f88b13d 100644 --- a/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.java +++ b/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.java @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.intellij.openapi.ui.ValidationInfo; +import com.intellij.openapi.util.Pair; import com.intellij.platform.WebProjectGenerator; import com.intellij.platform.templates.github.GithubTagInfo; import com.intellij.ui.ListCellRendererWrapper; @@ -33,6 +34,7 @@ public class GithubProjectGeneratorPeer implements WebProjectGenerator.Generator private JComponent myComponent; private JLabel myErrorMessage; private JButton myReloadButton; + private JPanel myVersionPanel; public GithubProjectGeneratorPeer(@NotNull AbstractGithubTagDownloadedProjectGenerator generator) { String ghUserName = generator.getGithubUserName(); @@ -144,6 +146,11 @@ public class GithubProjectGeneratorPeer implements WebProjectGenerator.Generator return myComponent; } + @Override + public Pair getSettingsField() { + return new Pair("\u001BVersion:", myVersionPanel); + } + @NotNull @Override public GithubTagInfo getSettings() { diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java index 9bb219046df7..87ad84e661ac 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java @@ -46,7 +46,7 @@ public class NativeFileIconProvider implements FileIconProvider { private static final Ext CLOSED_DIR = new Ext(null, 0); - public Icon getIcon(VirtualFile file, final int flags, @Nullable Project project) { + public Icon getIcon(@NotNull VirtualFile file, final int flags, @Nullable Project project) { if (!isNativeFileType(file)) return null; final Ext ext = getExtension(file, flags); diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/ui/UsagesPanel.java b/platform/lang-impl/src/com/intellij/packageDependencies/ui/UsagesPanel.java index 89733f8fc511..125a4e33e0f6 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/ui/UsagesPanel.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/ui/UsagesPanel.java @@ -29,6 +29,7 @@ import com.intellij.usageView.UsageInfo; import com.intellij.usages.*; import com.intellij.util.Alarm; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -63,7 +64,7 @@ public abstract class UsagesPanel extends JPanel implements Disposable, DataProv } } - protected void showUsages(final UsageInfoToUsageConverter.TargetElementsDescriptor descriptor, final UsageInfo[] usageInfos) { + protected void showUsages(@NotNull UsageInfoToUsageConverter.TargetElementsDescriptor descriptor, @NotNull UsageInfo[] usageInfos) { if (myCurrentUsageView != null) { Disposer.dispose(myCurrentUsageView); } @@ -85,10 +86,11 @@ public abstract class UsagesPanel extends JPanel implements Disposable, DataProv protected void setToComponent(final JComponent cmp) { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { if (myCurrentComponent != null) { if (myCurrentUsageView != null && myCurrentComponent == myCurrentUsageView.getComponent()){ - myCurrentUsageView.dispose(); + Disposer.dispose(myCurrentUsageView); } remove(myCurrentComponent); } @@ -99,6 +101,7 @@ public abstract class UsagesPanel extends JPanel implements Disposable, DataProv }); } + @Override public void dispose(){ if (myCurrentUsageView != null){ Disposer.dispose(myCurrentUsageView); @@ -111,6 +114,7 @@ public abstract class UsagesPanel extends JPanel implements Disposable, DataProv return label; } + @Override @Nullable @NonNls public Object getData(@NonNls String dataId) { diff --git a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/InjectedSelfElementInfo.java b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/InjectedSelfElementInfo.java index bf6c314cc572..fe4650f616c8 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/InjectedSelfElementInfo.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/InjectedSelfElementInfo.java @@ -67,6 +67,7 @@ class InjectedSelfElementInfo extends SelfElementInfo { final InjectedLanguageManager manager = InjectedLanguageManager.getInstance(getProject()); PsiFile hostFile = hostContext.getContainingFile(); + if (hostFile == null) return null; PsiLanguageInjectionHost.InjectedPsiVisitor visitor = new PsiLanguageInjectionHost.InjectedPsiVisitor() { @Override diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/DataContext.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/DataContext.java index a28cfb91f264..21d2141ce8f3 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/DataContext.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/DataContext.java @@ -24,6 +24,7 @@ import org.jetbrains.annotations.Nullable; * @see com.intellij.openapi.actionSystem.AnActionEvent#getDataContext() * @see com.intellij.openapi.actionSystem.PlatformDataKeys * @see com.intellij.openapi.actionSystem.DataKey + * @see com.intellij.ide.DataManager * @see DataProvider */ public interface DataContext { diff --git a/platform/platform-api/src/com/intellij/patterns/StringPattern.java b/platform/platform-api/src/com/intellij/patterns/StringPattern.java index 174f176e53db..4a812d788986 100644 --- a/platform/platform-api/src/com/intellij/patterns/StringPattern.java +++ b/platform/platform-api/src/com/intellij/patterns/StringPattern.java @@ -15,6 +15,7 @@ */ package com.intellij.patterns; +import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ProcessingContext; import dk.brics.automaton.Automaton; @@ -105,7 +106,7 @@ public class StringPattern extends ObjectPattern { return with(new ValuePatternCondition("matches") { @Override public boolean accepts(@NotNull final String str, final ProcessingContext context) { - return pattern.matcher(str).matches(); + return pattern.matcher(newBombedCharSequence(str)).matches(); } @Override @@ -211,4 +212,13 @@ public class StringPattern extends ObjectPattern { return super.oneOf(set); } + @NotNull + public static CharSequence newBombedCharSequence(@NotNull CharSequence sequence) { + return new StringUtil.BombedCharSequence(sequence) { + @Override + protected void checkCanceled() { + ProgressManager.checkCanceled(); + } + }; + } } diff --git a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java index e6f7e9a35fc4..202bb29fa9fd 100644 --- a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java +++ b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java @@ -22,8 +22,9 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.StringBuilderSpinAllocator; -import com.intellij.util.containers.HashMap; import com.intellij.util.ui.UIUtil; +import gnu.trove.TIntIntHashMap; +import org.intellij.lang.annotations.JdkConstants; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,7 +39,6 @@ import java.awt.*; import java.util.ArrayList; import java.util.List; import java.util.Locale; -import java.util.Map; /** * This is high performance Swing component which represents an icon @@ -52,44 +52,46 @@ public class SimpleColoredComponent extends JComponent implements Accessible { private static final Logger LOG = Logger.getInstance("#com.intellij.ui.SimpleColoredComponent"); public static final Color STYLE_SEARCH_MATCH_BACKGROUND = new Color(250, 250, 250, 140); - public static final int FRAGMENT_ICON = -2; + public static final int FRAGMENT_ICON = -2; - private final ArrayList myFragments; + private final ArrayList myFragments; private final ArrayList myAttributes; private ArrayList myFragmentTags = null; - + /** * Component's icon. It can be null. */ - private Icon myIcon; + private Icon myIcon; /** * Internal padding */ - private Insets myIpad; + private Insets myIpad; /** * Gap between icon and text. It is used only if icon is defined. */ - protected int myIconTextGap; + protected int myIconTextGap; /** * Defines whether the focus border around the text is painted or not. * For example, text can have a border if the component represents a selected item * in focused JList. */ - private boolean myPaintFocusBorder; + private boolean myPaintFocusBorder; /** * Defines whether the focus border around the text extends to icon or not */ - private boolean myFocusBorderAroundIcon; + private boolean myFocusBorderAroundIcon; /** * This is the border around the text. For example, text can have a border * if the component represents a selected item in a focused JList. * Border can be null. */ - private Border myBorder; + private Border myBorder; private int myMainTextLastIndex = -1; - private final Map myAligns; + private final TIntIntHashMap myFixedWidths; + + @JdkConstants.HorizontalAlignment private int myTextAlign = SwingConstants.LEFT; private boolean myIconOpaque = true; @@ -106,7 +108,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible { myIpad = new Insets(1, 2, 1, 2); myIconTextGap = 2; myBorder = new MyBorder(); - myAligns = new HashMap(10); + myFixedWidths = new TIntIntHashMap(10); setOpaque(true); } @@ -176,9 +178,13 @@ public class SimpleColoredComponent extends JComponent implements Accessible { myFragmentTags.add(tag); } - public synchronized void appendAlign(int alignWidth) { + public synchronized void appendFixedTextFragmentWidth(int width) { final int alignIndex = myFragments.size()-1; - myAligns.put(alignIndex, alignWidth); + myFixedWidths.put(alignIndex, width); + } + + public void setTextAlign(@JdkConstants.HorizontalAlignment int align) { + myTextAlign = align; } /** @@ -197,7 +203,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible { myAttributes.clear(); myFragmentTags = null; myMainTextLastIndex = -1; - myAligns.clear(); + myFixedWidths.clear(); } /** @@ -334,25 +340,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible { LOG.assertTrue(font != null); - int baseSize = font.getSize(); - boolean wasSmaller = false; - for (int i = 0; i < myAttributes.size(); i++) { - SimpleTextAttributes attributes = myAttributes.get(i); - boolean isSmaller = attributes.isSmaller(); - if (font.getStyle() != attributes.getFontStyle() || isSmaller != wasSmaller) { // derive font only if it is necessary - font = font.deriveFont(attributes.getFontStyle(), isSmaller ? UIUtil.getFontSize(UIUtil.FontSize.SMALL) : baseSize); - } - wasSmaller = isSmaller; - final FontMetrics metrics = getFontMetrics(font); - width += metrics.stringWidth(myFragments.get(i)); - - final Integer fixedWidth = myAligns.get(i); - if (fixedWidth != null && width < fixedWidth.intValue()) { - width = fixedWidth.intValue(); - } - - if (mainTextOnly && myMainTextLastIndex >= 0 && i == myMainTextLastIndex) break; - } + width += computeTextWidth(font, mainTextOnly); width += myIpad.right + borderInsets.right; // Calculate height @@ -379,6 +367,29 @@ public class SimpleColoredComponent extends JComponent implements Accessible { return new Dimension(width, height); } + private int computeTextWidth(@NotNull Font font, final boolean mainTextOnly) { + int result = 0; + int baseSize = font.getSize(); + boolean wasSmaller = false; + for (int i = 0; i < myAttributes.size(); i++) { + SimpleTextAttributes attributes = myAttributes.get(i); + boolean isSmaller = attributes.isSmaller(); + if (font.getStyle() != attributes.getFontStyle() || isSmaller != wasSmaller) { // derive font only if it is necessary + font = font.deriveFont(attributes.getFontStyle(), isSmaller ? UIUtil.getFontSize(UIUtil.FontSize.SMALL) : baseSize); + } + wasSmaller = isSmaller; + final FontMetrics metrics = getFontMetrics(font); + result += metrics.stringWidth(myFragments.get(i)); + + final int fixedWidth = myFixedWidths.get(i); + if (fixedWidth > 0 && result < fixedWidth) { + result = fixedWidth; + } + if (mainTextOnly && myMainTextLastIndex >= 0 && i == myMainTextLastIndex) break; + } + return result; + } + /** * Returns the index of text fragment at the specified X offset. * @@ -414,9 +425,9 @@ public class SimpleColoredComponent extends JComponent implements Accessible { return i; } curX += curWidth; - final Integer fixedWidth = myAligns.get(i); - if (fixedWidth != null && curX < fixedWidth.intValue()) { - curX = fixedWidth.intValue(); + final int fixedWidth = myFixedWidths.get(i); + if (fixedWidth > 0 && curX < fixedWidth) { + curX = fixedWidth; } } @@ -582,8 +593,8 @@ public class SimpleColoredComponent extends JComponent implements Accessible { UIUtil.applyRenderingHints(g); applyAdditionalHints(g); - final Font ownFont = getFont(); + offset += computeTextAlignShift(ownFont); int baseSize = ownFont != null ? ownFont.getSize() : g.getFont().getSize(); boolean wasSmaller = false; for (int i = 0; i < myFragments.size(); i++) { @@ -665,10 +676,9 @@ public class SimpleColoredComponent extends JComponent implements Accessible { searchMatches.add(new Object[] {offset, offset + fragmentWidth, textBaseline, fragment, g.getFont()}); } - final Integer fixedWidth = myAligns.get(i); - if (fixedWidth != null && fragmentWidth < fixedWidth.intValue()) { - //if (fixedWidth != null) { - offset = fixedWidth.intValue(); + final int fixedWidth = myFixedWidths.get(i); + if (fixedWidth > 0 && fragmentWidth < fixedWidth) { + offset = fixedWidth; } else { offset += fragmentWidth; } @@ -699,6 +709,27 @@ public class SimpleColoredComponent extends JComponent implements Accessible { return offset; } + private int computeTextAlignShift(@NotNull Font font) { + if (myTextAlign == SwingConstants.LEFT || myTextAlign == SwingConstants.LEADING) { + return 0; + } + + int componentWidth = getSize().width; + int excessiveWidth = componentWidth - computePreferredSize(false).width; + if (excessiveWidth <= 0) { + return 0; + } + + int textWidth = computeTextWidth(font, false); + if (myTextAlign == SwingConstants.CENTER) { + return excessiveWidth / 2; + } + else if (myTextAlign == SwingConstants.RIGHT || myTextAlign == SwingConstants.TRAILING) { + return excessiveWidth; + } + return 0; + } + protected boolean shouldDrawMacShadow() { return false; } diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/DefaultEditorTabsPainter.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/DefaultEditorTabsPainter.java index 35cdb14f2ec5..6a70ac5ec643 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/DefaultEditorTabsPainter.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/DefaultEditorTabsPainter.java @@ -59,7 +59,7 @@ public class DefaultEditorTabsPainter implements JBEditorTabsPainter { g2d.setColor(Gray._255.withAlpha(100)); } - g2d.drawLine(x, y, x + w, y); + g2d.drawLine(x, y, x + w - 1, y); if (!vertical) { drawShadow(g2d, x, w, y + h); diff --git a/platform/platform-api/src/com/intellij/util/EditSourceOnDoubleClickHandler.java b/platform/platform-api/src/com/intellij/util/EditSourceOnDoubleClickHandler.java index 6c0bc76a69ba..f8ae101733d7 100644 --- a/platform/platform-api/src/com/intellij/util/EditSourceOnDoubleClickHandler.java +++ b/platform/platform-api/src/com/intellij/util/EditSourceOnDoubleClickHandler.java @@ -106,16 +106,16 @@ public class EditSourceOnDoubleClickHandler { @Override public boolean onDoubleClick(MouseEvent e) { - final TreePath path = myTree.getUI() instanceof WideSelectionTreeUI ? myTree.getClosestPathForLocation(e.getX(), e.getY()) - : myTree.getPathForLocation(e.getX(), e.getY()); - if (path == null) return false; + final TreePath clickPath = myTree.getUI() instanceof WideSelectionTreeUI ? myTree.getClosestPathForLocation(e.getX(), e.getY()) + : myTree.getPathForLocation(e.getX(), e.getY()); + if (clickPath == null) return false; final DataContext dataContext = DataManager.getInstance().getDataContext(myTree); final Project project = PlatformDataKeys.PROJECT.getData(dataContext); if (project == null) return false; final TreePath selectionPath = myTree.getSelectionPath(); - if (selectionPath == null) return false; + if (selectionPath == null || !clickPath.equals(selectionPath)) return false; final Object lastPathComponent = selectionPath.getLastPathComponent(); if (((TreeNode)lastPathComponent).isLeaf() || !expandOnDoubleClick(((TreeNode)lastPathComponent))) { //Node expansion for non-leafs has a higher priority diff --git a/platform/platform-api/src/com/intellij/util/ui/update/MergingUpdateQueue.java b/platform/platform-api/src/com/intellij/util/ui/update/MergingUpdateQueue.java index 2d53caf3d64b..b72fd6d5d077 100644 --- a/platform/platform-api/src/com/intellij/util/ui/update/MergingUpdateQueue.java +++ b/platform/platform-api/src/com/intellij/util/ui/update/MergingUpdateQueue.java @@ -33,7 +33,6 @@ import java.util.Map; import java.util.TreeMap; public class MergingUpdateQueue implements Runnable, Disposable, Activatable { - public static final JComponent ANY_COMPONENT = new JComponent() { }; @@ -124,7 +123,8 @@ public class MergingUpdateQueue implements Runnable, Disposable, Activatable { public void cancelAllUpdates() { synchronized (myScheduledUpdates) { - for (Update each : myScheduledUpdates.keySet()) { + Update[] updates = myScheduledUpdates.keySet().toArray(new Update[myScheduledUpdates.size()]); + for (Update each : updates) { try { each.setRejected(); } @@ -400,7 +400,9 @@ public class MergingUpdateQueue implements Runnable, Disposable, Activatable { @SuppressWarnings({"HardCodedStringLiteral"}) public String toString() { - return myName + " active=" + myActive + " scheduled=" + myScheduledUpdates.size(); + synchronized (myScheduledUpdates) { + return myName + " active=" + myActive + " scheduled=" + myScheduledUpdates.size(); + } } @Nullable diff --git a/platform/platform-impl/src/com/intellij/ide/ui/search/SearchableOptionsRegistrarImpl.java b/platform/platform-impl/src/com/intellij/ide/ui/search/SearchableOptionsRegistrarImpl.java index a37f6ebebd8b..dd08b4a5ce92 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/search/SearchableOptionsRegistrarImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/search/SearchableOptionsRegistrarImpl.java @@ -32,6 +32,7 @@ import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ResourceUtil; +import com.intellij.util.SingletonSet; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.StringInterner; import gnu.trove.THashMap; @@ -62,11 +63,10 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar { @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) private final StringInterner myIdentifierTable = new StringInterner() { + @Override @NotNull - public String intern(@NotNull final String name) { - synchronized (this) { - return super.intern(name); - } + public synchronized String intern(@NotNull final String name) { + return super.intern(name); } }; @@ -163,8 +163,6 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar { } } } - - } catch (Exception e) { LOG.error(e); @@ -191,16 +189,25 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar { myId2Name.put(myIdentifierTable.intern(id), myIdentifierTable.intern(groupName)); } + OptionDescription description = + new OptionDescription(null, myIdentifierTable.intern(id).trim(), hit != null ? myIdentifierTable.intern(hit).trim() : null, + path != null ? myIdentifierTable.intern(path).trim() : null); Set configs = myStorage.get(option); if (configs == null) { - configs = new THashSet(3, 0.9f); + configs = new SingletonSet(description); myStorage.put(new String(option), configs); } - - configs.add(new OptionDescription(null, myIdentifierTable.intern(id).trim(), hit != null ? myIdentifierTable.intern(hit).trim() : null, - path != null ? myIdentifierTable.intern(path).trim() : null)); + else if (configs instanceof SingletonSet){ + configs = new THashSet(configs); + configs.add(description); + myStorage.put(new String(option), configs); + } + else { + configs.add(description); + } } + @Override @NotNull public ConfigurableHit getConfigurables(ConfigurableGroup[] groups, final DocumentEvent.EventType type, @@ -313,6 +320,7 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar { return result; } + @Override @Nullable public String getInnerPath(SearchableConfigurable configurable, @NonNls String option) { loadHugeFilesIfNecessary(); @@ -354,15 +362,18 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar { } } + @Override public boolean isStopWord(String word) { return myStopWords.contains(word); } + @Override public Set getSynonym(final String option, @NotNull final SearchableConfigurable configurable) { loadHugeFilesIfNecessary(); return myHighlightOption2Synonym.get(Pair.create(option, configurable.getId())); } + @Override public Map> findPossibleExtension(@NotNull String prefix, final Project project) { loadHugeFilesIfNecessary(); final boolean perProject = CodeStyleFacade.getInstance(project).projectUsesOwnSettings(); @@ -399,10 +410,12 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar { return result; } + @Override public void addOption(String option, String path, final String hit, final String configurableId, final String configurableDisplayName) { putOptionWithHelpId(option, configurableId, configurableDisplayName, hit, path); } + @Override public Set getProcessedWordsWithoutStemming(@NotNull String text) { Set result = new HashSet(); @NonNls final String toLowerCase = text.toLowerCase(); @@ -416,6 +429,7 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar { return result; } + @Override public Set getProcessedWords(@NotNull String text) { Set result = new HashSet(); @NonNls final String toLowerCase = text.toLowerCase(); @@ -429,6 +443,7 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar { return result; } + @Override public Set replaceSynonyms(Set options, SearchableConfigurable configurable) { final Set result = new HashSet(options); for (String option : options) { diff --git a/platform/platform-impl/src/com/intellij/idea/CommandLineApplication.java b/platform/platform-impl/src/com/intellij/idea/CommandLineApplication.java index 349134150a67..ca5d6c24a5fd 100644 --- a/platform/platform-impl/src/com/intellij/idea/CommandLineApplication.java +++ b/platform/platform-impl/src/com/intellij/idea/CommandLineApplication.java @@ -63,21 +63,24 @@ public class CommandLineApplication { } public static class MyDataManagerImpl extends DataManagerImpl { - + @Override @NotNull public DataContext getDataContext() { return new CommandLineDataContext(); } + @Override public DataContext getDataContext(Component component) { return getDataContext(); } + @Override public DataContext getDataContext(@NotNull Component component, int x, int y) { return getDataContext(); } private static class CommandLineDataContext extends UserDataHolderBase implements DataContext { + @Override public Object getData(String dataId) { return ourInstance.getData(dataId); } diff --git a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java index 824178d548fb..ce2fe3dc895d 100644 --- a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java +++ b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java @@ -240,10 +240,12 @@ public class IdeaApplication { protected class IdeStarter implements ApplicationStarter { private Splash mySplash; + @Override public String getCommandName() { return null; } + @Override public void premain(String[] args) { initLAF(); } @@ -278,6 +280,7 @@ public class IdeaApplication { return SplashScreen.getSplashScreen(); } + @Override public void main(String[] args) { // Event queue should not be changed during initialization of application components. @@ -296,6 +299,7 @@ public class IdeaApplication { } app.invokeLater(new Runnable() { + @Override public void run() { if (mySplash != null) { mySplash.dispose(); @@ -306,6 +310,7 @@ public class IdeaApplication { app.invokeLater(new Runnable() { + @Override public void run() { if (myPerformProjectLoad) { loadProject(); @@ -323,6 +328,7 @@ public class IdeaApplication { //noinspection SSBasedInspection SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { PluginManager.reportPluginError(); } diff --git a/platform/platform-impl/src/com/intellij/idea/Launcher.java b/platform/platform-impl/src/com/intellij/idea/Launcher.java index 9a50cabaae16..8c45e3073eaa 100644 --- a/platform/platform-impl/src/com/intellij/idea/Launcher.java +++ b/platform/platform-impl/src/com/intellij/idea/Launcher.java @@ -49,6 +49,7 @@ public class Launcher { myOutput = output; } + @Override public void run() { Reader reader = new InputStreamReader(myInput); do { diff --git a/platform/platform-impl/src/com/intellij/idea/RareLogger.java b/platform/platform-impl/src/com/intellij/idea/RareLogger.java index 88bddb4743af..826a5e41a927 100644 --- a/platform/platform-impl/src/com/intellij/idea/RareLogger.java +++ b/platform/platform-impl/src/com/intellij/idea/RareLogger.java @@ -72,10 +72,12 @@ public class RareLogger extends Logger { // just passes to parent logger myProxy = new LogFilter() { + @Override @NotNull public Integer getAllowedLoggingInterval(Level level, String message, Throwable t, String[] details) { return -1; } + @Override public Object getKey(@NotNull Level level, @NonNls String message, @Nullable Throwable t, diff --git a/platform/platform-impl/src/com/intellij/idea/SocketLock.java b/platform/platform-impl/src/com/intellij/idea/SocketLock.java index ca9ebb6a06a2..7e15b46f7335 100644 --- a/platform/platform-impl/src/com/intellij/idea/SocketLock.java +++ b/platform/platform-impl/src/com/intellij/idea/SocketLock.java @@ -45,7 +45,7 @@ public class SocketLock { public static final int SOCKET_NUMBER_END = SOCKET_NUMBER_START + 50; // IMPORTANT: Some antiviral software detect viruses by the fact of accessing these ports so we should not touch them to appear innocent. - private static final int[] FORBIDDEN_PORTS = new int[]{6953, 6969, 6970}; + private static final int[] FORBIDDEN_PORTS = {6953, 6969, 6970}; private ServerSocket mySocket; private final List myLockedPaths = new ArrayList(); @@ -209,6 +209,7 @@ public class SocketLock { private class MyRunnable implements Runnable { + @Override public void run() { try { while (true) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorSettingsExternalizable.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorSettingsExternalizable.java index 0be8fe3d7f4d..8a7a3422ed8c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorSettingsExternalizable.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorSettingsExternalizable.java @@ -27,6 +27,7 @@ import com.intellij.openapi.util.NamedJDOMExternalizable; import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.encoding.EncodingManager; +import org.intellij.lang.annotations.MagicConstant; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -48,7 +49,7 @@ public class EditorSettingsExternalizable implements NamedJDOMExternalizable, Ex public int CUSTOM_SOFT_WRAP_INDENT = 0; public boolean IS_VIRTUAL_SPACE = true; public boolean IS_CARET_INSIDE_TABS; - @NonNls public String STRIP_TRAILING_SPACES = "Changed"; + @NonNls public String STRIP_TRAILING_SPACES = STRIP_TRAILING_SPACES_CHANGED; public boolean IS_ENSURE_NEWLINE_AT_EOF = false; public boolean IS_CARET_BLINKING = true; public int CARET_BLINKING_PERIOD = 500; @@ -109,6 +110,8 @@ public class EditorSettingsExternalizable implements NamedJDOMExternalizable, Ex @NonNls public static final String STRIP_TRAILING_SPACES_CHANGED = "Changed"; @NonNls public static final String STRIP_TRAILING_SPACES_WHOLE = "Whole"; + @MagicConstant(stringValues = {STRIP_TRAILING_SPACES_NONE, STRIP_TRAILING_SPACES_CHANGED, STRIP_TRAILING_SPACES_WHOLE}) + @interface StripTrailingSpaces {} @NonNls public static final String DEFAULT_FONT_NAME = "Courier"; @@ -356,12 +359,13 @@ public class EditorSettingsExternalizable implements NamedJDOMExternalizable, Ex public void setEnsureNewLineAtEOF(boolean ensure) { myOptions.IS_ENSURE_NEWLINE_AT_EOF = ensure; } - + + @StripTrailingSpaces public String getStripTrailingSpaces() { return myOptions.STRIP_TRAILING_SPACES; } // TODO: move to CodeEditorManager or something else - public void setStripTrailingSpaces(String stripTrailingSpaces) { + public void setStripTrailingSpaces(@StripTrailingSpaces String stripTrailingSpaces) { myOptions.STRIP_TRAILING_SPACES = stripTrailingSpaces; } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index fbed924fac7d..b641b949672d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -121,7 +121,6 @@ import java.text.AttributedString; import java.text.CharacterIterator; import java.util.*; import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -148,8 +147,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi private final CommandProcessor myCommandProcessor; @NotNull private final MyScrollBar myVerticalScrollBar; - private final CopyOnWriteArrayList myMouseListeners = ContainerUtil.createEmptyCOWList(); - @NotNull private final CopyOnWriteArrayList myMouseMotionListeners; + private final List myMouseListeners = ContainerUtil.createEmptyCOWList(); + @NotNull private final List myMouseMotionListeners = ContainerUtil.createEmptyCOWList(); private int myCharHeight = -1; private int myLineHeight = -1; @@ -313,7 +312,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi myConnection = project.getMessageBus().connect(); myConnection.subscribe(DocumentBulkUpdateListener.TOPIC, new EditorDocumentBulkUpdateAdapter()); } - myMouseMotionListeners = ContainerUtil.createEmptyCOWList(); MarkupModelListener markupModelListener = new MarkupModelListener() { @Override @@ -1017,6 +1015,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi } private int yPositionToVisibleLine(int y) { + LOG.assertTrue(y >= 0, y); return y / getLineHeight(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/TrailingSpacesStripper.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/TrailingSpacesStripper.java index ef7cb511f281..7958c1c78007 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/TrailingSpacesStripper.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/TrailingSpacesStripper.java @@ -37,6 +37,7 @@ import com.intellij.util.text.CharArrayUtil; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; +import java.awt.*; import java.util.Set; public final class TrailingSpacesStripper extends FileDocumentManagerAdapter { @@ -110,9 +111,9 @@ public final class TrailingSpacesStripper extends FileDocumentManagerAdapter { if (!(document instanceof DocumentImpl)) { return; } - if (!myDocumentsToStripLater.contains(document)) return; - DataContext dataContext = DataManager.getInstance().getDataContext(IdeFocusManager.getGlobalInstance().getFocusOwner()); + Component focusOwner = IdeFocusManager.getGlobalInstance().getFocusOwner(); + DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner); boolean isDisposeInProgress = ApplicationManager.getApplication().isDisposeInProgress(); // ignore caret placing when exiting Editor activeEditor = isDisposeInProgress ? null : PlatformDataKeys.EDITOR.getData(dataContext); diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java index 058531ccc711..1caa318409a0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java @@ -871,7 +871,7 @@ public final class IdeKeyEventDispatcher implements Disposable { if (value instanceof Pair) { final Pair pair = (Pair) value; append(KeymapUtil.getShortcutText(new KeyboardShortcut(pair.getSecond(), null)), SimpleTextAttributes.GRAY_ATTRIBUTES); - appendAlign(30); + appendFixedTextFragmentWidth(30); final String text = pair.getFirst().getTemplatePresentation().getText(); append(text, SimpleTextAttributes.REGULAR_ATTRIBUTES); } diff --git a/platform/platform-impl/src/com/intellij/platform/WebProjectGenerator.java b/platform/platform-impl/src/com/intellij/platform/WebProjectGenerator.java index fd61e900b344..abfec41aa9e2 100644 --- a/platform/platform-impl/src/com/intellij/platform/WebProjectGenerator.java +++ b/platform/platform-impl/src/com/intellij/platform/WebProjectGenerator.java @@ -22,6 +22,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.ValidationInfo; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.IdeBorderFactory; import org.jetbrains.annotations.Nls; @@ -81,6 +82,9 @@ public abstract class WebProjectGenerator implements DirectoryProjectGenerato @NotNull JComponent getComponent(); + @Nullable + Pair getSettingsField(); + @NotNull T getSettings(); diff --git a/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java b/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java index acd9ef72b903..bb211f7770d9 100644 --- a/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java +++ b/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java @@ -31,7 +31,7 @@ import java.awt.image.BufferedImage; import java.util.Collection; import java.util.Collections; -abstract public class AbstractExpandableItemsHandler implements ExpandableItemsHandler { +public abstract class AbstractExpandableItemsHandler implements ExpandableItemsHandler { private final Alarm myUpdateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD); protected final ComponentType myComponent; @@ -53,21 +53,26 @@ abstract public class AbstractExpandableItemsHandler + + + + +