diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/GenObsConfigPanel.form b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/GenObsConfigPanel.form new file mode 100644 index 0000000000000000000000000000000000000000..6c345bd828efaf12f11f904d00d943646ceb82bd --- /dev/null +++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/GenObsConfigPanel.form @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="70" pref="70" max="70" attributes="0"/> + <Component id="jLabel1" min="-2" pref="460" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="40" pref="40" max="40" attributes="0"/> + <Component id="NodeCancelButton" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="15" max="-2" attributes="0"/> + <Component id="NodeApplyButton" min="-2" pref="70" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace min="-2" pref="97" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="10" pref="10" max="10" attributes="0"/> + <Component id="jLabel1" min="-2" pref="20" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="250" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="NodeApplyButton" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="NodeCancelButton" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="NodeCancelButton"> + <Properties> + <Property name="text" type="java.lang.String" value="Cancel"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="NodeCancelButtonActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="NodeApplyButton"> + <Properties> + <Property name="text" type="java.lang.String" value="Apply"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="NodeApplyButtonActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" value="Node View Panel"/> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/GenObsConfigPanel.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/GenObsConfigPanel.java new file mode 100644 index 0000000000000000000000000000000000000000..05296bd3dc04ac8bcfc9c42313156ae92e14a520 --- /dev/null +++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/GenObsConfigPanel.java @@ -0,0 +1,263 @@ +/* + * GenObsConfigPanel.java + * + *Panel to set some general Observation configuration values + * + * Created on 18 May 2006, 09:47 + */ + +package nl.astron.lofar.sas.otbcomponents; + +import java.rmi.RemoteException; +import nl.astron.lofar.sas.otb.MainFrame; +import nl.astron.lofar.sas.otb.jotdb2.jOTDBnode; +import nl.astron.lofar.sas.otb.util.IViewPanel; +import nl.astron.lofar.sas.otb.util.OtdbRmi; +import nl.astron.lofar.sas.otb.util.UserAccount; +import org.apache.log4j.Logger; + +/** + * + * @author coolen + */ +public class GenObsConfigPanel extends javax.swing.JPanel implements IViewPanel{ + + static Logger logger = Logger.getLogger(GenObsConfigPanel.class); + static String name = "GenObsConfig"; + + + /** Creates new form BeanForm based upon aNode + * + * @params aNode node to obtain the info from + * + */ + public GenObsConfigPanel(MainFrame aMainFrame,jOTDBnode aNode) { + initComponents(); + itsMainFrame = aMainFrame; + itsNode=aNode; + itsOtdbRmi=itsMainFrame.getSharedVars().getOTDBrmi(); + initPanel(); + } + + /** Creates new form BeanForm */ + public GenObsConfigPanel() { + initComponents(); + } + + public void setMainFrame(MainFrame aMainFrame) { + if (aMainFrame != null) { + itsMainFrame=aMainFrame; + itsOtdbRmi=itsMainFrame.getSharedVars().getOTDBrmi(); + } else { + logger.debug("No Mainframe supplied"); + } + } + + public String getShortName() { + return name; + } + + public void setContent(Object anObject) { + itsNode=(jOTDBnode)anObject; + initPanel(); + } + + private void initPanel() { + // check access + UserAccount userAccount = itsMainFrame.getUserAccount(); + + // for now: + // set fields that can be changed here for now, later in the useraccount check + + + if(userAccount.isAdministrator()) { + // enable/disable certain controls + } + if(userAccount.isAstronomer()) { + // enable/disable certain controls + } + if(userAccount.isInstrumentScientist()) { + // enable/disable certain controls + } + + + + if (itsNode != null) { + setNodeName(itsNode.name); + } else { + logger.debug("ERROR: no node given"); + } + } + + + private String getNodeName() { +// return this.NodeNameText.getText(); + return ""; + } + + private void setNodeName(String aS) { +// this.NodeNameText.setText(aS); + } + + private void enableNodeName(boolean enabled) { +// this.NodeNameText.setEnabled(enabled); + } + + /** Enables/disables the buttons + * + * @param enabled true/false enabled/disabled + */ + public void enableButtons(boolean enabled) { + this.NodeApplyButton.setEnabled(enabled); + this.NodeCancelButton.setEnabled(enabled); + } + + /** Sets the buttons visible/invisible + * + * @param visible true/false visible/invisible + */ + public void setButtonsVisible(boolean visible) { + this.NodeApplyButton.setVisible(visible); + this.NodeCancelButton.setVisible(visible); + } + + /** Enables/disables the complete form + * + * @param enabled true/false enabled/disabled + */ + public void setAllEnabled(boolean enabled) { + enableNodeName(enabled); + enableButtons(enabled); + } + + private void saveInput() { + // Just check all possible fields that CAN change. The enabled method will take care if they COULD be changed. + // this way we keep this panel general for multiple use + boolean hasChanged = false; + if (itsNode != null) { + + } else { + logger.debug("ERROR: no Param given"); + } + } + /** 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. + */ + // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents + private void initComponents() { + NodeCancelButton = new javax.swing.JButton(); + NodeApplyButton = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + + NodeCancelButton.setText("Cancel"); + NodeCancelButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + NodeCancelButtonActionPerformed(evt); + } + }); + + NodeApplyButton.setText("Apply"); + NodeApplyButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + NodeApplyButtonActionPerformed(evt); + } + }); + + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setText("Node View Panel"); + + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(70, 70, 70) + .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 460, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(layout.createSequentialGroup() + .add(40, 40, 40) + .add(NodeCancelButton) + .add(15, 15, 15) + .add(NodeApplyButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .add(97, 97, 97)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(10, 10, 10) + .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(250, 250, 250) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(NodeApplyButton) + .add(NodeCancelButton))) + ); + }// </editor-fold>//GEN-END:initComponents + + private void NodeApplyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NodeApplyButtonActionPerformed + saveInput(); + }//GEN-LAST:event_NodeApplyButtonActionPerformed + + private void NodeCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NodeCancelButtonActionPerformed + initPanel(); + }//GEN-LAST:event_NodeCancelButtonActionPerformed + + private jOTDBnode itsNode = null; + private MainFrame itsMainFrame; + private OtdbRmi itsOtdbRmi; + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton NodeApplyButton; + private javax.swing.JButton NodeCancelButton; + private javax.swing.JLabel jLabel1; + // End of variables declaration//GEN-END:variables + + /** + * Utility field used by event firing mechanism. + */ + private javax.swing.event.EventListenerList listenerList = null; + + /** + * Registers ActionListener to receive events. + * @param listener The listener to register. + */ + public synchronized void addActionListener(java.awt.event.ActionListener listener) { + + if (listenerList == null ) { + listenerList = new javax.swing.event.EventListenerList(); + } + listenerList.add (java.awt.event.ActionListener.class, listener); + } + + /** + * Removes ActionListener from the list of listeners. + * @param listener The listener to remove. + */ + public synchronized void removeActionListener(java.awt.event.ActionListener listener) { + + listenerList.remove (java.awt.event.ActionListener.class, listener); + } + + /** + * Notifies all registered listeners about the event. + * + * @param event The event to be fired + */ + private void fireActionListenerActionPerformed(java.awt.event.ActionEvent event) { + + if (listenerList == null) return; + Object[] listeners = listenerList.getListenerList (); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i]==java.awt.event.ActionListener.class) { + ((java.awt.event.ActionListener)listeners[i+1]).actionPerformed (event); + } + } + } + + + + + +}