diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java index 6e4ba5a0fa48..bbcc925810e4 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java @@ -123,33 +123,6 @@ public class AddModuleWizard extends AbstractWizard { 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 { 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; } diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/ui/GenerateEqualsWizard.java b/java/java-impl/src/com/intellij/codeInsight/generation/ui/GenerateEqualsWizard.java index 0e3d87e63462..88cf4056f426 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/ui/GenerateEqualsWizard.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/ui/GenerateEqualsWizard.java @@ -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 { diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java index 570dddc0115d..85b1433fc9b8 100644 --- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java +++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java @@ -58,10 +58,6 @@ public abstract class ModuleWizardStep extends StepAdapter{ return ICON; } - public JComponent getPreferredFocusedComponent() { - return null; - } - public boolean isStepVisible() { return true; } diff --git a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java index b74b4c2cd2b5..7c4fbf4d1e80 100644 --- a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java +++ b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java @@ -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 extends DialogWrapper { protected final ArrayList 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 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 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 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 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 extends DialogWrapper { } } } + else { + doNextAction(); + } } - ); + }); + myCancelButton.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { @@ -302,13 +297,6 @@ public abstract class AbstractWizard 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 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 extends DialogWrapper { return myPreviousButton; } + @Deprecated protected JButton getFinishButton() { - return myFinishButton; + return new JButton(); } public Component getCurrentStepComponent() { diff --git a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizardEx.java b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizardEx.java index 0bfbf4744851..d8439f368fe6 100644 --- a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizardEx.java +++ b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizardEx.java @@ -129,16 +129,16 @@ public class AbstractWizardEx extends AbstractWizard { } } - 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() { diff --git a/platform/platform-api/src/com/intellij/ide/wizard/Step.java b/platform/platform-api/src/com/intellij/ide/wizard/Step.java index c773a413902d..e958737baa36 100644 --- a/platform/platform-api/src/com/intellij/ide/wizard/Step.java +++ b/platform/platform-api/src/com/intellij/ide/wizard/Step.java @@ -46,4 +46,6 @@ public interface Step { * method should not return null. */ JComponent getComponent(); + + JComponent getPreferredFocusedComponent(); } diff --git a/platform/platform-api/src/com/intellij/ide/wizard/StepAdapter.java b/platform/platform-api/src/com/intellij/ide/wizard/StepAdapter.java index ef6b36c0daab..f0e1b254e8e4 100644 --- a/platform/platform-api/src/com/intellij/ide/wizard/StepAdapter.java +++ b/platform/platform-api/src/com/intellij/ide/wizard/StepAdapter.java @@ -50,4 +50,8 @@ public class StepAdapter implements Step { listener.stateChanged(); } } + + public JComponent getPreferredFocusedComponent() { + return null; + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java index 8497a49f7eba..7f050bc1f5dc 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java @@ -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); diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java index edb25b41e47a..740006be1d55 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java @@ -271,8 +271,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap private void markPathsDirty(final List 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 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 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(); } diff --git a/platform/platform-resources/src/componentSets/Platform.xml b/platform/platform-resources/src/componentSets/Platform.xml index e2db313adf9b..4b6900d619f2 100644 --- a/platform/platform-resources/src/componentSets/Platform.xml +++ b/platform/platform-resources/src/componentSets/Platform.xml @@ -34,10 +34,12 @@ com.intellij.openapi.vfs.LocalFileSystem com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl + com.intellij.openapi.vfs.JarFileSystem com.intellij.openapi.vfs.impl.jar.JarFileSystemImpl + com.intellij.openapi.vfs.ex.temp.TempFileSystem @@ -155,7 +157,7 @@ com.intellij.ui.EditorNotifications - + com.intellij.openapi.vfs.encoding.EncodingProjectManager com.intellij.openapi.vfs.encoding.EncodingProjectManagerImpl diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java index 5ffdc7ac9319..8e35fad88bbf 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java @@ -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 Collection removeAncestors(final Collection files, final Convertor convertor, - final PairProcessor removeProcessor) { + public static Collection removeAncestors(final Collection files, + final Convertor convertor, + final PairProcessor removeProcessor) { if (files.isEmpty()) return files; final TreeMap paths = new TreeMap(); 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 { diff --git a/plugins/android/src/org/jetbrains/android/exportSignedPackage/ExportSignedPackageWizardStep.java b/plugins/android/src/org/jetbrains/android/exportSignedPackage/ExportSignedPackageWizardStep.java index a676bb78f1cb..cf1a715c525e 100644 --- a/plugins/android/src/org/jetbrains/android/exportSignedPackage/ExportSignedPackageWizardStep.java +++ b/plugins/android/src/org/jetbrains/android/exportSignedPackage/ExportSignedPackageWizardStep.java @@ -48,9 +48,4 @@ public abstract class ExportSignedPackageWizardStep extends StepAdapter { public Icon getIcon() { return null; } - - @Nullable - protected JComponent getPreferredFocusedComponent() { - return null; - } } diff --git a/plugins/android/src/org/jetbrains/android/exportSignedPackage/KeystoreStep.java b/plugins/android/src/org/jetbrains/android/exportSignedPackage/KeystoreStep.java index 0f282b6ee644..fd2532a90fe7 100644 --- a/plugins/android/src/org/jetbrains/android/exportSignedPackage/KeystoreStep.java +++ b/plugins/android/src/org/jetbrains/android/exportSignedPackage/KeystoreStep.java @@ -89,7 +89,7 @@ class KeystoreStep extends ExportSignedPackageWizardStep implements ApkSigningSe } @Override - protected JComponent getPreferredFocusedComponent() { + public JComponent getPreferredFocusedComponent() { if (myKeyStorePathField.getText().length() == 0) { return myKeyStorePathField; } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/CvsWizard.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/CvsWizard.java index ec92397d2f29..366e3f8aa0b0 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/CvsWizard.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/CvsWizard.java @@ -29,25 +29,6 @@ public class CvsWizard extends AbstractWizard { 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 { 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(); } } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/checkout/ChooseCheckoutMode.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/checkout/ChooseCheckoutMode.java index 1ecdc2d0708f..2d48210f26cd 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/checkout/ChooseCheckoutMode.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/checkout/ChooseCheckoutMode.java @@ -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(); } } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/importToCvs/ImportSettingsStep.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/importToCvs/ImportSettingsStep.java index a35737a9de6e..faaed5aad74b 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/importToCvs/ImportSettingsStep.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/importToCvs/ImportSettingsStep.java @@ -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(); } } diff --git a/plugins/git4idea/src/git4idea/status/GitChangeProvider.java b/plugins/git4idea/src/git4idea/status/GitChangeProvider.java index 635655cb18e7..b62994ca3a43 100644 --- a/plugins/git4idea/src/git4idea/status/GitChangeProvider.java +++ b/plugins/git4idea/src/git4idea/status/GitChangeProvider.java @@ -71,42 +71,7 @@ public class GitChangeProvider implements ChangeProvider { return; } - final LocalFileSystem lfs = LocalFileSystem.getInstance(); - final Set rootsUnderGit = new HashSet(Arrays.asList(myVcsManager.getRootsUnderVcs(vcs))); - final Set inputColl = new HashSet(rootsUnderGit); - final Set existingInScope = new HashSet(); - 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() { - @Override - public String convert(VirtualFile o) { - return o.getPath(); - } - }, new PairProcessor() { - @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 affected = dirtyScope.getAffectedContentRoots(); Collection 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 recursivelyDirtyDirectories = dirtyScope.getRecursivelyDirtyDirectories(); + if (recursivelyDirtyDirectories.isEmpty()) { + return; + } + + final LocalFileSystem lfs = LocalFileSystem.getInstance(); + final Set rootsUnderGit = new HashSet(Arrays.asList(vcsManager.getRootsUnderVcs(vcs))); + final Set inputColl = new HashSet(rootsUnderGit); + final Set existingInScope = new HashSet(); + 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() { + @Override + public String convert(VirtualFile o) { + return o.getPath(); + } + }, new PairProcessor() { + @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) { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/inspections/MavenDuplicatedInspectionTest.groovy b/plugins/maven/src/test/java/org/jetbrains/idea/maven/inspections/MavenDuplicatedInspectionTest.groovy index 8142c34dbed8..5db4fbaad682 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/inspections/MavenDuplicatedInspectionTest.groovy +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/inspections/MavenDuplicatedInspectionTest.groovy @@ -33,15 +33,15 @@ class MavenDuplicatedInspectionTest extends MavenDomTestCase { <dependency> - commons-collections - commons-collections - LATEST + junit + junit + 3.8.2 provided <dependency> - commons-collections - commons-collections - LATEST + junit + junit + 3.8.2 """) @@ -52,7 +52,7 @@ class MavenDuplicatedInspectionTest extends MavenDomTestCase { public void testDuplicatedInParent() { myFixture.enableInspections(MavenDuplicateDependenciesInspection) - def m = createModulePom("child", """ + createModulePom("child", """ mavenParent child 1.0 @@ -65,9 +65,9 @@ class MavenDuplicatedInspectionTest extends MavenDomTestCase { - commons-collections - commons-collections - LATEST + junit + junit + 3.8.2 runtime @@ -91,9 +91,9 @@ class MavenDuplicatedInspectionTest extends MavenDomTestCase { - commons-collections - commons-collections - LATEST + junit + junit + 3.8.2 provided <dependency> diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/wizard/DataBindingWizard.java b/plugins/ui-designer/src/com/intellij/uiDesigner/wizard/DataBindingWizard.java index 3f2b6cf2bef1..59f9dc45effc 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/wizard/DataBindingWizard.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/wizard/DataBindingWizard.java @@ -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,