mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: Unify boolean commit options implementation
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||
<orderEntry type="library" name="protobuf" level="project" />
|
||||
<orderEntry type="library" name="netty-codec-http" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.vcs.impl" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
|
||||
+12
-27
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.compiler.impl.vcs;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vcs.CheckinProjectPanel;
|
||||
import com.intellij.openapi.vcs.changes.CommitContext;
|
||||
import com.intellij.openapi.vcs.changes.CommitExecutor;
|
||||
import com.intellij.openapi.vcs.changes.ui.BooleanCommitOption;
|
||||
import com.intellij.openapi.vcs.checkin.CheckinHandler;
|
||||
import com.intellij.openapi.vcs.checkin.CheckinHandlerFactory;
|
||||
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
|
||||
@@ -26,15 +27,12 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.ui.NonFocusableCheckBox;
|
||||
import com.intellij.util.PairConsumer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.xml.util.XmlStringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -58,33 +56,15 @@ public class UnloadedModulesCompilationCheckinHandler extends CheckinHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
JCheckBox checkBox = new NonFocusableCheckBox(CompilerBundle.message("checkbox.text.compile.affected.unloaded.modules"));
|
||||
return new RefreshableOnComponent() {
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return JBUI.Panels.simplePanel().addToLeft(checkBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveState() {
|
||||
CompilerWorkspaceConfiguration.getInstance(myProject).COMPILE_AFFECTED_UNLOADED_MODULES_BEFORE_COMMIT = checkBox.isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState() {
|
||||
checkBox.setSelected(CompilerWorkspaceConfiguration.getInstance(myProject).COMPILE_AFFECTED_UNLOADED_MODULES_BEFORE_COMMIT);
|
||||
}
|
||||
};
|
||||
return new BooleanCommitOption(myCheckinPanel, CompilerBundle.message("checkbox.text.compile.affected.unloaded.modules"), false,
|
||||
() -> getSettings().COMPILE_AFFECTED_UNLOADED_MODULES_BEFORE_COMMIT,
|
||||
value -> getSettings().COMPILE_AFFECTED_UNLOADED_MODULES_BEFORE_COMMIT = value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) {
|
||||
if (!CompilerWorkspaceConfiguration.getInstance(myProject).COMPILE_AFFECTED_UNLOADED_MODULES_BEFORE_COMMIT
|
||||
|| ModuleManager.getInstance(myProject).getUnloadedModuleDescriptions().isEmpty()) {
|
||||
if (!getSettings().COMPILE_AFFECTED_UNLOADED_MODULES_BEFORE_COMMIT ||
|
||||
ModuleManager.getInstance(myProject).getUnloadedModuleDescriptions().isEmpty()) {
|
||||
return ReturnResult.COMMIT;
|
||||
}
|
||||
|
||||
@@ -142,6 +122,11 @@ public class UnloadedModulesCompilationCheckinHandler extends CheckinHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private CompilerWorkspaceConfiguration getSettings() {
|
||||
return CompilerWorkspaceConfiguration.getInstance(myProject);
|
||||
}
|
||||
|
||||
private enum BuildResult { SUCCESSFUL, FAILED, CANCELED }
|
||||
|
||||
public static class Factory extends CheckinHandlerFactory {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.vcs.changes.ui
|
||||
|
||||
import com.intellij.openapi.vcs.CheckinProjectPanel
|
||||
import com.intellij.openapi.vcs.checkin.CheckinHandlerUtil
|
||||
import com.intellij.openapi.vcs.ui.RefreshableOnComponent
|
||||
import com.intellij.ui.NonFocusableCheckBox
|
||||
import java.util.function.Consumer
|
||||
import javax.swing.JComponent
|
||||
|
||||
open class BooleanCommitOption(panel: CheckinProjectPanel,
|
||||
text: String,
|
||||
disableWhenDumb: Boolean,
|
||||
private val getter: () -> Boolean,
|
||||
private val setter: Consumer<Boolean>) : RefreshableOnComponent {
|
||||
protected val checkBox = NonFocusableCheckBox(text).also {
|
||||
if (disableWhenDumb) CheckinHandlerUtil.disableWhenDumb(panel.project, it, "Impossible until indices are up-to-date")
|
||||
}
|
||||
|
||||
override fun refresh() {
|
||||
}
|
||||
|
||||
override fun saveState() {
|
||||
setter.accept(checkBox.isSelected)
|
||||
}
|
||||
|
||||
override fun restoreState() {
|
||||
checkBox.isSelected = getter()
|
||||
}
|
||||
|
||||
override fun getComponent(): JComponent = checkBox
|
||||
}
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.vcs.checkin;
|
||||
|
||||
import com.intellij.openapi.components.impl.stores.IProjectStore;
|
||||
@@ -82,7 +68,7 @@ public class CheckinHandlerUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void disableWhenDumb(@NotNull Project project, @NotNull JCheckBox checkBox, @NotNull String tooltip) {
|
||||
public static void disableWhenDumb(@NotNull Project project, @NotNull JCheckBox checkBox, @NotNull String tooltip) {
|
||||
boolean dumb = DumbService.isDumb(project);
|
||||
checkBox.setEnabled(!dumb);
|
||||
checkBox.setToolTipText(dumb ? tooltip : "");
|
||||
|
||||
+5
-42
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.openapi.vcs.checkin;
|
||||
|
||||
@@ -31,14 +17,12 @@ import com.intellij.openapi.vcs.CodeSmellDetector;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.changes.CommitExecutor;
|
||||
import com.intellij.openapi.vcs.changes.ui.BooleanCommitOption;
|
||||
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
|
||||
import com.intellij.ui.NonFocusableCheckBox;
|
||||
import com.intellij.util.PairConsumer;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -62,30 +46,9 @@ public class CodeAnalysisBeforeCheckinHandler extends CheckinHandler {
|
||||
@Override
|
||||
@Nullable
|
||||
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
|
||||
final JCheckBox checkBox = new NonFocusableCheckBox(VcsBundle.message("before.checkin.standard.options.check.smells"));
|
||||
return new RefreshableOnComponent() {
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(checkBox);
|
||||
CheckinHandlerUtil.disableWhenDumb(myProject, checkBox, "Code analysis is impossible until indices are up-to-date");
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveState() {
|
||||
getSettings().CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT = checkBox.isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState() {
|
||||
checkBox.setSelected(getSettings().CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT);
|
||||
}
|
||||
};
|
||||
return new BooleanCommitOption(myCheckinPanel, VcsBundle.message("before.checkin.standard.options.check.smells"), true,
|
||||
() -> getSettings().CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT,
|
||||
value -> getSettings().CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT = value);
|
||||
}
|
||||
|
||||
private VcsConfiguration getSettings() {
|
||||
|
||||
+11
-47
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.openapi.vcs.checkin;
|
||||
|
||||
@@ -24,13 +10,11 @@ import com.intellij.openapi.vcs.CheckinProjectPanel;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.changes.CommitContext;
|
||||
import com.intellij.openapi.vcs.changes.ui.BooleanCommitOption;
|
||||
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.NonFocusableCheckBox;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -52,44 +36,24 @@ public class CodeCleanupCheckinHandlerFactory extends CheckinHandlerFactory {
|
||||
|
||||
@Override
|
||||
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
|
||||
final JCheckBox cleanupCodeCb = new NonFocusableCheckBox(VcsBundle.message("before.checkin.cleanup.code"));
|
||||
return new RefreshableOnComponent() {
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
final JPanel cbPanel = new JPanel(new BorderLayout());
|
||||
cbPanel.add(cleanupCodeCb, BorderLayout.WEST);
|
||||
CheckinHandlerUtil
|
||||
.disableWhenDumb(myProject, cleanupCodeCb, "Code analysis is impossible until indices are up-to-date");
|
||||
return cbPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveState() {
|
||||
VcsConfiguration.getInstance(myProject).CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT = cleanupCodeCb.isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState() {
|
||||
cleanupCodeCb.setSelected(VcsConfiguration.getInstance(myProject).CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT);
|
||||
}
|
||||
};
|
||||
return new BooleanCommitOption(myPanel, VcsBundle.message("before.checkin.cleanup.code"), true,
|
||||
() -> getSettings().CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT,
|
||||
value -> getSettings().CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT = value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void runCheckinHandlers(@NotNull Runnable runnable) {
|
||||
if (VcsConfiguration.getInstance(myProject).CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT && !DumbService.isDumb(myProject)) {
|
||||
|
||||
if (getSettings().CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT && !DumbService.isDumb(myProject)) {
|
||||
List<VirtualFile> filesToProcess = CheckinHandlerUtil.filterOutGeneratedAndExcludedFiles(myPanel.getVirtualFiles(), myProject);
|
||||
GlobalInspectionContextBase.modalCodeCleanup(myProject, new AnalysisScope(myProject, filesToProcess), runnable);
|
||||
|
||||
} else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private VcsConfiguration getSettings() {
|
||||
return VcsConfiguration.getInstance(myProject);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-43
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.openapi.vcs.checkin;
|
||||
|
||||
@@ -24,14 +10,12 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.CheckinProjectPanel;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.changes.ui.BooleanCommitOption;
|
||||
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.NonFocusableCheckBox;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
|
||||
public class OptimizeImportsBeforeCheckinHandler extends CheckinHandler implements CheckinMetaHandler {
|
||||
@@ -49,31 +33,9 @@ public class OptimizeImportsBeforeCheckinHandler extends CheckinHandler implemen
|
||||
@Override
|
||||
@Nullable
|
||||
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
|
||||
final JCheckBox optimizeBox = new NonFocusableCheckBox(VcsBundle.message("checkbox.checkin.options.optimize.imports"));
|
||||
CheckinHandlerUtil.disableWhenDumb(myProject, optimizeBox, "Impossible until indices are up-to-date");
|
||||
return new RefreshableOnComponent() {
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
final JPanel panel = new JPanel(new GridLayout(1, 0));
|
||||
panel.add(optimizeBox);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveState() {
|
||||
getSettings().OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT = optimizeBox.isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState() {
|
||||
optimizeBox.setSelected(getSettings().OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT);
|
||||
}
|
||||
};
|
||||
|
||||
return new BooleanCommitOption(myPanel, VcsBundle.message("checkbox.checkin.options.optimize.imports"), true,
|
||||
() -> getSettings().OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT,
|
||||
value -> getSettings().OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT = value);
|
||||
}
|
||||
|
||||
protected VcsConfiguration getSettings() {
|
||||
|
||||
+5
-43
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.vcs.checkin;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
@@ -23,14 +9,11 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.CheckinProjectPanel;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.changes.ui.BooleanCommitOption;
|
||||
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
|
||||
import com.intellij.ui.NonFocusableCheckBox;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class RearrangeBeforeCheckinHandler extends CheckinHandler implements CheckinMetaHandler {
|
||||
public static final String COMMAND_NAME = CodeInsightBundle.message("process.rearrange.code.before.commit");
|
||||
|
||||
@@ -45,30 +28,9 @@ public class RearrangeBeforeCheckinHandler extends CheckinHandler implements Che
|
||||
@Override
|
||||
@Nullable
|
||||
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
|
||||
final JCheckBox rearrangeBox = new NonFocusableCheckBox(VcsBundle.message("checkbox.checkin.options.rearrange.code"));
|
||||
CheckinHandlerUtil.disableWhenDumb(myProject, rearrangeBox, "Impossible until indices are up-to-date");
|
||||
return new RefreshableOnComponent() {
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
final JPanel panel = new JPanel(new GridLayout(1, 0));
|
||||
panel.add(rearrangeBox);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveState() {
|
||||
getSettings().REARRANGE_BEFORE_PROJECT_COMMIT = rearrangeBox.isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState() {
|
||||
rearrangeBox.setSelected(getSettings().REARRANGE_BEFORE_PROJECT_COMMIT);
|
||||
}
|
||||
};
|
||||
return new BooleanCommitOption(myPanel, VcsBundle.message("checkbox.checkin.options.rearrange.code"), true,
|
||||
() -> getSettings().REARRANGE_BEFORE_PROJECT_COMMIT,
|
||||
value -> getSettings().REARRANGE_BEFORE_PROJECT_COMMIT = value);
|
||||
}
|
||||
|
||||
private VcsConfiguration getSettings() {
|
||||
|
||||
+5
-43
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.openapi.vcs.checkin;
|
||||
|
||||
@@ -23,15 +9,13 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.CheckinProjectPanel;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.changes.ui.BooleanCommitOption;
|
||||
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.formatter.FormatterUtil;
|
||||
import com.intellij.ui.NonFocusableCheckBox;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ReformatBeforeCheckinHandler extends CheckinHandler implements CheckinMetaHandler {
|
||||
@@ -46,31 +30,9 @@ public class ReformatBeforeCheckinHandler extends CheckinHandler implements Chec
|
||||
@Override
|
||||
@Nullable
|
||||
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
|
||||
final JCheckBox reformatBox = new NonFocusableCheckBox(VcsBundle.message("checkbox.checkin.options.reformat.code"));
|
||||
CheckinHandlerUtil.disableWhenDumb(myProject, reformatBox, "Impossible until indices are up-to-date");
|
||||
return new RefreshableOnComponent() {
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
final JPanel panel = new JPanel(new GridLayout(1, 0));
|
||||
panel.add(reformatBox);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveState() {
|
||||
getSettings().REFORMAT_BEFORE_PROJECT_COMMIT = reformatBox.isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState() {
|
||||
reformatBox.setSelected(getSettings().REFORMAT_BEFORE_PROJECT_COMMIT);
|
||||
}
|
||||
};
|
||||
|
||||
return new BooleanCommitOption(myPanel, VcsBundle.message("checkbox.checkin.options.reformat.code"), true,
|
||||
() -> getSettings().REFORMAT_BEFORE_PROJECT_COMMIT,
|
||||
value -> getSettings().REFORMAT_BEFORE_PROJECT_COMMIT = value);
|
||||
}
|
||||
|
||||
protected VcsConfiguration getSettings() {
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.vcs.checkin;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
@@ -38,6 +24,7 @@ import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.CommitExecutor;
|
||||
import com.intellij.openapi.vcs.changes.ui.BooleanCommitOption;
|
||||
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
@@ -77,12 +64,13 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
|
||||
@Override
|
||||
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
|
||||
JCheckBox checkBox = new JCheckBox(VcsBundle.message("before.checkin.new.todo.check", ""));
|
||||
return new RefreshableOnComponent() {
|
||||
return new BooleanCommitOption(myCheckinProjectPanel, VcsBundle.message("before.checkin.new.todo.check", ""), true,
|
||||
() -> myConfiguration.CHECK_NEW_TODO, value -> myConfiguration.CHECK_NEW_TODO = value) {
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
JPanel panel = new JPanel(new BorderLayout(4, 0));
|
||||
panel.add(checkBox, BorderLayout.WEST);
|
||||
panel.add(getCheckBox(), BorderLayout.WEST);
|
||||
setFilterText(myConfiguration.myTodoPanelSettings.todoFilterName);
|
||||
if (myConfiguration.myTodoPanelSettings.todoFilterName != null) {
|
||||
myTodoFilter = TodoConfiguration.getInstance().getTodoFilter(myConfiguration.myTodoPanelSettings.todoFilterName);
|
||||
@@ -104,31 +92,16 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
}
|
||||
}, null);
|
||||
panel.add(linkLabel, BorderLayout.CENTER);
|
||||
|
||||
CheckinHandlerUtil.disableWhenDumb(myProject, checkBox, "TODO check is impossible until indices are up-to-date");
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void setFilterText(String filterName) {
|
||||
if (filterName == null) {
|
||||
checkBox.setText(VcsBundle.message("before.checkin.new.todo.check", IdeBundle.message("action.todo.show.all")));
|
||||
} else {
|
||||
checkBox.setText(VcsBundle.message("before.checkin.new.todo.check", "Filter: " + filterName));
|
||||
getCheckBox().setText(VcsBundle.message("before.checkin.new.todo.check", IdeBundle.message("action.todo.show.all")));
|
||||
}
|
||||
else {
|
||||
getCheckBox().setText(VcsBundle.message("before.checkin.new.todo.check", "Filter: " + filterName));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveState() {
|
||||
myConfiguration.CHECK_NEW_TODO = checkBox.isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState() {
|
||||
checkBox.setSelected(myConfiguration.CHECK_NEW_TODO);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,5 +20,6 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.testFramework" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.configurationStore.impl" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.externalSystem" />
|
||||
<orderEntry type="module" module-name="intellij.platform.vcs.impl" />
|
||||
</component>
|
||||
</module>
|
||||
+10
-35
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.maddyhome.idea.copyright.actions;
|
||||
|
||||
@@ -20,6 +6,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.vcs.CheckinProjectPanel;
|
||||
import com.intellij.openapi.vcs.changes.CommitContext;
|
||||
import com.intellij.openapi.vcs.changes.CommitExecutor;
|
||||
import com.intellij.openapi.vcs.changes.ui.BooleanCommitOption;
|
||||
import com.intellij.openapi.vcs.checkin.CheckinHandler;
|
||||
import com.intellij.openapi.vcs.checkin.CheckinHandlerFactory;
|
||||
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
|
||||
@@ -28,11 +15,9 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.PairConsumer;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -44,34 +29,24 @@ public class UpdateCopyrightCheckinHandlerFactory extends CheckinHandlerFactory
|
||||
return new CheckinHandler() {
|
||||
@Override
|
||||
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
|
||||
final JCheckBox updateCopyrightCb = new JCheckBox("Update copyright");
|
||||
return new RefreshableOnComponent() {
|
||||
public JComponent getComponent() {
|
||||
return JBUI.Panels.simplePanel().addToLeft(updateCopyrightCb);
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
public void saveState() {
|
||||
UpdateCopyrightCheckinHandlerState.getInstance(panel.getProject()).UPDATE_COPYRIGHT = updateCopyrightCb.isSelected();
|
||||
}
|
||||
|
||||
public void restoreState() {
|
||||
updateCopyrightCb.setSelected(UpdateCopyrightCheckinHandlerState.getInstance(panel.getProject()).UPDATE_COPYRIGHT);
|
||||
}
|
||||
};
|
||||
return new BooleanCommitOption(panel, "Update copyright", false, () -> getSettings().UPDATE_COPYRIGHT,
|
||||
value -> getSettings().UPDATE_COPYRIGHT = value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) {
|
||||
if (UpdateCopyrightCheckinHandlerState.getInstance(panel.getProject()).UPDATE_COPYRIGHT) {
|
||||
if (getSettings().UPDATE_COPYRIGHT) {
|
||||
new UpdateCopyrightProcessor(panel.getProject(), null, getPsiFiles()).run();
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
}
|
||||
return super.beforeCheckin();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private UpdateCopyrightCheckinHandlerState getSettings() {
|
||||
return UpdateCopyrightCheckinHandlerState.getInstance(panel.getProject());
|
||||
}
|
||||
|
||||
private PsiFile[] getPsiFiles() {
|
||||
final Collection<VirtualFile> files = panel.getVirtualFiles();
|
||||
final List<PsiFile> psiFiles = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user