From 39cf7f9e6c42b3e5fd16c84337d4e8e3144ae38f Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 26 Dec 2011 19:03:39 +0400 Subject: [PATCH 01/31] IDEA-79333 Exception from paint() after switching branches under Git --- .../openapi/vcs/changes/ui/ChangesBrowserModuleNode.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserModuleNode.java b/platform/lang-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserModuleNode.java index 00fb025f7cd2..32f9cedbc1df 100644 --- a/platform/lang-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserModuleNode.java +++ b/platform/lang-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserModuleNode.java @@ -38,7 +38,11 @@ public class ChangesBrowserModuleNode extends ChangesBrowserNode { renderer.append(module.isDisposed() ? "" : module.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); appendCount(renderer); - renderer.setIcon(ModuleType.get(module).getNodeIcon(expanded)); + if (module.isDisposed()) { + renderer.setIcon(ModuleType.EMPTY.getNodeIcon(expanded)); + } else { + renderer.setIcon(ModuleType.get(module).getNodeIcon(expanded)); + } } @Override From c47c88d4bbe45b69f88edc127243cf52b69be8a7 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Mon, 26 Dec 2011 19:06:10 +0400 Subject: [PATCH 02/31] IDEA-79232 android: fix compilation of library module without sources --- .../android/compiler/AndroidCompileUtil.java | 84 ++++++++++++------- 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java index 2764d29c59e2..351cbc2b35ad 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java @@ -36,6 +36,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.*; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.*; import com.intellij.psi.JavaPsiFacade; @@ -724,28 +725,43 @@ public class AndroidCompileUtil { public static void packClassFilesIntoJar(@NotNull String[] firstPackageDirPaths, @NotNull String[] libFirstPackageDirPaths, @NotNull File jarFile) throws IOException { - final JarOutputStream jos = new JarOutputStream(new FileOutputStream(jarFile)); - try { - for (String path : firstPackageDirPaths) { - final File firstPackageDir = new File(path); - if (firstPackageDir.exists()) { - addFileToJar(jos, firstPackageDir, firstPackageDir.getParentFile(), true); - } - } - - for (String path : libFirstPackageDirPaths) { - final File firstPackageDir = new File(path); - if (firstPackageDir.exists()) { - addFileToJar(jos, firstPackageDir, firstPackageDir.getParentFile(), false); - } + final List> files = new ArrayList>(); + for (String path : firstPackageDirPaths) { + final File firstPackageDir = new File(path); + if (firstPackageDir.exists()) { + addFileToJar(firstPackageDir, firstPackageDir.getParentFile(), true, files); } } - finally { - jos.close(); + + for (String path : libFirstPackageDirPaths) { + final File firstPackageDir = new File(path); + if (firstPackageDir.exists()) { + addFileToJar(firstPackageDir, firstPackageDir.getParentFile(), false, files); + } + } + + if (files.size() > 0) { + final JarOutputStream jos = new JarOutputStream(new FileOutputStream(jarFile)); + try { + for (Pair pair : files) { + packIntoJar(jos, pair.getFirst(), pair.getSecond()); + } + } + finally { + jos.close(); + } + } + else if (jarFile.isFile()) { + if (!jarFile.delete()) { + throw new IOException("Cannot delete file " + FileUtil.toSystemDependentName(jarFile.getPath())); + } } } - private static void addFileToJar(@NotNull JarOutputStream jar, @NotNull File file, @NotNull File rootDirectory, boolean packRClasses) + private static void addFileToJar(@NotNull File file, + @NotNull File rootDirectory, + boolean packRClasses, + @NotNull List> files) throws IOException { if (file.isDirectory()) { @@ -753,7 +769,7 @@ public class AndroidCompileUtil { if (children != null) { for (File child : children) { - addFileToJar(jar, child, rootDirectory, packRClasses); + addFileToJar(child, rootDirectory, packRClasses, files); } } } @@ -774,22 +790,26 @@ public class AndroidCompileUtil { path = path.substring(1); } - final JarEntry entry = new JarEntry(path); - entry.setTime(file.lastModified()); - jar.putNextEntry(entry); + files.add(new Pair(file, path)); + } + } - BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); - try { - final byte[] buffer = new byte[1024]; - int count; - while ((count = bis.read(buffer)) != -1) { - jar.write(buffer, 0, count); - } - jar.closeEntry(); - } - finally { - bis.close(); + private static void packIntoJar(@NotNull JarOutputStream jar, @NotNull File file, @NotNull String path) throws IOException { + final JarEntry entry = new JarEntry(path); + entry.setTime(file.lastModified()); + jar.putNextEntry(entry); + + BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); + try { + final byte[] buffer = new byte[1024]; + int count; + while ((count = bis.read(buffer)) != -1) { + jar.write(buffer, 0, count); } + jar.closeEntry(); + } + finally { + bis.close(); } } From 3091fe4c572f9588c134ea68704ca78f221a0a21 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 26 Dec 2011 19:22:59 +0400 Subject: [PATCH 03/31] IDEA-79150 non Mac-friendly text in settings about image zooming --- .../intellij/images/ImagesBundle.properties | 2 +- .../images/options/impl/OptionsUIForm.java | 353 +++++++++--------- 2 files changed, 180 insertions(+), 175 deletions(-) diff --git a/images/src/org/intellij/images/ImagesBundle.properties b/images/src/org/intellij/images/ImagesBundle.properties index 37ddc5e45914..a6d4876ef429 100644 --- a/images/src/org/intellij/images/ImagesBundle.properties +++ b/images/src/org/intellij/images/ImagesBundle.properties @@ -22,7 +22,7 @@ settings.preffered.smart.zoom.width=Preferred minimum wi&dth for smart zooming ( settings.preffered.smart.zoom.height=Preferred minimum &height for smart zooming (pixels): show.grid.lines=Show &Grid lines by default show.transparency.chessboard=Show &transparency chessboard by default -enable.mousewheel.zooming=Use &mouse wheel for image zooming (Ctrl+Wheel) +enable.mousewheel.zooming=Use &mouse wheel for image zooming ({0}+Wheel) smart.zoom=Enable smart &zooming for small images chessboard.cell.size=Chessboard cell &size (pixels): show.grid.every=Show Grid line after &every (pixels): diff --git a/images/src/org/intellij/images/options/impl/OptionsUIForm.java b/images/src/org/intellij/images/options/impl/OptionsUIForm.java index af9efa329267..913fb3cd96a1 100644 --- a/images/src/org/intellij/images/options/impl/OptionsUIForm.java +++ b/images/src/org/intellij/images/options/impl/OptionsUIForm.java @@ -49,207 +49,212 @@ import java.awt.event.ItemListener; * @author Alexey Efimov */ final class OptionsUIForm { - private JPanel contentPane; - private JCheckBox showGrid; - private JLabel gridLineZoomFactorlLabel; - private JSpinner gridLineZoomFactor; - private JLabel gridLineSpanLabel; - private JSpinner gridLineSpan; - private JCheckBox showChessboard; - private JSpinner chessboardSize; - private JLabel chessboardSizeLabel; - private JCheckBox wheelZooming; - private JCheckBox smartZooming; - private JSpinner smartZoomingWidth; - private JLabel smartZoomingWidthLabel; - private JSpinner smartZoomingHeight; - private JLabel smartZoomingHeightLabel; - private JLabel gridLineColorLabel; - private ColorPanel gridLineColor; - private JLabel chessboardWhiteColorLabel; - private JLabel chessboardBlackColorLabel; - private ColorPanel chessboardBlackColor; - private ColorPanel chessboardWhiteColor; - private JLabel externalEditorLabel; - private TextFieldWithBrowseButton externalEditorPath; + private JPanel contentPane; + private JCheckBox showGrid; + private JLabel gridLineZoomFactorlLabel; + private JSpinner gridLineZoomFactor; + private JLabel gridLineSpanLabel; + private JSpinner gridLineSpan; + private JCheckBox showChessboard; + private JSpinner chessboardSize; + private JLabel chessboardSizeLabel; + private JCheckBox wheelZooming; + private JCheckBox smartZooming; + private JSpinner smartZoomingWidth; + private JLabel smartZoomingWidthLabel; + private JSpinner smartZoomingHeight; + private JLabel smartZoomingHeightLabel; + private JLabel gridLineColorLabel; + private ColorPanel gridLineColor; + private JLabel chessboardWhiteColorLabel; + private JLabel chessboardBlackColorLabel; + private ColorPanel chessboardBlackColor; + private ColorPanel chessboardWhiteColor; + private JLabel externalEditorLabel; + private TextFieldWithBrowseButton externalEditorPath; - // Options - private final Options options = new OptionsImpl(); + // Options + private final Options options = new OptionsImpl(); - OptionsUIForm() { - // Setup labels - gridLineZoomFactorlLabel.setLabelFor(gridLineZoomFactor); - gridLineSpanLabel.setLabelFor(gridLineSpan); - chessboardSizeLabel.setLabelFor(chessboardSize); - smartZoomingWidthLabel.setLabelFor(smartZoomingWidth); - smartZoomingHeightLabel.setLabelFor(smartZoomingHeight); - gridLineColorLabel.setLabelFor(gridLineColor); - chessboardWhiteColorLabel.setLabelFor(chessboardWhiteColor); - chessboardBlackColorLabel.setLabelFor(chessboardBlackColor); - externalEditorLabel.setLabelFor(externalEditorPath); + OptionsUIForm() { - // Setup listeners for enabling and disabling linked checkbox groups - smartZooming.addItemListener(new LinkEnabledListener(new JComponent[]{ - smartZoomingHeightLabel, - smartZoomingHeight, - smartZoomingWidthLabel, - smartZoomingWidth, - })); - // Setup spinners models - gridLineZoomFactor.setModel(new SpinnerNumberModel(GridOptions.DEFAULT_LINE_ZOOM_FACTOR, 2, 8, 1)); - gridLineSpan.setModel(new SpinnerNumberModel(GridOptions.DEFAULT_LINE_SPAN, 1, 100, 1)); - chessboardSize.setModel(new SpinnerNumberModel(TransparencyChessboardOptions.DEFAULT_CELL_SIZE, 1, 100, 1)); - smartZoomingWidth.setModel(new SpinnerNumberModel(ZoomOptions.DEFAULT_PREFFERED_SIZE.width, 1, 9999, 1)); - smartZoomingHeight.setModel(new SpinnerNumberModel(ZoomOptions.DEFAULT_PREFFERED_SIZE.height, 1, 9999, 1)); + wheelZooming.setText(ImagesBundle.message("enable.mousewheel.zooming", SystemInfo.isMac ? "Cmd" : "Ctrl")); + + // Setup labels + gridLineZoomFactorlLabel.setLabelFor(gridLineZoomFactor); + gridLineSpanLabel.setLabelFor(gridLineSpan); + chessboardSizeLabel.setLabelFor(chessboardSize); + smartZoomingWidthLabel.setLabelFor(smartZoomingWidth); + smartZoomingHeightLabel.setLabelFor(smartZoomingHeight); + gridLineColorLabel.setLabelFor(gridLineColor); + chessboardWhiteColorLabel.setLabelFor(chessboardWhiteColor); + chessboardBlackColorLabel.setLabelFor(chessboardBlackColor); + externalEditorLabel.setLabelFor(externalEditorPath); - // Setup listeners for chnages - showGrid.addItemListener(new CheckboxOptionsListener(GridOptions.ATTR_SHOW_DEFAULT)); - gridLineZoomFactor.addChangeListener(new SpinnerOptionsListener(GridOptions.ATTR_LINE_ZOOM_FACTOR)); - gridLineSpan.addChangeListener(new SpinnerOptionsListener(GridOptions.ATTR_LINE_SPAN)); - showChessboard.addItemListener(new CheckboxOptionsListener(TransparencyChessboardOptions.ATTR_SHOW_DEFAULT)); - chessboardSize.addChangeListener(new SpinnerOptionsListener(TransparencyChessboardOptions.ATTR_CELL_SIZE)); - wheelZooming.addItemListener(new CheckboxOptionsListener(ZoomOptions.ATTR_WHEEL_ZOOMING)); - smartZooming.addItemListener(new CheckboxOptionsListener(ZoomOptions.ATTR_SMART_ZOOMING)); - smartZoomingWidth.addChangeListener(new SpinnerOptionsListener(ZoomOptions.ATTR_PREFFERED_WIDTH)); - smartZoomingHeight.addChangeListener(new SpinnerOptionsListener(ZoomOptions.ATTR_PREFFERED_HEIGHT)); - gridLineColor.addActionListener(new ColorOptionsListener(GridOptions.ATTR_LINE_COLOR)); - chessboardWhiteColor.addActionListener(new ColorOptionsListener(TransparencyChessboardOptions.ATTR_WHITE_COLOR)); - chessboardBlackColor.addActionListener(new ColorOptionsListener(TransparencyChessboardOptions.ATTR_BLACK_COLOR)); - externalEditorPath.getTextField().getDocument().addDocumentListener(new TextDocumentOptionsListener(ExternalEditorOptions.ATTR_EXECUTABLE_PATH)); + // Setup listeners for enabling and disabling linked checkbox groups + smartZooming.addItemListener(new LinkEnabledListener(new JComponent[]{ + smartZoomingHeightLabel, + smartZoomingHeight, + smartZoomingWidthLabel, + smartZoomingWidth, + })); + // Setup spinners models + gridLineZoomFactor.setModel(new SpinnerNumberModel(GridOptions.DEFAULT_LINE_ZOOM_FACTOR, 2, 8, 1)); + gridLineSpan.setModel(new SpinnerNumberModel(GridOptions.DEFAULT_LINE_SPAN, 1, 100, 1)); + chessboardSize.setModel(new SpinnerNumberModel(TransparencyChessboardOptions.DEFAULT_CELL_SIZE, 1, 100, 1)); + smartZoomingWidth.setModel(new SpinnerNumberModel(ZoomOptions.DEFAULT_PREFFERED_SIZE.width, 1, 9999, 1)); + smartZoomingHeight.setModel(new SpinnerNumberModel(ZoomOptions.DEFAULT_PREFFERED_SIZE.height, 1, 9999, 1)); - externalEditorPath.addActionListener(new ExternalEditorPathActionListener()); + // Setup listeners for chnages + showGrid.addItemListener(new CheckboxOptionsListener(GridOptions.ATTR_SHOW_DEFAULT)); + gridLineZoomFactor.addChangeListener(new SpinnerOptionsListener(GridOptions.ATTR_LINE_ZOOM_FACTOR)); + gridLineSpan.addChangeListener(new SpinnerOptionsListener(GridOptions.ATTR_LINE_SPAN)); + showChessboard.addItemListener(new CheckboxOptionsListener(TransparencyChessboardOptions.ATTR_SHOW_DEFAULT)); + chessboardSize.addChangeListener(new SpinnerOptionsListener(TransparencyChessboardOptions.ATTR_CELL_SIZE)); + wheelZooming.addItemListener(new CheckboxOptionsListener(ZoomOptions.ATTR_WHEEL_ZOOMING)); + smartZooming.addItemListener(new CheckboxOptionsListener(ZoomOptions.ATTR_SMART_ZOOMING)); + smartZoomingWidth.addChangeListener(new SpinnerOptionsListener(ZoomOptions.ATTR_PREFFERED_WIDTH)); + smartZoomingHeight.addChangeListener(new SpinnerOptionsListener(ZoomOptions.ATTR_PREFFERED_HEIGHT)); + gridLineColor.addActionListener(new ColorOptionsListener(GridOptions.ATTR_LINE_COLOR)); + chessboardWhiteColor.addActionListener(new ColorOptionsListener(TransparencyChessboardOptions.ATTR_WHITE_COLOR)); + chessboardBlackColor.addActionListener(new ColorOptionsListener(TransparencyChessboardOptions.ATTR_BLACK_COLOR)); + externalEditorPath.getTextField().getDocument() + .addDocumentListener(new TextDocumentOptionsListener(ExternalEditorOptions.ATTR_EXECUTABLE_PATH)); - updateUI(); + externalEditorPath.addActionListener(new ExternalEditorPathActionListener()); + + updateUI(); + } + + public JPanel getContentPane() { + return contentPane; + } + + private static class LinkEnabledListener implements ItemListener { + private final JComponent[] children; + + LinkEnabledListener(JComponent[] children) { + this.children = children.clone(); } - public JPanel getContentPane() { - return contentPane; + public void itemStateChanged(ItemEvent e) { + setSelected(e.getStateChange() == ItemEvent.SELECTED); } - private static class LinkEnabledListener implements ItemListener { - private final JComponent[] children; + private void setSelected(boolean selected) { + for (JComponent component : children) { + component.setEnabled(selected); + } + } + } - LinkEnabledListener(JComponent[] children) { - this.children = children.clone(); - } + public Options getOptions() { + return options; + } - public void itemStateChanged(ItemEvent e) { - setSelected(e.getStateChange() == ItemEvent.SELECTED); - } + public void updateUI() { + // Grid options + EditorOptions editorOptions = options.getEditorOptions(); + ExternalEditorOptions externalEditorOptions = options.getExternalEditorOptions(); - private void setSelected(boolean selected) { - for (JComponent component : children) { - component.setEnabled(selected); - } - } + GridOptions gridOptions = editorOptions.getGridOptions(); + showGrid.setSelected(gridOptions.isShowDefault()); + gridLineZoomFactor.setValue(gridOptions.getLineZoomFactor()); + gridLineSpan.setValue(gridOptions.getLineSpan()); + gridLineColor.setSelectedColor(gridOptions.getLineColor()); + TransparencyChessboardOptions transparencyChessboardOptions = editorOptions.getTransparencyChessboardOptions(); + showChessboard.setSelected(transparencyChessboardOptions.isShowDefault()); + chessboardSize.setValue(transparencyChessboardOptions.getCellSize()); + chessboardWhiteColor.setSelectedColor(transparencyChessboardOptions.getWhiteColor()); + chessboardBlackColor.setSelectedColor(transparencyChessboardOptions.getBlackColor()); + ZoomOptions zoomOptions = editorOptions.getZoomOptions(); + wheelZooming.setSelected(zoomOptions.isWheelZooming()); + smartZooming.setSelected(zoomOptions.isSmartZooming()); + Dimension prefferedSize = zoomOptions.getPrefferedSize(); + smartZoomingWidth.setValue(prefferedSize.width); + smartZoomingHeight.setValue(prefferedSize.height); + externalEditorPath.setText(externalEditorOptions.getExecutablePath()); + } + + private final class CheckboxOptionsListener implements ItemListener { + private final String name; + + private CheckboxOptionsListener(String name) { + this.name = name; } - public Options getOptions() { - return options; + @SuppressWarnings({"UnnecessaryBoxing"}) + public void itemStateChanged(ItemEvent e) { + options.setOption(name, Boolean.valueOf(ItemEvent.SELECTED == e.getStateChange())); + } + } + + private final class SpinnerOptionsListener implements ChangeListener { + private final String name; + + private SpinnerOptionsListener(String name) { + this.name = name; } - public void updateUI() { - // Grid options - EditorOptions editorOptions = options.getEditorOptions(); - ExternalEditorOptions externalEditorOptions = options.getExternalEditorOptions(); + public void stateChanged(ChangeEvent e) { + JSpinner source = (JSpinner)e.getSource(); + options.setOption(name, source.getValue()); + } + } - GridOptions gridOptions = editorOptions.getGridOptions(); - showGrid.setSelected(gridOptions.isShowDefault()); - gridLineZoomFactor.setValue(gridOptions.getLineZoomFactor()); - gridLineSpan.setValue(gridOptions.getLineSpan()); - gridLineColor.setSelectedColor(gridOptions.getLineColor()); - TransparencyChessboardOptions transparencyChessboardOptions = editorOptions.getTransparencyChessboardOptions(); - showChessboard.setSelected(transparencyChessboardOptions.isShowDefault()); - chessboardSize.setValue(transparencyChessboardOptions.getCellSize()); - chessboardWhiteColor.setSelectedColor(transparencyChessboardOptions.getWhiteColor()); - chessboardBlackColor.setSelectedColor(transparencyChessboardOptions.getBlackColor()); - ZoomOptions zoomOptions = editorOptions.getZoomOptions(); - wheelZooming.setSelected(zoomOptions.isWheelZooming()); - smartZooming.setSelected(zoomOptions.isSmartZooming()); - Dimension prefferedSize = zoomOptions.getPrefferedSize(); - smartZoomingWidth.setValue(prefferedSize.width); - smartZoomingHeight.setValue(prefferedSize.height); - externalEditorPath.setText(externalEditorOptions.getExecutablePath()); + private final class ColorOptionsListener implements ActionListener { + private final String name; + + private ColorOptionsListener(String name) { + this.name = name; } - private final class CheckboxOptionsListener implements ItemListener { - private final String name; + public void actionPerformed(ActionEvent e) { + ColorPanel source = (ColorPanel)e.getSource(); + options.setOption(name, source.getSelectedColor()); + } + } - private CheckboxOptionsListener(String name) { - this.name = name; - } + private final class TextDocumentOptionsListener extends DocumentAdapter { + private final String name; - @SuppressWarnings({"UnnecessaryBoxing"}) - public void itemStateChanged(ItemEvent e) { - options.setOption(name, Boolean.valueOf(ItemEvent.SELECTED == e.getStateChange())); - } + public TextDocumentOptionsListener(String name) { + this.name = name; } - private final class SpinnerOptionsListener implements ChangeListener { - private final String name; - - private SpinnerOptionsListener(String name) { - this.name = name; - } - - public void stateChanged(ChangeEvent e) { - JSpinner source = (JSpinner)e.getSource(); - options.setOption(name, source.getValue()); - } + protected void textChanged(DocumentEvent documentEvent) { + Document document = documentEvent.getDocument(); + Position startPosition = document.getStartPosition(); + try { + options.setOption(name, document.getText(startPosition.getOffset(), document.getLength())); + } + catch (BadLocationException e) { + // Ignore + } } + } - private final class ColorOptionsListener implements ActionListener { - private final String name; - - private ColorOptionsListener(String name) { - this.name = name; + private final class ExternalEditorPathActionListener implements ActionListener { + public void actionPerformed(ActionEvent e) { + Application application = ApplicationManager.getApplication(); + VirtualFile previous = application.runWriteAction(new Computable() { + public VirtualFile compute() { + return LocalFileSystem.getInstance().refreshAndFindFileByPath(externalEditorPath.getText().replace('\\', '/')); } - - public void actionPerformed(ActionEvent e) { - ColorPanel source = (ColorPanel)e.getSource(); - options.setOption(name, source.getSelectedColor()); - } - } - - private final class TextDocumentOptionsListener extends DocumentAdapter { - private final String name; - - public TextDocumentOptionsListener(String name) { - this.name = name; - } - - protected void textChanged(DocumentEvent documentEvent) { - Document document = documentEvent.getDocument(); - Position startPosition = document.getStartPosition(); - try { - options.setOption(name, document.getText(startPosition.getOffset(), document.getLength())); - } catch (BadLocationException e) { - // Ignore - } - } - } - - private final class ExternalEditorPathActionListener implements ActionListener { - public void actionPerformed(ActionEvent e) { - Application application = ApplicationManager.getApplication(); - VirtualFile previous = application.runWriteAction(new Computable() { - public VirtualFile compute() { - return LocalFileSystem.getInstance().refreshAndFindFileByPath(externalEditorPath.getText().replace('\\', '/')); - } - }); - FileChooserDescriptor fileDescriptor = new FileChooserDescriptor(true, SystemInfo.isMac, false, false, false, false); - fileDescriptor.setShowFileSystemRoots(true); - fileDescriptor.setTitle(ImagesBundle.message("select.external.executable.title")); - fileDescriptor.setDescription(ImagesBundle.message("select.external.executable.message")); - FileChooser.chooseFilesWithSlideEffect(fileDescriptor, null, previous, new Consumer() { - @Override - public void consume(VirtualFile[] virtualFiles) { - if (virtualFiles != null && virtualFiles.length > 0) { - String path = virtualFiles[0].getPath(); - externalEditorPath.setText(path); - } - } - }); + }); + FileChooserDescriptor fileDescriptor = new FileChooserDescriptor(true, SystemInfo.isMac, false, false, false, false); + fileDescriptor.setShowFileSystemRoots(true); + fileDescriptor.setTitle(ImagesBundle.message("select.external.executable.title")); + fileDescriptor.setDescription(ImagesBundle.message("select.external.executable.message")); + FileChooser.chooseFilesWithSlideEffect(fileDescriptor, null, previous, new Consumer() { + @Override + public void consume(VirtualFile[] virtualFiles) { + if (virtualFiles != null && virtualFiles.length > 0) { + String path = virtualFiles[0].getPath(); + externalEditorPath.setText(path); + } } + }); } + } } From a57ad831bd2b265e1533cefe36868ff68396177a Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 26 Dec 2011 19:27:19 +0400 Subject: [PATCH 04/31] IDEA-77313 Broken controls layout on Add/Edit External Tool dialog --- .../lang-impl/src/com/intellij/tools/ToolEditorDialog.java | 4 ++-- .../platform-resources-en/src/messages/ToolsBundle.properties | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/tools/ToolEditorDialog.java b/platform/lang-impl/src/com/intellij/tools/ToolEditorDialog.java index 5a8333de970b..05213b718c8f 100644 --- a/platform/lang-impl/src/com/intellij/tools/ToolEditorDialog.java +++ b/platform/lang-impl/src/com/intellij/tools/ToolEditorDialog.java @@ -302,14 +302,14 @@ public class ToolEditorDialog extends DialogWrapper { constr.gridy = 2; constr.insets = new Insets(5, 0, 0, 0); constr.fill = GridBagConstraints.HORIZONTAL; - constr.anchor = GridBagConstraints.WEST; + constr.anchor = GridBagConstraints.BASELINE_LEADING; myInsertWorkingDirectoryMacroButton = new JButton(ToolsBundle.message("tools.insert.macro.button.c")); pane.add(myInsertWorkingDirectoryMacroButton, constr); // for normal resizing constr = new GridBagConstraints(); constr.gridy = 3; - constr.fill = GridBagConstraints.VERTICAL; + constr.fill = GridBagConstraints.BASELINE_LEADING; constr.weighty = 1.0; pane.add(new JLabel(), constr); diff --git a/platform/platform-resources-en/src/messages/ToolsBundle.properties b/platform/platform-resources-en/src/messages/ToolsBundle.properties index 712bd71e7f40..64e8da352a35 100644 --- a/platform/platform-resources-en/src/messages/ToolsBundle.properties +++ b/platform/platform-resources-en/src/messages/ToolsBundle.properties @@ -34,9 +34,9 @@ tools.parameters.label=Parameters: tools.insert.macro.button.a=Insert m&acro... tools.working.directory.label=Working directory: tools.insert.macro.button.c=Insert ma&cro... -tools.menu.group=Menu +tools.menu.group=Show In tools.options.group=Options -tools.tool.group=Tool Options +tools.tool.group=Tool Settings tools.settings=Tools tools.completed.message=External tool ''{0}'' completed with exit code {1} tools.add.button=&Add... From 0a45db0dc41d3ca2499845adb843ef670cc740a2 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 26 Dec 2011 19:59:52 +0400 Subject: [PATCH 05/31] Settings -> Editor -> Colors and Fonts: After clicking on highlighted elements correctly selected setting for its. Correct order applying highligting setting for JSP, Velocity, EL, LayeredLexerEditorHighlighter. IDEA-76380 HTML colors and fonts settings don't let you click on what you want to change --- .../application/options/colors/ClickNavigator.java | 7 ++++--- .../editor/ex/util/LayeredLexerEditorHighlighter.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ClickNavigator.java b/platform/lang-impl/src/com/intellij/application/options/colors/ClickNavigator.java index 61b243c92d74..f229c5233a66 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ClickNavigator.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ClickNavigator.java @@ -1,3 +1,4 @@ +/* /* * Copyright 2000-2009 JetBrains s.r.o. * @@ -113,9 +114,9 @@ public class ClickNavigator { public static String highlightingTypeFromTokenType(IElementType tokenType, SyntaxHighlighter highlighter) { TextAttributesKey[] highlights = highlighter.getTokenHighlights(tokenType); String s = null; - for (TextAttributesKey highlight : highlights) { - if (highlight != HighlighterColors.TEXT) { - s = highlight.getExternalName(); + for (int i = highlights.length - 1; i >= 0; i--) { + if (highlights[i] != HighlighterColors.TEXT) { + s = highlights[i].getExternalName(); break; } } diff --git a/platform/lang-impl/src/com/intellij/openapi/editor/ex/util/LayeredLexerEditorHighlighter.java b/platform/lang-impl/src/com/intellij/openapi/editor/ex/util/LayeredLexerEditorHighlighter.java index 6abf29dcb3ca..35ea4a661d46 100644 --- a/platform/lang-impl/src/com/intellij/openapi/editor/ex/util/LayeredLexerEditorHighlighter.java +++ b/platform/lang-impl/src/com/intellij/openapi/editor/ex/util/LayeredLexerEditorHighlighter.java @@ -318,7 +318,7 @@ public class LayeredLexerEditorHighlighter extends LexerEditorHighlighter { public TextAttributes getAttributes(IElementType tokenType) { TextAttributes attrs = myAttributesMap.get(tokenType); if (attrs == null) { - attrs = convertAttributes(SyntaxHighlighterBase.pack(mySyntaxHighlighter.getTokenHighlights(tokenType), myBackground)); + attrs = convertAttributes(SyntaxHighlighterBase.pack(myBackground, mySyntaxHighlighter.getTokenHighlights(tokenType))); myAttributesMap.put(tokenType, attrs); } return attrs; From ef0026e49755750b3ce855d25385a0c1e02ebbcc Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 26 Dec 2011 20:07:34 +0400 Subject: [PATCH 06/31] Some UI fixes --- .../options/editor/EditorOptionsPanel.form | 98 +++++++++---------- 1 file changed, 44 insertions(+), 54 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form index 2721f16caa1c..ae5e2aecd4de 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form @@ -2,7 +2,7 @@
- + @@ -26,7 +26,7 @@ - + @@ -44,9 +44,7 @@ - - - + @@ -54,9 +52,7 @@ - - - + @@ -67,7 +63,7 @@ - + @@ -77,7 +73,7 @@ - + @@ -85,7 +81,7 @@ - + @@ -93,17 +89,17 @@ - + - + - + @@ -117,51 +113,51 @@ - + - + - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + - - - - - - - - @@ -169,7 +165,7 @@ - + @@ -206,7 +202,7 @@ - + @@ -244,7 +240,7 @@ - + @@ -254,9 +250,7 @@ - - - + @@ -264,7 +258,7 @@ - + @@ -274,9 +268,7 @@ - - - + @@ -284,9 +276,7 @@ - - - + @@ -294,7 +284,7 @@ - + @@ -304,7 +294,7 @@ - + @@ -317,7 +307,7 @@ - + @@ -346,7 +336,7 @@ - + @@ -378,7 +368,7 @@ - + From a1dc6c95b056e70d0f302082f573ee26b4a5169b Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 26 Dec 2011 18:20:53 +0100 Subject: [PATCH 07/31] AppCode:Debugger: displaying objects' addresses OC-1695 --- .../com/intellij/xdebugger/XDebuggerTestUtil.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java index d2b00a705058..7d983d653130 100644 --- a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java +++ b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java @@ -190,15 +190,21 @@ public class XDebuggerTestUtil { } } - public static void assertVariableTypeMatches(@NotNull XValue var, - @Nullable String name, + public static void assertVariableTypeMatches(@NotNull Collection vars, + @Nullable String name, + @Nullable @Language("RegExp") String typePattern) throws InterruptedException { + assertVariableTypeMatches(findVar(vars, name), name, typePattern); + } + + public static void assertVariableTypeMatches(@NotNull XValue var, + @Nullable String name, @Nullable @Language("RegExp") String typePattern) throws InterruptedException { XTestValueNode node = computePresentation(var); if (name != null) { Assert.assertEquals(name, node.myName); } if (typePattern != null) { - Assert.assertTrue("Expected type" + typePattern + " Actual type: " + node.myType, node.myType.matches(typePattern)); + Assert.assertTrue("Expected type: " + typePattern + " Actual type: " + node.myType, node.myType.matches(typePattern)); } } From 939cefd95ae98997856b7953b5964bcb5d8f88a0 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Mon, 26 Dec 2011 21:19:22 +0400 Subject: [PATCH 08/31] IDEA-64695 android: fix red code in xsd file --- .../android/AndroidXmlSchemaProvider.java | 28 ++++++++++++++++--- .../android/testData/dom/layout/XsdFile.xsd | 14 ++++++++++ .../android/dom/AndroidLayoutDomTest.java | 14 +++++++++- 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 plugins/android/testData/dom/layout/XsdFile.xsd diff --git a/plugins/android/src/org/jetbrains/android/AndroidXmlSchemaProvider.java b/plugins/android/src/org/jetbrains/android/AndroidXmlSchemaProvider.java index 943d39fc03e5..9916c9cffec8 100644 --- a/plugins/android/src/org/jetbrains/android/AndroidXmlSchemaProvider.java +++ b/plugins/android/src/org/jetbrains/android/AndroidXmlSchemaProvider.java @@ -16,12 +16,14 @@ package org.jetbrains.android; +import com.android.sdklib.SdkConstants; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.psi.util.CachedValue; @@ -30,20 +32,19 @@ import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.util.PsiModificationTracker; import com.intellij.psi.xml.XmlFile; import com.intellij.xml.XmlSchemaProvider; -import com.android.sdklib.SdkConstants; import gnu.trove.THashMap; +import org.jetbrains.android.dom.manifest.ManifestDomFileDescription; import org.jetbrains.android.facet.AndroidFacet; import org.jetbrains.android.resourceManagers.ResourceManager; -import org.jetbrains.android.dom.manifest.ManifestDomFileDescription; import org.jetbrains.android.util.AndroidUtils; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.net.URL; +import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.HashSet; /** * Created by IntelliJ IDEA. @@ -87,7 +88,8 @@ public class AndroidXmlSchemaProvider extends XmlSchemaProvider { public boolean isAvailable(@NotNull final XmlFile file) { return ApplicationManager.getApplication().runReadAction(new Computable() { public Boolean compute() { - if (ResourceManager.isInResourceSubdirectory(file, null) || ManifestDomFileDescription.isManifestFile(file)) { + if (isXmlResourceFile(file) || + ManifestDomFileDescription.isManifestFile(file)) { return AndroidFacet.getInstance(file) != null; } return false; @@ -95,6 +97,24 @@ public class AndroidXmlSchemaProvider extends XmlSchemaProvider { }); } + private static boolean isXmlResourceFile(XmlFile file) { + if (!ResourceManager.isInResourceSubdirectory(file, null)) { + return false; + } + + final PsiDirectory parent = file.getParent(); + if (parent == null) { + return false; + } + + final String resType = ResourceManager.getResourceTypeByDirName(parent.getName()); + if (resType == null) { + return false; + } + + return !resType.equals("raw"); + } + @NotNull @Override public Set getAvailableNamespaces(@NotNull XmlFile file, @Nullable String tagName) { diff --git a/plugins/android/testData/dom/layout/XsdFile.xsd b/plugins/android/testData/dom/layout/XsdFile.xsd new file mode 100644 index 000000000000..01b27853cb9f --- /dev/null +++ b/plugins/android/testData/dom/layout/XsdFile.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java index 415a5609aaf1..bc2c6d48a911 100644 --- a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java +++ b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java @@ -356,7 +356,19 @@ public class AndroidLayoutDomTest extends AndroidDomTest { actions.get(0).invoke(getProject(), myFixture.getEditor(), myFixture.getFile()); } }.execute(); - myFixture.checkResultByFile("res/values/drawables.xml", testFolder + '/' + getTestName(true) + "_drawable_after.xml", true); + myFixture.checkResultByFile("res/values/drawables.xml", testFolder + '/' + getTestName(true) + "_drawable_after.xml", true); + } + + public void testXsdFile1() throws Throwable { + final VirtualFile virtualFile = copyFileToProject("XsdFile.xsd", "res/raw/XsdFile.xsd"); + myFixture.configureFromExistingVirtualFile(virtualFile); + myFixture.checkHighlighting(false, false, false); + } + + public void testXsdFile2() throws Throwable { + final VirtualFile virtualFile = copyFileToProject("XsdFile.xsd", "res/assets/XsdFile.xsd"); + myFixture.configureFromExistingVirtualFile(virtualFile); + myFixture.checkHighlighting(false, false, false); } private void copyOnClickClasses() throws IOException { From 1163c292c30b489ca2ffa0e2a6e00e293ad379ea Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 19 Dec 2011 16:34:33 +0100 Subject: [PATCH 09/31] Unused --- .../vfs/impl/local/VirtualFileImpl.java | 120 ------------------ 1 file changed, 120 deletions(-) delete mode 100644 platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/VirtualFileImpl.java diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/VirtualFileImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/VirtualFileImpl.java deleted file mode 100644 index 29da9bafca03..000000000000 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/VirtualFileImpl.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2000-2009 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.openapi.vfs.impl.local; - -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.VirtualFileSystem; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -public class VirtualFileImpl extends VirtualFile { - @SuppressWarnings({"WeakerAccess"}) public long myTimeStamp = -1; // -1, if file content has not been requested yet - - @SuppressWarnings({"WeakerAccess"}) - public void cacheIsWritableInitialized() { - } - - //do not delete or rename or change visibility without correcting native code - @SuppressWarnings({"WeakerAccess"}) - public void cacheIsWritable(final boolean canWrite) { - } - - //do not delete or rename or change visibility without correcting native code - @SuppressWarnings({"WeakerAccess"}) - public void cacheIsDirectory(final boolean isDirectory) { - } - - @Override - @NotNull - public byte[] contentsToByteArray() throws IOException { - throw new UnsupportedOperationException("contentsToByteArray is not implemented"); // TODO - } - - @Override - public VirtualFile[] getChildren() { - throw new UnsupportedOperationException("getChildren is not implemented"); // TODO - } - - @Override - @NotNull - public VirtualFileSystem getFileSystem() { - throw new UnsupportedOperationException("getFileSystem is not implemented"); // TODO - } - - @Override - public InputStream getInputStream() throws IOException { - throw new UnsupportedOperationException("getInputStream is not implemented"); // TODO - } - - @Override - public long getLength() { - throw new UnsupportedOperationException("getLength is not implemented"); // TODO - } - - @Override - @NotNull - @NonNls - public String getName() { - throw new UnsupportedOperationException("getName is not implemented"); // TODO - } - - @Override - @NotNull - public OutputStream getOutputStream(final Object requestor, final long newModificationStamp, final long newTimeStamp) throws IOException { - throw new UnsupportedOperationException("getOutputStream is not implemented"); // TODO - } - - @Override - @Nullable - public VirtualFile getParent() { - throw new UnsupportedOperationException("getParent is not implemented"); // TODO - } - - @Override - public String getPath() { - throw new UnsupportedOperationException("getPath is not implemented"); // TODO - } - - @Override - public long getTimeStamp() { - throw new UnsupportedOperationException("getTimeStamp is not implemented"); // TODO - } - - @Override - public boolean isDirectory() { - throw new UnsupportedOperationException("isDirectory is not implemented"); // TODO - } - - @Override - public boolean isValid() { - throw new UnsupportedOperationException("isValid is not implemented"); // TODO - } - - @Override - public boolean isWritable() { - throw new UnsupportedOperationException("isWritable is not implemented"); // TODO - } - - @Override - public void refresh(final boolean asynchronous, final boolean recursive, final Runnable postRunnable) { - throw new UnsupportedOperationException("refresh is not implemented"); // TODO - } -} From bda988d0e06b58c9b45eacbbabcd49e0ad4b009e Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 20 Dec 2011 19:16:55 +0100 Subject: [PATCH 10/31] Fix VFS events filtering --- .../vfs/newvfs/events/VFileCreateEvent.java | 44 +++++++--- .../vfs/newvfs/persistent/PersistentFS.java | 82 +++++++++++-------- .../vfs/newvfs/persistent/RefreshWorker.java | 21 +++-- .../vfs/local/SymLinkHandlingTest.java | 68 +++++++++++---- 4 files changed, 146 insertions(+), 69 deletions(-) diff --git a/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCreateEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCreateEvent.java index 7b9a7b86d8bd..4d9df7675eb0 100644 --- a/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCreateEvent.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCreateEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -13,26 +13,40 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.openapi.vfs.newvfs.events; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileSystem; import org.jetbrains.annotations.NonNls; +/** + * @author max + */ public class VFileCreateEvent extends VFileEvent { private final VirtualFile myParent; private final boolean myDirectory; private final String myChildName; + private final boolean myReCreation; - public VFileCreateEvent(final Object requestor, final VirtualFile parent, final String childName, boolean isDirectory, boolean isFromRefresh) { + public VFileCreateEvent(final Object requestor, + final VirtualFile parent, + final String childName, + final boolean isDirectory, + final boolean isFromRefresh) { + this(requestor, parent, childName, isDirectory, isFromRefresh, false); + } + + public VFileCreateEvent(final Object requestor, + final VirtualFile parent, + final String childName, + final boolean isDirectory, + final boolean isFromRefresh, + final boolean isReCreation) { super(requestor, isFromRefresh); myChildName = childName; myParent = parent; myDirectory = isDirectory; + myReCreation = isReCreation; } public String getChildName() { @@ -48,8 +62,10 @@ public class VFileCreateEvent extends VFileEvent { } @NonNls + @Override public String toString() { - return "VfsEvent[create " + (isDirectory() ? "dir " : "file ") + myChildName + " in " + myParent.getUrl() + "]"; + return "VfsEvent[" + (myReCreation ? "re" : "") + "create " + (myDirectory ? "dir " : "file ") + + myChildName + " in " + myParent.getUrl() + "]"; } @Override @@ -69,9 +85,15 @@ public class VFileCreateEvent extends VFileEvent { @Override public boolean isValid() { - return myParent.isValid() && myParent.findChild(myChildName) == null; + if (myParent.isValid()) { + final VirtualFile child = myParent.findChild(myChildName); + return !myReCreation && child == null || myReCreation && child != null; + } + + return false; } + @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; @@ -81,15 +103,17 @@ public class VFileCreateEvent extends VFileEvent { if (myDirectory != event.myDirectory) return false; if (!myChildName.equals(event.myChildName)) return false; if (!myParent.equals(event.myParent)) return false; + if (myReCreation != event.myReCreation) return false; return true; } + @Override public int hashCode() { - int result; - result = myParent.hashCode(); + int result = myParent.hashCode(); result = 31 * result + (myDirectory ? 1 : 0); result = 31 * result + myChildName.hashCode(); + result = 31 * result + (myReCreation ? 1 : 0); return result; } } diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFS.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFS.java index cf65976d4e4d..b9328df06ea0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFS.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFS.java @@ -13,12 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.openapi.vfs.newvfs.persistent; +import com.google.common.collect.Lists; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.application.ex.ApplicationEx; @@ -45,6 +42,7 @@ import com.intellij.util.containers.StripedLockIntObjectConcurrentHashMap; import com.intellij.util.io.DupOutputStream; import com.intellij.util.io.ReplicatorInputStream; import com.intellij.util.messages.MessageBus; +import gnu.trove.TIntHashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -53,6 +51,9 @@ import java.io.*; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; +/** + * @author max + */ public class PersistentFS extends ManagingFS implements ApplicationComponent { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.newvfs.persistent.PersistentFS"); @@ -638,48 +639,58 @@ public class PersistentFS extends ManagingFS implements ApplicationComponent { processEvents(Collections.singletonList(event)); } - private static final Comparator DEPTH_COMPARATOR = new Comparator() { + private static class EventWrapper { + private final VFileDeleteEvent event; + private final int id; + + private EventWrapper(final VFileDeleteEvent event, final int id) { + this.event = event; + this.id = id; + } + } + + private static final Comparator DEPTH_COMPARATOR = new Comparator() { @Override - public int compare(final VFileDeleteEvent o1, final VFileDeleteEvent o2) { - return o1.getFileDepth() - o2.getFileDepth(); + public int compare(final EventWrapper o1, final EventWrapper o2) { + return o1.event.getFileDepth() - o2.event.getFileDepth(); } }; - private static List validateEvents(List events) { - List filtered = new ArrayList(events.size()); - List deletionList = new ArrayList(); - - for (VFileEvent event : events) { - if (event.isValid()) { - if (event instanceof VFileDeleteEvent) { - deletionList.add((VFileDeleteEvent)event); - } - else { - filtered.add(event); - } + private static List validateEvents(final List events) { + final List deletionEvents = Lists.newArrayList(); + for (int i = 0, size = events.size(); i < size; i++) { + final VFileEvent event = events.get(i); + if (event instanceof VFileDeleteEvent && event.isValid()) { + deletionEvents.add(new EventWrapper((VFileDeleteEvent)event, i)); } } - ContainerUtil.quickSort(deletionList, DEPTH_COMPARATOR); - List filesToBeDeleted = new ArrayList(); - for (VFileDeleteEvent event : deletionList) { - boolean ok = true; - VirtualFile candidate = event.getFile(); - for (VirtualFile file : filesToBeDeleted) { + ContainerUtil.quickSort(deletionEvents, DEPTH_COMPARATOR); + + final TIntHashSet invalidIDs = new TIntHashSet(deletionEvents.size()); + final List dirsToBeDeleted = new ArrayList(); + nextEvent: + for (EventWrapper wrapper : deletionEvents) { + final VirtualFile candidate = wrapper.event.getFile(); + for (VirtualFile file : dirsToBeDeleted) { if (VfsUtilCore.isAncestor(file, candidate, false)) { - ok = false; - break; + invalidIDs.add(wrapper.id); + continue nextEvent; } } - if (ok) { - filtered.add(event); - if (candidate.isDirectory()) { - filesToBeDeleted.add(candidate); - } + if (candidate.isDirectory()) { + dirsToBeDeleted.add(candidate); } } + final List filtered = Lists.newArrayListWithCapacity(events.size() - invalidIDs.size()); + for (int i = 0, size = events.size(); i < size; i++) { + final VFileEvent event = events.get(i); + if (event.isValid() && !(event instanceof VFileDeleteEvent && invalidIDs.contains(i))) { + filtered.add(event); + } + } return filtered; } @@ -829,6 +840,7 @@ public class PersistentFS extends ManagingFS implements ApplicationComponent { return _findFileById(id, true); } + @Nullable private NewVirtualFile _findFileById(int id, final boolean cachedOnly) { final NewVirtualFile cached = myIdToDirCache.get(id); if (cached != null) { @@ -951,9 +963,9 @@ public class PersistentFS extends ManagingFS implements ApplicationComponent { } private static void appendIdToParentList(final int parentId, final int childId) { - int[] childrenlist = FSRecords.list(parentId); - childrenlist = ArrayUtil.append(childrenlist, childId); - FSRecords.updateList(parentId, childrenlist); + int[] childrenList = FSRecords.list(parentId); + childrenList = ArrayUtil.append(childrenList, childId); + FSRecords.updateList(parentId, childrenList); } private void executeDelete(final VirtualFile file) { diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/RefreshWorker.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/RefreshWorker.java index 6369f30c92cf..39f9da022ab9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/RefreshWorker.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/RefreshWorker.java @@ -13,10 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.openapi.vfs.newvfs.persistent; import com.intellij.openapi.vfs.VfsUtil; @@ -32,6 +28,9 @@ import com.intellij.util.containers.Queue; import java.util.*; +/** + * @author max + */ public class RefreshWorker { private final VirtualFile myRefreshRoot; private final boolean myIsRecursive; @@ -135,10 +134,14 @@ public class RefreshWorker { private void scheduleChildRefresh(final VirtualFileSystemEntry file, final VirtualFile child, final NewVirtualFileSystem delegate) { final boolean currentIsDirectory = child.isDirectory(); + final boolean currentIsSymlink = child.isSymLink(); + final boolean currentIsSpecial = child.isSpecialFile(); final boolean upToDateIsDirectory = delegate.isDirectory(child); - if (currentIsDirectory != upToDateIsDirectory) { + final boolean upToDateIsSymlink = delegate.isSymLink(child); + final boolean upToDateIsSpecial = delegate.isSpecialFile(child); + if (currentIsDirectory != upToDateIsDirectory || currentIsSymlink != upToDateIsSymlink || currentIsSpecial != upToDateIsSpecial) { scheduleDeletion(child); - scheduleCreation(file, child.getName(), upToDateIsDirectory); + scheduleReCreation(file, child.getName(), upToDateIsDirectory); } else if (myIsRecursive || !currentIsDirectory) { myRefreshQueue.addLast(child); @@ -156,7 +159,11 @@ public class RefreshWorker { } private void scheduleCreation(final VirtualFileSystemEntry parent, final String childName, final boolean isDirectory) { - myEvents.add(new VFileCreateEvent(null, parent, childName, isDirectory, true)); + myEvents.add(new VFileCreateEvent(null, parent, childName, isDirectory, true, false)); + } + + private void scheduleReCreation(final VirtualFileSystemEntry parent, final String childName, final boolean isDirectory) { + myEvents.add(new VFileCreateEvent(null, parent, childName, isDirectory, true, true)); } private void scheduleDeletion(final VirtualFile file) { diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/SymLinkHandlingTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/SymLinkHandlingTest.java index 41afb77e8246..38c562f69237 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/SymLinkHandlingTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/SymLinkHandlingTest.java @@ -15,27 +15,22 @@ */ package com.intellij.openapi.vfs.local; +import com.intellij.execution.ExecutionException; +import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.testFramework.LightPlatformTestCase; -import com.intellij.testFramework.PlatformTestCase; +import com.intellij.testFramework.LightPlatformLangTestCase; import org.jetbrains.annotations.Nullable; import java.io.File; -import java.io.IOException; -public class SymLinkHandlingTest extends LightPlatformTestCase { +public class SymLinkHandlingTest extends LightPlatformLangTestCase { private LocalFileSystem myFileSystem; - @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") - public SymLinkHandlingTest() { - PlatformTestCase.initPlatformLangPrefix(); - } - @Override protected void setUp() throws Exception { super.setUp(); @@ -135,25 +130,64 @@ public class SymLinkHandlingTest extends LightPlatformTestCase { assertTrue(childFile.exists()); } + public void testTransGenderRefresh() throws Exception { + if (!SystemInfo.areSymLinksSupported) return; + + final File targetFile = FileUtil.createTempFile("target", ""); + final File targetDir = FileUtil.createTempDirectory("targetDir", ""); + + // file link + File link = createTempLink(targetFile.getAbsolutePath(), "link"); + VirtualFile vFile1 = refreshAndFind(link); + assertTrue("link=" + link + ", vLink=" + vFile1, + vFile1 != null && !vFile1.isDirectory() && vFile1.isSymLink()); + + // file link => dir + assertTrue(link.getAbsolutePath(), link.delete() && link.mkdir() && link.isDirectory()); + VirtualFile vFile2 = refreshAndFind(link); + assertTrue("link=" + link + ", vLink=" + vFile2, + !vFile1.isValid() && vFile2 != null && vFile2.isDirectory() && !vFile2.isSymLink()); + + // dir => dir link + assertTrue(link.getAbsolutePath(), link.delete()); + link = createTempLink(targetDir.getAbsolutePath(), "link"); + vFile1 = refreshAndFind(link); + assertTrue("link=" + link + ", vLink=" + vFile1, + !vFile2.isValid() && vFile1 != null && vFile1.isDirectory() && vFile1.isSymLink()); + + // dir link => file + assertTrue(link.getAbsolutePath(), link.delete() && link.createNewFile() && link.isFile()); + vFile2 = refreshAndFind(link); + assertTrue("link=" + link + ", vLink=" + vFile1, + !vFile1.isValid() && vFile2 != null && !vFile2.isDirectory() && !vFile2.isSymLink()); + + // file => file link + assertTrue(link.getAbsolutePath(), link.delete()); + link = createTempLink(targetFile.getAbsolutePath(), "link"); + vFile1 = refreshAndFind(link); + assertTrue("link=" + link + ", vLink=" + vFile1, + !vFile2.isValid() && vFile1 != null && !vFile1.isDirectory() && vFile1.isSymLink()); + } + // todo[r.sh] use NIO2 API after migration to JDK 7 - private static File createTempLink(final String target, final String link) throws IOException, InterruptedException { + private static File createTempLink(final String target, final String link) throws InterruptedException, ExecutionException { final File linkFile = new File(FileUtil.getTempDirectory(), link); assertTrue(link, !linkFile.exists() || linkFile.delete()); final File parentDir = linkFile.getParentFile(); assertTrue("link=" + link + ", parent=" + parentDir, parentDir != null && (parentDir.isDirectory() || parentDir.mkdirs())); - final ProcessBuilder builder; + final GeneralCommandLine commandLine; if (SystemInfo.isWindows) { - builder = new File(target).isDirectory() - ? new ProcessBuilder("cmd", "/C", "mklink", "/D", linkFile.getAbsolutePath(), target) - : new ProcessBuilder("cmd", "/C", "mklink", linkFile.getAbsolutePath(), target); + commandLine = new File(target).isDirectory() + ? new GeneralCommandLine("cmd", "/C", "mklink", "/D", linkFile.getAbsolutePath(), target) + : new GeneralCommandLine("cmd", "/C", "mklink", linkFile.getAbsolutePath(), target); } else { - builder = new ProcessBuilder("ln", "-s", target, linkFile.getAbsolutePath()); + commandLine = new GeneralCommandLine("ln", "-s", target, linkFile.getAbsolutePath()); } - final Process process = builder.start(); + final Process process = commandLine.createProcess(); final int res = process.waitFor(); - assertTrue(builder.command() + ": " + res, res == 0); + assertTrue(commandLine.getCommandLineString() + ": " + res, res == 0); final File targetFile = new File(target); assertEquals("target=" + target + ", link=" + linkFile, targetFile.exists(), linkFile.exists()); return linkFile; From e34d1f521499996ba5724d4cb370c86ebb052daa Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 26 Dec 2011 18:44:40 +0100 Subject: [PATCH 11/31] Fix incorrect message bundle loading --- .../codeInsight/daemon/JavaErrorMessages.java | 20 +++------ .../intellij/lang/java/parser/FileParser.java | 15 ++++--- .../util/src/com/intellij/AbstractBundle.java | 43 ++++++++++++------- 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/daemon/JavaErrorMessages.java b/java/java-psi-impl/src/com/intellij/codeInsight/daemon/JavaErrorMessages.java index c874afcb270a..3fc250b1c0ab 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/daemon/JavaErrorMessages.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/daemon/JavaErrorMessages.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -15,31 +15,23 @@ */ package com.intellij.codeInsight.daemon; -import com.intellij.CommonBundle; +import com.intellij.AbstractBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.PropertyKey; -import java.util.ResourceBundle; - /** * @author max */ -public class JavaErrorMessages { +public class JavaErrorMessages extends AbstractBundle { + public static final JavaErrorMessages INSTANCE = new JavaErrorMessages(); @NonNls public static final String BUNDLE = "messages.JavaErrorMessages"; private JavaErrorMessages() { + super(BUNDLE); } public static String message(@PropertyKey(resourceBundle = BUNDLE)String key, Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static class ResourceBundleHolder { - private static final ResourceBundle ourBundle = ResourceBundle.getBundle(BUNDLE); - } - - private static ResourceBundle getBundle() { - return ResourceBundleHolder.ourBundle; + return INSTANCE.getMessage(key, params); } } diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/FileParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/FileParser.java index e4ef509e762e..11828295ce42 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/FileParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/FileParser.java @@ -15,7 +15,7 @@ */ package com.intellij.lang.java.parser; -import com.intellij.CommonBundle; +import com.intellij.AbstractBundle; import com.intellij.codeInsight.daemon.JavaErrorMessages; import com.intellij.lang.PsiBuilder; import com.intellij.openapi.util.Pair; @@ -27,8 +27,6 @@ import com.intellij.psi.tree.TokenSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ResourceBundle; - import static com.intellij.lang.PsiBuilderUtil.expect; import static com.intellij.lang.java.parser.JavaParserUtil.*; @@ -52,14 +50,17 @@ public class FileParser { } public void parse(final PsiBuilder builder) { - parseFile(builder, IMPORT_LIST_STOPPER_SET, JavaErrorMessages.BUNDLE, "expected.class.or.interface"); + parseFile(builder, IMPORT_LIST_STOPPER_SET, JavaErrorMessages.INSTANCE, "expected.class.or.interface"); } - private static String error(@NotNull String bundle, @NotNull String errorMessageKey) { - return CommonBundle.message(ResourceBundle.getBundle(bundle), errorMessageKey); + private static String error(@NotNull AbstractBundle bundle, @NotNull String errorMessageKey) { + return bundle.getMessage(errorMessageKey); } - public void parseFile(final PsiBuilder builder, final TokenSet importListStoppers, @NotNull String bundle, @NotNull String errorMessageKey) { + public void parseFile(@NotNull final PsiBuilder builder, + @NotNull final TokenSet importListStoppers, + @NotNull final AbstractBundle bundle, + @NotNull final String errorMessageKey) { parsePackageStatement(builder); final Pair impListInfo = parseImportList(builder, importListStoppers); diff --git a/platform/util/src/com/intellij/AbstractBundle.java b/platform/util/src/com/intellij/AbstractBundle.java index aa934966deee..9230d95e1776 100644 --- a/platform/util/src/com/intellij/AbstractBundle.java +++ b/platform/util/src/com/intellij/AbstractBundle.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2011 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; import com.intellij.util.containers.ConcurrentHashMap; @@ -27,33 +42,31 @@ import java.util.ResourceBundle; * @author Denis Zhdanov * @since 8/1/11 2:37 PM */ -public class AbstractBundle { - - @NonNls - private final String myPathToBundle; +public abstract class AbstractBundle { + @NonNls private final String myPathToBundle; protected AbstractBundle(@NonNls @NotNull String pathToBundle) { myPathToBundle = pathToBundle; } - public String getMessage(String key, Object... params) { + public String getMessage(@NotNull String key, Object... params) { return CommonBundle.message(getBundle(), key, params); } private ResourceBundle getBundle() { return getResourceBundle(myPathToBundle, getClass().getClassLoader()); } - - @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") - private static FactoryMap>> ourCache = - new ConcurrentWeakFactoryMap>>() { - @Override - protected ConcurrentHashMap> create(ClassLoader key) { - return new ConcurrentHashMap>(); - } - }; - public static ResourceBundle getResourceBundle(String pathToBundle, ClassLoader loader) { + @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") + private static final FactoryMap>> ourCache = + new ConcurrentWeakFactoryMap>>() { + @Override + protected ConcurrentHashMap> create(ClassLoader key) { + return new ConcurrentHashMap>(); + } + }; + + public static ResourceBundle getResourceBundle(@NotNull String pathToBundle, @NotNull ClassLoader loader) { ConcurrentHashMap> map = ourCache.get(loader); SoftReference reference = map.get(pathToBundle); ResourceBundle result = reference == null ? null : reference.get(); From 60d4f4236373d786eb911804413215b2479264c1 Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 26 Dec 2011 18:26:39 +0100 Subject: [PATCH 12/31] constructor parameters from fields: sort params in fields order --- .../CreateConstructorParameterFromFieldFix.java | 13 ++++++++++--- .../afterMultipleFields.java | 6 +++--- .../afterMultipleFieldsNoConstructorNoUsages.java | 6 +++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorParameterFromFieldFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorParameterFromFieldFix.java index 216a3c44afdc..3eff28e67732 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorParameterFromFieldFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorParameterFromFieldFix.java @@ -152,8 +152,15 @@ public class CreateConstructorParameterFromFieldFix implements IntentionAction { } } - - addParameterToConstructor(project, file, editor, constructor, constrs.size() == constructors.length ? fields.toArray(new PsiField[fields.size()]) : new PsiField[]{getField()}); + Collections.sort(fields, new Comparator() { + @Override + public int compare(PsiField o1, PsiField o2) { + return o1.getTextOffset() - o2.getTextOffset(); + } + }); + addParameterToConstructor(project, file, editor, constructor, constrs.size() == constructors.length + ? fields.toArray(new PsiField[fields.size()]) + : new PsiField[]{getField()}); fieldsToFix.clear(); } } @@ -217,7 +224,7 @@ public class CreateConstructorParameterFromFieldFix implements IntentionAction { expressions[i++] = factory.createExpressionFromText(field.getName(), constructor); } if (constructor.isVarArgs()) { - ArrayUtil.swap(expressions, parameters.length - 1, expressions.length - 1); + ArrayUtil.rotateLeft(expressions, parameters.length - 1, expressions.length - 1); } final SmartPointerManager manager = SmartPointerManager.getInstance(project); final SmartPsiElementPointer constructorPointer = manager.createSmartPsiElementPointer(constructor); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/afterMultipleFields.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/afterMultipleFields.java index db50428a883e..79a6f917ba56 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/afterMultipleFields.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/afterMultipleFields.java @@ -3,10 +3,10 @@ class A { private final int field; private final Object o; private final Runnable runnable; - A(int field, Runnable runnable, Object o, String... strs) { - this.field = field; - this.runnable = runnable; + A(int field, Object o, Runnable runnable, String... strs) { + this.field = field; this.o = o; + this.runnable = runnable; } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/afterMultipleFieldsNoConstructorNoUsages.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/afterMultipleFieldsNoConstructorNoUsages.java index e142c903f5ff..97b2c31c0350 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/afterMultipleFieldsNoConstructorNoUsages.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/afterMultipleFieldsNoConstructorNoUsages.java @@ -4,9 +4,9 @@ public class A { private final Object o; private final Runnable runnable; - public A(Runnable runnable, Object o, int field) { - this.runnable = runnable; + public A(int field, Object o, Runnable runnable) { + this.field = field; this.o = o; - this.field = field; + this.runnable = runnable; } } From 446810994688bd41bf3a2d0b257c6619e5d7571e Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 26 Dec 2011 18:50:20 +0100 Subject: [PATCH 13/31] background/foreground (IDEA-79153) --- .../encapsulateFields/EncapsulateFieldsDialog.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsDialog.java b/java/java-impl/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsDialog.java index f686c9c7bef5..6a8011e49d98 100644 --- a/java/java-impl/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsDialog.java @@ -707,12 +707,8 @@ public String getAccessorsVisibility() { } private void configureColors(boolean isSelected, JTable table, boolean hasFocus, final int row, final int column) { - if (isSelected) { - setForeground(table.getSelectionForeground()); - } else { - setForeground(UIUtil.getTableForeground()); - } - + setForeground(isSelected ? UIUtil.getTableSelectionForeground() : UIUtil.getTableForeground()); + setBackground(isSelected ? UIUtil.getTableSelectionBackground() : UIUtil.getTableBackground()); if (hasFocus) { if (table.isCellEditable(row, column)) { super.setForeground(UIUtil.getTableFocusCellForeground()); From ea3974763da51518eb2c0c0acd5dac998c322583 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 26 Dec 2011 18:57:56 +0100 Subject: [PATCH 14/31] show parameter info after completing a groovy method call --- .../plugins/groovy/lang/completion/GroovyInsertHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyInsertHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyInsertHandler.java index 21079ad200d5..4dfd43772e81 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyInsertHandler.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyInsertHandler.java @@ -111,6 +111,7 @@ public class GroovyInsertHandler implements InsertHandler { } new MethodParenthesesHandler(method, true).handleInsert(context, item); + AutoPopupController.getInstance(context.getProject()).autoPopupParameterInfo(editor, method); return; } From bb8450ab1d5b5b693a90c93a2323d7c5dc5c97a0 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 26 Dec 2011 19:22:00 +0100 Subject: [PATCH 15/31] ability to hide search popup --- .../platform-impl/src/com/intellij/ui/SpeedSearchBase.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java index 64b6801313ec..47cf9f8343c3 100644 --- a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java +++ b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java @@ -270,6 +270,10 @@ public abstract class SpeedSearchBase extends SpeedSear return null; } + public void hidePopup() { + manageSearchPopup(null); + } + private void processKeyEvent(KeyEvent e) { if (e.isAltDown()) return; if (mySearchPopup != null) { @@ -462,7 +466,7 @@ public abstract class SpeedSearchBase extends SpeedSear return keyCode == KeyEvent.VK_HOME || keyCode == KeyEvent.VK_END || keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN; } - private void manageSearchPopup(SearchPopup searchPopup) { + private void manageSearchPopup(@Nullable SearchPopup searchPopup) { final Project project; if (ApplicationManager.getApplication() != null && !ApplicationManager.getApplication().isDisposed()) { project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myComponent)); From 21d45ca4ac4ef077988202633a447968012db906 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 26 Dec 2011 19:22:24 +0100 Subject: [PATCH 16/31] smart ESCAPE --- .../src/com/intellij/ide/util/FileStructurePopup.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java index f16f82428105..f1d5762ca206 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java @@ -183,6 +183,7 @@ public class FileStructurePopup implements Disposable { .setResizable(true) .setFocusable(true) .setMovable(true) + .setCancelKeyEnabled(false) .setDimensionServiceKey(null, getDimensionServiceKey(), false) .createPopup(); Disposer.register(myPopup, myDisposable); @@ -284,6 +285,16 @@ public class FileStructurePopup implements Disposable { } }.registerCustomShortcutSet(shortcutSet, panel); + new AnAction() { + public void actionPerformed(AnActionEvent e) { + if (mySpeedSearch != null && mySpeedSearch.isPopupActive()) { + mySpeedSearch.hidePopup(); + } else { + myPopup.cancel(); + } + } + }.registerCustomShortcutSet(CustomShortcutSet.fromString("ESCAPE"), myTree); + //myCommanderPanel.setPreferredSize(new Dimension(400, 500)); addNarrowDownCheckbox(comboPanel); From 551cfe36c65329d8ba10f4140a789f2c61ba3182 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 26 Dec 2011 22:30:50 +0400 Subject: [PATCH 17/31] IDEA-79296 Can't edit HTML code style settings with low screen resolution --- .../intellij/ui/components/JBScrollPane.java | 8 + .../options/CodeStyleHtmlPanel.form | 641 +++++++++--------- .../options/CodeStyleHtmlPanel.java | 14 + 3 files changed, 350 insertions(+), 313 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java b/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java index bb9196113d16..e72e1b24ea86 100644 --- a/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java +++ b/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java @@ -88,6 +88,14 @@ public class JBScrollPane extends JScrollPane { return new MyScrollBar(JScrollBar.HORIZONTAL); } + public boolean isHaveBorder() { + return getBorder() != null; + } + + public void setHaveBorder(boolean haveBorder) { + setBorder(haveBorder ? IdeBorderFactory.createBorder() : null); + } + @Override protected JViewport createViewport() { return new JBViewport(); diff --git a/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.form b/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.form index dff5cd64df47..b547b5288445 100644 --- a/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.form +++ b/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.form @@ -1,324 +1,13 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -328,6 +17,332 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.java b/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.java index 80fabfee6ca3..4af26f0b6d2d 100644 --- a/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.java +++ b/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.java @@ -26,11 +26,13 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.CodeStyleSettings; +import com.intellij.ui.components.JBScrollPane; import com.intellij.util.ArrayUtil; import com.intellij.util.PlatformIcons; import org.jetbrains.annotations.NotNull; import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -60,6 +62,7 @@ public class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { private JCheckBox myWrapText; private JCheckBox myShouldKeepLineBreaksInText; private TextFieldWithBrowseButton myDontBreakIfInlineContent; + private JBScrollPane myJBScrollPane; public CodeStyleHtmlPanel(CodeStyleSettings settings) { super(settings); @@ -89,6 +92,17 @@ public class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { return XmlHighlighterFactory.createXMLHighlighter(scheme); } + private void createUIComponents() { + myJBScrollPane = new JBScrollPane() { + @Override + public Dimension getPreferredSize() { + Dimension prefSize = super.getPreferredSize(); + return new Dimension(prefSize.width + 15, prefSize.height); + } + }; + myJBScrollPane.setHaveBorder(false); + } + private static void customizeField(final String title, final TextFieldWithBrowseButton uiField) { uiField.getTextField().setEditable(false); uiField.setButtonIcon(PlatformIcons.OPEN_EDIT_DIALOG_ICON); From 8267b4c04339850703570c6b0e79416a463041d4 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 26 Dec 2011 23:15:03 +0400 Subject: [PATCH 18/31] IDEA-79296 Can't edit HTML code style settings with low screen resolution Same problem for XML code style settings --- .../options/CodeStyleHtmlPanel.java | 1 - .../options/CodeStyleXmlPanel.form | 307 +++++++++--------- .../options/CodeStyleXmlPanel.java | 13 + 3 files changed, 169 insertions(+), 152 deletions(-) diff --git a/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.java b/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.java index 4af26f0b6d2d..bde6a85f6f5f 100644 --- a/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.java +++ b/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.java @@ -100,7 +100,6 @@ public class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { return new Dimension(prefSize.width + 15, prefSize.height); } }; - myJBScrollPane.setHaveBorder(false); } private static void customizeField(final String title, final TextFieldWithBrowseButton uiField) { diff --git a/xml/impl/src/com/intellij/application/options/CodeStyleXmlPanel.form b/xml/impl/src/com/intellij/application/options/CodeStyleXmlPanel.form index 67711d557694..4e59aa28561b 100644 --- a/xml/impl/src/com/intellij/application/options/CodeStyleXmlPanel.form +++ b/xml/impl/src/com/intellij/application/options/CodeStyleXmlPanel.form @@ -1,6 +1,6 @@
- + @@ -8,23 +8,111 @@ - - + - + - + + + + - + - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -32,189 +120,106 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + + + + + + + + + + + - - - - - - - - - - + - + - + - - + - + - + - - + + - + - + - - + - + - + - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/xml/impl/src/com/intellij/application/options/CodeStyleXmlPanel.java b/xml/impl/src/com/intellij/application/options/CodeStyleXmlPanel.java index 90e17d71907e..b7f0bd3ecac7 100644 --- a/xml/impl/src/com/intellij/application/options/CodeStyleXmlPanel.java +++ b/xml/impl/src/com/intellij/application/options/CodeStyleXmlPanel.java @@ -23,9 +23,11 @@ import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.formatter.xml.XmlCodeStyleSettings; +import com.intellij.ui.components.JBScrollPane; import org.jetbrains.annotations.NotNull; import javax.swing.*; +import java.awt.*; public class CodeStyleXmlPanel extends CodeStyleAbstractPanel{ private JTextField myKeepBlankLines; @@ -44,6 +46,7 @@ public class CodeStyleXmlPanel extends CodeStyleAbstractPanel{ private JCheckBox myKeepLineBreaksInText; private JComboBox myWhiteSpaceAroundCDATA; private JCheckBox myKeepWhitespaceInsideCDATACheckBox; + private JBScrollPane myJBScrollPane; public CodeStyleXmlPanel(CodeStyleSettings settings) { super(settings); @@ -171,4 +174,14 @@ public class CodeStyleXmlPanel extends CodeStyleAbstractPanel{ protected void prepareForReformat(final PsiFile psiFile) { //psiFile.putUserData(PsiUtil.FILE_LANGUAGE_LEVEL_KEY, LanguageLevel.HIGHEST); } + + private void createUIComponents() { + myJBScrollPane = new JBScrollPane() { + @Override + public Dimension getPreferredSize() { + Dimension prefSize = super.getPreferredSize(); + return new Dimension(prefSize.width + 15, prefSize.height); + } + }; + } } From 120e650056dabec1bc98656195627e6428c72b17 Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 26 Dec 2011 20:18:48 +0100 Subject: [PATCH 19/31] install plugin from disk: do not delete plugin's jar as it seems to be unexpected (IDEA-78517) --- .../ide/plugins/InstalledPluginsManagerMain.java | 2 +- .../openapi/updateSettings/impl/PluginDownloader.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsManagerMain.java b/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsManagerMain.java index 5abc980f9788..e62952115f43 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsManagerMain.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsManagerMain.java @@ -90,7 +90,7 @@ public class InstalledPluginsManagerMain extends PluginManagerMain { Messages.showErrorDialog("Fail to load plugin descriptor from file " + file.getName(), CommonBundle.getErrorTitle()); return; } - PluginDownloader.install(file, file.getName()); + PluginDownloader.install(file, file.getName(), false); ((InstalledPluginsTableModel)pluginsModel).appendOrUpdateDescriptor(pluginDescriptor); select(pluginDescriptor); setRequireShutdown(true); diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java index 22c75f2852ed..8f41e8c9300c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java @@ -185,6 +185,10 @@ public class PluginDownloader { } public static void install(final File fromFile, final String pluginName) throws IOException { + install(fromFile, pluginName, true); + } + + public static void install(final File fromFile, final String pluginName, boolean deleteFromFile) throws IOException { //noinspection HardCodedStringLiteral if (fromFile.getName().endsWith(".jar")) { // add command to copy file to the IDEA/plugins path @@ -207,8 +211,10 @@ public class PluginDownloader { } // add command to remove temp plugin file - StartupActionScriptManager.ActionCommand deleteTemp = new StartupActionScriptManager.DeleteCommand(fromFile); - StartupActionScriptManager.addActionCommand(deleteTemp); + if (deleteFromFile) { + StartupActionScriptManager.ActionCommand deleteTemp = new StartupActionScriptManager.DeleteCommand(fromFile); + StartupActionScriptManager.addActionCommand(deleteTemp); + } } private File downloadPlugin(final ProgressIndicator pi) throws IOException { From 2fdd01834e167cfb94a83a72a476d084547f9588 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 27 Dec 2011 01:02:50 +0100 Subject: [PATCH 20/31] + navigation --- .../intellij/ide/util/FileStructurePopup.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java index f1d5762ca206..d539d5f4fcb4 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java @@ -72,7 +72,6 @@ import javax.swing.border.Border; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeModel; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -160,8 +159,8 @@ public class FileStructurePopup implements Disposable { ElementFilter filter = new FileStructurePopupFilter(); final FilteringTreeStructure treeStructure = new FilteringTreeStructure(project, filter, smartTreeStructure); - final DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode(treeStructure.getRootElement())); - myTree = new Tree(model); + //final DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode(treeStructure.getRootElement())); + myTree = new Tree(new DefaultMutableTreeNode(treeStructure.getRootElement())); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); @@ -307,20 +306,36 @@ public class FileStructurePopup implements Disposable { addCheckbox(comboPanel, provider); } - //myCommanderPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP)); panel.add(comboPanel, BorderLayout.NORTH); panel.add(ScrollPaneFactory.createScrollPane(myAbstractTreeBuilder.getTree()), BorderLayout.CENTER); - //new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); return panel; } + + @Nullable + private AbstractTreeNode getSelectedNode() { + Object component = myTree.getSelectionPath().getLastPathComponent(); + if (component instanceof DefaultMutableTreeNode) { + component = ((DefaultMutableTreeNode)component).getUserObject(); + if (component instanceof FilteringTreeStructure.Node) { + component = ((FilteringTreeStructure.Node)component).getDelegate(); + if (component instanceof FilteringTreeStructure.Node) { + component = ((FilteringTreeStructure.Node)component).getDelegate(); + if (component instanceof AbstractTreeNode) { + return (AbstractTreeNode)component; + } + } + } + } + return null; + } public boolean navigateSelectedElement() { final Ref succeeded = new Ref(); final CommandProcessor commandProcessor = CommandProcessor.getInstance(); commandProcessor.executeCommand(myProject, new Runnable() { public void run() { - final AbstractTreeNode selectedNode = (AbstractTreeNode)myTree.getSelectionPath().getLastPathComponent(); + final AbstractTreeNode selectedNode = getSelectedNode(); if (selectedNode != null) { if (selectedNode.canNavigateToSource()) { selectedNode.navigate(true); @@ -388,6 +403,7 @@ public class FileStructurePopup implements Disposable { } final boolean state = chkFilter.isSelected(); myTreeActionsOwner.setActionIncluded(action, action instanceof FileStructureFilter ? !state : state); + myAbstractTreeBuilder.refilter(); //todo full update myAbstractTreeBuilder.queueUpdate(); if (currentParent != null) { boolean oldNarrowDown = myShouldNarrowDown; From 0f4ff0803be967493c33208494ef745e0a49d32a Mon Sep 17 00:00:00 2001 From: irengrig Date: Tue, 27 Dec 2011 13:27:59 +0400 Subject: [PATCH 21/31] fix of Null assertion in IDEA-56157 Sort out performance problem with Perforce changelists refresh --- .../src/com/intellij/openapi/vcs/impl/ContentRevisionCache.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/impl/ContentRevisionCache.java b/platform/vcs-api/src/com/intellij/openapi/vcs/impl/ContentRevisionCache.java index b2e4c19b18b1..3059bada685c 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/impl/ContentRevisionCache.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/impl/ContentRevisionCache.java @@ -58,6 +58,7 @@ public class ContentRevisionCache { } private void put(FilePath path, VcsRevisionNumber number, @NotNull VcsKey vcsKey, @NotNull UniqueType type, final byte[] bytes) { + if (bytes == null) return; synchronized (myLock) { myCache.put(new Key(path, number, vcsKey, type), bytes); } From 241e1dc476dd5b9ed483725bb5c9c11964dacde1 Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 27 Dec 2011 13:28:36 +0400 Subject: [PATCH 22/31] added 'clean' action to 'Build Artifacts' popup (IDEA-79174) --- .../compiler/actions/BuildArtifactAction.java | 92 +++++++++++++++++-- 1 file changed, 85 insertions(+), 7 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/actions/BuildArtifactAction.java b/java/compiler/impl/src/com/intellij/compiler/actions/BuildArtifactAction.java index de755eef5ed5..4c48887f958c 100644 --- a/java/compiler/impl/src/com/intellij/compiler/actions/BuildArtifactAction.java +++ b/java/compiler/impl/src/com/intellij/compiler/actions/BuildArtifactAction.java @@ -15,16 +15,26 @@ */ package com.intellij.compiler.actions; -import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonShortcuts; +import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.compiler.CompileScope; import com.intellij.openapi.compiler.CompilerManager; import com.intellij.openapi.keymap.KeymapUtil; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService; +import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.ListSeparator; import com.intellij.openapi.ui.popup.PopupStep; import com.intellij.openapi.ui.popup.util.BaseListPopupStep; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.impl.artifacts.ArtifactUtil; import com.intellij.packaging.impl.compiler.ArtifactCompileScope; @@ -37,9 +47,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.event.ActionEvent; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.io.File; +import java.util.*; /** * @author nik @@ -102,10 +111,9 @@ public class BuildArtifactAction extends AnAction { } protected static void doBuild(@NotNull Project project, final @NotNull ArtifactPopupItem item, boolean rebuild) { - final Artifact artifact = item.getArtifact(); - final List artifacts = artifact != null ? Collections.singletonList(artifact) : ArtifactUtil.getArtifactWithOutputPaths(project); + final List artifacts = item.getArtifacts(project); final CompileScope scope = ArtifactCompileScope.createArtifactsScope(project, artifacts); - ArtifactsWorkspaceSettings.getInstance(project).setArtifactsToBuild(ContainerUtil.createMaybeSingletonList(artifact)); + ArtifactsWorkspaceSettings.getInstance(project).setArtifactsToBuild(ContainerUtil.createMaybeSingletonList(item.getArtifact())); if (!rebuild) { CompilerManager.getInstance(project).make(scope, null); } @@ -125,6 +133,70 @@ public class BuildArtifactAction extends AnAction { } } + private static class CleanArtifactItem extends ArtifactActionItem { + private CleanArtifactItem(@NotNull ArtifactPopupItem item, @NotNull Project project) { + super(item, project, "Clean"); + } + + @Override + public void run() { + Set parents = new HashSet(); + final VirtualFile[] roots = ProjectRootManager.getInstance(myProject).getContentSourceRoots(); + for (VirtualFile root : roots) { + VirtualFile parent = root; + while (parent != null && !parents.contains(parent)) { + parents.add(parent); + parent = parent.getParent(); + } + } + + Map outputPathContainingSourceRoots = new HashMap(); + final List files = new ArrayList(); + for (Artifact artifact : myArtifactPopupItem.getArtifacts(myProject)) { + String outputPath = artifact.getOutputFilePath(); + if (outputPath != null) { + files.add(new File(FileUtil.toSystemDependentName(outputPath))); + final VirtualFile outputFile = LocalFileSystem.getInstance().findFileByPath(outputPath); + if (parents.contains(outputFile)) { + outputPathContainingSourceRoots.put(artifact.getName(), outputPath); + } + } + } + + if (!outputPathContainingSourceRoots.isEmpty()) { + final String message; + if (outputPathContainingSourceRoots.size() == 1 && outputPathContainingSourceRoots.values().size() == 1) { + final String name = ContainerUtil.getFirstItem(outputPathContainingSourceRoots.keySet()); + final String output = outputPathContainingSourceRoots.get(name); + message = "The output directory '" + output + "' of '" + name + "' artifact contains source roots of the project. Do you want to continue and clear it?"; + } + else { + StringBuilder info = new StringBuilder(); + for (String name : outputPathContainingSourceRoots.keySet()) { + info.append(" '").append(name).append("' artifact ('").append(outputPathContainingSourceRoots.get(name)).append("')\n"); + } + message = "The output directories of the following artifacts contains source roots:\n" + + info + "Do you want to continue and clear these directories?"; + } + final int answer = Messages.showYesNoDialog(myProject, message, "Clean Artifacts", null); + if (answer != 0) { + return; + } + } + + new Task.Backgroundable(myProject, "Cleaning artifacts...", true) { + @Override + public void run(@NotNull ProgressIndicator indicator) { + for (File file : files) { + indicator.checkCanceled(); + FileUtil.delete(file); + } + LocalFileSystem.getInstance().refreshIoFiles(files, true, true, null); + } + }.queue(); + } + } + private static class RebuildArtifactItem extends ArtifactActionItem { private RebuildArtifactItem(ArtifactPopupItem item, Project project) { super(item, project, "Rebuild"); @@ -189,6 +261,11 @@ public class BuildArtifactAction extends AnAction { public Icon getIcon() { return myIcon; } + + public List getArtifacts(Project project) { + final Artifact artifact = getArtifact(); + return artifact != null ? Collections.singletonList(artifact) : ArtifactUtil.getArtifactWithOutputPaths(project); + } } private static class ChooseArtifactStep extends BaseListPopupStep { @@ -244,6 +321,7 @@ public class BuildArtifactAction extends AnAction { final List actions = new ArrayList(); actions.add(new BuildArtifactItem(selectedValue, myProject)); actions.add(new RebuildArtifactItem(selectedValue, myProject)); + actions.add(new CleanArtifactItem(selectedValue, myProject)); if (mySettingsService != null) { actions.add(new EditArtifactItem(selectedValue, myProject, mySettingsService)); } From d0793827aac777cccb9ed7c45497dbe0075da6ad Mon Sep 17 00:00:00 2001 From: Serega Vasiliev Date: Tue, 27 Dec 2011 10:32:56 +0100 Subject: [PATCH 23/31] catch AssertionError --- .../persistence/BasicSentUsagesPersistenceComponent.java | 3 +-- .../persistence/UsageStatisticsPersistenceComponent.java | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/BasicSentUsagesPersistenceComponent.java b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/BasicSentUsagesPersistenceComponent.java index b77ea2367816..0e195bc87d55 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/BasicSentUsagesPersistenceComponent.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/BasicSentUsagesPersistenceComponent.java @@ -78,8 +78,7 @@ public class BasicSentUsagesPersistenceComponent extends SentUsagesPersistence { @NotNull - public Map> getSentUsages - () { + public Map> getSentUsages () { return mySentDescriptors; } } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java index d840a0f88994..5e459e3f9483 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java @@ -79,7 +79,11 @@ public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersiste String valueData = groupElement.getAttributeValue(DATA_ATTR); if (!StringUtil.isEmptyOrSpaces(groupId) && !StringUtil.isEmptyOrSpaces(valueData)) { - getSentUsages().putAll(ConvertUsagesUtil.convertValueString(GroupDescriptor.create(groupId, groupPriority), valueData)); + try { + getSentUsages().putAll(ConvertUsagesUtil.convertValueString(GroupDescriptor.create(groupId, groupPriority), valueData)); + } catch (AssertionError e) { + //don't load incorrect groups + } } } From f67b824d0bb73706dbcc8883ae2a01ca76e0ada9 Mon Sep 17 00:00:00 2001 From: irengrig Date: Tue, 27 Dec 2011 13:34:26 +0400 Subject: [PATCH 24/31] fix of NPE in IDEA-56157 Sort out performance problem with Perforce changelists refresh --- .../openapi/vcs/contentAnnotation/VcsContentAnnotationImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/contentAnnotation/VcsContentAnnotationImpl.java b/platform/vcs-api/src/com/intellij/openapi/vcs/contentAnnotation/VcsContentAnnotationImpl.java index 18e680a7b2f7..243e0fc60037 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/contentAnnotation/VcsContentAnnotationImpl.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/contentAnnotation/VcsContentAnnotationImpl.java @@ -76,7 +76,7 @@ public class VcsContentAnnotationImpl implements VcsContentAnnotation { public boolean intervalRecentlyChanged(VirtualFile file, TextRange lineInterval, VcsRevisionNumber currentRevisionNumber) { final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject); final AbstractVcs vcs = vcsManager.getVcsFor(file); - if (vcs == null) return false; + if (vcs == null || vcs.getDiffProvider() == null) return false; if (currentRevisionNumber == null) { currentRevisionNumber = vcs.getDiffProvider().getCurrentRevision(file); assert currentRevisionNumber != null; From e43d5d34e3c1d1b4cf9ff7dc97ace6283eed1a33 Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 27 Dec 2011 14:43:35 +0400 Subject: [PATCH 25/31] IDEA-76898: Some characters in archive names are replaced by underscore --- .../intellij/packaging/impl/artifacts/ArtifactUtil.java | 5 +++++ .../intellij/packaging/impl/artifacts/JarArtifactType.java | 4 ++-- .../packaging/impl/artifacts/JarFromModulesTemplate.java | 3 +-- .../ui/configuration/artifacts/ArtifactEditorImpl.java | 4 ++-- platform/platform-api/src/com/intellij/util/PathUtil.java | 7 ++++++- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactUtil.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactUtil.java index fa1b38dee670..9cde8f07e2df 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactUtil.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactUtil.java @@ -33,6 +33,7 @@ import com.intellij.packaging.artifacts.ArtifactProperties; import com.intellij.packaging.artifacts.ArtifactType; import com.intellij.packaging.elements.*; import com.intellij.packaging.impl.elements.*; +import com.intellij.util.PathUtil; import com.intellij.util.Processor; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; @@ -554,5 +555,9 @@ public class ArtifactUtil { } return result; } + + public static String suggestArtifactFileName(String artifactName) { + return PathUtil.suggestFileName(artifactName, true, true); + } } diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/JarArtifactType.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/JarArtifactType.java index 47d0033a6e09..678cd9cb6dd0 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/JarArtifactType.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/JarArtifactType.java @@ -15,13 +15,13 @@ */ package com.intellij.packaging.impl.artifacts; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.packaging.artifacts.ArtifactTemplate; import com.intellij.packaging.artifacts.ArtifactType; import com.intellij.packaging.elements.CompositePackagingElement; import com.intellij.packaging.elements.PackagingElementOutputKind; import com.intellij.packaging.elements.PackagingElementResolvingContext; import com.intellij.packaging.impl.elements.ArchivePackagingElement; +import com.intellij.util.PathUtil; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -54,7 +54,7 @@ public class JarArtifactType extends ArtifactType { @NotNull @Override public CompositePackagingElement createRootElement(@NotNull String artifactName) { - return new ArchivePackagingElement(FileUtil.sanitizeFileName(artifactName) + ".jar"); + return new ArchivePackagingElement(ArtifactUtil.suggestArtifactFileName(artifactName) + ".jar"); } @NotNull diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/JarFromModulesTemplate.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/JarFromModulesTemplate.java index bfce865fdd4a..542db382fd4b 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/JarFromModulesTemplate.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/JarFromModulesTemplate.java @@ -24,7 +24,6 @@ import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.packaging.artifacts.ArtifactTemplate; @@ -94,7 +93,7 @@ public class JarFromModulesTemplate extends ArtifactTemplate { String name = modules.length == 1 ? modules[0].getName() : project.getName(); final PackagingElementFactory factory = PackagingElementFactory.getInstance(); - final CompositePackagingElement archive = factory.createArchive(FileUtil.sanitizeFileName(name) + ".jar"); + final CompositePackagingElement archive = factory.createArchive(ArtifactUtil.suggestArtifactFileName(name) + ".jar"); OrderEnumerator orderEnumerator = ProjectRootManager.getInstance(project).orderEntries(Arrays.asList(modules)); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java index 272d0f645c7c..86394d0e5d1a 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java @@ -429,14 +429,14 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { setOutputPath(ArtifactUtil.getDefaultArtifactOutputPath(newArtifactName, myProject)); final CompositePackagingElement root = getRootElement(); if (root instanceof ArchivePackagingElement) { - String oldFileName = FileUtil.sanitizeFileName(oldArtifactName); + String oldFileName = ArtifactUtil.suggestArtifactFileName(oldArtifactName); final String name = ((ArchivePackagingElement)root).getArchiveFileName(); final String fileName = FileUtil.getNameWithoutExtension(name); final String extension = FileUtil.getExtension(name); if (fileName.equals(oldFileName) && extension.length() > 0) { myLayoutTreeComponent.editLayout(new Runnable() { public void run() { - ((ArchivePackagingElement)getRootElement()).setArchiveFileName(FileUtil.sanitizeFileName(newArtifactName) + "." + extension); + ((ArchivePackagingElement)getRootElement()).setArchiveFileName(ArtifactUtil.suggestArtifactFileName(newArtifactName) + "." + extension); } }); myLayoutTreeComponent.updateRootNode(); diff --git a/platform/platform-api/src/com/intellij/util/PathUtil.java b/platform/platform-api/src/com/intellij/util/PathUtil.java index c85296d6ea58..26d7b9433a8f 100644 --- a/platform/platform-api/src/com/intellij/util/PathUtil.java +++ b/platform/platform-api/src/com/intellij/util/PathUtil.java @@ -101,10 +101,15 @@ public class PathUtil { @NotNull public static String suggestFileName(@NotNull String text) { + return suggestFileName(text, false, false); + } + + @NotNull + public static String suggestFileName(@NotNull String text, final boolean allowDots, final boolean allowSpaces) { StringBuilder result = new StringBuilder(); for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); - if (!isValidFileNameChar(c) || c == '.' || Character.isWhitespace(c)) { + if (!isValidFileNameChar(c) || (!allowDots && c == '.') || (!allowSpaces && Character.isWhitespace(c))) { result.append('_'); } else { From f4970f79c2bfdf2faab97e307356c9b63debdcd1 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 27 Dec 2011 11:52:23 +0100 Subject: [PATCH 26/31] EA-32773 CCE fix --- .../GenerateInstanceDocumentFromSchemaAction.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java index fbb4fd56d5d5..22c7bbb7a5df 100644 --- a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java +++ b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java @@ -31,6 +31,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.psi.xml.XmlFile; import com.intellij.util.ArrayUtil; @@ -81,6 +82,12 @@ public class GenerateInstanceDocumentFromSchemaAction extends AnAction { final String url = dialog.getUrl().getText(); final VirtualFile relativeFile = VfsUtil.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(url), null); + final PsiFile file = PsiManager.getInstance(project).findFile(relativeFile); + if (! (file instanceof XmlFile)) { + Messages.showErrorDialog(project, "This is not XmlFile" + file == null ? "" : " (" + file.getFileType().getName() + ")", XmlBundle.message("error")); + return; + } + VirtualFile relativeFileDir; if (relativeFile == null) { Messages.showErrorDialog(project, XmlBundle.message("file.doesnt.exist", url), XmlBundle.message("error")); @@ -110,7 +117,7 @@ public class GenerateInstanceDocumentFromSchemaAction extends AnAction { tempDir.mkdir(); pathToUse = tempDir.getPath() + File.separatorChar + Xsd2InstanceUtils.processAndSaveAllSchemas( - (XmlFile) PsiManager.getInstance(project).findFile(relativeFile), + (XmlFile) file, new THashMap(), new Xsd2InstanceUtils.SchemaReferenceProcessor() { public void processSchema(String schemaFileName, byte[] schemaContent) { From 44681c9a9536987c51b464acab13b867b113a3ac Mon Sep 17 00:00:00 2001 From: irengrig Date: Tue, 27 Dec 2011 15:52:12 +0400 Subject: [PATCH 27/31] shelve changes manager: more clear naming --- .../openapi/vcs/changes/shelf/ShelveChangesManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java index 5add4b0df6de..a426483d0a65 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java @@ -369,7 +369,7 @@ public class ShelveChangesManager implements ProjectComponent, JDOMExternalizabl final boolean silentAddDelete) { context.next(new TaskDescriptor("", Where.AWT) { @Override - public void run(ContinuationContext context) { + public void run(ContinuationContext contextInner) { final List remainingPatches = new ArrayList(); final CommitContext commitContext = new CommitContext(); @@ -402,7 +402,7 @@ public class ShelveChangesManager implements ProjectComponent, JDOMExternalizabl patches, targetChangeList, binaryPatchApplier, commitContext); // after patch applier part - context.next(new TaskDescriptor("", Where.AWT) { + contextInner.next(new TaskDescriptor("", Where.AWT) { @Override public void run(ContinuationContext context) { remainingPatches.addAll(patchApplier.getRemainingPatches()); @@ -416,7 +416,7 @@ public class ShelveChangesManager implements ProjectComponent, JDOMExternalizabl } }); - patchApplier.scheduleSelf(showSuccessNotification, context, silentAddDelete); + patchApplier.scheduleSelf(showSuccessNotification, contextInner, silentAddDelete); } }); } From b8939b4e9e88458616e0927ebc99c68990a71064 Mon Sep 17 00:00:00 2001 From: irengrig Date: Tue, 27 Dec 2011 16:01:28 +0400 Subject: [PATCH 28/31] IDEA-18861 Apply patch: When project/module file has changed, IDEA should ask to reload the project --- .../com/intellij/ide/impl/ProjectUtil.java | 6 +++ .../diff/impl/mergeTool/MergeVersion.java | 38 ++++++++++++++++++- .../diff/impl/patch/formove/PatchApplier.java | 35 ++++++++++++++--- .../vcs/merge/MultipleFileMergeDialog.java | 14 ++----- 4 files changed, 75 insertions(+), 18 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java b/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java index 13f8e8ed2cc3..f304cf85b715 100644 --- a/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java +++ b/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java @@ -18,12 +18,14 @@ package com.intellij.ide.impl; import com.intellij.CommonBundle; import com.intellij.ide.GeneralSettings; import com.intellij.ide.IdeBundle; +import com.intellij.ide.highlighter.InternalFileType; import com.intellij.ide.highlighter.ProjectFileType; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.components.impl.stores.IProjectStore; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.project.ex.ProjectEx; @@ -262,4 +264,8 @@ public class ProjectUtil { IdeFocusManager.getInstance(p).requestFocus(cmd, false); } } + + public static boolean isProjectOrWorkspaceFile(final VirtualFile file) { + return com.intellij.openapi.project.ProjectUtil.isProjectOrWorkspaceFile(file); + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/MergeVersion.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/MergeVersion.java index 5fb199d9bfdb..3e73523eb032 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/MergeVersion.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/MergeVersion.java @@ -30,10 +30,16 @@ import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectUtil; import com.intellij.openapi.project.ex.ProjectManagerEx; +import com.intellij.openapi.util.EmptyRunnable; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.projectImport.ProjectOpenProcessor; +import org.jetbrains.annotations.Nullable; import java.io.IOException; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; public interface MergeVersion { Document createWorkingDocument(Project project); @@ -91,13 +97,38 @@ public interface MergeVersion { FileDocumentManager.getInstance().saveDocument(myDocument); final VirtualFile file = getFile(); + reportProjectFileChangeIfNeeded(project, file); + } + + public static void reportProjectFileChangeIfNeeded(Project project, VirtualFile file) { if (file != null) { - if (ProjectUtil.isProjectOrWorkspaceFile(file)) { + if (ProjectUtil.isProjectOrWorkspaceFile(file) || isProjectFile(file)) { ProjectManagerEx.getInstanceEx().saveChangedProjectFile(file, project); } } } + @Nullable + public static Runnable prepareToReportChangedProjectFiles(final Project project, final Collection files) { + final Set vfs = new HashSet(); + for (VirtualFile vf : files) { + if (vf != null) { + if (ProjectUtil.isProjectOrWorkspaceFile(vf) || isProjectFile(vf)) { + vfs.add(vf); + } + } + } + return vfs.isEmpty() ? null : new Runnable() { + @Override + public void run() { + ProjectManagerEx ex = ProjectManagerEx.getInstanceEx(); + for (VirtualFile vf : vfs) { + ex.saveChangedProjectFile(vf, project); + } + } + }; + } + @Override public void restoreOriginalContent(final Project project) { ApplicationManager.getApplication().runWriteAction(new Runnable() { @@ -107,6 +138,11 @@ public interface MergeVersion { }); } + public static boolean isProjectFile(VirtualFile file) { + final ProjectOpenProcessor importProvider = ProjectOpenProcessor.getImportProvider(file); + return importProvider != null && importProvider.lookForProjectsInDirectory(); + } + protected void doRestoreOriginalContent(Project project) { setDocumentText(myDocument, myTextBeforeMerge, "", project); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PatchApplier.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PatchApplier.java index 4d7da2e5d131..87c12abf6c76 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PatchApplier.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PatchApplier.java @@ -18,6 +18,7 @@ package com.intellij.openapi.diff.impl.patch.formove; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; +import com.intellij.openapi.diff.impl.mergeTool.MergeVersion; import com.intellij.openapi.diff.impl.patch.ApplyPatchContext; import com.intellij.openapi.diff.impl.patch.ApplyPatchStatus; import com.intellij.openapi.diff.impl.patch.FilePatch; @@ -33,10 +34,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Ref; -import com.intellij.openapi.vcs.FilePath; -import com.intellij.openapi.vcs.FilePathImpl; -import com.intellij.openapi.vcs.VcsBundle; -import com.intellij.openapi.vcs.VcsFileListenerContextHelper; +import com.intellij.openapi.vcs.*; import com.intellij.openapi.vcs.changes.*; import com.intellij.openapi.vcs.changes.patch.ApplyPatchAction; import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier; @@ -45,12 +43,14 @@ import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.newvfs.RefreshQueue; import com.intellij.openapi.vfs.newvfs.RefreshSession; +import com.intellij.ui.GuiUtils; import com.intellij.util.Consumer; import com.intellij.util.WaitForProgressToShow; import com.intellij.util.continuation.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.io.IOException; import java.util.*; @@ -289,7 +289,7 @@ public class PatchApplier { } } - protected void refreshFiles(final Collection additionalDirectly, @Nullable final ContinuationPause context) { + protected void refreshFiles(final Collection additionalDirectly, @Nullable final ContinuationContext context) { final List directlyAffected = myVerifier.getDirectlyAffected(); final List indirectlyAffected = myVerifier.getAllAffected(); directlyAffected.addAll(additionalDirectly); @@ -305,11 +305,32 @@ public class PatchApplier { return myVerifier.getAllAffected(); } - public static void refreshPassedFilesAndMoveToChangelist(final Project project, final ContinuationPause context, + public static void refreshPassedFilesAndMoveToChangelist(final Project project, final ContinuationContext context, final Collection directlyAffected, final Collection indirectlyAffected, final Consumer> targetChangelistMover) { if (context != null) { context.suspend(); } + + final Runnable projectFilesReload = + MergeVersion.MergeDocumentVersion.prepareToReportChangedProjectFiles(project, ObjectsConvertor.fp2vf(directlyAffected)); + final TaskDescriptor projectFilesReloadTaskDescriptor = projectFilesReload == null ? null : new TaskDescriptor("", Where.AWT) { + @Override + public void run(final ContinuationContext context) { + projectFilesReload.run(); + } + }; + final Runnable scheduleProjectFilesReload = new Runnable() { + public void run() { + if (projectFilesReloadTaskDescriptor != null) { + if (context != null) { + context.last(projectFilesReloadTaskDescriptor); + } else { + SwingUtilities.invokeLater(projectFilesReload); + } + } + } + }; + final RefreshSession session = RefreshQueue.getInstance().createSession(false, true, new Runnable() { public void run() { if (project.isDisposed()) return; @@ -322,6 +343,7 @@ public class PatchApplier { if (targetChangelistMover != null) { targetChangelistMover.consume(directlyAffected); } + scheduleProjectFilesReload.run(); if (context != null) { context.ping(); } @@ -338,6 +360,7 @@ public class PatchApplier { final VcsDirtyScopeManager vcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(project); // will schedule update vcsDirtyScopeManager.filePathsDirty(directlyAffected, null); + scheduleProjectFilesReload.run(); if (context != null) { context.ping(); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/merge/MultipleFileMergeDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/merge/MultipleFileMergeDialog.java index 8bd7388573c2..c64484a612f4 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/merge/MultipleFileMergeDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/merge/MultipleFileMergeDialog.java @@ -17,12 +17,14 @@ package com.intellij.openapi.vcs.merge; import com.intellij.CommonBundle; +import com.intellij.ide.impl.ProjectUtil; import com.intellij.ide.presentation.VirtualFilePresentation; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diff.ActionButtonPresentation; import com.intellij.openapi.diff.DiffManager; import com.intellij.openapi.diff.DiffRequestFactory; import com.intellij.openapi.diff.MergeRequest; +import com.intellij.openapi.diff.impl.mergeTool.MergeVersion; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.Project; @@ -323,17 +325,7 @@ public class MultipleFileMergeDialog extends DialogWrapper { } private void checkMarkModifiedProject(final VirtualFile file) { - if (file.getFileType() == StdFileTypes.IDEA_MODULE || - file.getFileType() == StdFileTypes.IDEA_PROJECT || - file.getFileType() == StdFileTypes.IDEA_WORKSPACE || - isProjectFile(file)) { - myProjectManager.saveChangedProjectFile(file, myProject); - } - } - - private static boolean isProjectFile(VirtualFile file) { - final ProjectOpenProcessor importProvider = ProjectOpenProcessor.getImportProvider(file); - return importProvider != null && importProvider.lookForProjectsInDirectory(); + MergeVersion.MergeDocumentVersion.reportProjectFileChangeIfNeeded(myProject, file); } private static String decodeContent(final VirtualFile file, final byte[] content) { From d0c43a6385052dd15f9afeda6c354173ac8b0f1d Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 27 Dec 2011 12:50:19 +0100 Subject: [PATCH 29/31] plugins: do not force enable incompatible plugins --- .../com/intellij/ide/plugins/InstalledPluginsTableModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsTableModel.java b/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsTableModel.java index df0f61f083fa..f03df913a61a 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsTableModel.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsTableModel.java @@ -185,7 +185,7 @@ public class InstalledPluginsTableModel extends PluginTableModel { } } ); - if (enabled == null && !myDependentToRequiredListMap.containsKey(pluginId)) { + if (enabled == null && !myDependentToRequiredListMap.containsKey(pluginId) && !PluginManager.isIncompatible(descriptor)) { myEnabled.put(pluginId, true); } } From 07d37a288c27de7a44faf5b8940fba1abb497f9f Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 27 Dec 2011 13:03:53 +0100 Subject: [PATCH 30/31] exclude alt-rt.jar and alt-string.jar from created jdks - as they lead to incompatibility between cls and attached sources (IDEA-74547) --- .../src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java b/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java index 559f2d6cbcbe..de021bad6ae2 100644 --- a/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java +++ b/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java @@ -477,6 +477,8 @@ public class JavaSdkImpl extends JavaSdk { if (jarDir != null && jarDir.isDirectory()) { File[] jarFiles = jarDir.listFiles(jarFileFilter); for (File jarFile : jarFiles) { + final String jarFileName = jarFile.getName(); + if (jarFileName.equals("alt-rt.jar") || jarFileName.equals("alt-string.jar")) continue; try { // File.getCanonicalFile() allows us to filter out duplicate (symbolically linked) jar files, // commonly found in osx JDK distributions From 8d4a20f0cbb8faa6db165858ea2545bcaadd1937 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 27 Dec 2011 13:27:07 +0100 Subject: [PATCH 31/31] EA-32676 (NPE) --- .../application/options/InitialConfigurationDialog.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java index 577d96bb4f0e..a9446399ccf3 100644 --- a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java +++ b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java @@ -105,7 +105,9 @@ public class InitialConfigurationDialog extends DialogWrapper { myColorSchemeComboBox.setRenderer(new ListCellRendererWrapper(myColorSchemeComboBox.getRenderer()) { @Override public void customize(JList list, Object value, int index, boolean selected, boolean cellHasFocus) { - setText(((EditorColorsScheme)value).getName()); + if (value != null) { + setText(((EditorColorsScheme)value).getName()); + } } }); myColorSchemeComboBox.addActionListener(new ActionListener() {