94 lines
4.2 KiB
Java
94 lines
4.2 KiB
Java
package _VisualDVM.GlobalData.Compiler.UI;
|
|
import Common.Visual.CommonUI;
|
|
import _VisualDVM.Current;
|
|
import Common.Visual.TextField.StyledTextField;
|
|
import Common.Visual.Windows.Dialog.DialogFields;
|
|
import Common.Visual.Windows.Dialog.VDirectoryChooser;
|
|
import _VisualDVM.GlobalData.Compiler.CompilerType;
|
|
import _VisualDVM.GlobalData.Machine.MachineType;
|
|
import Visual_DVM_2021.Passes.PassCode;
|
|
import Visual_DVM_2021.Passes.Pass;
|
|
|
|
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;
|
|
if (Current.getMachine().type.equals(MachineType.Local)) {
|
|
File file = directoryChooser.ShowDialog();
|
|
if (file != null)
|
|
dst = file.getAbsolutePath();
|
|
} else {
|
|
if (Pass.passes.get(PassCode.SelectRemoteFile).Do(true))
|
|
dst = Current.getRemoteFile().full_name;
|
|
}
|
|
if (dst != null)
|
|
tfHome.setText(dst);
|
|
} else
|
|
CommonUI.Info("Назначение домашней папки поддерживается только для dvm системы.");
|
|
});
|
|
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;
|
|
}
|
|
}
|