Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/virtuosotechnologies/asaph/standardgui/MainFieldsEditor.java


1   /*
2   ================================================================================
3   
4     FILE:  MainFieldsEditor.java
5     
6     PROJECT:
7     
8       Asaph
9     
10    CONTENTS:
11    
12      Editor swing components for the title, author and copyright fields
13    
14    PROGRAMMERS:
15    
16      Daniel Azuma (DA)  <dazuma@kagi.com>
17    
18    COPYRIGHT:
19    
20      Copyright (C) 2003  Daniel Azuma  (dazuma@kagi.com)
21      
22      This program is free software; you can redistribute it and/or
23      modify it under the terms of the GNU General Public License as
24      published by the Free Software Foundation; either version 2
25      of the License, or (at your option) any later version.
26      
27      This program is distributed in the hope that it will be useful,
28      but WITHOUT ANY WARRANTY; without even the implied warranty of
29      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30      GNU General Public License for more details.
31      
32      You should have received a copy of the GNU General Public
33      License along with this program; if not, write to
34        Free Software Foundation, Inc.
35        59 Temple Place, Suite 330
36        Boston, MA 02111-1307 USA
37  
38  ================================================================================
39  */
40  
41  
42  package com.virtuosotechnologies.asaph.standardgui;
43  
44  
45  import java.awt.GridBagLayout;
46  import java.awt.GridBagConstraints;
47  import java.awt.Insets;
48  import javax.swing.JPanel;
49  import javax.swing.JLabel;
50  import javax.swing.JTextField;
51  import javax.swing.event.UndoableEditListener;
52  
53  import com.virtuosotechnologies.asaph.model.Song;
54  import com.virtuosotechnologies.asaph.model.StringField;
55  
56  
57  /**
58   * Editor swing components for the title, author and copyright fields
59   */
60  /*package*/ class MainFieldsEditor
61  extends JPanel
62  {
63    private static final String STR_MainFieldsEditor_TitleLabel =
64      ResourceAccess.Strings.buildString("MainFieldsEditor_TitleLabel");
65    private static final String STR_MainFieldsEditor_AuthorLabel =
66      ResourceAccess.Strings.buildString("MainFieldsEditor_AuthorLabel");
67    private static final String STR_MainFieldsEditor_CopyrightLabel =
68      ResourceAccess.Strings.buildString("MainFieldsEditor_CopyrightLabel");
69    private static final String STR_MainFieldsEditor_CommentLabel =
70      ResourceAccess.Strings.buildString("MainFieldsEditor_CommentLabel");
71    
72    
73    /**
74     * Constructor
75     */
76    /*package*/ MainFieldsEditor(
77      Song song,
78      SongEditor editor,
79      UndoableEditListener undoListener)
80    {
81      super(new GridBagLayout());
82      GridBagConstraints gbc = new GridBagConstraints();
83      
84      addField(STR_MainFieldsEditor_TitleLabel, Song.MAINTITLE_FIELD,
85        gbc, song, editor, undoListener);
86      addField(STR_MainFieldsEditor_CommentLabel, Song.COMMENT_FIELD,
87        gbc, song, editor, undoListener);
88      addField(STR_MainFieldsEditor_AuthorLabel, Song.AUTHOR_FIELD,
89        gbc, song, editor, undoListener);
90      addField(STR_MainFieldsEditor_CopyrightLabel, Song.COPYRIGHT_FIELD,
91        gbc, song, editor, undoListener);
92    }
93    
94    
95    private void addField(
96      String labelStr,
97      String fieldName,
98      GridBagConstraints gbc,
99      Song song,
100     SongEditor editor,
101     UndoableEditListener undoListener)
102   {
103     JLabel label = new JLabel(labelStr);
104     gbc.gridx = 0;
105     gbc.weightx = 0;
106     gbc.fill = GridBagConstraints.NONE;
107     gbc.anchor = GridBagConstraints.EAST;
108     gbc.insets = new Insets(0, 0, 2, 5);
109     add(label, gbc);
110     
111     StringField songField = (StringField)song.getNamedField(fieldName);
112     JTextField textField = new JTextField(songField.getString());
113     gbc.gridx = 1;
114     gbc.weightx = 1;
115     gbc.fill = GridBagConstraints.HORIZONTAL;
116     gbc.anchor = GridBagConstraints.WEST;
117     gbc.insets = new Insets(0, 0, 2, 0);
118     add(textField, gbc);
119     StringUpdater.install(textField, songField, editor, undoListener);
120   }
121 }