From 35acdbe690655e0931bc9f4eeb11bf1bfef9ce37 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 12 Jul 2016 16:45:50 +0200 Subject: [PATCH] cleanup --- .../config/PasswordSafeOptionsPanel.java | 19 +++++++- .../masterKey/MasterKeyPasswordSafe.java | 6 +-- .../masterKey/MasterPasswordDialog.java | 48 ++++++++----------- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/config/PasswordSafeOptionsPanel.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/config/PasswordSafeOptionsPanel.java index a6235068ac94..d8b52bdead19 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/config/PasswordSafeOptionsPanel.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/config/PasswordSafeOptionsPanel.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2016 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.ide.passwordSafe.config; import com.intellij.ide.passwordSafe.PasswordSafe; @@ -49,10 +64,10 @@ public class PasswordSafeOptionsPanel { myManagePasswordButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myPasswordSafe.getMasterKeyProvider().isEmpty()) { - MasterPasswordDialog.resetMasterPasswordDialog(null, myPasswordSafe.getMasterKeyProvider(), PasswordSafeOptionsPanel.class).show(); + MasterPasswordDialog.resetMasterPasswordDialog(null, myPasswordSafe.getMasterKeyProvider()).show(); } else { - MasterPasswordDialog.changeMasterPasswordDialog(null, myPasswordSafe.getMasterKeyProvider(), PasswordSafeOptionsPanel.class).show(); + MasterPasswordDialog.changeMasterPasswordDialog(null, myPasswordSafe.getMasterKeyProvider()).show(); } updateMasterPasswordState(); } diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java index d72e1b21605f..c755bcd24ff9 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java @@ -173,10 +173,6 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider { } } - if (ApplicationManager.getApplication().isHeadlessEnvironment()) { - throw new MasterPasswordUnavailableException("The provider is not available in headless environment"); - } - key = invokeAndWait(() -> { Object key1 = myKey.get().get(); if (key1 instanceof byte[] || key1 instanceof PasswordSafeException && ((PasswordSafeException)key1).justHappened()) { @@ -184,7 +180,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider { } try { if (myDatabase.isEmpty()) { - if (!MasterPasswordDialog.resetMasterPasswordDialog(project, this, requestor).showAndGet()) { + if (!MasterPasswordDialog.resetMasterPasswordDialog(project, this).showAndGet()) { throw new MasterPasswordUnavailableException("Master password is required to store passwords in the database."); } } diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterPasswordDialog.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterPasswordDialog.java index f9d16b0bc63c..8478ab7701d7 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterPasswordDialog.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterPasswordDialog.java @@ -1,18 +1,18 @@ /* -* Copyright 2000-2010 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. -*/ + * Copyright 2000-2016 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.ide.passwordSafe.impl.providers.masterKey; import com.intellij.ide.passwordSafe.MasterPasswordUnavailableException; @@ -38,10 +38,6 @@ import java.util.List; public class MasterPasswordDialog extends DialogWrapper { private final static int NUMBER_OF_RETRIES = 5; - /** - * @noinspection FieldCanBeLocal - */ - private final Class myRequestor; private final JPanel myRootPanel = new JPanel(new CardLayout()); private final List myComponents = ContainerUtil.newArrayList(); private final DialogWrapperAction myCardAction; @@ -68,26 +64,24 @@ public class MasterPasswordDialog extends DialogWrapper { } public static MasterPasswordDialog resetMasterPasswordDialog(@Nullable Project project, - @NotNull MasterKeyPasswordSafe safe, - @NotNull Class requestor) { - return new MasterPasswordDialog(project, requestor, new ResetPasswordComponent(safe, true)); + @NotNull MasterKeyPasswordSafe safe) { + return new MasterPasswordDialog(project, new ResetPasswordComponent(safe, true)); } public static MasterPasswordDialog changeMasterPasswordDialog(@Nullable Project project, - @NotNull MasterKeyPasswordSafe safe, - Class requestor) { - return new MasterPasswordDialog(project, requestor, new ChangePasswordComponent(safe), new ResetPasswordComponent(safe, false)); + @NotNull MasterKeyPasswordSafe safe) { + return new MasterPasswordDialog(project, new ChangePasswordComponent(safe), new ResetPasswordComponent(safe, false)); } public static MasterPasswordDialog enterMasterPasswordDialog(@Nullable Project project, @NotNull MasterKeyPasswordSafe safe, @NotNull Class requestor) { - return new MasterPasswordDialog(project, requestor, new EnterPasswordComponent(safe, requestor), new ResetPasswordComponent(safe, false)); + return new MasterPasswordDialog(project, new EnterPasswordComponent(safe, requestor), new ResetPasswordComponent(safe, false)); } - protected MasterPasswordDialog(@Nullable Project project, Class requestor, PasswordComponentBase... components) { + protected MasterPasswordDialog(@Nullable Project project, PasswordComponentBase... components) { super(project, false); - myRequestor = requestor; + setResizable(false); assert components.length > 0; myComponents.addAll(Arrays.asList(components));