Merge remote-tracking branch 'origin/master'

This commit is contained in:
Konstantin Bulenkov
2012-10-26 17:43:04 +02:00
163 changed files with 2210 additions and 1205 deletions
Binary file not shown.
Binary file not shown.
@@ -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) {
@@ -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("<br>");
}
else if (" ".equals(each)) {
tipBuilder.append("&nbsp ");
}
else {
tipBuilder.append(JDOMUtil.legalizeText(each));
}
while (tokenizer.hasMoreElements()) {
final String each = tokenizer.nextElement();
if ("\n".equals(each)) {
tipBuilder.append("<br>");
}
else if (" ".equals(each)) {
tipBuilder.append("&nbsp ");
}
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);
}
}
}
}
}
@@ -71,7 +71,6 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
public static final DataKey<DebuggerTree> 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) {
@@ -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<ExceptionFilterFactory> EP_NAME = ExtensionPointName.create("com.intellij.exceptionFilter");
Filter create(final GlobalSearchScope searchScope);
@NotNull
Filter create(@NotNull GlobalSearchScope searchScope);
}
@@ -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<Filter> getFilters(final GlobalSearchScope searchScope) {
List<Filter> filters = new ArrayList<Filter>();
@NotNull
public static List<Filter> getFilters(@NotNull GlobalSearchScope searchScope) {
ExceptionFilterFactory[] extensions = ExceptionFilterFactory.EP_NAME.getExtensions();
List<Filter> filters = new ArrayList<Filter>(extensions.length);
for (ExceptionFilterFactory extension : extensions) {
filters.add(extension.create(searchScope));
}
@@ -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;
}
}
@@ -1,93 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.util.newProjectWizard.ProjectSettingsStep">
<grid id="807b" binding="myModulePanel" layout-manager="GridBagLayout">
<constraints>
<xy x="20" y="20" width="893" height="453"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="8a2b7" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
<gridbag weightx="1.0" weighty="0.0"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="e6ad1" class="javax.swing.JTextField" binding="myModuleName">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="1f996" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="e6ad1"/>
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.name.title"/>
</properties>
</component>
<component id="4af6e" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myModuleContentRoot">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="c4851" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="4af6e"/>
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.root.title"/>
</properties>
</component>
<component id="83a50" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myModuleFileLocation">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<preferredSize width="280" height="20"/>
</properties>
</component>
<component id="a4319" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="83a50"/>
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.file.title"/>
</properties>
</component>
</children>
</grid>
<grid id="fa640" binding="myHeader" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<visible value="true"/>
</properties>
<border type="none"/>
<children/>
</grid>
<grid id="8ada9" binding="myExpertPanel" layout-manager="GridBagLayout">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</form>
@@ -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;
}
}
@@ -3,14 +3,16 @@
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="503" height="400"/>
<xy x="20" y="20" width="608" height="393"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="ac540" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false">
<preferred-size width="155" height="44"/>
</grid>
</constraints>
<properties/>
<border type="none"/>
@@ -60,7 +62,15 @@
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
</clientProperties>
<border type="etched" title="Settings"/>
<children/>
<children>
<grid id="14333" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints border-constraint="North"/>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
<grid id="5732c" binding="myDescriptionPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
@@ -93,7 +103,70 @@
</constraints>
<properties/>
<border type="none"/>
<children/>
<children>
<grid id="a59bf" binding="myExpertPanel" layout-manager="GridBagLayout">
<constraints border-constraint="Center"/>
<properties/>
<border type="none"/>
<children>
<component id="edb8a" class="javax.swing.JTextField" binding="myModuleName">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
<gridbag top="2" left="0" bottom="2" right="0" weightx="1.0" weighty="1.0"/>
</constraints>
<properties/>
</component>
<component id="40abf" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="1.0"/>
</constraints>
<properties>
<labelFor value="e6ad1"/>
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.name.title"/>
</properties>
</component>
<component id="d2d6b" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myModuleContentRoot">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<gridbag top="2" left="0" bottom="2" right="0" weightx="1.0" weighty="1.0"/>
</constraints>
<properties/>
</component>
<component id="7afef" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="1.0"/>
</constraints>
<properties>
<labelFor value="4af6e"/>
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.root.title"/>
</properties>
</component>
<component id="9e1b8" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myModuleFileLocation">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<gridbag top="2" left="0" bottom="2" right="0" weightx="1.0" weighty="1.0"/>
</constraints>
<properties>
<preferredSize width="280" height="20"/>
</properties>
</component>
<component id="2ac4e" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="1.0"/>
</constraints>
<properties>
<labelFor value="83a50"/>
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.file.title"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</children>
</grid>
@@ -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<SimpleNode> 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<String, ProjectTemplate> groups = new MultiMap<String, ProjectTemplate>();
@@ -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("<html><body><font face=\"Verdana\" ");
@@ -265,17 +309,24 @@ public class SelectTemplateStep extends ModuleWizardStep {
}
}
mySettingsPanel.setVisible(mySettingsStep != null);
myExpertPanel.setVisible(expertSettingsPanel != null);
mySettingsPanel.setVisible(template != null);
myExpertPlaceholder.setVisible(myModuleBuilder != null && !myModuleBuilder.isTemplateBased());
myDescriptionPanel.setVisible(StringUtil.isNotEmpty(description));
mySettingsPanel.revalidate();
mySettingsPanel.repaint();
}
private static void restorePanel(JPanel component, int i) {
while (component.getComponentCount() > 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<ProjectTemplate> 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();
}
}
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.util.projectWizard.JavaSettingsStep">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="5" left="0" bottom="0" right="0"/>
<margin top="2" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="31"/>
</constraints>
@@ -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<SdkType> sdkFilter) {
super(wizardContext);
public JavaSettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder, Condition<SdkType> 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<JTextField> listener =
new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
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) {
@@ -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<SdkType> sdkFilter) {
return new JavaSettingsStep(context, moduleBuilder, sdkFilter);
public ModuleWizardStep createJavaSettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder, Condition<SdkType> sdkFilter) {
return new JavaSettingsStep(settingsStep, moduleBuilder, sdkFilter);
}
}
@@ -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<SdkType> 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;
}
}
@@ -61,6 +61,11 @@ class TemplateModuleBuilder extends ModuleBuilder {
return myType;
}
@Override
public boolean isTemplateBased() {
return true;
}
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
@@ -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;
@@ -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]) {
@@ -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;
}
@@ -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());
}
}
@@ -103,8 +103,8 @@ public class JavaModuleType extends ModuleType<JavaModuleBuilder> {
@Nullable
@Override
public SettingsStep createSettingsStep(WizardContext context, ModuleBuilder moduleBuilder) {
return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(context, moduleBuilder, new Condition<SdkType>() {
public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder) {
return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, moduleBuilder, new Condition<SdkType>() {
@Override
public boolean value(SdkType sdk) {
return sdk instanceof JavaSdkType;
@@ -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 <constructorDeclaration>SomeClass</constructorDeclaration>(<interface>AnInterface</interface> <param>param</param>, int[] <reassignedParameter>reassignedParam</reassignedParameter>) {\n" +
" <error>int <localVar>localVar</localVar> = \"IntelliJ\"</error>; // Error, incompatible types\n" +
" <class>System</class>.<static>out</static>.<methodCall>println</methodCall>(<field>anotherString</field> + <field>field</field> + <localVar>localVar</localVar>);\n" +
" <class>System</class>.<static>out</static>.<methodCall>println</methodCall>(<field>anotherString</field> + <inherited_method>toString</inherited_method>() + <localVar>localVar</localVar>);\n" +
" long <localVar>time</localVar> = <class>Date</class>.<static_method><deprecated>parse</deprecated></static_method>(\"1.2.3\"); // Method is deprecated\n" +
" int <reassignedLocalVar>reassignedValue</reassignedLocalVar> = this.<warning>staticField</warning>; \n" +
" <reassignedLocalVar>reassignedValue</reassignedLocalVar> ++; \n" +
" <field>field</field>.<abstract_method>run</abstract_method>(); \n" +
" new <anonymousClass>SomeClass</anonymousClass>() {\n" +
" {\n" +
" int <localVar>a</localVar> = <implicitAnonymousParameter>localVar</implicitAnonymousParameter>;\n" +
@@ -177,8 +186,9 @@ public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColor
" <reassignedParameter>reassignedParam</reassignedParameter> = new int[2];\n" +
" }\n" +
"}\n" +
"enum <enum>AnEnum</enum> { <static_final>CONST1</static_final>, <static_final>CONST2</static_final> }\n"+
"interface <interface>AnInterface</interface> {\n" +
" int <static>CONSTANT</static> = 2;\n" +
" int <static_final>CONSTANT</static_final> = 2;\n" +
" void <methodDeclaration>method</methodDeclaration>();\n" +
"}\n" +
"abstract class <abstractClass>SomeAbstractClass</abstractClass> {\n" +
@@ -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<VirtualFile,VcsRevisionNumber> myRevNumbersCache;
public VcsContentAnnotationExceptionFilter(GlobalSearchScope scope) {
public VcsContentAnnotationExceptionFilter(@NotNull GlobalSearchScope scope) {
myScope = scope;
myProject = scope.getProject();
mySettings = VcsContentAnnotationSettings.getInstance(myProject);
@@ -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<JavaElementArrangementEntry>, ArrangementStandardSettingsAware,
ArrangementConditionsGrouper
ArrangementConditionsGrouper, ArrangementColorsAware
{
// Type
@@ -201,6 +210,7 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>,
break;
case OVERRIDDEN_METHODS:
setupOverriddenMethods(parseInfo);
default: assert false;
}
}
}
@@ -374,4 +384,66 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>,
}
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;
}
}
@@ -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);
}
}
@@ -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;
}
}
@@ -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);
@@ -273,8 +273,8 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
}
}
if (lowerBound != PsiType.NULL) return new Pair<PsiType, ConstraintType>(lowerBound, ConstraintType.EQUALS);
if (rawInference != null) return rawInference;
if (lowerBound != PsiType.NULL) return new Pair<PsiType, ConstraintType>(lowerBound, ConstraintType.EQUALS);
if (parent != null) {
final Pair<PsiType, ConstraintType> constraint =
@@ -0,0 +1,17 @@
import java.util.*;
class Test {
interface Condition<K> {}
class IOC<M> implements Condition {}
static <T> List<T> filter(T[] c, Condition<? super T> con) {
return null;
}
interface OE {}
interface LOE extends OE {}
void foo(OE[] es, IOC<LOE> con) {
List<LOE> l = filter(es, con);
}
}
@@ -0,0 +1,14 @@
// "Replace with lambda" "true"
class Test {
interface Eff<A, B> {
B f(A a);
}
interface InOut<A> {
A run() throws IOException;
<B> InOut<B> bind(final Eff<A, InOut<B>> f) default {
return () -> f.f(InOut.this.run()).run();
}
}
}
@@ -0,0 +1,19 @@
// "Replace with lambda" "true"
class Test {
interface Eff<A, B> {
B f(A a);
}
interface InOut<A> {
A run() throws IOException;
<B> InOut<B> bind(final Eff<A, InOut<B>> f) default {
return new In<caret>Out<B>() {
@Override
public B run() throws IOException {
return f.f(InOut.this.run()).run();
}
};
}
}
}
@@ -1,12 +0,0 @@
// "Replace with method reference" "true"
interface Foo<A, B> {
B f(A a);
}
interface DeeBee<A> {
A run(Void c) throws SQLException;
<B> DeeBee<B> bind(final Foo<A, DeeBee<B>> f) default {
return f.f(null)::run;
}
}
@@ -1,4 +1,4 @@
// "Replace with method reference" "true"
// "Replace with method reference" "false"
interface Foo<A, B> {
B f(A a);
}
@@ -0,0 +1,5 @@
package bar;
public class A {
public static void foo() {}
}
@@ -0,0 +1,5 @@
package bar;
public class B {
public static void foo(String s) {}
}
@@ -0,0 +1,7 @@
import bar.A;
class Usage {
void bar() {
A.foo();
}
}
@@ -0,0 +1,4 @@
package bar;
public class A {
}
@@ -0,0 +1,6 @@
package bar;
public class B {
public static void foo() {}
public static void foo(String s) {}
}
@@ -0,0 +1,7 @@
import static bar.B.foo;
class Usage {
void bar() {
foo();
}
}
@@ -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); }
@@ -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 {
@@ -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);
@@ -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<TextRange, TextRange, TextRange> 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);
}
}
}
@@ -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<SdkType> sdkFilter);
public abstract ModuleWizardStep createJavaSettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder, Condition<SdkType> sdkFilter);
}
@@ -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<FileIconProvider> 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);
}
@@ -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.
@@ -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");
@@ -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;
@@ -46,7 +46,7 @@ import java.awt.image.BufferedImage;
public class IconUtil {
private static final Key<Boolean> 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;
@@ -110,6 +110,9 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
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<T> implements ExtensionPoint<T> {
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<T> implements ExtensionPoint<T> {
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<T> implements ExtensionPoint<T> {
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<T> implements ExtensionPoint<T> {
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<T> implements ExtensionPoint<T> {
return getName();
}
synchronized void registerExtensionAdapter(ExtensionComponentAdapter adapter) {
synchronized void registerExtensionAdapter(@NotNull ExtensionComponentAdapter adapter) {
myExtensionAdapters.add(adapter);
clearCache();
}
private void assertClass(@NotNull Class<?> extensionClass) {
Class<T> expectedClass = getExtensionClass();
assert expectedClass.isAssignableFrom(extensionClass) : "Expected: "+ expectedClass +"; Actual: "+ extensionClass;
}
private void clearCache() {
myExtensionsCache = null;
}
@@ -421,7 +434,7 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
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;
@@ -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) {
@@ -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);
}
@@ -171,7 +171,7 @@ public class WizardContext {
return myProjectBuilder;
}
public void setProjectBuilder(final ProjectBuilder projectBuilder) {
public void setProjectBuilder(@Nullable final ProjectBuilder projectBuilder) {
myProjectBuilder = projectBuilder;
}
@@ -50,7 +50,7 @@ public abstract class ModuleType<T extends ModuleBuilder> {
}
@Nullable
public SettingsStep createSettingsStep(WizardContext context, ModuleBuilder moduleBuilder) {
public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder) {
return null;
}
@@ -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.
* <p/>
* 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);
@@ -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);
}
@@ -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<ArrangementSettingType, Color> myTextColors
= new EnumMap<ArrangementSettingType, Color>(ArrangementSettingType.class);
@NotNull private final Map<ArrangementSettingType, Color> myBackgroundColors
= new EnumMap<ArrangementSettingType, Color>(ArrangementSettingType.class);
@NotNull private final Map<ArrangementSettingType, Color> mySelectedTextColors
= new EnumMap<ArrangementSettingType, Color>(ArrangementSettingType.class);
@NotNull private final Map<ArrangementSettingType, Color> mySelectedBackgroundColors
= new EnumMap<ArrangementSettingType, Color>(ArrangementSettingType.class);
@NotNull private final Map<ArrangementSettingType, TextAttributes> myTextAttributes
= new EnumMap<ArrangementSettingType, TextAttributes>(ArrangementSettingType.class);
@NotNull private final Map<ArrangementSettingType, TextAttributes> mySelectedTextAttributes
= new EnumMap<ArrangementSettingType, TextAttributes>(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<ArrangementSettingType, Color> 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);
}
}
}
@@ -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<ArrangementSettingType> myMaxWidths = new TObjectIntHashMap<ArrangementSettingType>();
@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<Set<ArrangementMatchCondition>> groupingRules)
@NotNull ArrangementColorsProvider colorsProvider,
@NotNull ArrangementStandardSettingsRepresentationAware representationManager)
{
myFilter = filter;
myColorsProvider = colorsProvider;
myRepresentationManager = representationManager;
Map<ArrangementSettingType, Collection<?>> map = ArrangementConfigUtil.buildAvailableConditions(filter, null);
for (Map.Entry<ArrangementSettingType, Collection<?>> 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<ArrangementSettingType, Collection<?>> map = ArrangementConfigUtil.buildAvailableConditions(myFilter, null);
for (Map.Entry<ArrangementSettingType, Collection<?>> 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).
*
@@ -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);
@@ -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;
}
}
@@ -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;
@@ -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);
@@ -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;
@@ -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);
@@ -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());
@@ -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<String, OccurenceNavigator> myOccurrenceNavigators = new HashMap<String, OccurenceNavigator>();
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<String, String> myType2ScopeMap = new HashMap<String, String>();
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<Image, Point> 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<HierarchyTreeBuilder> 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<Object> storedInfo = new Ref<Object>();
final Ref<Pair<ArrayList<Object>, ArrayList<Object>>> storedInfo = new Ref<Pair<ArrayList<Object>, ArrayList<Object>>>();
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);
@@ -57,10 +57,12 @@ public final class HierarchyBrowserManager implements PersistentStateComponent<H
return myContentManager;
}
@Override
public State getState() {
return myState;
}
@Override
public void loadState(final State state) {
myState = state;
}
@@ -30,7 +30,6 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiTreeChangeAdapter;
import com.intellij.psi.PsiTreeChangeEvent;
import com.intellij.psi.PsiTreeChangeListener;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -39,11 +38,6 @@ import java.util.ArrayList;
import java.util.Comparator;
public class HierarchyTreeBuilder extends AbstractTreeBuilder {
private final Project myProject;
private final PsiTreeChangeListener myPsiTreeChangeListener;
private final MyFileStatusListener myFileStatusListener;
public HierarchyTreeBuilder(final Project project,
final JTree tree,
final DefaultTreeModel treeModel,
@@ -51,95 +45,93 @@ public class HierarchyTreeBuilder extends AbstractTreeBuilder {
final Comparator<NodeDescriptor> 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<Object>, ArrayList<Object>> storeExpandedAndSelectedInfo() {
final ArrayList<Object> pathsToExpand = new ArrayList<Object>();
final ArrayList<Object> selectionPaths = new ArrayList<Object>();
TreeBuilderUtil.storePaths(this, getRootNode(), pathsToExpand, selectionPaths, true);
return new Pair<ArrayList<Object>, ArrayList<Object>>(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<Object>, ArrayList<Object>> 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());
}
@@ -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);
}
@@ -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<String, JComponent> getSettingsField() {
return null;
}
@NotNull
@Override
public Object getSettings() {
@@ -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<T> extends WebProjectGenerator<T> imple
return builder.getModuleType();
}
@Override
public boolean isTemplateBased() {
return true;
}
@Override
public List<Module> commit(Project project, ModifiableModuleModel model, ModulesProvider modulesProvider) {
List<Module> modules = builder.commit(project, model, modulesProvider);
@@ -70,6 +77,25 @@ public abstract class WebProjectTemplate<T> extends WebProjectGenerator<T> imple
}
return modules;
}
@Nullable
@Override
public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep) {
Pair<String, JComponent> 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() {
}
};
}
};
}
@@ -1,13 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.lang.javascript.boilerplate.GithubProjectGeneratorPeer">
<grid id="27dc6" binding="myComponent" layout-manager="GridLayoutManager" row-count="3" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myComponent" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="100"/>
<xy x="20" y="20" width="500" height="107"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<vspacer id="61e03">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="6cca1" class="javax.swing.JLabel" binding="myErrorMessage">
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-52429"/>
<foreground color="-65434"/>
<text value="Error message"/>
</properties>
</component>
<grid id="55618" binding="myVersionPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="7379c" class="javax.swing.JComboBox" binding="myComboBox">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="dd95a" class="javax.swing.JButton" binding="myReloadButton">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Reload"/>
</properties>
</component>
<hspacer id="cb5b0">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
<component id="7efaf" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
@@ -17,42 +63,6 @@
<text value="&amp;Version:"/>
</properties>
</component>
<hspacer id="cb5b0">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<vspacer id="61e03">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="7379c" class="javax.swing.JComboBox" binding="myComboBox">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="6cca1" class="javax.swing.JLabel" binding="myErrorMessage">
<constraints>
<grid row="1" column="0" row-span="1" col-span="4" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-52429"/>
<foreground color="-65434"/>
<text value="Error message"/>
</properties>
</component>
<component id="dd95a" class="javax.swing.JButton" binding="myReloadButton">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Reload"/>
</properties>
</component>
</children>
</grid>
</form>
@@ -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<String, JComponent> getSettingsField() {
return new Pair<String, JComponent>("\u001BVersion:", myVersionPanel);
}
@NotNull
@Override
public GithubTagInfo getSettings() {
@@ -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);
@@ -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) {
@@ -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
@@ -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 {
@@ -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<String, StringPattern> {
return with(new ValuePatternCondition<String>("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<String, StringPattern> {
return super.oneOf(set);
}
@NotNull
public static CharSequence newBombedCharSequence(@NotNull CharSequence sequence) {
return new StringUtil.BombedCharSequence(sequence) {
@Override
protected void checkCanceled() {
ProgressManager.checkCanceled();
}
};
}
}
@@ -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<String> myFragments;
private final ArrayList<String> myFragments;
private final ArrayList<SimpleTextAttributes> myAttributes;
private ArrayList<Object> myFragmentTags = null;
/**
* Component's icon. It can be <code>null</code>.
*/
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 <code>null</code>.
*/
private Border myBorder;
private Border myBorder;
private int myMainTextLastIndex = -1;
private final Map<Integer, Integer> 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<Integer, Integer>(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;
}
@@ -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);
@@ -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
@@ -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
@@ -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<OptionDescription> configs = myStorage.get(option);
if (configs == null) {
configs = new THashSet<OptionDescription>(3, 0.9f);
configs = new SingletonSet<OptionDescription>(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<OptionDescription>(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<String> getSynonym(final String option, @NotNull final SearchableConfigurable configurable) {
loadHugeFilesIfNecessary();
return myHighlightOption2Synonym.get(Pair.create(option, configurable.getId()));
}
@Override
public Map<String, Set<String>> 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<String> getProcessedWordsWithoutStemming(@NotNull String text) {
Set<String> result = new HashSet<String>();
@NonNls final String toLowerCase = text.toLowerCase();
@@ -416,6 +429,7 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar {
return result;
}
@Override
public Set<String> getProcessedWords(@NotNull String text) {
Set<String> result = new HashSet<String>();
@NonNls final String toLowerCase = text.toLowerCase();
@@ -429,6 +443,7 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar {
return result;
}
@Override
public Set<String> replaceSynonyms(Set<String> options, SearchableConfigurable configurable) {
final Set<String> result = new HashSet<String>(options);
for (String option : options) {
@@ -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);
}
@@ -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();
}
@@ -49,6 +49,7 @@ public class Launcher {
myOutput = output;
}
@Override
public void run() {
Reader reader = new InputStreamReader(myInput);
do {
@@ -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,
@@ -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<String> myLockedPaths = new ArrayList<String>();
@@ -209,6 +209,7 @@ public class SocketLock {
private class MyRunnable implements Runnable {
@Override
public void run() {
try {
while (true) {
@@ -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;
}
@@ -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<EditorMouseListener> myMouseListeners = ContainerUtil.createEmptyCOWList();
@NotNull private final CopyOnWriteArrayList<EditorMouseMotionListener> myMouseMotionListeners;
private final List<EditorMouseListener> myMouseListeners = ContainerUtil.createEmptyCOWList();
@NotNull private final List<EditorMouseMotionListener> 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();
}
@@ -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);
@@ -871,7 +871,7 @@ public final class IdeKeyEventDispatcher implements Disposable {
if (value instanceof Pair) {
final Pair<AnAction, KeyStroke> pair = (Pair<AnAction, KeyStroke>) 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);
}
@@ -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<T> implements DirectoryProjectGenerato
@NotNull
JComponent getComponent();
@Nullable
Pair<String, JComponent> getSettingsField();
@NotNull
T getSettings();
@@ -31,7 +31,7 @@ import java.awt.image.BufferedImage;
import java.util.Collection;
import java.util.Collections;
abstract public class AbstractExpandableItemsHandler<KeyType, ComponentType extends JComponent> implements ExpandableItemsHandler<KeyType> {
public abstract class AbstractExpandableItemsHandler<KeyType, ComponentType extends JComponent> implements ExpandableItemsHandler<KeyType> {
private final Alarm myUpdateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
protected final ComponentType myComponent;
@@ -53,21 +53,26 @@ abstract public class AbstractExpandableItemsHandler<KeyType, ComponentType exte
myTipComponent = new TipComponent();
myComponent.addMouseListener(
new MouseListener() {
@Override
public void mouseEntered(MouseEvent e) {
handleMouseEvent(e);
}
@Override
public void mouseExited(MouseEvent e) {
hideHint();
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
handleMouseEvent(e);
}
@Override
public void mouseReleased(MouseEvent e) {
handleMouseEvent(e);
}
@@ -76,10 +81,12 @@ abstract public class AbstractExpandableItemsHandler<KeyType, ComponentType exte
myComponent.addMouseMotionListener(
new MouseMotionListener() {
@Override
public void mouseDragged(MouseEvent e) {
handleMouseEvent(e);
}
@Override
public void mouseMoved(MouseEvent e) {
handleMouseEvent(e, false);
}
@@ -88,10 +95,12 @@ abstract public class AbstractExpandableItemsHandler<KeyType, ComponentType exte
myComponent.addFocusListener(
new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
onFocusLost();
}
@Override
public void focusGained(FocusEvent e) {
updateCurrentSelection();
}
@@ -100,10 +109,12 @@ abstract public class AbstractExpandableItemsHandler<KeyType, ComponentType exte
myComponent.addComponentListener(
new ComponentAdapter() {
@Override
public void componentHidden(ComponentEvent e) {
hideHint();
}
@Override
public void componentMoved(ComponentEvent e) {
updateCurrentSelection();
}
@@ -129,6 +140,7 @@ abstract public class AbstractExpandableItemsHandler<KeyType, ComponentType exte
myComponent.addHierarchyListener(
new HierarchyListener() {
@Override
public void hierarchyChanged(HierarchyEvent e) {
hideHint();
}
@@ -179,6 +191,7 @@ abstract public class AbstractExpandableItemsHandler<KeyType, ComponentType exte
}
myUpdateAlarm.cancelAllRequests();
myUpdateAlarm.addRequest(new Runnable() {
@Override
public void run() {
doHandleSelectionChange(selected, processIfUnfocused);
}
@@ -362,18 +375,22 @@ abstract public class AbstractExpandableItemsHandler<KeyType, ComponentType exte
protected abstract KeyType getCellKeyForPoint(Point point);
private class TipComponent extends JComponent {
@Override
public Dimension getMaximumSize() {
return getPreferredSize();
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
}
@Override
public Dimension getPreferredSize() {
return new Dimension(myImage.getWidth(), myImage.getHeight());
}
@Override
public void paint(Graphics g) {
g.drawImage(myImage, 0, 0, null);
}
@@ -13,6 +13,7 @@ import org.jboss.netty.channel.group.ChannelGroup;
import org.jboss.netty.channel.group.DefaultChannelGroup;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jboss.netty.handler.codec.http.*;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.net.InetAddress;
@@ -32,6 +33,9 @@ public class WebServer {
private static final Logger LOG = Logger.getInstance(WebServer.class);
@NonNls
private static final String PROPERTY_ONLY_ANY_HOST = "rpc.onlyAnyHost";
public WebServer() {
final Application application = ApplicationManager.getApplication();
final Executor pooledThreadExecutor = new Executor() {
@@ -74,11 +78,13 @@ public class WebServer {
// but if we bind only to any local port (0.0.0.0), instance of idea <121 can bind to our ports and any request to us will be intercepted
// so, we bind to 127.0.0.1 and 0.0.0.0
private int bind(int firstPort, int portsCount, boolean tryAnyPort, ServerBootstrap bootstrap) {
String property = System.getProperty(PROPERTY_ONLY_ANY_HOST);
boolean onlyAnyHost = property == null ? SystemInfo.isLinux || SystemInfo.isWindowsXP : (property.isEmpty() || Boolean.valueOf(property));
for (int i = 0; i < portsCount; i++) {
int port = firstPort + i;
try {
openChannels.add(bootstrap.bind(new InetSocketAddress(port)));
if (!SystemInfo.isLinux) {
if (!onlyAnyHost) {
openChannels.add(bootstrap.bind(new InetSocketAddress(InetAddress.getByName("127.0.0.1"), port)));
}
return port;
@@ -71,18 +71,22 @@ options.java.attribute.descriptor.anonymous.class=Anonymous class
options.java.attribute.descriptor.type.parameter=Type parameter
options.java.attribute.descriptor.abstract.class=Abstract class
options.java.attribute.descriptor.interface=Interface
options.java.attribute.descriptor.enum=Enum
options.java.attribute.descriptor.local.variable=Local variable
options.java.attribute.descriptor.reassigned.local.variable=Reassigned local variable
options.java.attribute.descriptor.reassigned.parameter=Reassigned parameter
options.java.attribute.descriptor.implicit.anonymous.parameter=Implicit anonymous class parameter
options.java.attribute.descriptor.instance.field=Instance field
options.java.attribute.descriptor.static.field=Static field
options.java.attribute.descriptor.static.final.field=Constant
options.java.attribute.descriptor.parameter=Parameter
options.java.attribute.descriptor.method.call=Method call
options.java.attribute.descriptor.method.declaration=Method declaration
options.java.attribute.descriptor.constructor.call=Constructor call
options.java.attribute.descriptor.constructor.declaration=Constructor declaration
options.java.attribute.descriptor.static.method=Static method
options.java.attribute.descriptor.abstract.method=Abstract method
options.java.attribute.descriptor.inherited.method=Inherited method
options.java.attribute.descriptor.matched.brace=Matched brace
options.java.attribute.descriptor.unmatched.brace=Unmatched brace
options.java.attribute.descriptor.bad.character=Bad character
@@ -454,6 +454,13 @@
<option name="EFFECT_COLOR"/>
</value>
</option>
<option name="ENUM_NAME_ATTRIBUTES">
<value>
<option name="FOREGROUND"/>
<option name="BACKGROUND"/>
<option name="EFFECT_COLOR"/>
</value>
</option>
<option name="METHOD_CALL_ATTRIBUTES">
<value>
@@ -493,6 +500,22 @@
</value>
</option>
<option name="ABSTRACT_METHOD_ATTRIBUTES">
<value>
<option name="FOREGROUND"/>
<option name="BACKGROUND"/>
<option name="EFFECT_COLOR"/>
</value>
</option>
<option name="INHERITED_METHOD_ATTRIBUTES">
<value>
<option name="FOREGROUND"/>
<option name="BACKGROUND"/>
<option name="EFFECT_COLOR"/>
</value>
</option>
<option name="ANNOTATION_ATTRIBUTE_NAME_ATTRIBUTES">
<value>
<option name="FOREGROUND"/>
@@ -735,6 +758,14 @@
</option>
<option name="STATIC_FIELD_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="660e7a"/>
<option name="BACKGROUND"/>
<option name="EFFECT_COLOR"/>
<option name="FONT_TYPE" value="2"/>
</value>
</option>
<option name="STATIC_FINAL_FIELD_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="660e7a"/>
<option name="BACKGROUND"/>
@@ -125,6 +125,24 @@ public class StripTrailingSpacesTest extends LightPlatformCodeInsightTestCase {
checkResultByText("xxx\n<caret>yyy\n"); // now we can strip
}
public void testDisableStrip_Modify_Save_EnableOnModifiedLines_Modify_Save_ShouldStripModifiedOnly() throws IOException {
EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
settings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE);
configureFromFileText("x.txt", "");
type("xxx \nyyy \nzzz \n");
myEditor.getCaretModel().moveToOffset(0);
end();end();
FileDocumentManager.getInstance().saveAllDocuments();
checkResultByText("xxx <caret>\nyyy \nzzz \n");
settings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_CHANGED);
type(' ');
myEditor.getCaretModel().moveToOffset(myEditor.getDocument().getText().length());
FileDocumentManager.getInstance().saveAllDocuments();
checkResultByText("xxx\nyyy \nzzz \n<caret>");
}
public void testDoNotStripModifiedLines_And_EnsureBlankLineAtTheEnd_LeavesWhitespacesAtTheEndOfFileAlone() throws IOException {
EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
settings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE);
@@ -17,7 +17,11 @@ package com.intellij.openapi.fileEditor;
import com.intellij.codeStyle.CodeStyleFacade;
import com.intellij.codeStyle.DefaultCodeStyleFacade;
import com.intellij.mock.*;
import com.intellij.ide.DataManager;
import com.intellij.ide.impl.DataManagerImpl;
import com.intellij.mock.MockCommandProcessor;
import com.intellij.mock.MockEditorFactory;
import com.intellij.mock.MockVirtualFile;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.UndoConfirmationPolicy;
import com.intellij.openapi.editor.Document;
@@ -91,6 +95,7 @@ public class FileDocumentManagerImplTest extends PlatformLiteFixture {
final ProjectManager projectManager = EasyMock.createMock(ProjectManager.class);
myDocumentManager = new MyMockFileDocumentManager(virtualFileManager, projectManager);
getApplication().registerService(FileDocumentManager.class, myDocumentManager);
getApplication().registerService(DataManager.class, new DataManagerImpl());
}
public void testGetCachedDocument_Cached() throws Exception {

Some files were not shown because too many files have changed in this diff Show More