Mercurial > hg > ltpda
view src/MPipeline2/src/mpipeline/workspace/WorkspaceBrowserDialog.java @ 29:54f14716c721 database-connection-manager
Update Java code
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Mon, 05 Dec 2011 16:20:06 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line source
/* * Class WorkspaceBrowserDialog <one line to give the program's name and a brief idea of what it does.> * * Copyright (c) 2009 Max-Planck-Gesellschaft, Martin Hewitson <martin.hewitson at aei.mpg.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 3 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, see <http://www.gnu.org/licenses/>. * */ /* * WorkspaceBrowserDialog.java * * Created on 28-Jul-2009, 08:50:11 */ package mpipeline.workspace; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.util.ArrayList; import javax.swing.AbstractAction; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JTree; import javax.swing.KeyStroke; import javax.swing.tree.TreePath; import mpipeline.main.MainWindow; /** * * @author Martin Hewitson <martin.hewitson at aei.mpg.de> */ public class WorkspaceBrowserDialog extends javax.swing.JDialog { private MainWindow mw = null; private final int keyModifier; /** Define the key modifier for the different OS */ {if (System.getProperty("os.name").equals("Mac OS X")) keyModifier = KeyEvent.META_DOWN_MASK; else keyModifier = KeyEvent.CTRL_DOWN_MASK; } /** Creates new form WorkspaceBrowserDialog * @param parent * @param modal */ public WorkspaceBrowserDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); if (parent instanceof MainWindow) { mw = (MainWindow) parent; } // Close the GUI with CTRL+W KeyStroke keyStrokeW = KeyStroke.getKeyStroke(KeyEvent.VK_W, keyModifier); rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStrokeW, "CTRL_W"); rootPane.getActionMap().put("CTRL_W", new ActionCTRL_W()); } private class ActionCTRL_W extends AbstractAction { public void actionPerformed(ActionEvent e) { dispose(); } } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jToolBar1 = new javax.swing.JToolBar(); plotBtn = new javax.swing.JButton(); displayBtn = new javax.swing.JButton(); plotHistoryBtn = new javax.swing.JButton(); exploreBtn = new javax.swing.JButton(); jSeparator1 = new javax.swing.JToolBar.Separator(); submitBtn = new javax.swing.JButton(); queryBtn = new javax.swing.JButton(); retrieveBtn = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); doneBtn = new javax.swing.JButton(); refreshBtn = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); workspaceTree = new WorkspaceTree(mw); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Workspace Browser"); setLocationByPlatform(true); jToolBar1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); jToolBar1.setFloatable(false); jToolBar1.setOrientation(javax.swing.SwingConstants.VERTICAL); jToolBar1.setRollover(true); plotBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/plot_small.png"))); // NOI18N plotBtn.setToolTipText("Plot the selected AOs."); plotBtn.setFocusable(false); plotBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); plotBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/plot_small_ro.png"))); // NOI18N plotBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToolBar1.add(plotBtn); displayBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/display.png"))); // NOI18N displayBtn.setToolTipText("Display the selected object(s) on the Matlab terminal"); displayBtn.setFocusable(false); displayBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); displayBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/display_ro.png"))); // NOI18N displayBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToolBar1.add(displayBtn); plotHistoryBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/history_small.png"))); // NOI18N plotHistoryBtn.setToolTipText("Display the history of the selected objects."); plotHistoryBtn.setFocusable(false); plotHistoryBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); plotHistoryBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/history_small_ro.png"))); // NOI18N plotHistoryBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToolBar1.add(plotHistoryBtn); exploreBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/explore.png"))); // NOI18N exploreBtn.setToolTipText("Explore the selected objects."); exploreBtn.setFocusable(false); exploreBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); exploreBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/explore_ro.png"))); // NOI18N exploreBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToolBar1.add(exploreBtn); jToolBar1.add(jSeparator1); submitBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/add_to_database.png"))); // NOI18N submitBtn.setToolTipText("Submit the selected objects to a repository."); submitBtn.setFocusable(false); submitBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); submitBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/add_to_database_ro.png"))); // NOI18N submitBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToolBar1.add(submitBtn); queryBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/search_database.png"))); // NOI18N queryBtn.setToolTipText("Query an LTPDA Repository"); queryBtn.setFocusable(false); queryBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); queryBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/search_database_ro.png"))); // NOI18N queryBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToolBar1.add(queryBtn); retrieveBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/download_database.png"))); // NOI18N retrieveBtn.setToolTipText("Retrieve objecst from a repository."); retrieveBtn.setFocusable(false); retrieveBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); retrieveBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/download_database_ro.png"))); // NOI18N retrieveBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToolBar1.add(retrieveBtn); jPanel2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); doneBtn.setText("Done"); doneBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { doneBtnActionPerformed(evt); } }); refreshBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/refresh_small.png"))); // NOI18N refreshBtn.setToolTipText("Refresh the workspace."); refreshBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/refresh_small_ro.png"))); // NOI18N org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .add(refreshBtn) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 140, Short.MAX_VALUE) .add(doneBtn) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .addContainerGap() .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(doneBtn) .add(refreshBtn)) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel2Layout.linkSize(new java.awt.Component[] {doneBtn, refreshBtn}, org.jdesktop.layout.GroupLayout.VERTICAL); jScrollPane1.setViewportView(workspaceTree); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jToolBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE) .add(jToolBar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void doneBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doneBtnActionPerformed this.dispose(); }//GEN-LAST:event_doneBtnActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton displayBtn; private javax.swing.JButton doneBtn; private javax.swing.JButton exploreBtn; private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JToolBar.Separator jSeparator1; private javax.swing.JToolBar jToolBar1; private javax.swing.JButton plotBtn; private javax.swing.JButton plotHistoryBtn; private javax.swing.JButton queryBtn; private javax.swing.JButton refreshBtn; private javax.swing.JButton retrieveBtn; private javax.swing.JButton submitBtn; private javax.swing.JTree workspaceTree; // End of variables declaration//GEN-END:variables public JTree getWorkspaceTree() { return workspaceTree; } public JButton getDisplayBtn() { return displayBtn; } public JButton getPlotHistoryBtn() { return plotHistoryBtn; } public JButton getSubmitBtn() { return submitBtn; } public JButton getExploreBtn() { return exploreBtn; } public JButton getQueryBtn() { return queryBtn; } public JButton getPlotBtn() { return plotBtn; } public JButton getRefreshBtn() { return refreshBtn; } public JButton getRetrieveBtn() { return retrieveBtn; } public TreePath[] getSelectedPaths() { return workspaceTree.getSelectionPaths(); } public ArrayList<WorkspaceVar> getSelectedVars() { ArrayList<WorkspaceVar> wsvars = new ArrayList<WorkspaceVar>(); TreePath[] paths = workspaceTree.getSelectionPaths(); for (int kk=0; kk< paths.length; kk++) { TreePath path = paths[kk]; Object obj = path.getLastPathComponent(); if (obj instanceof WorkspaceVar) { wsvars.add((WorkspaceVar) obj); } } return wsvars; } }