2024-10-09 22:21:57 +03:00
|
|
|
package _VisualDVM.GlobalData.Compiler.UI;
|
2024-10-09 20:35:18 +03:00
|
|
|
import Common.Visual.TextField.StyledTextField;
|
2024-10-14 15:19:13 +03:00
|
|
|
import Common.Visual.UI_;
|
2024-10-08 22:33:49 +03:00
|
|
|
import Common.Visual.Windows.Dialog.DialogFields;
|
2024-10-08 23:45:06 +03:00
|
|
|
import Common.Visual.Windows.Dialog.VDirectoryChooser;
|
2024-10-13 22:08:13 +03:00
|
|
|
import _VisualDVM.Global;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.GlobalData.Compiler.CompilerType;
|
|
|
|
|
import _VisualDVM.GlobalData.Machine.MachineType;
|
2024-10-14 12:14:01 +03:00
|
|
|
import _VisualDVM.Passes.PassCode;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import javax.swing.event.DocumentEvent;
|
|
|
|
|
import javax.swing.event.DocumentListener;
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
public class CompilerFields implements DialogFields {
|
|
|
|
|
public JPanel content;
|
|
|
|
|
public JTextField tfHome;
|
|
|
|
|
public JButton bBrowse;
|
|
|
|
|
public JTextField tfDescription;
|
|
|
|
|
public JTextField tfCallCommand;
|
|
|
|
|
public JTextField tfVersionCommand;
|
|
|
|
|
public JTextField tfHelpCommand;
|
|
|
|
|
public JComboBox<CompilerType> cbCompilerType;
|
|
|
|
|
public boolean events_on = false;
|
|
|
|
|
VDirectoryChooser directoryChooser = new VDirectoryChooser("Выбор домашней папки dvm системы");
|
|
|
|
|
public CompilerFields() {
|
|
|
|
|
bBrowse.addActionListener(e -> {
|
|
|
|
|
CompilerType type = (CompilerType) cbCompilerType.getSelectedItem();
|
|
|
|
|
if (type == CompilerType.dvm) {
|
|
|
|
|
String dst = null;
|
2024-10-13 22:08:13 +03:00
|
|
|
if (Global.mainModule.getMachine().type.equals(MachineType.Local)) {
|
2023-09-17 22:13:42 +03:00
|
|
|
File file = directoryChooser.ShowDialog();
|
|
|
|
|
if (file != null)
|
|
|
|
|
dst = file.getAbsolutePath();
|
|
|
|
|
} else {
|
2024-10-14 15:19:13 +03:00
|
|
|
if (Global.mainModule.getPass(PassCode.SelectRemoteFile).Do(true))
|
2024-10-13 22:08:13 +03:00
|
|
|
dst = Global.mainModule.getRemoteFile().full_name;
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
if (dst != null)
|
|
|
|
|
tfHome.setText(dst);
|
|
|
|
|
} else
|
2024-10-11 00:00:30 +03:00
|
|
|
UI_.Info("Назначение домашней папки поддерживается только для dvm системы.");
|
2023-09-17 22:13:42 +03:00
|
|
|
});
|
|
|
|
|
tfHome.getDocument().addDocumentListener(new DocumentListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void insertUpdate(DocumentEvent e) {
|
|
|
|
|
TryRestoreCallCommand();
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void removeUpdate(DocumentEvent e) {
|
|
|
|
|
TryRestoreCallCommand();
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void changedUpdate(DocumentEvent e) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
cbCompilerType.addActionListener(e -> {
|
|
|
|
|
if (Objects.requireNonNull(cbCompilerType.getSelectedItem()) == CompilerType.dvm) {
|
|
|
|
|
tfVersionCommand.setText("ver");
|
|
|
|
|
tfHelpCommand.setText("help");
|
|
|
|
|
} else {
|
|
|
|
|
tfVersionCommand.setText("--version");
|
|
|
|
|
tfHelpCommand.setText("--help");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
public void TryRestoreCallCommand() {
|
|
|
|
|
if (events_on && (cbCompilerType.getSelectedItem() != null) && cbCompilerType.getSelectedItem().equals(CompilerType.dvm))
|
|
|
|
|
tfCallCommand.setText(tfHome.getText() +
|
|
|
|
|
(tfHome.getText().endsWith("/") ? "" : "/") +
|
|
|
|
|
"bin/dvm_drv");
|
|
|
|
|
}
|
|
|
|
|
private void createUIComponents() {
|
|
|
|
|
// TODO: place custom component creation code here
|
|
|
|
|
tfDescription = new StyledTextField();
|
|
|
|
|
tfHome = new StyledTextField();
|
|
|
|
|
tfCallCommand = new StyledTextField();
|
|
|
|
|
tfVersionCommand = new StyledTextField();
|
|
|
|
|
tfHelpCommand = new StyledTextField();
|
|
|
|
|
cbCompilerType = new JComboBox<>();
|
|
|
|
|
cbCompilerType.addItem(CompilerType.dvm);
|
|
|
|
|
cbCompilerType.addItem(CompilerType.intel);
|
|
|
|
|
cbCompilerType.addItem(CompilerType.gnu);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public Component getContent() {
|
|
|
|
|
return content;
|
|
|
|
|
}
|
|
|
|
|
}
|