mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
settings-repository: remove unused code
GitOrigin-RevId: 0dc03b99f355e454efe17af72ceb3738b2d3188e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ba65cd10c8
commit
d433529923
@@ -1,75 +0,0 @@
|
||||
// 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 org.jetbrains.settingsRepository;
|
||||
|
||||
import com.intellij.configurationStore.StateStorageManager;
|
||||
import com.intellij.openapi.components.PathMacroSubstitutor;
|
||||
import com.intellij.openapi.components.RoamingType;
|
||||
import com.intellij.openapi.components.ServiceKt;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ui.SimpleChangesBrowser;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
|
||||
public class CommitToIcsDialog extends DialogWrapper {
|
||||
private final SimpleChangesBrowser browser;
|
||||
private final Project project;
|
||||
private final String projectId;
|
||||
|
||||
public CommitToIcsDialog(Project project, String projectId, List<Change> projectFileChanges) {
|
||||
super(project, true);
|
||||
|
||||
this.project = project;
|
||||
this.projectId = projectId;
|
||||
|
||||
browser = new SimpleChangesBrowser(project, true, false);
|
||||
browser.setIncludedChanges(projectFileChanges);
|
||||
browser.setChangesToDisplay(projectFileChanges);
|
||||
|
||||
setTitle(IcsBundleKt.icsMessage("action.CommitToIcs.text"));
|
||||
setOKButtonText(IcsBundleKt.icsMessage("action.CommitToIcs.text"));
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doOKAction() {
|
||||
List<Change> selectedChanges = browser.getSelectedChanges();
|
||||
if (!selectedChanges.isEmpty()) {
|
||||
commitChanges(selectedChanges);
|
||||
}
|
||||
|
||||
super.doOKAction();
|
||||
}
|
||||
|
||||
private void commitChanges(List<Change> changes) {
|
||||
StateStorageManager storageManager = ServiceKt.getStateStore(project).getStorageManager();
|
||||
PathMacroSubstitutor macroSubstitutor = storageManager.getMacroSubstitutor();
|
||||
assert macroSubstitutor != null;
|
||||
IcsManager icsManager = IcsManagerKt.getIcsManager();
|
||||
|
||||
SmartList<String> addToIcs = new SmartList<>();
|
||||
for (Change change : changes) {
|
||||
VirtualFile file = change.getVirtualFile();
|
||||
assert file != null;
|
||||
String fileSpec = macroSubstitutor.collapsePath(file.getPath());
|
||||
String repoPath = IcsUrlBuilderKt.toRepositoryPath(fileSpec, RoamingType.DEFAULT, projectId);
|
||||
addToIcs.add(repoPath);
|
||||
if (!icsManager.getRepositoryManager().has(repoPath)) {
|
||||
// new, revert local
|
||||
// todo
|
||||
}
|
||||
}
|
||||
//icsManager.getRepositoryManager().commit(addToIcs);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
return browser;
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* 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 org.jetbrains.settingsRepository.actions
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.openapi.ui.MessageDialogBuilder
|
||||
import com.intellij.openapi.ui.Messages
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vcs.changes.Change
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.util.SmartList
|
||||
import org.jetbrains.settingsRepository.CommitToIcsDialog
|
||||
import org.jetbrains.settingsRepository.ProjectId
|
||||
import org.jetbrains.settingsRepository.icsManager
|
||||
import java.util.*
|
||||
|
||||
private class ProjectChangeCollectConsumer(private val project: Project) {
|
||||
private var projectChanges: MutableList<Change>? = null
|
||||
|
||||
fun consume(change: Change) {
|
||||
if (isProjectConfigFile(change.virtualFile, project)) {
|
||||
if (projectChanges == null) {
|
||||
projectChanges = SmartList<Change>()
|
||||
}
|
||||
projectChanges!!.add(change)
|
||||
}
|
||||
}
|
||||
|
||||
fun getResult() = if (projectChanges == null) listOf<Change>() else projectChanges!!
|
||||
|
||||
fun hasResult() = projectChanges != null
|
||||
}
|
||||
|
||||
private fun getProjectId(project: Project): String? {
|
||||
val projectId = ServiceManager.getService<ProjectId>(project, ProjectId::class.java)!!
|
||||
if (projectId.uid == null) {
|
||||
if (icsManager.settings.doNoAskMapProject ||
|
||||
MessageDialogBuilder.yesNo("Settings Server Project Mapping", "Project is not mapped on Settings Server. Would you like to map?").project(project).doNotAsk(object : DialogWrapper.DoNotAskOption.Adapter() {
|
||||
override fun isSelectedByDefault(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun rememberChoice(isSelected: Boolean, exitCode: Int) {
|
||||
icsManager.settings.doNoAskMapProject = isSelected
|
||||
}
|
||||
}).show() == Messages.YES) {
|
||||
projectId.uid = UUID.randomUUID().toString()
|
||||
}
|
||||
}
|
||||
|
||||
return projectId.uid
|
||||
}
|
||||
|
||||
private fun showDialog(project: Project, collectConsumer: ProjectChangeCollectConsumer, projectId: String?) {
|
||||
if (!collectConsumer.hasResult()) {
|
||||
return
|
||||
}
|
||||
|
||||
var effectiveProjectId = projectId
|
||||
if (effectiveProjectId == null) {
|
||||
effectiveProjectId = getProjectId(project)
|
||||
if (effectiveProjectId == null) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
CommitToIcsDialog(project, effectiveProjectId, collectConsumer.getResult()).show()
|
||||
}
|
||||
|
||||
private fun collectProjectChanges(changes: Collection<Change>, collectConsumer: ProjectChangeCollectConsumer) {
|
||||
for (change in changes) {
|
||||
collectConsumer.consume(change)
|
||||
}
|
||||
}
|
||||
|
||||
private fun isProjectConfigFile(file: VirtualFile?, project: Project): Boolean {
|
||||
if (file == null) {
|
||||
return false
|
||||
}
|
||||
return FileUtil.isAncestor(project.basePath!!, file.path, true)
|
||||
}
|
||||
Reference in New Issue
Block a user