diff --git a/.gitignore b/.gitignore index 14a9049..2d85ce6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,8 @@ /application/data/ /application/config/ /application/logs/ -/application/scans/ \ No newline at end of file +/application/scans/ +/nbactions.xml +/application/nbactions.xml +/fda.ui.cdump/target/ +/fda.ui.cdump/nbactions.xml \ No newline at end of file diff --git a/application/pom.xml b/application/pom.xml index 0d52367..2dcfec6 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -67,6 +67,11 @@ fda.ui.preferences ${project.version} + + ${project.groupId} + fda.ui.cdump + ${project.version} + diff --git a/branding/src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.properties b/branding/src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.properties index d92fdcc..a0af6ee 100644 --- a/branding/src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.properties +++ b/branding/src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.properties @@ -1,4 +1,4 @@ -currentVersion=fda.ui {0} +currentVersion=FDA {0} LBL_splash_window_title=Starting FDA SPLASH_HEIGHT=329 SPLASH_WIDTH=522 diff --git a/branding/src/main/nbm-branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties b/branding/src/main/nbm-branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties index e7f8d8d..976150e 100644 --- a/branding/src/main/nbm-branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties +++ b/branding/src/main/nbm-branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties @@ -1,2 +1,2 @@ -CTL_MainWindow_Title=fda.ui {0} -CTL_MainWindow_Title_No_Project=fda.ui {0} +CTL_MainWindow_Title=FDA {0} +CTL_MainWindow_Title_No_Project=FDA {0} diff --git a/branding/src/main/nbm-branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties b/branding/src/main/nbm-branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties index 3cd6943..c98b74f 100644 --- a/branding/src/main/nbm-branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties +++ b/branding/src/main/nbm-branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties @@ -1 +1 @@ -LBL_ProductInformation=fda.ui +LBL_ProductInformation=FDA diff --git a/fda.ui.cdump/pom.xml b/fda.ui.cdump/pom.xml new file mode 100644 index 0000000..4c7a624 --- /dev/null +++ b/fda.ui.cdump/pom.xml @@ -0,0 +1,130 @@ + + + 4.0.0 + + fda.ui + ch.psi + 1.0.0-SNAPSHOT + + + ch.psi + fda.ui.cdump + 1.0.0-SNAPSHOT + nbm + + fda.ui.cdump NetBeans Module + + + UTF-8 + + + + + + netbeans + NetBeans + http://bits.netbeans.org/maven2/ + + false + + + + + + + org.netbeans.api + org-netbeans-api-annotations-common + RELEASE701 + + + org.netbeans.api + org-openide-util + RELEASE701 + jar + + + org.netbeans.api + org-openide-windows + RELEASE701 + jar + + + org.netbeans.api + org-netbeans-modules-settings + RELEASE701 + jar + + + org.netbeans.api + org-openide-io + RELEASE701 + jar + + + org.netbeans.api + org-openide-util-lookup + RELEASE701 + jar + + + org.netbeans.api + org-openide-awt + RELEASE701 + jar + + + org.netbeans.api + org-openide-dialogs + RELEASE701 + jar + + + ch.psi + fda.ui.preferences + 1.0.0-SNAPSHOT + nbm + + + ch.psi + cdump + 0.9.6-SNAPSHOT + jar + + + + + + + org.codehaus.mojo + nbm-maven-plugin + 3.5 + true + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + + true + + + + + diff --git a/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.form b/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.form new file mode 100644 index 0000000..a75903f --- /dev/null +++ b/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.form @@ -0,0 +1,99 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.java b/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.java new file mode 100644 index 0000000..9ec9585 --- /dev/null +++ b/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.java @@ -0,0 +1,291 @@ +/* + * Copyright (C) 2011 Paul Scherrer Institute + * + * 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 . + */ +package ch.psi.fda.ui.cdump; + +import ch.psi.cdump.CdumpConfiguration; +import ch.psi.cdump.CdumpService; +import ch.psi.cdump.RunConfiguration; +import ch.psi.fda.ui.preferences.api.Preferences; +import java.io.File; +import java.util.Date; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.openide.util.NbBundle; +import org.openide.windows.TopComponent; +import org.openide.windows.WindowManager; +import org.netbeans.api.settings.ConvertAsProperties; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; +import org.openide.util.Lookup; +import org.openide.windows.IOProvider; +import org.openide.windows.InputOutput; + +/** + * Top component which displays something. + */ +@ConvertAsProperties(dtd = "-//ch.psi.fda.ui.cdump//CdumpExecution//EN", +autostore = false) +public final class CdumpExecutionTopComponent extends TopComponent { + + private static CdumpExecutionTopComponent instance; + /** path to the icon used by the component and its open action */ +// static final String ICON_PATH = "SET/PATH/TO/ICON/HERE"; + private static final String PREFERRED_ID = "CdumpExecutionTopComponent"; + + private CdumpService service; + + public CdumpExecutionTopComponent() { + initComponents(); + + // Set default to 10 kHz + jComboBox1.setSelectedItem("10kHz"); + + setName(NbBundle.getMessage(CdumpExecutionTopComponent.class, "CTL_CdumpExecutionTopComponent")); + setToolTipText(NbBundle.getMessage(CdumpExecutionTopComponent.class, "HINT_CdumpExecutionTopComponent")); +// setIcon(ImageUtilities.loadImage(ICON_PATH, true)); + + } + + /** 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. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jComboBox1 = new javax.swing.JComboBox(); + jLabel1 = new javax.swing.JLabel(); + jTextField1 = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(RunConfiguration.rates)); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(CdumpExecutionTopComponent.class, "CdumpExecutionTopComponent.jLabel1.text")); // NOI18N + + jTextField1.setText(org.openide.util.NbBundle.getMessage(CdumpExecutionTopComponent.class, "CdumpExecutionTopComponent.jTextField1.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(CdumpExecutionTopComponent.class, "CdumpExecutionTopComponent.jLabel2.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(CdumpExecutionTopComponent.class, "CdumpExecutionTopComponent.jButton1.text")); // NOI18N + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addComponent(jLabel2)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE))) + .addComponent(jButton1)) + .addContainerGap(108, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1) + .addContainerGap(187, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + if(jButton1.getText().equals("Start")){ + try{ + // Start acquisition + startAcquisition(); + jButton1.setText("Stop"); + } + catch(Exception e){ + NotifyDescriptor d = new NotifyDescriptor.Message("Unable to start data acquisition:\n" + e.getMessage(), NotifyDescriptor.ERROR_MESSAGE); + DialogDisplayer.getDefault().notifyLater(d); + + // Print exception to output window of the application + InputOutput io = IOProvider.getDefault().getIO("Error", false); + // Set output console visible + io.select(); + io.getOut().println("Cannot start continuous detector"); + e.printStackTrace(io.getErr()); + } + } + else { + try{ + // Stop acquisition + jButton1.setText("Start"); + stopAcquisition(); + } + catch(Exception e){ + NotifyDescriptor d = new NotifyDescriptor.Message("Unable to stop data acquisition:\n" + e.getMessage(), NotifyDescriptor.ERROR_MESSAGE); + DialogDisplayer.getDefault().notifyLater(d); + + // Print exception to output window of the application + InputOutput io = IOProvider.getDefault().getIO("Error", false); + // Set output console visible + io.select(); + io.getOut().println("Cannot stop continuous detector"); + e.printStackTrace(io.getErr()); + } + } + }//GEN-LAST:event_jButton1ActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JComboBox jComboBox1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JTextField jTextField1; + // End of variables declaration//GEN-END:variables + /** + * Gets default instance. Do not use directly: reserved for *.settings files only, + * i.e. deserialization routines; otherwise you could get a non-deserialized instance. + * To obtain the singleton instance, use {@link #findInstance}. + */ + public static synchronized CdumpExecutionTopComponent getDefault() { + if (instance == null) { + instance = new CdumpExecutionTopComponent(); + } + return instance; + } + + /** + * Obtain the CdumpExecutionTopComponent instance. Never call {@link #getDefault} directly! + */ + public static synchronized CdumpExecutionTopComponent findInstance() { + TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID); + if (win == null) { + Logger.getLogger(CdumpExecutionTopComponent.class.getName()).warning( + "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system."); + return getDefault(); + } + if (win instanceof CdumpExecutionTopComponent) { + return (CdumpExecutionTopComponent) win; + } + Logger.getLogger(CdumpExecutionTopComponent.class.getName()).warning( + "There seem to be multiple components with the '" + PREFERRED_ID + + "' ID. That is a potential source of errors and unexpected behavior."); + return getDefault(); + } + + @Override + public int getPersistenceType() { + return TopComponent.PERSISTENCE_ALWAYS; + } + + @Override + public void componentOpened() { + // TODO add custom code on component opening + } + + @Override + public void componentClosed() { + // TODO add custom code on component closing + } + + void writeProperties(java.util.Properties p) { + // better to version settings since initial version as advocated at + // http://wiki.apidesign.org/wiki/PropertyFiles + p.setProperty("version", "1.0"); + // TODO store your settings + } + + Object readProperties(java.util.Properties p) { + if (instance == null) { + instance = this; + } + instance.readPropertiesImpl(p); + return instance; + } + + private void readPropertiesImpl(java.util.Properties p) { + String version = p.getProperty("version"); + // TODO read your settings according to their version + } + + @Override + protected String preferredID() { + return PREFERRED_ID; + } + + /** + * Start CDUMP logic + */ + public void startAcquisition() { + Preferences p = Lookup.getDefault().lookup(Preferences.class); + System.setProperty("ch.psi.cdump.home", p.getHome().getAbsolutePath()); + + Logger.getLogger(CdumpExecutionTopComponent.class.getName()).log(Level.INFO, "Start acquisition"); + + RunConfiguration c = new RunConfiguration(); + c.setSamplingRate((String) jComboBox1.getSelectedItem()); + + // Calculate data file location/name + String fname = jTextField1.getText(); + CdumpConfiguration cc = CdumpConfiguration.getInstance(); + String d = cc.getDataDirectory() + "/" + cc.replaceMacros(cc.getFilePrefix(), new Date(), fname) + fname + ".txt"; + File f = new File(d); + f.getParentFile().mkdirs(); // Create data base directory + // Set file to save data + c.setDatafile(f); + + // Create execution service + service = new CdumpService(); + + // Take data + service.startAcquisition(c); + } + + /** + * Stop CDUMP logic + */ + public void stopAcquisition() { + + if(service != null){ + Logger.getLogger(CdumpExecutionTopComponent.class.getName()).log(Level.INFO, "Stop acquisition"); + service.stopAcquisition(); + } + +// // Destroy jca context to let the program abort +// try { +// ChannelBeanFactory.getFactory().getChannelFactory().getContext().destroy(); +// } catch (IllegalStateException e) { +// throw new RuntimeException(e); +// } catch (CAException e) { +// throw new RuntimeException(e); +// } + } +} diff --git a/fda.ui.cdump/src/main/nbm/manifest.mf b/fda.ui.cdump/src/main/nbm/manifest.mf new file mode 100644 index 0000000..b126358 --- /dev/null +++ b/fda.ui.cdump/src/main/nbm/manifest.mf @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +OpenIDE-Module-Localizing-Bundle: ch/psi/fda/ui/cdump/Bundle.properties +OpenIDE-Module-Layer: ch/psi/fda/ui/cdump/layer.xml +OpenIDE-Module-Requires: org.openide.windows.WindowManager diff --git a/fda.ui.cdump/src/main/nbm/module.xml b/fda.ui.cdump/src/main/nbm/module.xml new file mode 100644 index 0000000..a34f8a8 --- /dev/null +++ b/fda.ui.cdump/src/main/nbm/module.xml @@ -0,0 +1,9 @@ + + + + diff --git a/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/Bundle.properties b/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/Bundle.properties new file mode 100644 index 0000000..2aca7f7 --- /dev/null +++ b/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/Bundle.properties @@ -0,0 +1,12 @@ +# Localized module labels. Defaults taken from POM (, , ) if unset. +#OpenIDE-Module-Name= +#OpenIDE-Module-Short-Description= +#OpenIDE-Module-Long-Description= +#OpenIDE-Module-Display-Category= +CdumpExecutionTopComponent.jLabel1.text=Sampling Rate +CdumpExecutionTopComponent.jTextField1.text= +CdumpExecutionTopComponent.jLabel2.text=Scan Name +CdumpExecutionTopComponent.jButton1.text=Start +CTL_CdumpExecutionAction=Stream Detector Acquisition +CTL_CdumpExecutionTopComponent=Stream Detector Acquisition +HINT_CdumpExecutionTopComponent=This is a Continuous Execution window diff --git a/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/CdumpExecutionTopComponentSettings.xml b/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/CdumpExecutionTopComponentSettings.xml new file mode 100644 index 0000000..e7bb811 --- /dev/null +++ b/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/CdumpExecutionTopComponentSettings.xml @@ -0,0 +1,24 @@ + + + + + + + + + diff --git a/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/CdumpExecutionTopComponentWstcref.xml b/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/CdumpExecutionTopComponentWstcref.xml new file mode 100644 index 0000000..0710242 --- /dev/null +++ b/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/CdumpExecutionTopComponentWstcref.xml @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/layer.xml b/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/layer.xml new file mode 100644 index 0000000..fa54f5b --- /dev/null +++ b/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/layer.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fda.ui.ee/pom.xml b/fda.ui.ee/pom.xml index 62b582d..e7eca84 100644 --- a/fda.ui.ee/pom.xml +++ b/fda.ui.ee/pom.xml @@ -2,10 +2,10 @@ 4.0.0 - fda.ui - ch.psi - 1.0.0-SNAPSHOT - + fda.ui + ch.psi + 1.0.0-SNAPSHOT + fda.ui.ee nbm diff --git a/pom.xml b/pom.xml index 3756ce4..127acf0 100644 --- a/pom.xml +++ b/pom.xml @@ -85,10 +85,11 @@ fda.ui.preferences fda.ui.ce fda.ui.cm + fda.ui.cdump RELEASE701 - fda_ui + fda \ No newline at end of file