diff --git a/plugins/settings-repository/src/CommitToIcsDialog.java b/plugins/settings-repository/src/CommitToIcsDialog.java deleted file mode 100644 index 2897b678d3c5..000000000000 --- a/plugins/settings-repository/src/CommitToIcsDialog.java +++ /dev/null @@ -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 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 selectedChanges = browser.getSelectedChanges(); - if (!selectedChanges.isEmpty()) { - commitChanges(selectedChanges); - } - - super.doOKAction(); - } - - private void commitChanges(List changes) { - StateStorageManager storageManager = ServiceKt.getStateStore(project).getStorageManager(); - PathMacroSubstitutor macroSubstitutor = storageManager.getMacroSubstitutor(); - assert macroSubstitutor != null; - IcsManager icsManager = IcsManagerKt.getIcsManager(); - - SmartList 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; - } -} diff --git a/plugins/settings-repository/src/actions/CommitToIcsAction.kt b/plugins/settings-repository/src/actions/CommitToIcsAction.kt deleted file mode 100644 index 6419876bea64..000000000000 --- a/plugins/settings-repository/src/actions/CommitToIcsAction.kt +++ /dev/null @@ -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? = null - - fun consume(change: Change) { - if (isProjectConfigFile(change.virtualFile, project)) { - if (projectChanges == null) { - projectChanges = SmartList() - } - projectChanges!!.add(change) - } - } - - fun getResult() = if (projectChanges == null) listOf() else projectChanges!! - - fun hasResult() = projectChanges != null -} - -private fun getProjectId(project: Project): String? { - val projectId = ServiceManager.getService(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, 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) -}