📄 datafeaturebar.java
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.//// $Id: DataFeatureBar.java,v 1.4 2003/04/27 13:49:40 per_nyfelt Exp $package org.ozoneDB.adminGui.feature.data;import org.ozoneDB.adminGui.res.Images;import org.ozoneDB.adminGui.main.AdminGui;import org.ozoneDB.adminGui.widget.MessageBox;import org.ozoneDB.adminGui.util.ThreadWorker;import org.ozoneDB.adminGui.feature.ActionBar;import org.ozoneDB.adminGui.feature.InfoPanel;import javax.swing.*;import java.awt.*;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import java.io.File;/** * @author Per Nyfelt */public class DataFeatureBar extends ActionBar { private InfoPanel dataInfoPanel; private GridBagConstraints gbc = new GridBagConstraints(); public DataFeatureBar(DataInfoPanel dataInfoPanel) { this.dataInfoPanel = dataInfoPanel; addComponents(); } protected void addComponents() { this.removeAll(); //gbc.gridx = GridBagConstraints.REMAINDER; gbc.insets = new Insets(1, 5, 1, 5); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridy = 0; // Add label //gbc.anchor = GridBagConstraints.SOUTHWEST; //gbc.weighty = .3; add(new ActionButton("named objects", Images.DATA_OBJECT_NAMES, new NamedObjectsLister()), gbc); gbc.gridy++; add(new ActionButton("backup", Images.DATA_BACKUP, new BackupListener()), gbc); gbc.gridy++; add(new ActionButton("restore", Images.DATA_RESTORE, new RestoreListener()), gbc); } private class NamedObjectsLister implements ActionListener { public void actionPerformed(ActionEvent event) { System.out.println("list all named objects"); String[] objectNames = new String[0]; try { objectNames = AdminGui.instance().getDb().objectNames(); } catch (Exception e) { dataInfoPanel.setDisplay(new JTextArea("Unable to retrieve object names: " + e.getMessage())); } if (objectNames.length == 0) { dataInfoPanel.setDisplay(new JTextArea("No named objects found.")); } else { JTextArea display = new JTextArea(); for (int i = 0; i < objectNames.length; i++) { display.append(objectNames[i] + "\n"); } dataInfoPanel.setDisplay(display); } } } private class BackupListener implements ActionListener { public void actionPerformed(ActionEvent event) { System.out.println("perform backup"); ThreadWorker worker = new ThreadWorker() { public Object construct() { JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); fileChooser.showOpenDialog(DataFeatureBar.this); return fileChooser.getSelectedFile(); } public void finished() { try { BackupWorker.backup((File) get()); } catch (Exception e) { e.printStackTrace(); MessageBox.showError("Backup failed", "Unable to backup: " + e); } } }; worker.start(); } } private class RestoreListener implements ActionListener { public void actionPerformed(ActionEvent event) { System.out.println("perform restore"); ThreadWorker worker = new ThreadWorker() { public Object construct() { JFileChooser fileChooser = new JFileChooser(); fileChooser.showOpenDialog(DataFeatureBar.this); return fileChooser.getSelectedFile(); } public void finished() { try { BackupWorker.restore((File) get()); } catch (Exception e) { MessageBox.showError("Restore failed", "Unable to restore: " + e); } } }; worker.start(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -