mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
"Switch Boot Runtime" improvement.
Uninstall action. New Bintray layout. GitOrigin-RevId: bd8eee7cc2ceb07dcc2d7d877f00572ca71ff330
This commit is contained in:
committed by
intellij-monorepo-bot
parent
47f33e433c
commit
25dd8ba8f9
@@ -17,6 +17,7 @@ import com.intellij.ui.components.JBOptionButton
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import java.awt.GridBagConstraints
|
||||
import java.awt.Insets
|
||||
import javax.swing.Action
|
||||
import javax.swing.JButton
|
||||
import javax.swing.SwingUtilities
|
||||
|
||||
@@ -36,7 +37,10 @@ class Controller(val project: Project, val actionPanel:ActionPanel, val model: M
|
||||
actionPanel.removeAll()
|
||||
val list = runtimeStateToActions(runtime, model.currentState()).toList()
|
||||
|
||||
val job = JBOptionButton(list.firstOrNull(), list.subList(1, list.size).toTypedArray())
|
||||
val job = if (list.size > 1)
|
||||
JBOptionButton(list.firstOrNull(), list.subList(1, list.size).toTypedArray())
|
||||
else
|
||||
JButton(list.firstOrNull())
|
||||
|
||||
val constraint = GridBagConstraints()
|
||||
constraint.insets = Insets(0,0,0, 0)
|
||||
@@ -69,6 +73,7 @@ class Controller(val project: Project, val actionPanel:ActionPanel, val model: M
|
||||
EXTRACTED -> listOf(produce(INSTALL, runtime), produce(DELETE, runtime))
|
||||
UNINSTALLED -> listOf(produce(INSTALL, runtime), produce(DELETE, runtime))
|
||||
INSTALLED -> listOf(produce(UNINSTALL, runtime))
|
||||
LOCAL -> listOf(produce(INSTALL, runtime))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// Copyright 2000-2019 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.bootRuntime
|
||||
|
||||
import com.intellij.bootRuntime.bundles.Local
|
||||
import com.intellij.bootRuntime.bundles.Remote
|
||||
import com.intellij.bootRuntime.bundles.Runtime
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
|
||||
enum class BundleState {
|
||||
REMOTE,
|
||||
LOCAL,
|
||||
DOWNLOADED,
|
||||
EXTRACTED,
|
||||
INSTALLED,
|
||||
@@ -25,6 +27,7 @@ class Model(var selectedBundle: Runtime, val bundles:MutableList<Runtime>) {
|
||||
isExtracted(selectedBundle) -> BundleState.EXTRACTED
|
||||
isDownloaded(selectedBundle) -> BundleState.DOWNLOADED
|
||||
isRemote(selectedBundle) -> BundleState.REMOTE
|
||||
isLocal(selectedBundle) -> BundleState.LOCAL
|
||||
else -> BundleState.UNINSTALLED
|
||||
}
|
||||
}
|
||||
@@ -38,4 +41,6 @@ class Model(var selectedBundle: Runtime, val bundles:MutableList<Runtime>) {
|
||||
private fun isDownloaded(bundle:Runtime):Boolean = bundle.downloadPath.exists()
|
||||
|
||||
fun isRemote(bundle:Runtime):Boolean = bundle is Remote
|
||||
|
||||
fun isLocal(bundle:Runtime):Boolean = bundle is Local
|
||||
}
|
||||
|
||||
@@ -49,9 +49,7 @@ public class CommandFactory {
|
||||
case INSTALL:
|
||||
return new Install(getInstance().myProject, getInstance().myController, runtime);
|
||||
case UNINSTALL:
|
||||
Install install = new Install(getInstance().myProject, getInstance().myController, runtime);
|
||||
install.setEnabled(false);
|
||||
return install;
|
||||
return new Uninstall(getInstance().myProject, getInstance().myController, runtime);
|
||||
case DELETE:
|
||||
return new Delete(getInstance().myProject, getInstance().myController, runtime);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2000-2019 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.bootRuntime.command;
|
||||
|
||||
import com.intellij.bootRuntime.BinTrayUtil;
|
||||
import com.intellij.bootRuntime.Controller;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.bootRuntime.bundles.Runtime;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class Uninstall extends RuntimeCommand {
|
||||
public Uninstall(Project project, Controller controller, Runtime runtime) {
|
||||
super(project, controller, "Uninstall", runtime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
runWithProgress("Uninstalling...", indicator -> {
|
||||
FileUtil.delete(BinTrayUtil.getJdkConfigFilePath());
|
||||
myController.restart();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user