📄 generationpanel.java
字号:
/*
* The contents of this file are subject to the BT "ZEUS" Open Source
* Licence (L77741), Version 1.0 (the "Licence"); you may not use this file
* except in compliance with the Licence. You may obtain a copy of the Licence
* from $ZEUS_INSTALL/licence.html or alternatively from
* http://www.labs.bt.com/projects/agents/zeus/licence.htm
*
* Except as stated in Clause 7 of the Licence, software distributed under the
* Licence is distributed WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the Licence for the specific language governing rights and
* limitations under the Licence.
*
* The Original Code is within the package zeus.*.
* The Initial Developer of the Original Code is British Telecommunications
* public limited company, whose registered office is at 81 Newgate Street,
* London, EC1A 7AJ, England. Portions created by British Telecommunications
* public limited company are Copyright 1996-9. All Rights Reserved.
*
* THIS NOTICE MUST BE INCLUDED ON ANY COPY OF THIS FILE
*/
/*****************************************************************************
* GenerationPanel.java
*
* The 'summary' panel for the code generation process
*****************************************************************************/
package zeus.generator.code;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import javax.swing.border.*;
import zeus.gui.help.*;
import zeus.util.*;
import zeus.generator.*;
public class GenerationPanel extends JPanel
implements ActionListener,
ChangeListener,
FocusListener {
static final String[] ERROR_MESSAGE = {
/* 0 */ "Please select a row before\ncalling this operation"
};
protected JTable table;
protected GenerationTableModel model;
protected JTextField dirField;
protected JRadioButton win;
protected JRadioButton unix;
protected JRadioButton zsh;
protected JButton selectBtn;
protected GenerationPlan genplan;
protected JTextArea textArea;
public GenerationPanel(GenerationPlan genplan) {
this.genplan = genplan;
genplan.addChangeListener(this);
setBackground(Color.lightGray);
GridBagLayout gridBagLayout = new GridBagLayout();
setLayout(gridBagLayout);
GridBagConstraints gbc = new GridBagConstraints();
JPanel dirPanel = new JPanel();
gbc = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(8,8,0,8);
gridBagLayout.setConstraints(dirPanel,gbc);
add(dirPanel);
JPanel topPanel = new JPanel();
gbc = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(8,8,0,8);
gbc.weightx = gbc.weighty = 1;
gridBagLayout.setConstraints(topPanel,gbc);
add(topPanel);
JPanel bottomPanel = new JPanel();
gbc = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(8,8,0,8);
gbc.weightx = gbc.weighty = 1;
gridBagLayout.setConstraints(bottomPanel,gbc);
add(bottomPanel);
// create top panel
topPanel.setBackground(Color.lightGray);
TitledBorder b1 = (BorderFactory.createTitledBorder("Generation Plan"));
b1.setTitlePosition(TitledBorder.TOP);
b1.setTitleJustification(TitledBorder.RIGHT);
b1.setTitleFont(new Font("Helvetica", Font.BOLD, 14));
b1.setTitleColor(Color.blue);
topPanel.setBorder(b1);
model = new GenerationTableModel(genplan);
JToolBar toolbar = new GenerationToolBar();
TableColumnModel tm = new DefaultTableColumnModel();
TableColumn column;
column = new TableColumn(GenerationInfo.NAME,24);
column.setHeaderValue(model.getColumnName(GenerationInfo.NAME));
tm.addColumn(column);
column = new TableColumn(GenerationInfo.TYPE,24);
column.setHeaderValue(model.getColumnName(GenerationInfo.TYPE));
tm.addColumn(column);
column = new TableColumn(GenerationInfo.COMMAND,24);
column.setHeaderValue(model.getColumnName(GenerationInfo.COMMAND));
tm.addColumn(column);
table = new JTable(model,tm);
table.getTableHeader().setReorderingAllowed(false);
table.setColumnSelectionAllowed(false);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setBorder(new BevelBorder(BevelBorder.LOWERED));
scrollPane.setPreferredSize(new Dimension(300,160));
table.setBackground(Color.white);
gridBagLayout = new GridBagLayout();
gbc = new GridBagConstraints();
topPanel.setLayout(gridBagLayout);
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.NONE;
gbc.insets = new Insets(0,8,0,0);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gridBagLayout.setConstraints(toolbar,gbc);
topPanel.add(toolbar);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = gbc.weighty = 1;
gbc.insets = new Insets(8,8,8,8);
gridBagLayout.setConstraints(scrollPane, gbc);
topPanel.add(scrollPane);
// create top panel
bottomPanel.setBackground(Color.lightGray);
b1 = (BorderFactory.createTitledBorder("Generation Messages"));
b1.setTitlePosition(TitledBorder.TOP);
b1.setTitleJustification(TitledBorder.RIGHT);
b1.setTitleFont(new Font("Helvetica", Font.BOLD, 14));
b1.setTitleColor(Color.blue);
bottomPanel.setBorder(b1);
textArea = new JTextArea(12,80);
textArea.setEditable(false);
textArea.setLineWrap(true);
textArea.setBackground(Color.white);
scrollPane = new JScrollPane(textArea);
scrollPane.setBorder(new BevelBorder(BevelBorder.LOWERED));
scrollPane.setPreferredSize(new Dimension(300,160));
gridBagLayout = new GridBagLayout();
gbc = new GridBagConstraints();
bottomPanel.setLayout(gridBagLayout);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.fill = GridBagConstraints.BOTH;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.weightx = gbc.weighty = 1;
gbc.insets = new Insets(8,8,8,8);
gridBagLayout.setConstraints(scrollPane,gbc);
bottomPanel.add(scrollPane);
// directory panel info
dirPanel.setBackground(Color.lightGray);
BevelBorder b2 = new BevelBorder(BevelBorder.LOWERED);
dirPanel.setBorder(b2);
gridBagLayout = new GridBagLayout();
gbc = new GridBagConstraints();
dirPanel.setLayout(gridBagLayout);
dirField = new JTextField(20);
dirField.addActionListener(this);
dirField.addFocusListener(this);
dirField.setText(genplan.getDirectory());
String path = SystemProps.getProperty("gif.dir") + "generator" +
System.getProperty("file.separator");
selectBtn = new JButton("Choose Target Directory", new ImageIcon(path + "open.gif"));
selectBtn.setToolTipText("Choose where source code will be written");
selectBtn.addActionListener(this);
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = gbc.weighty = 0;
gbc.insets = new Insets(4,4,4,4);
gridBagLayout.setConstraints(selectBtn, gbc);
dirPanel.add(selectBtn);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = gbc.weighty = 1;
gbc.insets = new Insets(4,4,4,4);
gridBagLayout.setConstraints(dirField, gbc);
dirPanel.add(dirField);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -