Class: Clevic::TagEditor
Overview
all this just to format a display item… .… and work around various other Swing stupidities
Instance Attribute Summary collapse
-
#add_button ⇒ Object
readonly
Returns the value of attribute add_button.
-
#cancel_button ⇒ Object
readonly
Returns the value of attribute cancel_button.
-
#entity ⇒ Object
readonly
Returns the value of attribute entity.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#item_list ⇒ Object
readonly
Returns the value of attribute item_list.
-
#ok_button ⇒ Object
readonly
Returns the value of attribute ok_button.
-
#remove_button ⇒ Object
readonly
Returns the value of attribute remove_button.
-
#text_field ⇒ Object
readonly
Returns the value of attribute text_field.
Instance Method Summary collapse
-
#configureEditor(editor, entity) ⇒ Object
Hopefully called by the editor framework might be init_component.
- #create_fields ⇒ Object
- #init_layout ⇒ Object
-
#initialize(field) ⇒ TagEditor
constructor
A new instance of TagEditor.
Constructor Details
#initialize(field) ⇒ TagEditor
Returns a new instance of TagEditor.
8 9 10 11 12 13 14 |
# File 'lib/clevic/swing/tag_editor.rb', line 8 def initialize( field ) super() @field = field create_fields init_layout end |
Instance Attribute Details
#add_button ⇒ Object (readonly)
Returns the value of attribute add_button.
26 27 28 |
# File 'lib/clevic/swing/tag_editor.rb', line 26 def @add_button end |
#cancel_button ⇒ Object (readonly)
Returns the value of attribute cancel_button.
26 27 28 |
# File 'lib/clevic/swing/tag_editor.rb', line 26 def @cancel_button end |
#entity ⇒ Object (readonly)
Returns the value of attribute entity.
17 18 19 |
# File 'lib/clevic/swing/tag_editor.rb', line 17 def entity @entity end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
16 17 18 |
# File 'lib/clevic/swing/tag_editor.rb', line 16 def field @field end |
#item_list ⇒ Object (readonly)
Returns the value of attribute item_list.
26 27 28 |
# File 'lib/clevic/swing/tag_editor.rb', line 26 def item_list @item_list end |
#ok_button ⇒ Object (readonly)
Returns the value of attribute ok_button.
26 27 28 |
# File 'lib/clevic/swing/tag_editor.rb', line 26 def @ok_button end |
#remove_button ⇒ Object (readonly)
Returns the value of attribute remove_button.
26 27 28 |
# File 'lib/clevic/swing/tag_editor.rb', line 26 def @remove_button end |
#text_field ⇒ Object (readonly)
Returns the value of attribute text_field.
26 27 28 |
# File 'lib/clevic/swing/tag_editor.rb', line 26 def text_field @text_field end |
Instance Method Details
#configureEditor(editor, entity) ⇒ Object
Hopefully called by the editor framework might be init_component
21 22 23 24 |
# File 'lib/clevic/swing/tag_editor.rb', line 21 def configureEditor( editor, entity ) @entity = entity item_list.model.one = entity end |
#create_fields ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/clevic/swing/tag_editor.rb', line 28 def create_fields @item_list = TableView.new( field.many_view ) @text_field = javax.swing.JTextField.new @ok_button = javax.swing.JButton.new @cancel_button = javax.swing.JButton.new @add_button = javax.swing.JButton.new @remove_button = javax.swing.JButton.new end |
#init_layout ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/clevic/swing/tag_editor.rb', line 38 def init_layout # This is mostly cut-n-pasted from the Netbeans Java sources. So don't tweak it. text_field.setName("text_field"); item_list.setName("item_list"); .setText("OK"); .setToolTipText("Accept edits"); .setName("ok_button"); .setText("Cancel"); .setToolTipText("Cancel edits"); .setName("cancel_button"); .setText("+"); .setToolTipText("Add a new item"); .setBorder(nil); .setName("add_button"); .setText("-"); .setToolTipText("Remove selected item"); .setBorder(nil); .setName("remove_button"); layout = org.jdesktop.layout.GroupLayout.new( self ); setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout::LEADING) \ .add(layout.createSequentialGroup() \ .addContainerGap() \ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout::LEADING) \ .add(item_list, org.jdesktop.layout.GroupLayout::DEFAULT_SIZE, 210, java.lang.Short::MAX_VALUE) \ .add(text_field, org.jdesktop.layout.GroupLayout::DEFAULT_SIZE, 210, java.lang.Short::MAX_VALUE) \ .add(layout.createSequentialGroup() \ .add() \ .addPreferredGap(org.jdesktop.layout.LayoutStyle::RELATED, 82, java.lang.Short::MAX_VALUE) \ .add()) \ .add(layout.createSequentialGroup() \ .add(, org.jdesktop.layout.GroupLayout::PREFERRED_SIZE, 27, org.jdesktop.layout.GroupLayout::PREFERRED_SIZE) \ .addPreferredGap(org.jdesktop.layout.LayoutStyle::RELATED) \ .add(, org.jdesktop.layout.GroupLayout::PREFERRED_SIZE, 27, org.jdesktop.layout.GroupLayout::PREFERRED_SIZE))) \ .addContainerGap()) \ ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout::LEADING) \ .add(layout.createSequentialGroup() \ .addContainerGap() \ .add(text_field, org.jdesktop.layout.GroupLayout::PREFERRED_SIZE, org.jdesktop.layout.GroupLayout::DEFAULT_SIZE, org.jdesktop.layout.GroupLayout::PREFERRED_SIZE) \ .add(18, 18, 18) \ .add(item_list, org.jdesktop.layout.GroupLayout::PREFERRED_SIZE, 202, org.jdesktop.layout.GroupLayout::PREFERRED_SIZE) \ .addPreferredGap(org.jdesktop.layout.LayoutStyle::RELATED) \ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout::BASELINE) \ .add(, org.jdesktop.layout.GroupLayout::PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout::PREFERRED_SIZE) \ .add(, org.jdesktop.layout.GroupLayout::PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout::PREFERRED_SIZE)) \ .addPreferredGap(org.jdesktop.layout.LayoutStyle::RELATED, 30, java.lang.Short::MAX_VALUE) \ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout::BASELINE) \ .add() \ .add()) \ .addContainerGap()) \ ); end |