From 51de0abc3fd42019b39769d55538c0bdf2368294 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 16 May 2017 14:33:57 +0200 Subject: [PATCH] cleanup (default impl) --- .../openapi/vcs/changes/CommitSession.java | 51 +++++++------------ .../patch/CreatePatchCommitExecutor.java | 12 +---- .../shelf/ShelveChangesCommitExecutor.java | 20 +++----- .../util/CloudGitDeploymentRuntime.java | 44 ++++++---------- 4 files changed, 41 insertions(+), 86 deletions(-) diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/CommitSession.java b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/CommitSession.java index 9f56a5495155..56cdd2eed130 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/CommitSession.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/CommitSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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,43 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.openapi.vcs.changes; import com.intellij.openapi.ui.ValidationInfo; import org.jetbrains.annotations.CalledInAwt; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.Collection; -/** - * @author max - */ public interface CommitSession { CommitSession VCS_COMMIT = new CommitSession() { - public JComponent getAdditionalConfigurationUI() { - return null; - } - - public JComponent getAdditionalConfigurationUI(Collection changes, String commitMessage) { - return null; - } - - public boolean canExecute(Collection changes, String commitMessage) { - return true; - } - - public void execute(Collection changes, String commitMessage) { - } - - public void executionCanceled() { - } - @Override - public String getHelpId() { - return null; + public void execute(Collection changes, String commitMessage) { } }; @@ -57,21 +33,32 @@ public interface CommitSession { * @deprecated Since version 7.0, {@link #getAdditionalConfigurationUI(java.util.Collection, String)} is called instead */ @Nullable - JComponent getAdditionalConfigurationUI(); + default JComponent getAdditionalConfigurationUI() { + return null; + } @Nullable - JComponent getAdditionalConfigurationUI(Collection changes, String commitMessage); + default JComponent getAdditionalConfigurationUI(Collection changes, String commitMessage) { + return null; + } + + default boolean canExecute(Collection changes, String commitMessage) { + return true; + } - boolean canExecute(Collection changes, String commitMessage); void execute(Collection changes, String commitMessage); - void executionCanceled(); + + default void executionCanceled() { + } /** * @return the ID of the help topic to show for the dialog * @since 10.5 */ - @NonNls - String getHelpId(); + @Nullable + default String getHelpId() { + return null; + } @CalledInAwt default ValidationInfo validateFields() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java index 28781af8177f..03e3d3c58e12 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.openapi.vcs.changes.patch; import com.intellij.CommonBundle; @@ -55,7 +54,7 @@ import java.util.List; import java.util.Set; public class CreatePatchCommitExecutor extends LocalCommitExecutor implements ProjectComponent { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.patch.CreatePatchCommitExecutor"); + private static final Logger LOG = Logger.getInstance(CreatePatchCommitExecutor.class); private static final String VCS_PATCH_PATH_KEY = "vcs.patch.path"; private final Project myProject; @@ -203,20 +202,11 @@ public class CreatePatchCommitExecutor extends LocalCommitExecutor implements Pr } } - @Override - public void executionCanceled() { - } - @Override @Nullable public ValidationInfo validateFields() { return myPanel.validateFields(); } - - @Override - public String getHelpId() { - return null; - } } @NotNull diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesCommitExecutor.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesCommitExecutor.java index e0492caa70dd..74f204826f22 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesCommitExecutor.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesCommitExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -26,9 +26,7 @@ import com.intellij.openapi.vcs.changes.*; import com.intellij.util.WaitForProgressToShow; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import javax.swing.*; import java.util.Collection; public class ShelveChangesCommitExecutor extends LocalCommitExecutor { @@ -40,11 +38,13 @@ public class ShelveChangesCommitExecutor extends LocalCommitExecutor { myProject = project; } + @Override @Nls public String getActionText() { return VcsBundle.message("shelve.changes.action"); } + @Override @NotNull public CommitSession createCommitSession() { return new ShelveChangesCommitSession(); @@ -56,25 +56,16 @@ public class ShelveChangesCommitExecutor extends LocalCommitExecutor { } private class ShelveChangesCommitSession implements CommitSession, CommitSessionContextAware { - - @Nullable - public JComponent getAdditionalConfigurationUI() { - return null; - } - @Override public void setContext(CommitContext context) { } - @Nullable - public JComponent getAdditionalConfigurationUI(final Collection changes, final String commitMessage) { - return null; - } - + @Override public boolean canExecute(Collection changes, String commitMessage) { return changes.size() > 0; } + @Override public void execute(Collection changes, String commitMessage) { if (changes.size() > 0 && !ChangesUtil.hasFileChanges(changes)) { WaitForProgressToShow.runOrInvokeLaterAboveProgress(() -> Messages @@ -102,6 +93,7 @@ public class ShelveChangesCommitExecutor extends LocalCommitExecutor { } } + @Override public void executionCanceled() { } diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java index 1136bddac4a0..27a00d309e6c 100644 --- a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java +++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2017 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.remoteServer.util; import com.intellij.openapi.application.ApplicationManager; @@ -34,7 +49,6 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.swing.*; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -52,38 +66,10 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime { private static final String COMMIT_MESSAGE = "Deploy"; private static final CommitSession NO_COMMIT = new CommitSession() { - - @Nullable - @Override - public JComponent getAdditionalConfigurationUI() { - return null; - } - - @Nullable - @Override - public JComponent getAdditionalConfigurationUI(Collection changes, String commitMessage) { - return null; - } - - @Override - public boolean canExecute(Collection changes, String commitMessage) { - return true; - } - @Override public void execute(Collection changes, String commitMessage) { } - - @Override - public void executionCanceled() { - - } - - @Override - public String getHelpId() { - return null; - } }; private static final List ourCommitExecutors = Arrays.asList(