Skip to content

Commit 0d94b7e

Browse files
committed
WIP
mejora gridBagConstraints mejora colores added getContentPaneFromMyTab() added getButtonPanel()
1 parent 0aeec45 commit 0d94b7e

2 files changed

Lines changed: 119 additions & 51 deletions

File tree

Tutorial-o-Matic/Tutorial-o-Matic.mm

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<map version="freeplane 1.9.8">
22
<!--To view this file, download free mind mapping software Freeplane from http://freeplane.sourceforge.net -->
3-
<node TEXT="Tutorial-o-Matic" FOLDED="false" ID="ID_696401721" CREATED="1632150064080" MODIFIED="1632151614538" LINK="https://github.com/EdoFro/Freeplane_Tutorial-o-Matic" BACKGROUND_COLOR="#97c7dc">
3+
<node TEXT="Tutorial-o-Matic" FOLDED="false" ID="ID_696401721" LINK="https://github.com/EdoFro/Freeplane_Tutorial-o-Matic" BACKGROUND_COLOR="#97c7dc">
44
<font SIZE="16" BOLD="true" ITALIC="true"/>
55
<attribute_layout NAME_WIDTH="111.75 pt" VALUE_WIDTH="165.75 pt"/>
66
<attribute NAME="name" VALUE="tutorialOMatic"/>
@@ -130,7 +130,7 @@
130130
</map_styles>
131131
</hook>
132132
<hook NAME="AutomaticEdgeColor" COUNTER="13" RULE="ON_BRANCH_CREATION"/>
133-
<node TEXT="description" POSITION="left" ID="ID_1678998363" CREATED="1632150064153" MODIFIED="1632151614580">
133+
<node TEXT="description" POSITION="left" ID="ID_1678998363">
134134
<edge COLOR="#ff0000"/>
135135
<richcontent TYPE="NOTE" CONTENT-TYPE="xml/">
136136
<html>
@@ -150,9 +150,9 @@
150150
</body>
151151
</html>
152152
</richcontent>
153-
<node TEXT="Tutorial-o-Matic for Freeplane!!&#xa;Tutorial-o-Matic is an AddOn for Freeplane that gives the user the possibility to create his/her own tutorials." ID="ID_1642042079" CREATED="1632150064153" MODIFIED="1632150064153"/>
153+
<node TEXT="Tutorial-o-Matic for Freeplane!!&#xa;Tutorial-o-Matic is an AddOn for Freeplane that gives the user the possibility to create his/her own tutorials." ID="ID_1642042079"/>
154154
</node>
155-
<node TEXT="changes" POSITION="left" ID="ID_461119253" CREATED="1632150064153" MODIFIED="1632151614582">
155+
<node TEXT="changes" POSITION="left" ID="ID_461119253">
156156
<edge COLOR="#0000ff"/>
157157
<richcontent TYPE="NOTE" CONTENT-TYPE="xml/">
158158
<html>
@@ -167,7 +167,7 @@
167167
</html>
168168
</richcontent>
169169
</node>
170-
<node TEXT="license" FOLDED="true" POSITION="left" ID="ID_624388795" CREATED="1632150064154" MODIFIED="1632151614583">
170+
<node TEXT="license" FOLDED="true" POSITION="left" ID="ID_624388795">
171171
<edge COLOR="#00ff00"/>
172172
<richcontent TYPE="NOTE" CONTENT-TYPE="xml/">
173173
<html>
@@ -187,7 +187,7 @@
187187
</body>
188188
</html>
189189
</richcontent>
190-
<node ID="ID_444630498" CREATED="1632150064156" MODIFIED="1632150064156"><richcontent TYPE="NODE">
190+
<node ID="ID_444630498"><richcontent TYPE="NODE">
191191

192192
<html>
193193
<head>
@@ -262,7 +262,7 @@
262262
</richcontent>
263263
</node>
264264
</node>
265-
<node TEXT="preferences.xml" POSITION="left" ID="ID_1967714695" CREATED="1632150064157" MODIFIED="1632151614586">
265+
<node TEXT="preferences.xml" POSITION="left" ID="ID_1967714695">
266266
<edge COLOR="#ff00ff"/>
267267
<richcontent TYPE="NOTE" CONTENT-TYPE="xml/">
268268
<html>
@@ -280,7 +280,7 @@
280280
</html>
281281
</richcontent>
282282
</node>
283-
<node TEXT="default.properties" POSITION="left" ID="ID_1398497950" CREATED="1632150064157" MODIFIED="1632151614588">
283+
<node TEXT="default.properties" POSITION="left" ID="ID_1398497950">
284284
<edge COLOR="#00ffff"/>
285285
<richcontent TYPE="NOTE" CONTENT-TYPE="xml/">
286286
<html>
@@ -303,7 +303,7 @@ For each menu item with an icon add an attribute with the icon key (use develope
303303
</html>
304304
</richcontent>
305305
</node>
306-
<node TEXT="translations" POSITION="left" ID="ID_546877695" CREATED="1632150064157" MODIFIED="1632151614590">
306+
<node TEXT="translations" POSITION="left" ID="ID_546877695">
307307
<edge COLOR="#7c0000"/>
308308
<richcontent TYPE="NOTE" CONTENT-TYPE="xml/">
309309
<html>
@@ -328,14 +328,14 @@ For each menu item with an icon add an attribute with the icon key (use develope
328328
</body>
329329
</html>
330330
</richcontent>
331-
<node TEXT="en" ID="ID_1998059292" CREATED="1632150064157" MODIFIED="1632150064157">
331+
<node TEXT="en" ID="ID_1998059292">
332332
<attribute_layout NAME_WIDTH="162 pt" VALUE_WIDTH="281.24999 pt"/>
333333
<attribute NAME="addons.${name}" VALUE="Tutorial-o-Matic"/>
334334
<attribute NAME="addons.${name}.ActionInstruction1" VALUE="&lt;html&gt;In submenu &lt;b&gt;{0}&lt;/b&gt; &lt;br&gt;click on &lt;b&gt;{1}&lt;/b&gt;&lt;/html&gt;"/>
335335
<attribute NAME="addons.${name}.ActionInstruction2" VALUE="&lt;html&gt;You can also use de keyboard shortcut &lt;b&gt;{0}&lt;/b&gt; for this command&lt;/html&gt;"/>
336336
</node>
337337
</node>
338-
<node TEXT="deinstall" POSITION="left" ID="ID_378917294" CREATED="1632150064157" MODIFIED="1632151614592">
338+
<node TEXT="deinstall" POSITION="left" ID="ID_378917294">
339339
<edge COLOR="#00007c"/>
340340
<richcontent TYPE="NOTE" CONTENT-TYPE="xml/">
341341
<html>
@@ -355,7 +355,7 @@ For each menu item with an icon add an attribute with the icon key (use develope
355355
<attribute NAME="delete" VALUE="${installationbase}/addons/${name}/lib/markedj-1.0.16.jar"/>
356356
<attribute NAME="delete" VALUE="${installationbase}/addons/${name}/lib/jsoup-1.10.2.jar"/>
357357
</node>
358-
<node TEXT="scripts" POSITION="right" ID="ID_1037882722" CREATED="1632150064158" MODIFIED="1632151614598">
358+
<node TEXT="scripts" POSITION="right" ID="ID_1037882722">
359359
<edge COLOR="#007c00"/>
360360
<richcontent TYPE="NOTE" CONTENT-TYPE="xml/">
361361
<html>
@@ -475,7 +475,7 @@ For each menu item with an icon add an attribute with the icon key (use develope
475475
</html>
476476
</richcontent>
477477
</node>
478-
<node TEXT="lib" POSITION="right" ID="ID_1814812956" CREATED="1632150064158" MODIFIED="1632151614659">
478+
<node TEXT="lib" POSITION="right" ID="ID_1814812956">
479479
<edge COLOR="#7c007c"/>
480480
<richcontent TYPE="NOTE" CONTENT-TYPE="xml/">
481481
<html>
@@ -513,11 +513,11 @@ For each menu item with an icon add an attribute with the icon key (use develope
513513
</body>
514514
</html>
515515
</richcontent>
516-
<node TEXT="Tutorial-o-Matic.jar" ID="ID_1864463328" CREATED="1632150064158" MODIFIED="1632150064158"/>
517-
<node TEXT="markedj-1.0.16.jar" ID="ID_1060333872" CREATED="1632150064158" MODIFIED="1632150064158"/>
518-
<node TEXT="jsoup-1.10.2.jar" ID="ID_1151792763" CREATED="1632150064158" MODIFIED="1632150064158"/>
516+
<node TEXT="Tutorial-o-Matic.jar" ID="ID_1864463328"/>
517+
<node TEXT="markedj-1.0.16.jar" ID="ID_1060333872"/>
518+
<node TEXT="jsoup-1.10.2.jar" ID="ID_1151792763"/>
519519
</node>
520-
<node TEXT="zips" POSITION="right" ID="ID_1623122610" CREATED="1632150064158" MODIFIED="1632151614672">
520+
<node TEXT="zips" POSITION="right" ID="ID_1623122610">
521521
<edge COLOR="#007c7c"/>
522522
<richcontent TYPE="NOTE" CONTENT-TYPE="xml/">
523523
<html>
@@ -555,11 +555,11 @@ For each menu item with an icon add an attribute with the icon key (use develope
555555
</body>
556556
</html>
557557
</richcontent>
558-
<node TEXT="doc" ID="ID_281158802" CREATED="1632150064158" MODIFIED="1632150064158"/>
559-
<node TEXT="icons" ID="ID_211861022" CREATED="1632150064158" MODIFIED="1632150064158"/>
560-
<node TEXT="templates" ID="ID_553385296" CREATED="1632150064158" MODIFIED="1632150064158"/>
558+
<node TEXT="doc" ID="ID_281158802"/>
559+
<node TEXT="icons" ID="ID_211861022"/>
560+
<node TEXT="templates" ID="ID_553385296"/>
561561
</node>
562-
<node TEXT="images" POSITION="right" ID="ID_1856886559" CREATED="1632150064158" MODIFIED="1632151614689">
562+
<node TEXT="images" POSITION="right" ID="ID_1856886559">
563563
<edge COLOR="#7c7c00"/>
564564
<richcontent TYPE="NOTE" CONTENT-TYPE="xml/">
565565
<html>
@@ -594,12 +594,12 @@ For each menu item with an icon add an attribute with the icon key (use develope
594594
</html>
595595
</richcontent>
596596
</node>
597-
<node TEXT="DevTools - MoM" POSITION="right" ID="ID_989188638" CREATED="1632150064159" MODIFIED="1632150064159">
597+
<node TEXT="DevTools - MoM" POSITION="right" ID="ID_989188638">
598598
<edge COLOR="#ff0000"/>
599-
<node TEXT="Build add-on" ID="ID_1016684737" CREATED="1632150064159" MODIFIED="1632150064159" LINK="menuitem:_addons.devtools.checkAddOn_on_single_node">
599+
<node TEXT="Build add-on" ID="ID_1016684737" LINK="menuitem:_addons.devtools.checkAddOn_on_single_node">
600600
<icon BUILTIN="emoji-1F527"/>
601601
</node>
602-
<node TEXT="Package add-on for publication" ID="ID_806418866" CREATED="1632150064159" MODIFIED="1632150064159" LINK="menuitem:_addons.devtools.releaseAddOn_on_single_node">
602+
<node TEXT="Package add-on for publication" ID="ID_806418866" LINK="menuitem:_addons.devtools.releaseAddOn_on_single_node">
603603
<icon BUILTIN="emoji-1F5DC"/>
604604
</node>
605605
</node>

Tutorial-o-Matic/src/main/groovy/ToM_ui.groovy

Lines changed: 95 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import java.awt.Font
99
import java.awt.Insets
1010
import java.awt.GridBagConstraints
1111
import java.awt.Dimension
12-
//import java.awt.* //Insets
1312
import java.awt.GridBagLayout
1413

1514
// import javax.swing.*
1615
import javax.swing.border.EmptyBorder
17-
import javax.swing.border.LineBorder;
16+
import javax.swing.border.LineBorder
17+
import javax.swing.border.CompoundBorder
1818

1919
import groovy.swing.SwingBuilder
2020

@@ -25,9 +25,26 @@ import io.github.gitbucket.markedj.Marked
2525

2626
class ToM_ui{
2727

28-
static final myPaneName = 'PanelDeContenido'
29-
static SwingBuilder swing = new SwingBuilder()
30-
28+
static final int minContentPaneWidth = 408
29+
static final int maxContentPaneHeigth = 50000
30+
static final String myPaneName = 'PanelDeContenido'
31+
32+
static SwingBuilder swing = new SwingBuilder()
33+
34+
// info: https://docs.oracle.com/javase/7/docs/api/java/awt/GridBagConstraints.html
35+
static GridBagConstraints GBC = new GridBagConstraints(
36+
gridx : 0, // 0 -> allways first cell in a row
37+
gridy : GridBagConstraints.RELATIVE, // Relative -> The value RELATIVE specifies that the component be placed just below the component that was added to the container just before this component was added.
38+
gridwidth : 1, // Specifies the number of cells in a row for the component's display area.
39+
gridheight : 1, // Specifies the number of cells in a column for the component's display area.
40+
weightx : 1, // Specifies how to distribute extra horizontal space.
41+
weighty : 1, // Specifies how to distribute extra vertical space.
42+
anchor : GridBagConstraints.PAGE_START, // This field is used when the component is smaller than its display area. It determines where, within the display area, to place the component.
43+
fill : GridBagConstraints.HORIZONTAL, // This field is used when the component's display area is larger than the component's requested size. It determines whether to resize the component, and if so, how.
44+
insets : new Insets(5,2,5,2), // This field specifies the external padding of the component, the minimum amount of space between the component and the edges of its display area.
45+
ipadx : 0, // This field specifies the internal padding of the component, how much space to add to the minimum width of the component. The width of the component is at least its minimum width plus ipadx pixels.
46+
ipady : 0 // This field specifies the internal padding, that is, how much space to add to the minimum height of the component. The height of the component is at least its minimum height plus ipady pixels.
47+
)
3148

3249
def static showTextMessage(msg, lapseTime){
3350
def win = swing.dialog(
@@ -54,20 +71,6 @@ class ToM_ui{
5471
}
5572
win.setVisible( true )
5673
}
57-
58-
def static getContainerGBC(){
59-
GridBagConstraints gbc = new GridBagConstraints();
60-
gbc.gridx = 0;
61-
gbc.gridy = GridBagConstraints.RELATIVE ;
62-
gbc.weighty = 1;
63-
gbc.weightx = 1; // <----------------
64-
gbc.fill = GridBagConstraints.HORIZONTAL; // <----------------
65-
gbc.anchor = GridBagConstraints.PAGE_START // FIRST_LINE_START // PAGE_START
66-
//gbc.ipadx = 50
67-
//gbc.ipady = 50
68-
gbc.insets = new Insets(10,2,0,2)
69-
return gbc
70-
}
7174

7275
def static getHtmlFromNote(nodo){
7376
def noteType = nodo.noteContentType
@@ -96,29 +99,40 @@ class ToM_ui{
9699
contentType : "text/html",
97100
text : html,
98101
//margin : new Insets(30,10,30,10),
99-
border : new EmptyBorder(6, 10, 6, 10), //new LineBorder(Color.black, 1),
100-
//preferredSize: new Dimension(408, 500),
102+
//border : new EmptyBorder(6, 10, 6, 10), //new LineBorder(Color.black, 1),
103+
border : new CompoundBorder(new LineBorder(Color.gray, 1),new EmptyBorder(5, 10, 5, 10))
104+
//preferredSize: new Dimension(minContentPaneWidth, 500),
101105
//lineWrap : true
102106
)
103107
}
104108

105-
def static resizeContentPanel(com, H){
106-
com.parent.preferredSize = new Dimension(408, H)
109+
def static resizeContentPanel(comp, height){
110+
comp.parent.preferredSize = new Dimension(minContentPaneWidth, height)
111+
}
112+
113+
114+
def static adjustHeight(comp){
115+
TabPane.repaint()
116+
def timer = new Timer()
117+
timer.runAfter(1000) {
118+
resizeContentPanel(comp, comp.height + 200)
119+
TabPane.repaint()
120+
}
107121
}
108122

109-
def static getTabContentPane(tabName,gbCons){
123+
def static getTabContentPane(tabName){
110124
def contentPane
111125
if( !TabPane.hasTab(tabName)) {
112126
contentPane = swing.panel(
113127
name: myPaneName,
114128
layout: new GridBagLayout(),
115-
background: Color.gray
129+
// background: Color.gray
116130
){}
117131
def panel = swing.panel(
118132
layout: new GridBagLayout(),
119-
preferredSize: new Dimension(408, 50000),
133+
preferredSize: new Dimension(minContentPaneWidth, maxContentPaneHeigth),
120134
){}
121-
panel.add(contentPane,gbCons)
135+
panel.add(contentPane,GBC)
122136
def sp = swing.scrollPane(){}
123137
sp.viewport.add(panel)
124138
TabPane.addTab(tabName, sp)
@@ -128,4 +142,58 @@ class ToM_ui{
128142
return contentPane
129143
}
130144

145+
def static getContentPaneFromMyTab(myTabName, doClear){
146+
def cPane = ToM_ui.getTabContentPane(myTabName)
147+
if(doClear) cPane.removeAll() //eliminar contenido existente en el panel
148+
TabPane.showTab(myTabName)
149+
ToM_ui.resizeContentPanel(cPane,maxContentPaneHeigth)
150+
return cPane
151+
}
152+
153+
// genera panel con botón
154+
def static getButtonPanel(htmlMsg, buttonLabel, buttonToolTip, buttonAction, boolean isToggleButton = false){
155+
def panel = swing.panel(
156+
border : new LineBorder(Color.gray, 1)
157+
) {
158+
borderLayout()
159+
editorPane(
160+
editable : false,
161+
contentType : "text/html",
162+
text : htmlMsg,
163+
margin : new Insets(30,10,30,10),
164+
border : new EmptyBorder(5, 10, 5, 10), // <------- éste
165+
//border: new CompoundBorder(new LineBorder(Color.green, 1),new EmptyBorder(5, 10, 5, 10)), // éste es de prueba poder ver el borde
166+
constraints : CENTER,
167+
)
168+
vbox(constraints:SOUTH) {
169+
panel(
170+
// border : new LineBorder(Color.black, 1),
171+
border : new EmptyBorder(5, 10, 5, 10), // <------- éste
172+
//border: new CompoundBorder(new LineBorder(Color.red, 1),new EmptyBorder(5, 10, 5, 10)) // éste es de prueba poder ver el borde
173+
//insets : new Insets(30,10,30,10),
174+
) {
175+
borderLayout()
176+
if (isToggleButton){
177+
toggleButton(
178+
label : buttonLabel,
179+
constraints : EAST,
180+
margin : new Insets(10,15,10,15),
181+
toolTipText : buttonToolTip,
182+
actionPerformed : buttonAction,
183+
)
184+
} else {
185+
button(
186+
label : buttonLabel,
187+
constraints : EAST,
188+
margin : new Insets(10,15,10,15),
189+
toolTipText : buttonToolTip,
190+
actionPerformed : buttonAction,
191+
)
192+
}
193+
}
194+
}
195+
}
196+
return panel
197+
}
198+
131199
}

0 commit comments

Comments
 (0)