commit e2cc7e1fd83a2bae57761f22bf3c5ce25d1f6a96 Author: Alexandre Gobbo Date: Fri Dec 5 17:44:40 2014 +0100 Added support for plugins diff --git a/nbactions.xml b/nbactions.xml new file mode 100644 index 0000000..d55cef1 --- /dev/null +++ b/nbactions.xml @@ -0,0 +1,52 @@ + + + + run + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:1.2.1:exec + + + -classpath %classpath ch.psi.pshell.ui.App -p=ch.psi.plugin.TestPlugin + java + ../pshell + + + + + debug + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:1.2.1:exec + + + -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ch.psi.pshell.ui.App -p=ch.psi.plugin.TestPlugin + java + true + ../pshell + + + + + profile + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:1.2.1:exec + + + -classpath %classpath ch.psi.pshell.ui.App -p=ch.psi.plugin.TestPlugin + java + ../pshell + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..5e3b7c1 --- /dev/null +++ b/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + ch.psi + plugin + 1.0-SNAPSHOT + jar + + + ${project.groupId} + pshell + ${project.version} + + + + UTF-8 + 1.7 + 1.7 + + \ No newline at end of file diff --git a/pshell.properties b/pshell.properties new file mode 100644 index 0000000..a0bb8ee --- /dev/null +++ b/pshell.properties @@ -0,0 +1,16 @@ +#Thu Dec 04 18:06:51 CET 2014 +dataPath={home}/data +logPath={home}/log +logLevel=Info +libraryPath={script}; {script}/site-packages +scriptPath={home}/script +serverPort=-1 +contextPath={home}/context +logDaysToLive=-1 +devicePoolFile={devices}/devices.properties +homePath=./home +deviceUpdateStrategyFile={devices}/update.properties +devicesPath={home}/devices +test=false +sessionsPath={home}/sessions +scriptType=py diff --git a/src/main/java/ch/psi/plugin/MainPanel.form b/src/main/java/ch/psi/plugin/MainPanel.form new file mode 100644 index 0000000..5607514 --- /dev/null +++ b/src/main/java/ch/psi/plugin/MainPanel.form @@ -0,0 +1,135 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/ch/psi/plugin/MainPanel.java b/src/main/java/ch/psi/plugin/MainPanel.java new file mode 100644 index 0000000..d5046da --- /dev/null +++ b/src/main/java/ch/psi/plugin/MainPanel.java @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. + */ +package ch.psi.plugin; + +import ch.psi.pshell.core.Controller; +import ch.psi.pshell.ui.App; +import ch.psi.pshell.ui.View; +import ch.psi.utils.State; +import ch.psi.utils.Swing; +import ch.psi.wsaf.ApplicationStateAdapter; +import ch.psi.wsaf.ApplicationStateListener; + +/** + * + */ +public class MainPanel extends javax.swing.JPanel { + final App app; + final View view; + final Controller controller; + /** + * Creates new form MainPanel + */ + public MainPanel() { + initComponents(); + app=App.getInstance(); + controller=app.getController(); + view=(View) app.getMainFrame(); + app.addStateListener(applicationStateListener); + } + + ApplicationStateListener applicationStateListener = new ApplicationStateAdapter() { + @Override + public void onChangedState(State newState, State curState) { + try{ + if (newState==State.Ready){ + motorPanel1.setDevice(controller.getDevicePool().getByName("motor")); + motorPanel2.setDevice(controller.getDevicePool().getByName("m")); + }else{ + if (!newState.isInitialized()){ + motorPanel1.setDevice(null); + motorPanel2.setDevice(null); + } + } + + buttonStart1.setEnabled(newState==State.Ready); + buttonStart2.setEnabled(newState==State.Ready); + buttonStart3.setEnabled(newState==State.Ready); + buttonStart4.setEnabled(newState==State.Ready); + motorPanel1.setEnabled(newState==State.Ready); + motorPanel2.setEnabled(newState==State.Ready); + } + catch (Exception ex){ + ex.printStackTrace(); + } + } + }; + + void runScript(final String name){ + new Thread(new Runnable() { + @Override + public void run() { + try{ + controller.evalFile(name, true); + }catch (Exception ex){ + Swing.showException(view, ex); + } + } + }).start(); + } + + /** + * 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + motorPanel1 = new ch.psi.pshell.swing.MotorPanel(); + motorPanel2 = new ch.psi.pshell.swing.MotorPanel(); + jPanel1 = new javax.swing.JPanel(); + buttonStart1 = new javax.swing.JButton(); + buttonStart2 = new javax.swing.JButton(); + buttonStart3 = new javax.swing.JButton(); + buttonStart4 = new javax.swing.JButton(); + + motorPanel1.setShowTitle(true); + + motorPanel2.setShowTitle(true); + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Tasks")); + + buttonStart1.setText("Start Data Acquisition 1"); + buttonStart1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonStart1ActionPerformed(evt); + } + }); + + buttonStart2.setText("Start Data Acquisition 2"); + buttonStart2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonStart2ActionPerformed(evt); + } + }); + + buttonStart3.setText("Start Data Acquisition 3"); + buttonStart3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonStart3ActionPerformed(evt); + } + }); + + buttonStart4.setText("Start Data Acquisition 4"); + buttonStart4.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonStart4ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(buttonStart1, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE) + .addComponent(buttonStart2, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE) + .addComponent(buttonStart3, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE) + .addComponent(buttonStart4, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonStart1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(buttonStart2) + .addGap(18, 18, 18) + .addComponent(buttonStart3) + .addGap(18, 18, 18) + .addComponent(buttonStart4) + .addGap(95, 95, 95)) + ); + + jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {buttonStart1, buttonStart2, buttonStart3, buttonStart4}); + + 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) + .addComponent(motorPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(motorPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(82, 82, 82)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(motorPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(motorPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(30, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void buttonStart1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStart1ActionPerformed + // TODO add your handling code here: + runScript("test1"); + }//GEN-LAST:event_buttonStart1ActionPerformed + + private void buttonStart2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStart2ActionPerformed + // TODO add your handling code here: + runScript("test2"); + }//GEN-LAST:event_buttonStart2ActionPerformed + + private void buttonStart3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStart3ActionPerformed + // TODO add your handling code here: + runScript("test3"); + }//GEN-LAST:event_buttonStart3ActionPerformed + + private void buttonStart4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStart4ActionPerformed + // TODO add your handling code here: + runScript("test4"); + }//GEN-LAST:event_buttonStart4ActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton buttonStart1; + private javax.swing.JButton buttonStart2; + private javax.swing.JButton buttonStart3; + private javax.swing.JButton buttonStart4; + private javax.swing.JPanel jPanel1; + private ch.psi.pshell.swing.MotorPanel motorPanel1; + private ch.psi.pshell.swing.MotorPanel motorPanel2; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/ch/psi/plugin/TestPlugin.java b/src/main/java/ch/psi/plugin/TestPlugin.java new file mode 100644 index 0000000..b973769 --- /dev/null +++ b/src/main/java/ch/psi/plugin/TestPlugin.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. + */ + +package ch.psi.plugin; + +import ch.psi.pshell.ui.Plugin; + +/** + * + */ +public class TestPlugin extends Plugin{ + MainPanel panel; + @Override + protected void onStart() { + panel = new MainPanel(); + getView().getDocumentsTab().insertTab("Main",null,panel,null,0); + getView().getDocumentsTab().setSelectedComponent(panel); + } + + @Override + protected void onStop() { + + } +}