Merge remote-tracking branch 'origin/master'

This commit is contained in:
Maxim.Mossienko
2014-05-31 02:03:06 +02:00
3 changed files with 22 additions and 14 deletions
@@ -113,6 +113,7 @@ public class CodeInsightSettings implements PersistentStateComponent<Element>, C
public boolean AUTOINSERT_PAIR_QUOTE = true;
public boolean REFORMAT_BLOCK_ON_RBRACE = true;
@MagicConstant(intValues = {NO_REFORMAT, INDENT_BLOCK, INDENT_EACH_LINE, REFORMAT_BLOCK})
public int REFORMAT_ON_PASTE = INDENT_EACH_LINE;
public static final int NO_REFORMAT = 1;
public static final int INDENT_BLOCK = 2;
@@ -121,7 +122,8 @@ public class CodeInsightSettings implements PersistentStateComponent<Element>, C
public boolean INDENT_TO_CARET_ON_PASTE = false;
public int ADD_IMPORTS_ON_PASTE = ASK; // YES, NO or ASK
@MagicConstant(intValues = {YES, NO, ASK})
public int ADD_IMPORTS_ON_PASTE = ASK;
public static final int YES = 1;
public static final int NO = 2;
public static final int ASK = 3;
@@ -151,9 +151,9 @@ public abstract class RemoteProcessSupport<Target, EntryPoint, Parameters> {
public void release(@NotNull Target target, @Nullable Parameters configuration) {
ArrayList<ProcessHandler> handlers = new ArrayList<ProcessHandler>();
synchronized (myProcMap) {
for (Pair<Target, Parameters> pair : myProcMap.keySet()) {
if (pair.first == target && (configuration == null || pair.second == configuration)) {
ContainerUtil.addIfNotNull(myProcMap.get(pair).handler, handlers);
for (Pair<Target, Parameters> key : myProcMap.keySet()) {
if (key.first == target && (configuration == null || key.second == configuration)) {
ContainerUtil.addIfNotNull(myProcMap.get(key).handler, handlers);
}
}
}
@@ -164,7 +164,7 @@ public abstract class RemoteProcessSupport<Target, EntryPoint, Parameters> {
fireModificationCountChanged();
}
private void startProcess(Target target, Parameters configuration, Pair<Target, Parameters> key) {
private void startProcess(Target target, Parameters configuration, @NotNull Pair<Target, Parameters> key) {
ProgramRunner runner = new DefaultProgramRunner() {
@Override
@NotNull
@@ -196,7 +196,7 @@ public abstract class RemoteProcessSupport<Target, EntryPoint, Parameters> {
protected abstract RunProfileState getRunProfileState(Target target, Parameters configuration, Executor executor)
throws ExecutionException;
private boolean getExistingInfo(Ref<RunningInfo> ref, Pair<Target, Parameters> key) {
private boolean getExistingInfo(@NotNull Ref<RunningInfo> ref, @NotNull Pair<Target, Parameters> key) {
Info info;
synchronized (myProcMap) {
info = myProcMap.get(key);
@@ -254,7 +254,7 @@ public abstract class RemoteProcessSupport<Target, EntryPoint, Parameters> {
return (T)(to.isInstance(remote) ? remote : PortableRemoteObject.narrow(remote, to));
}
private ProcessListener getProcessListener(final Pair<Target, Parameters> key) {
private ProcessListener getProcessListener(@NotNull final Pair<Target, Parameters> key) {
return new ProcessListener() {
@Override
public void startNotified(ProcessEvent event) {
@@ -183,24 +183,26 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
if (!isTestMode() && application.isHeadlessEnvironment()) {
throw new MasterPasswordUnavailableException("The provider is not available in headless environment");
}
if (key.get().get() == null) {
final Ref<byte[]> result = Ref.create(key.get().get());
if (result.isNull()) {
if (isPasswordEncrypted()) {
try {
String s = decryptPassword(database.getPasswordInfo());
setMasterPassword(s);
setMasterPassword(decryptPassword(database.getPasswordInfo()));
result.set(key.get().get());
}
catch (PasswordSafeException e) {
// ignore exception and ask password
}
}
if (key.get().get() == null) {
if (result.isNull()) {
final Ref<PasswordSafeException> ex = new Ref<PasswordSafeException>();
if (application.holdsReadLock()) {
throw new IllegalStateException("Access from read action is not allowed, because it might lead to a deadlock.");
}
application.invokeAndWait(new Runnable() {
public void run() {
if (key.get().get() == null) {
result.set(key.get().get());
if (result.isNull()) {
try {
if (isTestMode()) {
throw new MasterPasswordUnavailableException("Master password must be specified in test mode.");
@@ -212,6 +214,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
}
else {
MasterPasswordDialog.askPassword(project, MasterKeyPasswordSafe.this, requestor);
result.set(key.get().get());
}
}
catch (PasswordSafeException e) {
@@ -230,7 +233,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
}
}
}
return key.get().get();
return result.get();
}
/**
@@ -336,7 +339,8 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
* if decryption fails
*/
private static String decryptPassword(byte[] pw) throws MasterPasswordUnavailableException {
assert SystemInfo.isWindows;
if (!SystemInfo.isWindows) throw new AssertionError("Windows OS expected");
try {
return new String(WindowsCryptUtils.unprotect(pw), "UTF-8");
}
@@ -349,6 +353,8 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
* @return true, if the password is currently encrypted in the database
*/
public boolean isPasswordEncrypted() {
if (!isOsProtectedPasswordSupported()) return false;
byte[] i = database.getPasswordInfo();
return i != null && i.length > 0;
}