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

This commit is contained in:
Kirill Kalishev
2009-11-12 18:59:03 +03:00
10 changed files with 82 additions and 63 deletions
@@ -18,6 +18,7 @@ package com.intellij.packaging.impl.compiler;
import com.intellij.compiler.impl.ModuleCompileScope;
import com.intellij.openapi.compiler.CompileScope;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.packaging.artifacts.Artifact;
@@ -28,9 +29,11 @@ import com.intellij.packaging.impl.elements.ModuleOutputElementType;
import com.intellij.packaging.impl.elements.ModuleOutputPackagingElement;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
/**
* @author nik
@@ -68,22 +71,33 @@ public class ArtifactCompileScope {
return baseScope;
}
@Nullable
public static Artifact[] getArtifacts(@NotNull CompileScope compileScope) {
return compileScope.getUserData(ARTIFACTS_KEY);
}
public static Set<Artifact> getArtifactsToBuild(final Project project, final CompileScope compileScope) {
final Artifact[] artifactsFromScope = getArtifacts(compileScope);
final Artifact[] artifactsFromScope = compileScope.getUserData(ARTIFACTS_KEY);
if (artifactsFromScope != null) {
return new HashSet<Artifact>(Arrays.asList(artifactsFromScope));
}
Set<Artifact> artifacts = new HashSet<Artifact>();
for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
final ArtifactManager artifactManager = ArtifactManager.getInstance(project);
final Set<Module> modules = new HashSet<Module>(Arrays.asList(compileScope.getAffectedModules()));
for (Artifact artifact : artifactManager.getArtifacts()) {
if (artifact.isBuildOnMake()) {
artifacts.add(artifact);
if (modules.containsAll(Arrays.asList(ModuleManager.getInstance(project).getModules()))
|| containsModuleOutput(artifact, modules, artifactManager)) {
artifacts.add(artifact);
}
}
}
return artifacts;
}
private static boolean containsModuleOutput(Artifact artifact, final Set<Module> modules, ArtifactManager artifactManager) {
final PackagingElementResolvingContext context = artifactManager.getResolvingContext();
return !ArtifactUtil.processPackagingElements(artifact, ModuleOutputElementType.MODULE_OUTPUT_ELEMENT_TYPE,
new Processor<ModuleOutputPackagingElement>() {
public boolean process(ModuleOutputPackagingElement moduleOutputPackagingElement) {
final Module module = moduleOutputPackagingElement.findModule(context);
return module == null || !modules.contains(module);
}
}, context, true);
}
}
@@ -41,7 +41,8 @@ public class StringLiteralManipulator extends AbstractElementManipulator<PsiLite
}
public static TextRange getValueRange(PsiLiteralExpression element) {
if (!(element.getValue() instanceof String)) return TextRange.from(0, element.getTextLength());
final Object value = element.getValue();
if (!(value instanceof String || value instanceof Character)) return TextRange.from(0, element.getTextLength());
return new TextRange(1, Math.max(1, element.getTextLength() - 1));
}
}
@@ -156,10 +156,6 @@ public abstract class HierarchyTreeStructure extends AbstractTreeStructure {
}
protected boolean isInScope(final PsiElement baseClass, final PsiElement srcElement, final String scopeType) {
if (!srcElement.getManager().isInProject(srcElement)) {
//TODO why get here???
return false;
}
if (HierarchyBrowserBaseEx.SCOPE_CLASS.equals(scopeType)) {
if (!PsiTreeUtil.isAncestor(baseClass, srcElement, true)) {
return false;
@@ -426,7 +426,10 @@ public class FileSystemTreeImpl implements FileSystemTree {
final Object object = ((DefaultMutableTreeNode)last).getUserObject();
if (object instanceof FileNodeDescriptor) {
final FileElement element = ((FileNodeDescriptor)object).getElement();
selection.add(element.getFile());
final VirtualFile file = element.getFile();
if (file != null) {
selection.add(file);
}
}
}
}
@@ -18,8 +18,8 @@ package com.intellij.openapi.vcs.actions;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.editor.actions.ContentChooser;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.CheckinProjectPanel;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.VcsConfiguration;
@@ -29,7 +29,7 @@ import java.util.Collections;
import java.util.List;
/**
* Action showing the history of recently used commit messages. Source code of this class is provided
* Action showing the history of recently used commit messages. Source code of this class is provided
* as a sample of using the {@link CheckinProjectPanel} API. Actions to be shown in the commit dialog
* should be added to the <code>Vcs.MessageActionGroup</code> action group.
*
@@ -43,11 +43,14 @@ public class ShowMessageHistoryAction extends AnAction implements DumbAware {
public void update(AnActionEvent e) {
super.update(e);
CheckinProjectPanel panel = (CheckinProjectPanel)e.getDataContext().getData(CheckinProjectPanel.PANEL);
final CheckinProjectPanel panel = (CheckinProjectPanel)CheckinProjectPanel.PANEL_KEY.getData(e.getDataContext());
if (panel == null) {
e.getPresentation().setVisible(false);
e.getPresentation().setEnabled(false);
} else {
}
else {
e.getPresentation().setVisible(true);
final ArrayList<String> recentMessages = VcsConfiguration.getInstance(panel.getProject()).getRecentMessages();
e.getPresentation().setEnabled(!recentMessages.isEmpty());
@@ -55,37 +58,42 @@ public class ShowMessageHistoryAction extends AnAction implements DumbAware {
}
public void actionPerformed(AnActionEvent e) {
CheckinProjectPanel panel = (CheckinProjectPanel)e.getDataContext().getData(CheckinProjectPanel.PANEL);
final CheckinProjectPanel panel = (CheckinProjectPanel)CheckinProjectPanel.PANEL_KEY.getData(e.getDataContext());
if (panel != null) {
final Project project = panel.getProject();
final VcsConfiguration configuration = VcsConfiguration.getInstance(project);
final ArrayList<String> recentMessages = configuration.getRecentMessages();
Collections.reverse(recentMessages);
if (!recentMessages.isEmpty()) {
if (!configuration.getRecentMessages().isEmpty()) {
final ContentChooser<String> contentChooser = new ContentChooser<String>(project, VcsBundle.message("dialog.title.choose.commit.message.from.history"), false){
protected void removeContentAt(final String content) {
}
final ContentChooser<String> contentChooser =
new ContentChooser<String>(project, VcsBundle.message("dialog.title.choose.commit.message.from.history"), false) {
protected void removeContentAt(final String content) {
configuration.removeMessage(content);
}
protected String getStringRepresentationFor(final String content) {
return content;
}
protected String getStringRepresentationFor(final String content) {
return content;
}
protected List<String> getContents() {
final List<String> recentMessages = configuration.getRecentMessages();
Collections.reverse(recentMessages);
return recentMessages;
}
};
protected List<String> getContents() {
return recentMessages;
}
};
contentChooser.show();
if (contentChooser.isOK()) {
final int selectedIndex = contentChooser.getSelectedIndex();
if (selectedIndex >= 0) {
panel.setCommitMessage(contentChooser.getAllContents().get(selectedIndex));
}
}
}
}
}
}
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.vcs.ui;
import org.jetbrains.annotations.NonNls;
import com.intellij.openapi.actionSystem.DataKey;
/**
@@ -25,17 +24,19 @@ import com.intellij.openapi.actionSystem.DataKey;
* @author lesya
*/
public interface Refreshable {
DataKey<Refreshable> PANEL_KEY = DataKey.create("Panel");
/**
* The data ID which can be used to retrieve the active <code>Refreshable</code>
* instance from {@link com.intellij.openapi.actionSystem.DataContext}.
*
* @see com.intellij.openapi.actionSystem.DataContext#getData(String)
*/
@NonNls @Deprecated String PANEL = "Panel";
DataKey<Refreshable> PANEL_KEY = DataKey.create(PANEL);
@Deprecated String PANEL = PANEL_KEY.getName();
void refresh();
void saveState();
void restoreState();
}
@@ -262,11 +262,7 @@ public class GitRootTracker implements VcsListener {
if (!hasInvalidRoots) {
// check if roots have a problem
for (final VirtualFile root : rootSet) {
hasInvalidRoots = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
public Boolean compute() {
return hasUnmappedSubroots(root, rootSet);
}
});
hasInvalidRoots = hasUnmappedSubroots(root, rootSet);
if (hasInvalidRoots) {
break;
}
@@ -89,11 +89,10 @@ public class DeleteOptionsDialog extends DialogWrapper {
panel.add(new JLabel("Recent Messages: "), gc);
gc.gridy += 1;
ArrayList<String> messages = VcsConfiguration.getInstance(myProject).getRecentMessages();
if (messages != null) {
Collections.reverse(messages);
}
Object[] model = messages != null ? messages.toArray() : new Object[] {""};
final ArrayList<String> messages = VcsConfiguration.getInstance(myProject).getRecentMessages();
Collections.reverse(messages);
final String[] model = messages.toArray(new String[messages.size()]);
final JComboBox messagesBox = new JComboBox(model);
messagesBox.setRenderer(new MessageBoxCellRenderer());
panel.add(messagesBox, gc);
@@ -26,8 +26,8 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.DepthCombo;
import org.jetbrains.idea.svn.SvnBundle;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNURL;
import javax.swing.*;
import java.awt.*;
@@ -127,7 +127,7 @@ public class ImportOptionsDialog extends DialogWrapper implements ActionListener
final JLabel depthLabel = new JLabel(SvnBundle.message("label.depth.text"));
depthLabel.setToolTipText(SvnBundle.message("label.depth.description"));
panel.add(depthLabel, gc);
++ gc.gridx;
++gc.gridx;
myDepth = new DepthCombo();
panel.add(myDepth, gc);
depthLabel.setLabelFor(myDepth);
@@ -162,11 +162,10 @@ public class ImportOptionsDialog extends DialogWrapper implements ActionListener
panel.add(new JLabel("Recent Messages: "), gc);
gc.gridy += 1;
ArrayList<String> messages = VcsConfiguration.getInstance(myProject).getRecentMessages();
if (messages != null) {
Collections.reverse(messages);
}
Object[] model = messages != null ? messages.toArray() : new Object[] {""};
final ArrayList<String> messages = VcsConfiguration.getInstance(myProject).getRecentMessages();
Collections.reverse(messages);
final String[] model = messages.toArray(new String[messages.size()]);
final JComboBox messagesBox = new JComboBox(model);
messagesBox.setRenderer(new MessageBoxCellRenderer());
panel.add(messagesBox, gc);
@@ -199,7 +198,7 @@ public class ImportOptionsDialog extends DialogWrapper implements ActionListener
fcd.setDescription("Select directory to checkout from subversion");
fcd.setHideIgnored(false);
VirtualFile[] files = FileChooser.chooseFiles(getContentPane(), fcd, null);
if (files == null || files.length != 1 || files[0] == null) {
if (files.length != 1 || files[0] == null) {
return;
}
myPathField.setText(files[0].getPath().replace('/', File.separatorChar));
@@ -47,8 +47,8 @@ public class MkdirOptionsDialog extends DialogWrapper {
myOriginalURL = url;
try {
myURL = url.appendPath("NewFolder", true);
} catch (SVNException e) {
//
}
catch (SVNException ignore) {
}
setTitle("New Remote Folder");
init();
@@ -61,9 +61,10 @@ public class MkdirOptionsDialog extends DialogWrapper {
});
if (!project.isDefault()) {
ArrayList<String> messages = VcsConfiguration.getInstance(project).getRecentMessages();
final ArrayList<String> messages = VcsConfiguration.getInstance(project).getRecentMessages();
Collections.reverse(messages);
Object[] model = messages.toArray();
final String[] model = messages.toArray(new String[messages.size()]);
myMessagesBox.setModel(new DefaultComboBoxModel(model));
myMessagesBox.setRenderer(new MessageBoxCellRenderer());
}
@@ -98,8 +99,8 @@ public class MkdirOptionsDialog extends DialogWrapper {
if (getOKAction().isEnabled()) {
try {
return SVNURL.parseURIEncoded(myURLLabel.getText());
} catch (SVNException e) {
//
}
catch (SVNException ignore) {
}
}
return null;
@@ -128,7 +129,8 @@ public class MkdirOptionsDialog extends DialogWrapper {
try {
myURLLabel.setText(myOriginalURL.appendPath(newName, false).toString());
getOKAction().setEnabled(true);
} catch (SVNException e) {
}
catch (SVNException e) {
myURLLabel.setText(myOriginalURL.toString());
getOKAction().setEnabled(false);
}