Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 11 of 11

Thread: Editing open source code- tracing a value set to a concrete variable

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Editing open source code- tracing a value set to a concrete variable

    Hello, all. I apologize in advance for this undoubtedly foolish question, but I am very new to Java and programming in general, so I appreciate any assistance that can be given.

    I need to modify some of the code in this open source point-of-sale software for an internship and I (believe) that in order to do this I need to do an if then else statement using a variable set in the attached code. In this panel the customer tax category is set using a drop-down box (as shown in the screenshot) and I am unable to tell what is done with this information as I need this for the statement.

    I have attached the code, though I am unsure if I have given all that is required as the program itself is quite large, modularized, and sparsely commented. I am happy to provide any other files that are required.

    Thanks in advance.
    Attached Images Attached Images
    Attached Files Attached Files


  2. #2
    Junior Member Mrc0d3r's Avatar
    Join Date
    Jun 2011
    Location
    TCP/IP Layer 3
    Posts
    25
    My Mood
    Bored
    Thanks
    0
    Thanked 6 Times in 5 Posts

    Default Re: Editing open source code- tracing a value set to a concrete variable

    Post the portion of code (wrapped up in code tags) you require help with.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Editing open source code- tracing a value set to a concrete variable

    I need to modify some of the code
    That is a very vague statement of your problem. You will need to be a lot more specific
    I am unable to tell what is done with this information as I need this for the statement.
    The names of the variables and the names of the methods involved would be useful here.

  4. #4
    Junior Member
    Join Date
    Aug 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Editing open source code- tracing a value set to a concrete variable

    Thank you for the replies and apologies for being vague.

    It appears, to me at least, that the variable that I am looking could be m_jCategory as this appears to be what is set to the drop box in question (set to true and false values to handle usage). However, it seems to be defined in another module of the code relating to something different entirely, so I am unfortunately not sure of that either.

    For quick reference:

    ...
     
    m_jTaxID.setEnabled(false);
            m_jSearchkey.setEnabled(false);
            m_jName.setEnabled(false);
            m_jCategory.setEnabled(false);
            m_jNotes.setEnabled(false);
            txtMaxdebt.setEnabled(false);
            txtCurdebt.setEnabled(false);
            txtCurdate.setEnabled(false);
            m_jVisible.setEnabled(false);
            jcard.setEnabled(false);
     
    ...
     
     m_jTaxID.setEnabled(true);
            m_jSearchkey.setEnabled(true);
            m_jName.setEnabled(true);
            m_jCategory.setEnabled(true);
            m_jNotes.setEnabled(true);
            txtMaxdebt.setEnabled(true);
            txtCurdebt.setEnabled(true);
            txtCurdate.setEnabled(true);
            m_jVisible.setEnabled(true);
            jcard.setEnabled(true);
     
    ...
     
      txtAddress.setEnabled(false);
            txtAddress2.setEnabled(false);
            txtPostal.setEnabled(false);
            txtCity.setEnabled(false);
            txtRegion.setEnabled(false);
            txtCountry.setEnabled(false);        
            m_jCategory.setEnabled(false);        
            jButton2.setEnabled(false);
            jButton3.setEnabled(false);
     
    ...
     
     txtAddress.setEnabled(true);
            txtAddress2.setEnabled(true);
            txtPostal.setEnabled(true);
            txtCity.setEnabled(true);
            txtRegion.setEnabled(true);
            txtCountry.setEnabled(true);        
            m_jCategory.setEnabled(true);        
            jButton2.setEnabled(true);
            jButton3.setEnabled(true);

    and in the generated code at the bottom:

    ...
     
    m_jName = new javax.swing.JTextField();
            jLabel4 = new javax.swing.JLabel();
            m_jVisible = new javax.swing.JCheckBox();
            jLabel5 = new javax.swing.JLabel();
            jcard = new javax.swing.JTextField();
            jLabel9 = new javax.swing.JLabel();
            m_jCategory = new javax.swing.JComboBox();
            jButton2 = new javax.swing.JButton();
            jButton3 = new javax.swing.JButton();
            jLabel1 = new javax.swing.JLabel();
            txtMaxdebt = new javax.swing.JTextField();
            jTabbedPane1 = new javax.swing.JTabbedPane();
     
    ...
     
     .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jcard, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(12, 12, 12)
                                        .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton3)))

    I suppose what has me confused is that a document listener is used to put (somehow) the customer information into the database. I am looking for the customer tax category (not even a real value is needed, just whether or not it is null) for the if-then statement that I will put in another section of the code. I do not need assistance with that part as that is straightforward, and this is what I had meant by "some of the code" in my original message. I just need to somehow chase down the variable that corresponds to the customer tax category, and I realize that I probably convoluted the issue in explaining it as I did.

    I hope that I was able to be a bit more forthcoming with what I'm looking for help with this time, but please let me know if you need more information.

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Editing open source code- tracing a value set to a concrete variable

    Sorry, that generated code looks like it came from some IDE.
    I would not want to try to understand what it does.
    You'll have to use the IDE to make changes.
    Good luck.

  6. #6
    Junior Member
    Join Date
    Aug 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Editing open source code- tracing a value set to a concrete variable

    Yes, I think the code is from Netbeans or similar. Editing the code shouldn't be a problem because this particular file will not need the final change. I simply need to figure out how to find what variable is set to a value through the customer tax category drop box and tracking it down is a bit wooly as you've noticed lol.

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Editing open source code- tracing a value set to a concrete variable

    how to find what variable is set to a value
    The way I find where a variable is set to a value is by doing a Search in the file for: "variablename =" or "variablename=" to find where the variable is set a value.

    But you are looking at going the other way. You have a value and want to know what variable it is going to. Find the value and track it from where it starts to where ever it goes.
    Where does the value start from?

  8. #8
    Junior Member
    Join Date
    Aug 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Editing open source code- tracing a value set to a concrete variable

    Customer tax categories are created through user input in the following panel:

    The graphical part
     
    public class TaxCustCategoriesEditor extends JPanel implements EditorRecord {
     
        private Object m_oId;
     
        /** Creates new form taxEditor */
        public TaxCustCategoriesEditor(DirtyManager dirty) {
            initComponents();
     
            m_jName.getDocument().addDocumentListener(dirty);
     
            writeValueEOF();
        }
        public void writeValueEOF() {
            m_oId = null;
            m_jName.setText(null);
            m_jName.setEnabled(false);
        }
        public void writeValueInsert() {
            m_oId = UUID.randomUUID().toString();
            m_jName.setText(null);
            m_jName.setEnabled(true);
        }
        public void writeValueDelete(Object value) {
     
            Object[] taxcustcat = (Object[]) value;
            m_oId = taxcustcat[0];
            m_jName.setText(Formats.STRING.formatValue(taxcustcat[1]));
            m_jName.setEnabled(false);
        }    
        public void writeValueEdit(Object value) {
     
            Object[] taxcustcat = (Object[]) value;
            m_oId = taxcustcat[0];
            m_jName.setText(Formats.STRING.formatValue(taxcustcat[1]));
            m_jName.setEnabled(true);
        }
     
        public Object createValue() throws BasicException {
     
            Object[] taxcustcat = new Object[2];
     
            taxcustcat[0] = m_oId;
            taxcustcat[1] = m_jName.getText();
     
            return taxcustcat;
        }    
     
        public Component getComponent() {
            return this;
        }
     
        public void refresh() {
        }
     
        /** 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">                          
        private void initComponents() {
     
            jLabel2 = new javax.swing.JLabel();
            m_jName = new javax.swing.JTextField();
     
            setLayout(null);
     
            jLabel2.setText(AppLocal.getIntString("Label.Name")); // NOI18N
            add(jLabel2);
            jLabel2.setBounds(20, 20, 80, 15);
            add(m_jName);
            m_jName.setBounds(100, 20, 200, 19);
        }// </editor-fold>                        
     
     
        // Variables declaration - do not modify                     
        private javax.swing.JLabel jLabel2;
        private javax.swing.JTextField m_jName;
        // End of variables declaration                   
     
    }

    and this is what I am guessing to be the guts thereof:

    //    Openbravo POS is a point of sales application designed for touch screens.
    //    Copyright (C) 2008-2009 Openbravo, S.L.
    //    http://www.openbravo.com/product/pos
    //
    //    This file is part of Openbravo POS.
    //
    //    Openbravo POS 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.
    //
    //    Openbravo POS 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 Openbravo POS.  If not, see <http://www.gnu.org/licenses/>.
     
    package com.openbravo.pos.inventory;
     
    import com.openbravo.pos.panels.*;
    import javax.swing.ListCellRenderer;
    import com.openbravo.data.gui.ListCellRendererBasic;
    import com.openbravo.data.loader.ComparatorCreator;
    import com.openbravo.pos.forms.AppLocal;
    import com.openbravo.data.loader.TableDefinition;
    import com.openbravo.data.loader.Vectorer;
    import com.openbravo.data.user.EditorRecord;
    import com.openbravo.data.user.SaveProvider;
    import com.openbravo.data.user.ListProvider;
    import com.openbravo.data.user.ListProviderCreator;
    import com.openbravo.pos.forms.DataLogicSales;
     
    /**
     *
     * @author adrianromero
     */
    public class TaxCustCategoriesPanel extends JPanelTable {
     
        private TableDefinition ttaxcategories;
        private TaxCustCategoriesEditor jeditor;
     
        /** Creates a new instance of JPanelDuty */
        public TaxCustCategoriesPanel() {
        }
     
        protected void init() {
            DataLogicSales dlSales = (DataLogicSales) app.getBean("com.openbravo.pos.forms.DataLogicSales");        
            ttaxcategories = dlSales.getTableTaxCustCategories();
            jeditor = new TaxCustCategoriesEditor(dirty);
        }
     
        public ListProvider getListProvider() {
            return new ListProviderCreator(ttaxcategories);
        }
     
        public SaveProvider getSaveProvider() {
            return new SaveProvider(ttaxcategories);      
        }
     
        @Override
        public Vectorer getVectorer() {
            return ttaxcategories.getVectorerBasic(new int[]{1});
        }
     
        @Override
        public ComparatorCreator getComparatorCreator() {
            return ttaxcategories.getComparatorCreator(new int[] {1});
        }
     
        @Override
        public ListCellRenderer getListCellRenderer() {
            return new ListCellRendererBasic(ttaxcategories.getRenderStringBasic(new int[]{1}));
        }
     
        public EditorRecord getEditor() {
            return jeditor;
        }
     
        public String getTitle() {
            return AppLocal.getIntString("Menu.TaxCustCategories");
        }     
    }

    Any categories that are created using this form will be available to select in the drop box put forward in the above posts. The values of what is created here is what I will be wanting to check for a value (any value as the default will be null).

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Editing open source code- tracing a value set to a concrete variable

    The values of what is created here is what I will be wanting to check for a value
    How are values created there? Are they returned by a method?
    Add printlns before all the return statements to show what is being returned. Maybe you can see the value you are looking for in the print out. Be sure to have unique id Strings on all print outs so you will know where they came from.

  10. #10
    Junior Member
    Join Date
    Aug 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Editing open source code- tracing a value set to a concrete variable

    I believe that I have found at least where the information is put into the database. Running the debugger yielded the following when creating a new customer tax category:

    Aug 21, 2011 6:32:45 PM com.openbravo.data.loader.PreparedSentence openExec
    INFO: Executing prepared SQL: select ID, NAME from TAXCUSTCATEGORIES
    Aug 21, 2011 6:32:57 PM com.openbravo.data.loader.PreparedSentence openExec
    INFO: Executing prepared SQL: insert into TAXCUSTCATEGORIES (ID, NAME) values (?, ?)

    To answer your previous questions, I am not sure if they are returned by a method, but the values are created by the user entering a string into the text boxes provided and saving them (ie "tax exempt" etc). Based on this output, I'm assuming that this is put into the TAXCUSTCATEGORIES section of the database.

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Editing open source code- tracing a value set to a concrete variable

    Sorry, I know nothing about databases.

Similar Threads

  1. jsp/java based open source project
    By the light in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: July 17th, 2011, 03:24 AM
  2. Invitation for Open Source Project
    By rcbandit2 in forum Web Frameworks
    Replies: 3
    Last Post: June 9th, 2011, 08:05 AM
  3. Replies: 0
    Last Post: July 2nd, 2010, 01:56 PM
  4. How can i add a new count to this source code ?
    By mm2236 in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: January 30th, 2010, 10:21 PM
  5. Which is better for reporting tool: open source or charge?
    By freezea in forum JDBC & Databases
    Replies: 1
    Last Post: August 11th, 2009, 03:09 PM