📄 attributeeditordialog.java
字号:
/* * YALE - Yet Another Learning Environment * Copyright (C) 2002, 2003 * Simon Fischer, Ralf Klinkenberg, Ingo Mierswa, * Katharina Morik, Oliver Ritthoff * Artificial Intelligence Unit * Computer Science Department * University of Dortmund * 44221 Dortmund, Germany * email: yale@ls8.cs.uni-dortmund.de * web: http://yale.cs.uni-dortmund.de/ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA. */package edu.udo.cs.yale.gui;import edu.udo.cs.yale.operator.Operator;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JScrollPane;import javax.swing.JButton;import javax.swing.JPanel;import javax.swing.JOptionPane;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import java.awt.BorderLayout;import java.io.File;import java.io.FileWriter;import java.io.PrintWriter;/** @see edu.udo.cs.yale.gui.AttributeEditor */public class AttributeEditorDialog extends JDialog { private AttributeEditor attributeEditor; public AttributeEditorDialog(JFrame owner, Operator exampleSource, File file) { this(owner, exampleSource); if (file != null) attributeEditor.openAttributeFile(file); } public AttributeEditorDialog(JFrame owner, Operator exampleSource) { super(owner, "Attribute Editor", true); attributeEditor = new AttributeEditor(exampleSource); getContentPane().add(new JScrollPane(attributeEditor), BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); JButton openXML = new JButton("Open attribute file..."); openXML.setToolTipText("Click here to open an existing xml attribute descripiton file"); openXML.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { attributeEditor.openAttributeFile(); } }); buttonPanel.add(openXML); JButton saveAttr = new JButton("Save Attributes..."); saveAttr.setToolTipText("Click here to save the attribute description file."); saveAttr.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { saveAttributes(); } }); buttonPanel.add(saveAttr); JButton loadFile = new JButton("Load data..."); loadFile.setToolTipText("Click here to add data from a file"); loadFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { loadData(); } }); buttonPanel.add(loadFile); JButton saveData = new JButton("Save Data..."); saveData.setToolTipText("Click here to save the data to a single file."); saveData.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { saveData(); } }); buttonPanel.add(saveData); JButton clear = new JButton("Clear"); clear.setToolTipText("Click here to clear all columns"); clear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clear(); } }); buttonPanel.add(clear); getContentPane().add(buttonPanel, BorderLayout.SOUTH); pack(); } private void loadData() { File file = SwingTools.chooseFile(this, null, true); if (file != null) { try { attributeEditor.readFile(file); } catch (java.io.IOException e) { JOptionPane.showMessageDialog(this, e.toString(), "Error loading "+file, JOptionPane.ERROR_MESSAGE); } } } private void saveAttributes() { attributeEditor.saveAttributeFile(); } private void saveData() { File file = SwingTools.chooseFile(this, null, false); if (file != null) { try { attributeEditor.writeData(file); } catch (java.io.IOException e) { JOptionPane.showMessageDialog(this, e.toString(), "Error saving data file "+file, JOptionPane.ERROR_MESSAGE); } } } private void clear() { attributeEditor.clear(); } public File getFile() { return attributeEditor.getFile(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -