?? workbench.java
字號:
/*
* Workbench.java
* *
* This software is subject to the terms of the Common Public License
* Agreement, available at the following URL:
* http://www.opensource.org/licenses/cpl.html.
* Copyright (C) 1999-2005 Kana Software, Inc. and others.
* All Rights Reserved.
* You must accept the terms of that agreement to use this software.
*
* Created on September 26, 2002, 11:28 AM
* Modified on 15-Jun-2003 by ebengtso
*
*/
package mondrian.gui;
import mondrian.olap.Connection;
import mondrian.olap.DriverManager;
import mondrian.olap.MondrianDef;
import mondrian.olap.MondrianProperties;
import javax.swing.*;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;
import org.eigenbase.xom.XMLOutput;
/**
*
* @author sean
*/
public class Workbench extends javax.swing.JFrame
{
private static final String LAST_USED1 = "lastUsed1";
private static final String LAST_USED1_URL = "lastUsedUrl1";
private static final String LAST_USED2 = "lastUsed2";
private static final String LAST_USED2_URL = "lastUsedUrl2";
private static final String LAST_USED3 = "lastUsed3";
private static final String LAST_USED3_URL = "lastUsedUrl3";
private static final String LAST_USED4 = "lastUsed4";
private static final String LAST_USED4_URL = "lastUsedUrl4";
private Connection connection;
private String jdbcDriverClassName;
private String jdbcConnectionUrl;
private final ClassLoader myClassLoader;
private Properties workbenchProperties;
/** Creates new form Workbench */
public Workbench()
{
myClassLoader = this.getClass().getClassLoader();
loadWorkbenchProperties();
initDataSource();
initComponents();
ResourceBundle resources = ResourceBundle.getBundle("mondrian.gui.resources.gui", Locale.getDefault(), myClassLoader);
ImageIcon icon = new javax.swing.ImageIcon(myClassLoader.getResource(resources.getString("cube")));
this.setIconImage(icon.getImage());
}
/**
* load properties
*/
private void loadWorkbenchProperties()
{
workbenchProperties = new Properties();
try
{
workbenchProperties.load(new FileInputStream(new File("workbench.properties")));
}
catch (Exception e)
{
// TODO deal with exception
}
}
/**
* save properties
*/
private void storeWorkbenchProperties()
{
//save properties to file
OutputStream out = null;
try
{
out = (OutputStream) new FileOutputStream(new File("workbench.properties"));
workbenchProperties.store(out, "Workbench configuration");
}
catch (Exception e)
{
//TODO deal with exception
}
finally
{
try
{
out.close();
}
catch (IOException eIO)
{
//TODO deal with exception
}
}
}
/**
* Initialize the data source from a property file
*/
private void initDataSource()
{
jdbcDriverClassName = workbenchProperties.getProperty("jdbcDriverClassName");
jdbcConnectionUrl = workbenchProperties.getProperty("jdbcConnectionUrl");
}
/** This method is called from within the constructor to
* initialize the form.
*/
private void initComponents()
{
desktopPane = new javax.swing.JDesktopPane();
jToolBar1 = new javax.swing.JToolBar();
toolbarNewButton = new javax.swing.JButton();
toolbarOpenButton = new javax.swing.JButton();
toolbarSaveButton = new javax.swing.JButton();
toolbarSaveAsButton = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
toolbarPreferencesButton = new javax.swing.JButton();
menuBar = new javax.swing.JMenuBar();
fileMenu = new javax.swing.JMenu();
newMenu = new javax.swing.JMenu();
newSchemaMenuItem = new javax.swing.JMenuItem();
newQueryMenuItem = new javax.swing.JMenuItem();
newJDBCExplorerMenuItem = new javax.swing.JMenuItem();
openMenuItem = new javax.swing.JMenuItem();
lastUsed1MenuItem = new javax.swing.JMenuItem();
lastUsed2MenuItem = new javax.swing.JMenuItem();
lastUsed3MenuItem = new javax.swing.JMenuItem();
lastUsed4MenuItem = new javax.swing.JMenuItem();
saveMenuItem = new javax.swing.JMenuItem();
saveAsMenuItem = new javax.swing.JMenuItem();
jSeparator1 = new javax.swing.JSeparator();
jSeparator2 = new javax.swing.JSeparator();
exitMenuItem = new javax.swing.JMenuItem();
editMenu = new javax.swing.JMenu();
cutMenuItem = new javax.swing.JMenuItem();
copyMenuItem = new javax.swing.JMenuItem();
pasteMenuItem = new javax.swing.JMenuItem();
deleteMenuItem = new javax.swing.JMenuItem();
viewMenu = new javax.swing.JMenu();
viewDimensionsMenuItem = new javax.swing.JCheckBoxMenuItem();
viewMeasuresMenuItem = new javax.swing.JCheckBoxMenuItem();
viewCubesMenuItem = new javax.swing.JCheckBoxMenuItem();
setTitle("Mondrian Workbench");
addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent evt)
{
exitForm(evt);
}
});
getContentPane().add(desktopPane, java.awt.BorderLayout.CENTER);
toolbarNewButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/New16.gif")));
toolbarNewButton.setToolTipText("New");
jToolBar1.add(toolbarNewButton);
toolbarOpenButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Open16.gif")));
toolbarOpenButton.setToolTipText("New");
toolbarOpenButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
openMenuItemActionPerformed(evt);
}
});
jToolBar1.add(toolbarOpenButton);
toolbarSaveButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Save16.gif")));
toolbarSaveButton.setToolTipText("New");
toolbarSaveButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
saveMenuItemActionPerformed(evt);
}
});
jToolBar1.add(toolbarSaveButton);
toolbarSaveAsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/SaveAs16.gif")));
toolbarSaveAsButton.setToolTipText("New");
toolbarSaveAsButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
saveAsMenuItemActionPerformed(evt);
}
});
jToolBar1.add(toolbarSaveAsButton);
jPanel1.setMaximumSize(new java.awt.Dimension(8, 32767));
jToolBar1.add(jPanel1);
toolbarPreferencesButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Preferences16.gif")));
toolbarPreferencesButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
toolbarPreferencesButtonActionPerformed(evt);
}
});
jToolBar1.add(toolbarPreferencesButton);
getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH);
fileMenu.setText("File");
newMenu.setText("New");
newQueryMenuItem.setText("MDX Query");
newQueryMenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
newQueryMenuItemActionPerformed(evt);
}
});
newMenu.add(newQueryMenuItem);
newJDBCExplorerMenuItem.setText("JDBC Explorer");
newJDBCExplorerMenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
newJDBCExplorerMenuItemActionPerformed(evt);
}
});
newMenu.add(newJDBCExplorerMenuItem);
fileMenu.add(newMenu);
openMenuItem.setText("Open");
openMenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
openMenuItemActionPerformed(evt);
}
});
fileMenu.add(openMenuItem);
saveMenuItem.setText("Save");
saveMenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
saveMenuItemActionPerformed(evt);
}
});
fileMenu.add(saveMenuItem);
saveAsMenuItem.setText("Save As ...");
saveAsMenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
saveAsMenuItemActionPerformed(evt);
}
});
fileMenu.add(saveAsMenuItem);
//add last used
fileMenu.add(jSeparator2);
lastUsed1MenuItem.setText(workbenchProperties.getProperty("lastUsed1"));
lastUsed1MenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
lastUsed1MenuItemActionPerformed(evt);
}
});
fileMenu.add(lastUsed1MenuItem);
lastUsed2MenuItem.setText(workbenchProperties.getProperty("lastUsed2"));
lastUsed2MenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
lastUsed2MenuItemActionPerformed(evt);
}
});
fileMenu.add(lastUsed2MenuItem);
lastUsed3MenuItem.setText(workbenchProperties.getProperty("lastUsed3"));
lastUsed3MenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
lastUsed3MenuItemActionPerformed(evt);
}
});
fileMenu.add(lastUsed3MenuItem);
lastUsed4MenuItem.setText(workbenchProperties.getProperty("lastUsed4"));
lastUsed4MenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
lastUsed4MenuItemActionPerformed(evt);
}
});
fileMenu.add(lastUsed4MenuItem);
updateLastUsedMenu();
fileMenu.add(jSeparator1);
exitMenuItem.setText("Exit");
exitMenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
exitMenuItemActionPerformed(evt);
}
});
fileMenu.add(exitMenuItem);
menuBar.add(fileMenu);
editMenu.setText("Edit");
cutMenuItem.setText("Cut");
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -