diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/SharedVars.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/SharedVars.java index 8844e7152159b57c2e804982a35f8472b92fd4b6..cc0f86b192d74762a0b64e79881b493b6c1391e7 100644 --- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/SharedVars.java +++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/SharedVars.java @@ -25,6 +25,7 @@ package nl.astron.lofar.sas.otb; import java.rmi.Naming; +import java.rmi.RemoteException; import java.util.HashMap; import nl.astron.lofar.java.cep.jparmfacade.jParmFacadeInterface; import nl.astron.lofar.sas.otb.util.OtdbRmi; @@ -67,6 +68,8 @@ public class SharedVars { private int itsCurrentTreeID=0; // holds the current component ID private int itsCurrentComponentID=0; + // holds the treeState from the current tree + private int itsTreeState=-1; // holds the OtdbRmi Object (RMI/JNI access for OTDB) private static OtdbRmi itsOtdbRmi; // holds the jParmFacade Object (JNI access for ParmDB) @@ -83,9 +86,26 @@ public class SharedVars { /** sets the Current TreeID */ public void setTreeID(int aTreeID) { itsCurrentTreeID=aTreeID; + setTreeState(aTreeID); + } + + /** sets the Current TreeState */ + public void setTreeState(int aTreeID) { + try { + itsTreeState=itsOtdbRmi.getRemoteOTDB().getTreeInfo(aTreeID,false).state; + } catch (RemoteException ex) { + logger.debug("Exception during setTreeState(TreeID: "+aTreeID+")" ); + ex.printStackTrace(); + } + } + + /** gets the Current TreeState */ + public int getTreeState() { + return itsTreeState; } /** gets the Current ComponentID */ + public int getComponentID() { return itsCurrentComponentID; } @@ -142,6 +162,7 @@ public class SharedVars { itsCurrentTreeID=0; itsCurrentComponentID=0; + itsTreeState=-1; } diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/panels/TemplateMaintenancePanel.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/panels/TemplateMaintenancePanel.java index 81540b0df74711c8ec96d85442e0aee0a50fe3d8..6d614bf85632cec4c4a6957861130bbb9eea05de 100644 --- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/panels/TemplateMaintenancePanel.java +++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/panels/TemplateMaintenancePanel.java @@ -245,14 +245,18 @@ public class TemplateMaintenancePanel extends javax.swing.JPanel } } } else if (evt.getActionCommand().equals("Info")) { + int answer=JOptionPane.showConfirmDialog(this,"Altering the info wil automaticly close this Maintainance window. Do you want to continue ?","alert",JOptionPane.YES_NO_OPTION); if (itsTreeID > 0) { - if (viewInfo() ) { + if (viewInfo() && JOptionPane.YES_OPTION == answer) { logger.debug("Tree has been changed, reloading table line"); // flag has to be set that ppl using this treeid should be able to see that it's info has been changed itsMainFrame.setChanged(this.getFriendlyName(),true); + // if the treeinfo has been changed then it could be into a state where the loaded TemplateMaintenance panel + // is invalid (can not be changed anymore ) So it's better to close down this panel. + itsMainFrame.unregisterPlugin(this.getFriendlyName()); + itsMainFrame.showPanel(MainPanel.getFriendlyNameStatic()); } } - } else if (evt.getActionCommand().equals("Exit")) { itsMainFrame.unregisterPlugin(this.getFriendlyName()); itsMainFrame.showPanel(MainPanel.getFriendlyNameStatic()); diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/AccessRights.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/AccessRights.java new file mode 100644 index 0000000000000000000000000000000000000000..87ca65a5436a692878cff7c68ab3a63173bbdcd9 --- /dev/null +++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/AccessRights.java @@ -0,0 +1,79 @@ +/* + * AccessRights.java + * + * Copyright (C) 2002-2007 + * ASTRON (Netherlands Foundation for Research in Astronomy) + * P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package nl.astron.lofar.sas.otb.util; + +import nl.astron.lofar.sas.otb.MainFrame; +import nl.astron.lofar.sas.otb.jotdb2.jOTDBparam; + +/** + * @created 24-01-2007, 12:48 + * + * @author coolen + * + * @version $Id$ + * + * @updated + */ +public class AccessRights { + + private MainFrame itsMainFrame; + + /** Creates a new instance of AccessRights */ + public AccessRights() { + itsMainFrame = null; + } + + public void setMainFrame(MainFrame aMainFrame){ + itsMainFrame = aMainFrame; + } + /** + * Returns the accessrights for this parameter + * + * @param aParam the parameter you want to check accessrights on + * @return false if this param has no accessrights, otherwise true + */ + public boolean isWritable(jOTDBparam aParam) { + + int aTreeState= itsMainFrame.getSharedVars().getTreeState(); + + // if treeState == 0 all is allowed + if (aTreeState == 0) { + return true; + } + + // if treeState > 300 Nothing is allowed + if (aTreeState > 300) { + return false; + } + + short validation = aParam.valMoment; + + // all other cases (states between 0 and 300 inclusive) + // if validation = 0 All is allowed, otherwise nothing is allowed + if (validation == 0) { + return true; + } else { + return false; + } + } +} diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParameterViewPanel.form b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParameterViewPanel.form index d57836183b96b779acafa3d1aed2d1ab3fb43491..06b2f4a0dd7b4266433a5af18145ecbe3e9a6316 100644 --- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParameterViewPanel.form +++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParameterViewPanel.form @@ -149,6 +149,7 @@ </Component> <Component class="javax.swing.JTextField" name="ParamIndexText"> <Properties> + <Property name="editable" type="boolean" value="false"/> <Property name="text" type="java.lang.String" value="None"/> <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Dimension value="[200, 19]"/> @@ -163,6 +164,7 @@ </Component> <Component class="javax.swing.JTextField" name="ParamPruningText"> <Properties> + <Property name="editable" type="boolean" value="false"/> <Property name="text" type="java.lang.String" value="-1"/> <Property name="toolTipText" type="java.lang.String" value="Number of Instances for this Node "/> <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> @@ -178,6 +180,7 @@ </Component> <Component class="javax.swing.JTextField" name="ParamNameText"> <Properties> + <Property name="editable" type="boolean" value="false"/> <Property name="text" type="java.lang.String" value="None"/> <Property name="toolTipText" type="java.lang.String" value="Name for this Node"/> <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> @@ -206,9 +209,13 @@ <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ParamApplyButtonActionPerformed"/> </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="ParamApplyButton.setEnabled(false);"/> + </AuxValues> </Component> <Component class="javax.swing.JTextArea" name="ParamDescriptionText"> <Properties> + <Property name="editable" type="boolean" value="false"/> <Property name="rows" type="int" value="3"/> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> @@ -249,28 +256,32 @@ </Component> <Component class="javax.swing.JComboBox" name="ParamTypeText"> <Properties> - <Property name="editable" type="boolean" value="true"/> <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> <StringArray count="0"/> </Property> </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="ParamTypeText.setEnabled(false);"/> + </AuxValues> </Component> <Component class="javax.swing.JComboBox" name="ParamUnitText"> <Properties> - <Property name="editable" type="boolean" value="true"/> <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> <StringArray count="0"/> </Property> </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="ParamUnitText.setEnabled(false);"/> + </AuxValues> </Component> <Component class="javax.swing.JTextField" name="ParamValMomentText"> <Properties> + <Property name="editable" type="boolean" value="false"/> <Property name="text" type="java.lang.String" value="None"/> </Properties> </Component> <Component class="javax.swing.JComboBox" name="ParamRuntimeModText"> <Properties> - <Property name="editable" type="boolean" value="true"/> <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> <StringArray count="2"> <StringItem index="0" value="false"/> @@ -278,6 +289,9 @@ </StringArray> </Property> </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="ParamRuntimeModText.setEnabled(false);"/> + </AuxValues> </Component> <Component class="javax.swing.JLabel" name="derefLabel"> <Properties> @@ -301,6 +315,7 @@ <SubComponents> <Component class="javax.swing.JTextField" name="ParamLimitsText"> <Properties> + <Property name="editable" type="boolean" value="false"/> <Property name="text" type="java.lang.String" value="None"/> </Properties> <Constraints> @@ -321,6 +336,9 @@ </Property> <Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/> </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="ParamLimitsCombo.setEnabled(false);"/> + </AuxValues> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription"> <CardConstraints cardName="ComboCard"/> diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParameterViewPanel.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParameterViewPanel.java index 08835a82a8498e320216804992ee5a206cfef068..be5c1fd3613b292ad7fdaa7ddae8247b4f773039 100644 --- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParameterViewPanel.java +++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParameterViewPanel.java @@ -35,6 +35,7 @@ import nl.astron.lofar.lofarutils.LofarUtils; import nl.astron.lofar.sas.otb.MainFrame; import nl.astron.lofar.sas.otb.jotdb2.jOTDBnode; import nl.astron.lofar.sas.otb.jotdb2.jOTDBparam; +import nl.astron.lofar.sas.otb.util.AccessRights; import nl.astron.lofar.sas.otb.util.IViewPanel; import nl.astron.lofar.sas.otb.util.OtdbRmi; import nl.astron.lofar.sas.otb.util.UserAccount; @@ -208,7 +209,9 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel logger.debug("No choices provided for ParamLimits Combobox"); return; } - String[] choices = aS.split("[|]"); + // first strip input on ; because after the ; a default choice has been given. + String[] stripped = aS.split("[;]"); + String[] choices = stripped[0].split("[|]"); for (int i=0; i< choices.length;i++) { if (!choices[i].equals("")) { this.ParamLimitsCombo.addItem(choices[i]); @@ -257,12 +260,14 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel private void initPanel() { + if (itsAccessRights==null) { + itsAccessRights = new AccessRights(); + } + itsAccessRights.setMainFrame(itsMainFrame); + // check access UserAccount userAccount = itsMainFrame.getUserAccount(); - // For now: - enableLimits(true); - enableDescription(true); if(userAccount.isAdministrator()) { // enable/disable certain controls @@ -301,6 +306,9 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel setLimits(itsNode.limits); } setDescription(itsParam.description); + + // Check if the fields may be changed in this treestate/valmoment + setAllEnabled(itsAccessRights.isWritable(itsParam)); } else { logger.debug("ERROR: no Param given"); } @@ -316,6 +324,7 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel private void enableParamName(boolean enabled) { this.ParamNameText.setEnabled(enabled); + this.ParamNameText.setEditable(enabled); } private String getIndex() { @@ -328,6 +337,7 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel private void enableIndex(boolean enabled) { this.ParamIndexText.setEnabled(enabled); + this.ParamIndexText.setEditable(enabled); } private String getType() { @@ -344,6 +354,7 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel private void enableType(boolean enabled) { this.ParamTypeText.setEnabled(enabled); + this.ParamTypeText.setEditable(enabled); } private String getUnit() { @@ -360,6 +371,7 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel private void enableUnit(boolean enabled) { this.ParamUnitText.setEnabled(enabled); + this.ParamUnitText.setEditable(enabled); } private String getPruning() { @@ -372,6 +384,7 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel private void enablePruning(boolean enabled) { this.ParamPruningText.setEnabled(enabled); + this.ParamPruningText.setEditable(enabled); } private String getValMoment() { @@ -384,6 +397,7 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel private void enableValMoment(boolean enabled) { this.ParamValMomentText.setEnabled(enabled); + this.ParamValMomentText.setEditable(enabled); } private boolean getRuntimeMod() { @@ -404,6 +418,7 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel private void enableRuntimeMod(boolean enabled) { this.ParamRuntimeModText.setEnabled(enabled); + this.ParamRuntimeModText.setEditable(enabled); } @@ -421,6 +436,13 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel private void setLimits(String aS) { if (this.getType().substring(0,1).equals("p")) { + // The first time limits is set and it is a combochoice, the node will contain the complete list of choices. + // If this is the case, we will look if a default value is set in this string , deteremined by a ; at the end of the + // choice list. If it is found, the choice will be set accordingly + String split[] = aS.split("[;]"); + if (split.length > 1) { + aS=split[1]; + } this.ParamLimitsCombo.setSelectedItem(aS); } else { this.ParamLimitsText.setText(aS); @@ -434,6 +456,8 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel private void enableLimits(boolean enabled) { this.ParamLimitsCombo.setEnabled(enabled); this.ParamLimitsText.setEnabled(enabled); + this.ParamLimitsCombo.setEditable(enabled); + this.ParamLimitsText.setEditable(enabled); } private void enableDeref(boolean enabled) { @@ -591,17 +615,20 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel ParamLimitsLabel.setText("Value :"); + ParamIndexText.setEditable(false); ParamIndexText.setText("None"); ParamIndexText.setMaximumSize(new java.awt.Dimension(200, 19)); ParamIndexText.setMinimumSize(new java.awt.Dimension(200, 19)); ParamIndexText.setPreferredSize(new java.awt.Dimension(200, 19)); + ParamPruningText.setEditable(false); ParamPruningText.setText("-1"); ParamPruningText.setToolTipText("Number of Instances for this Node "); ParamPruningText.setMaximumSize(new java.awt.Dimension(200, 19)); ParamPruningText.setMinimumSize(new java.awt.Dimension(200, 19)); ParamPruningText.setPreferredSize(new java.awt.Dimension(200, 19)); + ParamNameText.setEditable(false); ParamNameText.setText("None"); ParamNameText.setToolTipText("Name for this Node"); ParamNameText.setMaximumSize(new java.awt.Dimension(440, 19)); @@ -616,12 +643,14 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel }); ParamApplyButton.setText("Apply"); + ParamApplyButton.setEnabled(false); ParamApplyButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ParamApplyButtonActionPerformed(evt); } }); + ParamDescriptionText.setEditable(false); ParamDescriptionText.setRows(3); ParamDescriptionText.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Description")); @@ -636,14 +665,15 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setText("Parameter View Panel"); - ParamTypeText.setEditable(true); + ParamTypeText.setEnabled(false); - ParamUnitText.setEditable(true); + ParamUnitText.setEnabled(false); + ParamValMomentText.setEditable(false); ParamValMomentText.setText("None"); - ParamRuntimeModText.setEditable(true); ParamRuntimeModText.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "false", "true" })); + ParamRuntimeModText.setEnabled(false); derefLabel.setText("Deref Value:"); derefLabel.setVisible(false); @@ -653,11 +683,13 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel CardPanel.setLayout(new java.awt.CardLayout()); + ParamLimitsText.setEditable(false); ParamLimitsText.setText("None"); CardPanel.add(ParamLimitsText, "TextCard"); ParamLimitsCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); ParamLimitsCombo.setVerifyInputWhenFocusTarget(false); + ParamLimitsCombo.setEnabled(false); CardPanel.add(ParamLimitsCombo, "ComboCard"); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); @@ -703,9 +735,8 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(ParamCancelButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(ParamApplyButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) - .add(68, 68, 68))) - .add(353, 353, 353)) + .add(ParamApplyButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))) + .add(421, 421, 421)) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) @@ -769,6 +800,7 @@ public class ParameterViewPanel extends javax.swing.JPanel implements IViewPanel private OtdbRmi itsOtdbRmi; private jOTDBnode itsNode; private jOTDBparam itsParam; + private AccessRights itsAccessRights; // Variables declaration - do not modify//GEN-BEGIN:variables