增加本地终端
This commit is contained in:
parent
425c4ce6bd
commit
e561439b4d
@ -12,16 +12,19 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
* @author luke
|
||||
*/
|
||||
public class TerminalEmulatorComponent extends VBox {
|
||||
|
||||
private CodeArea terminalOutput;
|
||||
private Process process;
|
||||
|
||||
public TerminalEmulatorComponent() {
|
||||
initializeUI();
|
||||
init();
|
||||
}
|
||||
|
||||
private void initializeUI() {
|
||||
private void init() {
|
||||
terminalOutput = new CodeArea();
|
||||
TextField commandInput = new TextField();
|
||||
|
||||
@ -41,7 +44,6 @@ public class TerminalEmulatorComponent extends VBox {
|
||||
|
||||
// 设置布局样式和大小
|
||||
setSpacing(10);
|
||||
setMinSize(800, 600);
|
||||
}
|
||||
|
||||
private void executeCommand(String command) {
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
package org.jcnc.jnotepad.views.root.bottom;
|
||||
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.scene.layout.VBox;
|
||||
import org.jcnc.jnotepad.ui.module.AbstractVerticalBox;
|
||||
import org.jcnc.jnotepad.ui.module.TerminalEmulatorComponent;
|
||||
import org.jcnc.jnotepad.views.root.bottom.cmd.CmdStatusBox;
|
||||
import org.jcnc.jnotepad.views.root.bottom.status.BottomStatusBox;
|
||||
import org.jcnc.jnotepad.views.root.left.sidebar.tools.SidebarToolBar;
|
||||
|
||||
/**
|
||||
* 底部根侧边栏垂直布局
|
||||
@ -17,6 +15,8 @@ import org.jcnc.jnotepad.views.root.left.sidebar.tools.SidebarToolBar;
|
||||
*/
|
||||
public class RootBottomSideBarVerticalBox extends AbstractVerticalBox {
|
||||
|
||||
VBox bottomSideBarVerticalBox;
|
||||
|
||||
/**
|
||||
* 获取 RootBottomSideBarVerticalBox 的唯一实例。
|
||||
*
|
||||
@ -26,10 +26,13 @@ public class RootBottomSideBarVerticalBox extends AbstractVerticalBox {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private void initSidebarVerticalBox() {
|
||||
VBox bottomSideBarVerticalBox = new VBox();
|
||||
public void initSidebarVerticalBox() {
|
||||
bottomSideBarVerticalBox = new VBox();
|
||||
|
||||
bottomSideBarVerticalBox.getChildren().addAll(CmdStatusBox.getInstance(), BottomStatusBox.getInstance());
|
||||
TerminalEmulatorComponent terminal = new TerminalEmulatorComponent();
|
||||
|
||||
|
||||
bottomSideBarVerticalBox.getChildren().addAll(terminal,CmdStatusBox.getInstance(), BottomStatusBox.getInstance());
|
||||
|
||||
|
||||
getChildren().addAll(bottomSideBarVerticalBox);
|
||||
@ -38,8 +41,17 @@ public class RootBottomSideBarVerticalBox extends AbstractVerticalBox {
|
||||
|
||||
private static final RootBottomSideBarVerticalBox INSTANCE = new RootBottomSideBarVerticalBox();
|
||||
|
||||
private RootBottomSideBarVerticalBox() {
|
||||
public RootBottomSideBarVerticalBox() {
|
||||
initSidebarVerticalBox();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 bottomSideBarVerticalBox 实例。
|
||||
*
|
||||
* @return bottomSideBarVerticalBox 的实例
|
||||
*/
|
||||
public VBox getBottomSideBarVerticalBox() {
|
||||
return bottomSideBarVerticalBox;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,19 +1,12 @@
|
||||
package org.jcnc.jnotepad.views.root.bottom.cmd;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Menu;
|
||||
import javafx.scene.control.MenuBar;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import org.jcnc.jnotepad.controller.event.handler.menubar.SaveAsFile;
|
||||
import org.jcnc.jnotepad.util.LogUtil;
|
||||
import org.jcnc.jnotepad.ui.module.TerminalEmulatorComponent;
|
||||
|
||||
/**
|
||||
* @author luke
|
||||
@ -22,6 +15,11 @@ public class CmdStatusBox extends HBox {
|
||||
|
||||
private static final CmdStatusBox CMD_STATUS_BOX = new CmdStatusBox();
|
||||
|
||||
/**
|
||||
* 用于跟踪终端的显示状态
|
||||
*/
|
||||
private boolean terminalVisible = false;
|
||||
|
||||
private CmdStatusBox() {
|
||||
initStatusBox();
|
||||
}
|
||||
@ -30,49 +28,46 @@ public class CmdStatusBox extends HBox {
|
||||
return CMD_STATUS_BOX;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化底部CMD按钮组件
|
||||
*/
|
||||
public void initStatusBox() {
|
||||
|
||||
|
||||
var menuBar = new MenuBar();
|
||||
HBox.setHgrow(menuBar, Priority.ALWAYS);
|
||||
menuBar.setPadding(new Insets(-3, 0, -3, 35));
|
||||
|
||||
// 创建菜单项 1
|
||||
var runMenu = new Menu();
|
||||
var cmdMenu = new Menu();
|
||||
var buildMenu = new Menu();
|
||||
|
||||
// 创建菜单项 2
|
||||
var runLabel = new Label("运行");
|
||||
var cmdLabel = new Label("终端");
|
||||
var buildLabel = new Label("构建");
|
||||
|
||||
// 创建菜单点击事件 2
|
||||
runMenu.setGraphic(runLabel);
|
||||
cmdMenu.setGraphic(cmdLabel);
|
||||
buildMenu.setGraphic(buildLabel);
|
||||
|
||||
cmdLabel.setOnMouseClicked(mouseEvent -> {
|
||||
showTerminal();
|
||||
LogUtil.getLogger(this.getClass()).info("打开终端成功!");
|
||||
toggleTerminal(); // 切换终端的显示/隐藏状态
|
||||
});
|
||||
|
||||
// 将一级菜单添加到菜单栏
|
||||
menuBar.getMenus().addAll(runMenu, cmdMenu, buildMenu);
|
||||
|
||||
// 将菜单栏添加到CmdStatusBox
|
||||
this.getChildren().add(menuBar);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 在菜单上方创建一个终端
|
||||
*/
|
||||
private void toggleTerminal() {
|
||||
if (terminalVisible) {
|
||||
// 隐藏终端
|
||||
terminalVisible = false;
|
||||
// 在这里添加隐藏终端的代码
|
||||
} else {
|
||||
// 显示终端
|
||||
terminalVisible = true;
|
||||
showTerminal(); // 显示终端
|
||||
}
|
||||
}
|
||||
|
||||
private void showTerminal() {
|
||||
TerminalEmulatorComponent terminal = new TerminalEmulatorComponent();
|
||||
// 在这里添加显示终端的代码
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user