Cleanup (deprecated API usage fixed)

This commit is contained in:
Roman Shevchenko
2015-04-30 19:07:27 +02:00
parent 8d38bb1bbf
commit 959ec4fe40
6 changed files with 37 additions and 41 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -16,6 +16,7 @@
package com.intellij.openapi.projectRoots;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.process.ProcessOutput;
import com.intellij.execution.util.ExecUtil;
import com.intellij.icons.AllIcons;
@@ -39,7 +40,6 @@ import java.awt.*;
import java.awt.event.InputEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -158,7 +158,7 @@ public class JdkPopupAction extends AnAction {
try {
File file = new File(path);
File javaExe = new File(new File(file, "bin"), "java.exe");
ProcessOutput output = ExecUtil.execAndGetOutput(Arrays.asList(javaExe.getAbsolutePath(), "-version"), null);
ProcessOutput output = ExecUtil.execAndGetOutput(new GeneralCommandLine(javaExe.getAbsolutePath(), "-version"));
List<String> lines = output.getStderrLines();
if (lines.isEmpty()) {
lines = output.getStdoutLines();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -129,7 +129,7 @@ public class CreateDesktopEntryAction extends DumbAwareAction {
}
private static void check() throws ExecutionException, InterruptedException {
final int result = ExecUtil.execAndGetResult("which", "xdg-desktop-menu");
int result = new GeneralCommandLine("which", "xdg-desktop-menu").createProcess().waitFor();
if (result != 0) throw new RuntimeException(ApplicationBundle.message("desktop.entry.xdg.missing"));
}
@@ -196,9 +196,9 @@ public class CreateDesktopEntryAction extends DumbAwareAction {
if (result != 0) throw new RuntimeException("'" + script.getAbsolutePath() + "' : " + result);
}
else {
int result = ExecUtil.execAndGetResult("xdg-desktop-menu", "install", "--mode", "user", entryFile.getAbsolutePath());
int result = new GeneralCommandLine("xdg-desktop-menu", "install", "--mode", "user", entryFile.getAbsolutePath()).createProcess().waitFor();
if (result != 0) throw new RuntimeException("'" + entryFile.getAbsolutePath() + "' : " + result);
ExecUtil.execAndGetResult("xdg-desktop-menu", "forceupdate", "--mode", "user");
new GeneralCommandLine("xdg-desktop-menu", "forceupdate", "--mode", "user").createProcess().waitFor();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -84,10 +84,10 @@ public class ShowFilePathAction extends AnAction {
return false;
}
String appName = ExecUtil.execAndReadLine("xdg-mime", "query", "default", "inode/directory");
String appName = ExecUtil.execAndReadLine(new GeneralCommandLine("xdg-mime", "query", "default", "inode/directory"));
if (appName == null || !appName.matches("nautilus.*\\.desktop")) return false;
String version = ExecUtil.execAndReadLine("nautilus", "--version");
String version = ExecUtil.execAndReadLine(new GeneralCommandLine("nautilus", "--version"));
if (version == null) return false;
Matcher m = Pattern.compile("GNOME nautilus ([0-9.]+)").matcher(version);
@@ -111,7 +111,7 @@ public class ShowFilePathAction extends AnAction {
@Nullable
private static String getUnixFileManagerName() {
String appName = ExecUtil.execAndReadLine("xdg-mime", "query", "default", "inode/directory");
String appName = ExecUtil.execAndReadLine(new GeneralCommandLine("xdg-mime", "query", "default", "inode/directory"));
if (appName == null || !appName.matches(".+\\.desktop")) return null;
String dirs = System.getenv("XDG_DATA_DIRS");
@@ -157,12 +157,15 @@ public class ShowFilePathAction extends AnAction {
show(getFile(e), new ShowAction() {
@Override
public void show(final ListPopup popup) {
DataManager.getInstance().getDataContextFromFocus().doWhenDone(new Consumer<DataContext>() {
@Override
public void consume(DataContext context) {
popup.showInBestPositionFor(context);
}
});
DataManager dataManager = DataManager.getInstance();
if (dataManager != null) {
dataManager.getDataContextFromFocus().doWhenDone(new Consumer<DataContext>() {
@Override
public void consume(DataContext context) {
popup.showInBestPositionFor(context);
}
});
}
}
});
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -16,6 +16,7 @@
package com.intellij.openapi.wm.impl;
import com.intellij.Patches;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.util.ExecUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.SystemInfo;
@@ -306,7 +307,7 @@ public class X11UiUtil {
@Nullable
private static String getAwesomeWMVersion() {
try {
String version = ExecUtil.execAndReadLine("awesome", "--version");
String version = ExecUtil.execAndReadLine(new GeneralCommandLine("awesome", "--version"));
if (version != null) {
Matcher m = Pattern.compile("awesome v([0-9.]+)").matcher(version);
if (m.find()) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -18,15 +18,21 @@ package com.intellij.openapi.diff.impl.external;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diff.*;
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.util.ArrayUtil;
import junit.framework.TestCase;
import org.easymock.classextension.EasyMock;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class DiffManagerTest extends TestCase {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class DiffManagerTest {
@Test
public void testAdditionalTools() {
DiffManagerImpl diffManager = new DiffManagerImpl();
MyDiffTool tool = new MyDiffTool();
@@ -46,6 +52,7 @@ public class DiffManagerTest extends TestCase {
private static class MyDiffTool implements DiffTool {
public int myCanShowCount = 0;
public int myShowCount = 0;
@Override
public boolean canShow(DiffRequest request) {
myCanShowCount++;
@@ -69,8 +76,8 @@ public class DiffManagerTest extends TestCase {
}
private static class MyDiffRequest extends DiffRequest {
private final ArrayList<String> myContentTitles = new ArrayList<String>();
private final ArrayList<DiffContent> myDiffContents = new ArrayList<DiffContent>();
private final List<String> myContentTitles = new ArrayList<String>();
private final List<DiffContent> myDiffContents = new ArrayList<DiffContent>();
public MyDiffRequest() {
super(null);
@@ -98,7 +105,8 @@ public class DiffManagerTest extends TestCase {
}
public void addContent() {
addContent(new BinaryContent(ArrayUtil.EMPTY_BYTE_ARRAY, null, FileTypes.UNKNOWN), "");
Project project = EasyMock.createMock(Project.class);
addContent(new BinaryContent(project, ArrayUtil.EMPTY_BYTE_ARRAY, null, FileTypes.UNKNOWN, null), "");
}
}
}
@@ -5,7 +5,6 @@ import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import javax.swing.*;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
@@ -240,21 +239,6 @@ public class Runner {
}
private static void install(final String jarFile, final String destFolder) throws Exception {
// todo[r.sh] to delete in IDEA 14 (after a full circle of platform updates)
if (System.getProperty("swing.defaultlaf") == null) {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception ignore) {
printStackTrace(ignore);
}
}
});
}
new SwingUpdaterUI(new SwingUpdaterUI.InstallOperation() {
public boolean execute(UpdaterUI ui) throws OperationCancelledException {
logger.info("installing patch to the " + destFolder);