Merge remote-tracking branch 'origin/master'

This commit is contained in:
Yann Cébron
2012-09-12 12:37:04 +02:00
19 changed files with 195 additions and 284 deletions
@@ -123,33 +123,6 @@ public class AddModuleWizard extends AbstractWizard<ModuleWizardStep> {
currentStep.updateStep();
super.updateStep();
updateButtons();
final JButton nextButton = getNextButton();
final JButton finishButton = getFinishButton();
final boolean isLastStep = isLastStep(getCurrentStep());
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (!isShowing()) {
return;
}
final JComponent preferredFocusedComponent = currentStep.getPreferredFocusedComponent();
if (preferredFocusedComponent != null) {
preferredFocusedComponent.requestFocus();
}
else {
if (isLastStep && finishButton.isVisible()) {
finishButton.requestFocus();
}
else {
nextButton.requestFocus();
}
}
getRootPane().setDefaultButton(isLastStep && finishButton.isVisible()? finishButton : nextButton);
}
});
}
protected void dispose() {
@@ -230,21 +203,6 @@ public class AddModuleWizard extends AbstractWizard<ModuleWizardStep> {
super.doCancelAction();
}
private void updateButtons() {
final boolean isLastStep = isLastStep(getCurrentStep());
if (SystemInfo.isMac) {
getNextButton().setEnabled(true);
getFinishButton().setVisible(false);
getNextButton().setText(isLastStep ? IdeBundle.message("button.finish") : IdeBundle.message("button.wizard.next"));
getRootPane().setDefaultButton(getNextButton());
} else {
getNextButton().setEnabled(!isLastStep);
getFinishButton().setEnabled(isLastStep);
getRootPane().setDefaultButton(isLastStep ? getFinishButton() : getNextButton());
}
}
private boolean isLastStep(int step) {
return getNextStep(step) == step;
}
@@ -23,7 +23,6 @@ import com.intellij.ide.wizard.StepAdapter;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.psi.*;
import com.intellij.refactoring.classMembers.MemberInfoBase;
import com.intellij.refactoring.classMembers.MemberInfoChange;
@@ -138,7 +137,7 @@ public class GenerateEqualsWizard extends AbstractWizard {
addStep(new MyStep(myNonNullPanel));
init();
updateStatus();
updateButtons();
}
public PsiField[] getEqualsFields() {
@@ -182,24 +181,7 @@ public class GenerateEqualsWizard extends AbstractWizard {
}
super.doNextAction();
updateStatus();
}
protected void updateStep() {
super.updateStep();
final Component stepComponent = getCurrentStepComponent();
if (stepComponent instanceof MemberSelectionPanel) {
((MemberSelectionPanel)stepComponent).getTable().requestFocus();
}
if (SystemInfo.isMac) {
getFinishButton().setVisible(false);
final JButton nextButton = getNextButton();
if (nextButton.isEnabled()) {
getRootPane().setDefaultButton(nextButton);
}
}
updateButtons();
}
protected String getHelpID() {
@@ -253,53 +235,35 @@ public class GenerateEqualsWizard extends AbstractWizard {
myNonNullPanel.getTable().setMemberInfos(list);
}
private void updateStatus() {
boolean finishEnabled = true;
boolean nextEnabled = true;
if (myEqualsPanel != null & getCurrentStep() < myEqualsStepCode) {
finishEnabled = false;
}
if (getCurrentStep() == myTestBoxedStep - 1) {
boolean anyNonBoxed = false;
@Override
protected int getNextStep(int step) {
if (step + 1 == myTestBoxedStep) {
for (MemberInfo classField : myClassFields) {
if (classField.isChecked()) {
PsiField field = (PsiField)classField.getMember();
if (!(field.getType() instanceof PsiPrimitiveType)) {
anyNonBoxed = true;
break;
return myTestBoxedStep;
}
}
}
nextEnabled = anyNonBoxed;
return step;
}
return super.getNextStep(step);
}
@Override
protected boolean canGoNext() {
if (getCurrentStep() == myEqualsStepCode) {
boolean anyChecked = false;
for (MemberInfo classField : myClassFields) {
if (classField.isChecked()) {
anyChecked = true;
break;
return true;
}
}
finishEnabled &= anyChecked;
nextEnabled &= anyChecked;
return false;
}
if (getCurrentStep() == myTestBoxedStep) {
finishEnabled = true;
nextEnabled = SystemInfo.isMac;
}
getFinishButton().setEnabled(finishEnabled);
getNextButton().setEnabled(nextEnabled);
if (finishEnabled && getFinishButton().isVisible()) {
getRootPane().setDefaultButton(getFinishButton());
}
else if (getNextButton().isEnabled()) {
getRootPane().setDefaultButton(getNextButton());
}
return true;
}
public JComponent getPreferredFocusedComponent() {
@@ -314,7 +278,7 @@ public class GenerateEqualsWizard extends AbstractWizard {
private class MyTableModelListener implements TableModelListener {
public void tableChanged(TableModelEvent e) {
updateStatus();
updateButtons();
}
}
@@ -360,6 +324,10 @@ public class GenerateEqualsWizard extends AbstractWizard {
return myPanel;
}
@Override
public JComponent getPreferredFocusedComponent() {
return myPanel.getTable();
}
}
private static class MyMemberInfoFilter implements MemberInfoBase.Filter<PsiMember> {
@@ -58,10 +58,6 @@ public abstract class ModuleWizardStep extends StepAdapter{
return ICON;
}
public JComponent getPreferredFocusedComponent() {
return null;
}
public boolean isStepVisible() {
return true;
}
@@ -26,7 +26,6 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.ui.components.panels.OpaquePanel;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.DialogUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -50,7 +49,6 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
protected final ArrayList<T> mySteps;
private JButton myPreviousButton;
private JButton myNextButton;
private JButton myFinishButton;
private JButton myCancelButton;
private JButton myHelpButton;
private JPanel myContentPanel;
@@ -80,7 +78,6 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
myCurrentStep = 0;
myPreviousButton = new JButton(IdeBundle.message("button.wizard.previous"));
myNextButton = new JButton(IdeBundle.message("button.wizard.next"));
myFinishButton = new JButton(IdeBundle.message("button.finish"));
myCancelButton = new JButton(CommonBundle.getCancelButtonText());
myHelpButton = new JButton(CommonBundle.getHelpButtonText());
myContentPanel = new JPanel(new CardLayout());
@@ -133,13 +130,12 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
leftPanel.add(myCancelButton);
panel.add(leftPanel, BorderLayout.WEST);
buttonPanel.add(myFinishButton);
if (mySteps.size() > 1) {
buttonPanel.add(Box.createHorizontalStrut(5));
buttonPanel.add(myPreviousButton);
buttonPanel.add(Box.createHorizontalStrut(5));
buttonPanel.add(myNextButton);
}
buttonPanel.add(Box.createHorizontalStrut(5));
buttonPanel.add(myNextButton);
}
else {
panel.add(buttonPanel, BorderLayout.CENTER);
@@ -157,9 +153,9 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
}
add(hGroup, vGroup, null, Box.createHorizontalGlue());
if (mySteps.size() > 1) {
add(hGroup, vGroup, buttons, myPreviousButton, myNextButton);
add(hGroup, vGroup, buttons, myPreviousButton);
}
add(hGroup, vGroup, buttons, myFinishButton, myCancelButton);
add(hGroup, vGroup, buttons, myNextButton, myCancelButton);
if (helpAvailable && !UIUtil.isUnderGTKLookAndFeel()) {
add(hGroup, vGroup, buttons, myHelpButton);
}
@@ -177,12 +173,7 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
});
myNextButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
doNextAction();
}
});
myFinishButton.addActionListener(
new ActionListener() {
public void actionPerformed(final ActionEvent e) {
if (isLastStep()) {
// Commit data of current step and perform OK action
final Step currentStep = mySteps.get(myCurrentStep);
LOG.assertTrue(currentStep != null);
@@ -197,8 +188,12 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
}
}
}
else {
doNextAction();
}
}
);
});
myCancelButton.addActionListener(
new ActionListener() {
public void actionPerformed(final ActionEvent e) {
@@ -302,13 +297,6 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
if (component != null) {
addStepComponent(component);
}
if (mySteps.size() > 1) {
myFinishButton.setText(IdeBundle.message("button.finish"));
}
else {
myFinishButton.setText(IdeBundle.message("button.ok"));
}
}
protected void init() {
@@ -433,18 +421,48 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
myIcon.setIcon(step.getIcon());
if (SystemInfo.isMac && isLastStep()) {
myFinishButton.setVisible(false);
myNextButton.setText(UIUtil.removeMnemonic(IdeBundle.message("button.finish")));
myNextButton.setVisible(true);
myNextButton.setEnabled(myFinishButton.isEnabled());
myNextButton.setMnemonic('F');
updateButtons();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (!isShowing()) return;
JComponent component = mySteps.get(getCurrentStep()).getPreferredFocusedComponent();
if (component != null) {
component.requestFocus();
}
}
});
}
protected boolean canGoNext() {
return true;
}
protected boolean canFinish() {
return isLastStep() && canGoNext();
}
protected void updateButtons() {
if (isLastStep()) {
if (mySteps.size() > 1) {
myNextButton.setText(UIUtil.removeMnemonic(IdeBundle.message("button.finish")));
myNextButton.setMnemonic('F');
}
else {
myNextButton.setText(IdeBundle.message("button.ok"));
}
myNextButton.setEnabled(canFinish());
}
else {
myNextButton.setText(UIUtil.removeMnemonic(IdeBundle.message("button.wizard.next")));
myFinishButton.setVisible(true);
myNextButton.setEnabled(mySteps.size() == 1 || !isLastStep());
myNextButton.setMnemonic('N');
myNextButton.setEnabled(canGoNext());
}
if (myNextButton.isEnabled()) {
getRootPane().setDefaultButton(myNextButton);
}
myPreviousButton.setEnabled(myCurrentStep > 0);
@@ -462,8 +480,9 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
return myPreviousButton;
}
@Deprecated
protected JButton getFinishButton() {
return myFinishButton;
return new JButton();
}
public Component getCurrentStepComponent() {
@@ -129,16 +129,16 @@ public class AbstractWizardEx extends AbstractWizard<AbstractWizardStepEx> {
}
}
private void updateButtons() {
protected void updateButtons() {
super.updateButtons();
getPreviousButton().setEnabled(getCurrentStepObject().getPreviousStepId() != null);
getFinishButton().setEnabled(canFinish());
if (SystemInfo.isMac && isLastStep()) {
getNextButton().setEnabled(getFinishButton().isEnabled());
}
else {
getNextButton().setEnabled(getCurrentStepObject().isComplete() && !isLastStep());
}
getNextButton().setEnabled(getCurrentStepObject().isComplete() && !isLastStep() || isLastStep() && canFinish());
}
@Override
protected boolean canGoNext() {
return getCurrentStepObject().isComplete();
}
protected boolean isLastStep() {
@@ -46,4 +46,6 @@ public interface Step {
* method should not return <code>null</code>.
*/
JComponent getComponent();
JComponent getPreferredFocusedComponent();
}
@@ -50,4 +50,8 @@ public class StepAdapter implements Step {
listener.stateChanged();
}
}
public JComponent getPreferredFocusedComponent() {
return null;
}
}
@@ -20,7 +20,6 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileAttributes;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -71,7 +70,7 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo
for (String jarPath : jarPaths) {
final String jarFile = jarPath.substring(0, jarPath.length() - JAR_SEPARATOR.length());
if (FileUtil.startsWith(jarFile, path, SystemInfo.isFileSystemCaseSensitive)) {
if (FileUtil.startsWith(jarFile, path)) {
VirtualFile jarRootToRefresh = markDirty(jarPath);
if (jarRootToRefresh != null) {
rootsToRefresh.add(jarRootToRefresh);
@@ -271,8 +271,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
private void markPathsDirty(final List<String> dirtyFiles) {
for (String dirtyFile : dirtyFiles) {
String path = dirtyFile.replace(File.separatorChar, '/');
VirtualFile file = findFileByPathIfCached(path);
VirtualFile file = findFileByPathIfCached(dirtyFile);
if (file instanceof NewVirtualFile) {
((NewVirtualFile)file).markDirty();
}
@@ -281,8 +280,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
private void markFlatDirsDirty(final List<String> dirtyFiles) {
for (String dirtyFile : dirtyFiles) {
String path = dirtyFile.replace(File.separatorChar, '/');
VirtualFile file = findFileByPathIfCached(path);
VirtualFile file = findFileByPathIfCached(dirtyFile);
if (file instanceof NewVirtualFile) {
final NewVirtualFile nvf = (NewVirtualFile)file;
nvf.markDirty();
@@ -295,8 +293,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
private void markRecursiveDirsDirty(final List<String> dirtyFiles) {
for (String dirtyFile : dirtyFiles) {
String path = dirtyFile.replace(File.separatorChar, '/');
VirtualFile file = findFileByPathIfCached(path);
VirtualFile file = findFileByPathIfCached(dirtyFile);
if (file instanceof NewVirtualFile) {
((NewVirtualFile)file).markDirtyRecursively();
}
@@ -34,10 +34,12 @@
<interface-class>com.intellij.openapi.vfs.LocalFileSystem</interface-class>
<implementation-class>com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl</implementation-class>
</component>
<component>
<interface-class>com.intellij.openapi.vfs.JarFileSystem</interface-class>
<implementation-class>com.intellij.openapi.vfs.impl.jar.JarFileSystemImpl</implementation-class>
</component>
<component>
<implementation-class>com.intellij.openapi.vfs.ex.temp.TempFileSystem</implementation-class>
</component>
@@ -155,7 +157,7 @@
<component>
<implementation-class>com.intellij.ui.EditorNotifications</implementation-class>
</component>
<component>
<interface-class>com.intellij.openapi.vfs.encoding.EncodingProjectManager</interface-class>
<implementation-class>com.intellij.openapi.vfs.encoding.EncodingProjectManagerImpl</implementation-class>
@@ -109,34 +109,49 @@ public class FileUtil extends FileUtilRt {
return isAncestor(ancestor.getPath(), file.getPath(), strict);
}
public static boolean isAncestor(@NotNull String ancestor, @NotNull String descendant, boolean strict) {
public static boolean isAncestor(@NotNull String ancestor, @NotNull String file, boolean strict) {
String ancestorPath = toCanonicalPath(ancestor);
String filePath = toCanonicalPath(descendant);
String filePath = toCanonicalPath(file);
if (ancestorPath == null || filePath == null) {
return false;
}
return isCanonicalAncestor(strict, ancestorPath, filePath);
return startsWith(filePath, ancestorPath, strict, SystemInfo.isFileSystemCaseSensitive);
}
private static boolean isCanonicalAncestor(boolean strict, String ancestorPath, String filePath) {
boolean startsWith = SystemInfo.isFileSystemCaseSensitive ? StringUtil.startsWith(filePath, ancestorPath)
: StringUtil.startsWithIgnoreCase(filePath, ancestorPath);
if (!startsWith) {
return false;
}
public static boolean startsWith(@NotNull String path, @NotNull String start) {
return startsWith(path, start, false, SystemInfo.isFileSystemCaseSensitive);
}
return ancestorPath.length() > 0 && ancestorPath.charAt(ancestorPath.length() - 1) == '/' ||
filePath.length() > ancestorPath.length() && filePath.charAt(ancestorPath.length()) == '/' ||
!strict && filePath.length() == ancestorPath.length();
public static boolean startsWith(@NotNull String path, @NotNull String start, boolean caseSensitive) {
return startsWith(path, start, false, caseSensitive);
}
private static boolean startsWith(@NotNull String path, @NotNull String start, boolean strict, boolean caseSensitive) {
final int length1 = path.length();
final int length2 = start.length();
if (length2 == 0) return true;
if (length2 > length1) return false;
if (!path.regionMatches(!caseSensitive, 0, start, 0, length2)) return false;
if (length1 == length2) return !strict;
char last2 = start.charAt(length2 - 1);
char next1;
if (last2 == '/' || last2 == File.separatorChar) {
next1 = path.charAt(length2 - 1);
}
else {
next1 = path.charAt(length2);
}
return next1 == '/' || next1 == File.separatorChar;
}
/**
* @param removeProcessor parent, child
*/
public static<T> Collection<T> removeAncestors(final Collection<T> files, final Convertor<T, String> convertor,
final PairProcessor<T, T> removeProcessor) {
public static <T> Collection<T> removeAncestors(final Collection<T> files,
final Convertor<T, String> convertor,
final PairProcessor<T, T> removeProcessor) {
if (files.isEmpty()) return files;
final TreeMap<String, T> paths = new TreeMap<String, T>();
for (T file : files) {
@@ -156,7 +171,7 @@ public class FileUtil extends FileUtilRt {
// possible parents
final String parent = ordered.get(j).getKey();
if (parent == null) continue;
if (isCanonicalAncestor(false, parent, child) && removeProcessor.process(ordered.get(j).getValue(), entry.getValue())) {
if (startsWith(child, parent) && removeProcessor.process(ordered.get(j).getValue(), entry.getValue())) {
parentNotFound = false;
break;
}
@@ -366,7 +381,7 @@ public class FileUtil extends FileUtilRt {
}, null);
try {
// Attempt to execute on pooled thread
// attempt to execute on pooled thread
final Class<?> aClass = Class.forName("com.intellij.openapi.application.ApplicationManager");
final Method getApplicationMethod = aClass.getMethod("getApplication");
final Object application = getApplicationMethod.invoke(null);
@@ -374,13 +389,12 @@ public class FileUtil extends FileUtilRt {
executeOnPooledThreadMethod.invoke(application, deleteFilesTask);
}
catch (Exception e) {
//noinspection HardCodedStringLiteral
Thread t = new Thread(deleteFilesTask, "File deletion thread");
t.start();
new Thread(deleteFilesTask, "File deletion thread").start();
}
return deleteFilesTask;
}
@Nullable
private static File renameToTempFileOrDelete(@NotNull File file) {
final File tempDir = new File(getTempDirectory());
boolean isSameDrive = true;
@@ -821,28 +835,6 @@ public class FileUtil extends FileUtilRt {
delete(source);
}
public static boolean startsWith(@NotNull @NonNls String path, @NotNull @NonNls String start) {
return startsWith(path, start, SystemInfo.isFileSystemCaseSensitive);
}
public static boolean startsWith(@NotNull String path, @NotNull String start, final boolean caseSensitive) {
final int length1 = path.length();
final int length2 = start.length();
if (length2 == 0) return true;
if (length2 > length1) return false;
if (!path.regionMatches(!caseSensitive, 0, start, 0, length2)) return false;
if (length1 == length2) return true;
char last2 = start.charAt(length2 - 1);
char next1;
if (last2 == '/' || last2 == File.separatorChar) {
next1 = path.charAt(length2 - 1);
}
else {
next1 = path.charAt(length2);
}
return next1 == '/' || next1 == File.separatorChar;
}
public static boolean filesEqual(@Nullable File file1, @Nullable File file2) {
// on MacOS java.io.File.equals() is incorrectly case-sensitive
return pathsEqual(file1 == null ? null : file1.getPath(),
@@ -874,10 +866,9 @@ public class FileUtil extends FileUtilRt {
}
public static int pathHashCode(@Nullable String path) {
return StringUtil.isEmpty(path)? 0 : PATH_HASHING_STRATEGY.computeHashCode(toSystemIndependentName(path));
return StringUtil.isEmpty(path) || path == null ? 0 : PATH_HASHING_STRATEGY.computeHashCode(toSystemIndependentName(path));
}
@NotNull
public static String getExtension(@NotNull String fileName) {
return FileUtilRt.getExtension(fileName);
@@ -904,9 +895,12 @@ public class FileUtil extends FileUtilRt {
if (dirs == null) return;
for (File dir : dirs) {
if (dir.isFile()) {
final String path = toSystemIndependentName(getRelativePath(absoluteRoot, dir));
if (pattern.matcher(path).matches()) {
files.add(dir);
final String relativePath = getRelativePath(absoluteRoot, dir);
if (relativePath != null) {
final String path = toSystemIndependentName(relativePath);
if (pattern.matcher(path).matches()) {
files.add(dir);
}
}
}
else {
@@ -48,9 +48,4 @@ public abstract class ExportSignedPackageWizardStep extends StepAdapter {
public Icon getIcon() {
return null;
}
@Nullable
protected JComponent getPreferredFocusedComponent() {
return null;
}
}
@@ -89,7 +89,7 @@ class KeystoreStep extends ExportSignedPackageWizardStep implements ApkSigningSe
}
@Override
protected JComponent getPreferredFocusedComponent() {
public JComponent getPreferredFocusedComponent() {
if (myKeyStorePathField.getText().length() == 0) {
return myKeyStorePathField;
}
@@ -29,25 +29,6 @@ public class CvsWizard extends AbstractWizard<WizardStep> {
super(title, project);
}
@Override
protected void init() {
super.init();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
final boolean isLastStep = (getCurrentStep() + 1) == getNumberOfSteps();
final JButton defaultButton;
if (SystemInfo.isMac) {
defaultButton = getNextButton();
} else {
defaultButton = isLastStep ? getFinishButton() : getNextButton();
}
getRootPane().setDefaultButton(defaultButton);
updateStep();
}
});
}
@Override
protected String getHelpID() {
return null;
@@ -79,19 +60,16 @@ public class CvsWizard extends AbstractWizard<WizardStep> {
if (numberOfSteps == 0) return;
final WizardStep currentStep = getCurrentStepObject();
currentStep.activate();
final boolean enableNext = currentStep.nextIsEnabled();
getNextButton().setEnabled(enableNext && (!isLastStep() || SystemInfo.isMac));
getFinishButton().setEnabled(enableNext && isLastStep());
}
public void disableNextAndFinish() {
if (getNextButton().isEnabled() || getFinishButton().isEnabled()) {
public void disableNext() {
if (getNextButton().isEnabled()) {
updateStep();
}
}
public void enableNextAndFinish() {
if ((!getNextButton().isEnabled()) || (!getFinishButton().isEnabled())) {
public void enableNext() {
if ((!getNextButton().isEnabled())) {
updateStep();
}
}
@@ -152,11 +152,11 @@ public class ChooseCheckoutMode extends WizardStep {
final StringBuilder message = composeLocationsMessage();
myMessage.setText(message.toString());
show(MESSAGE);
getWizard().enableNextAndFinish();
getWizard().enableNext();
}
}
else if (selectedLocation == null) {
getWizard().disableNextAndFinish();
getWizard().disableNext();
}
}
@@ -121,10 +121,10 @@ public class ImportSettingsStep extends WizardStep {
private void checkFields() {
final CvsWizard wizard = getWizard();
if (!isValidInput()) {
wizard.disableNextAndFinish();
wizard.disableNext();
}
else {
wizard.enableNextAndFinish();
wizard.enableNext();
}
}
@@ -71,42 +71,7 @@ public class GitChangeProvider implements ChangeProvider {
return;
}
final LocalFileSystem lfs = LocalFileSystem.getInstance();
final Set<VirtualFile> rootsUnderGit = new HashSet<VirtualFile>(Arrays.asList(myVcsManager.getRootsUnderVcs(vcs)));
final Set<VirtualFile> inputColl = new HashSet<VirtualFile>(rootsUnderGit);
final Set<VirtualFile> existingInScope = new HashSet<VirtualFile>();
for (FilePath dir : dirtyScope.getRecursivelyDirtyDirectories()) {
VirtualFile vf = dir.getVirtualFile();
if (vf == null) {
vf = lfs.findFileByIoFile(dir.getIOFile());
}
if (vf == null) {
vf = lfs.refreshAndFindFileByIoFile(dir.getIOFile());
}
if (vf != null) {
existingInScope.add(vf);
}
// we don't expect any vcs roots to be under deleted directories
/* else {
PROFILE_LOG.error("Can not find virtual file for recursively dirty dir: " + dir.getIOFile().getPath());
}*/
}
inputColl.addAll(existingInScope);
FileUtil.removeAncestors(inputColl, new Convertor<VirtualFile, String>() {
@Override
public String convert(VirtualFile o) {
return o.getPath();
}
}, new PairProcessor<VirtualFile, VirtualFile>() {
@Override
public boolean process(VirtualFile parent, VirtualFile child) {
if (! existingInScope.contains(child)) {
debug("adding git root for check: " + child.getPath());
((VcsModifiableDirtyScope) dirtyScope).addDirtyDirRecursively(new FilePathImpl(child));
}
return true;
}
});
appendNestedVcsRootsToDirt(dirtyScope, vcs, myVcsManager);
final Collection<VirtualFile> affected = dirtyScope.getAffectedContentRoots();
Collection<VirtualFile> roots = GitUtil.gitRootsForPaths(affected);
@@ -141,6 +106,47 @@ public class GitChangeProvider implements ChangeProvider {
}
}
public static void appendNestedVcsRootsToDirt(final VcsDirtyScope dirtyScope, GitVcs vcs, final ProjectLevelVcsManager vcsManager) {
final Set<FilePath> recursivelyDirtyDirectories = dirtyScope.getRecursivelyDirtyDirectories();
if (recursivelyDirtyDirectories.isEmpty()) {
return;
}
final LocalFileSystem lfs = LocalFileSystem.getInstance();
final Set<VirtualFile> rootsUnderGit = new HashSet<VirtualFile>(Arrays.asList(vcsManager.getRootsUnderVcs(vcs)));
final Set<VirtualFile> inputColl = new HashSet<VirtualFile>(rootsUnderGit);
final Set<VirtualFile> existingInScope = new HashSet<VirtualFile>();
for (FilePath dir : recursivelyDirtyDirectories) {
VirtualFile vf = dir.getVirtualFile();
if (vf == null) {
vf = lfs.findFileByIoFile(dir.getIOFile());
}
if (vf == null) {
vf = lfs.refreshAndFindFileByIoFile(dir.getIOFile());
}
if (vf != null) {
existingInScope.add(vf);
}
}
inputColl.addAll(existingInScope);
FileUtil.removeAncestors(inputColl, new Convertor<VirtualFile, String>() {
@Override
public String convert(VirtualFile o) {
return o.getPath();
}
}, new PairProcessor<VirtualFile, VirtualFile>() {
@Override
public boolean process(VirtualFile parent, VirtualFile child) {
if (! existingInScope.contains(child) && existingInScope.contains(parent)) {
debug("adding git root for check: " + child.getPath());
((VcsModifiableDirtyScope)dirtyScope).addDirtyDirRecursively(new FilePathImpl(child));
}
return true;
}
}
);
}
private boolean isNewGitChangeProviderAvailable() {
GitVcs vcs = GitVcs.getInstance(myProject);
if (vcs == null) {
@@ -33,15 +33,15 @@ class MavenDuplicatedInspectionTest extends MavenDomTestCase {
<dependencies>
<<warning>dependency</warning>>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>LATEST</version>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>provided</scope>
</dependency>
<<warning>dependency</warning>>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>LATEST</version>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
</dependency>
</dependencies>
""")
@@ -52,7 +52,7 @@ class MavenDuplicatedInspectionTest extends MavenDomTestCase {
public void testDuplicatedInParent() {
myFixture.enableInspections(MavenDuplicateDependenciesInspection)
def m = createModulePom("child", """
createModulePom("child", """
<groupId>mavenParent</groupId>
<artifactId>child</artifactId>
<version>1.0</version>
@@ -65,9 +65,9 @@ class MavenDuplicatedInspectionTest extends MavenDomTestCase {
<dependencies>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>LATEST</version>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
@@ -91,9 +91,9 @@ class MavenDuplicatedInspectionTest extends MavenDomTestCase {
<dependencies>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>LATEST</version>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>provided</scope>
</dependency>
<<warning>dependency</warning>>
@@ -58,13 +58,6 @@ public final class DataBindingWizard extends AbstractWizard{
return myBeanStep.myTfShortClassName;
}
protected void updateStep() {
// "Finish" button is enabled only at the last step
getFinishButton().setEnabled(isLastStep());
super.updateStep();
}
protected void doOKAction() {
CommandProcessor.getInstance().executeCommand(
myProject,