Skip to content

Commit 5443269

Browse files
authored
Merge pull request #300 from cubitusgh2/MN_EFA_099_METEO_LEVEL_WIDGETS_250Base
Update Widgets: Better scrolling, retry on loading weather data.
2 parents 7c93cc0 + cba2a7f commit 5443269

19 files changed

+666
-216
lines changed

de/nmichael/efa/Daten.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public class Daten {
8080

8181
public final static String VERSIONID = "2.5.1_#9"; // VersionsID: Format: "X.Y.Z_MM"; final-Version z.B. 1.4.0_00;
8282
// beta-Version z.B. 1.4.0_#1 //# is not good, is used in efa.data.Waters
83-
public final static String VERSIONRELEASEDATE = "17.02.2026"; // Release Date: TT.MM.JJJJ
83+
public final static String VERSIONRELEASEDATE = "19.02.2026"; // Release Date: TT.MM.JJJJ
8484
public final static String MAJORVERSION = "2";
8585
public final static String PROGRAMMID = "EFA.251"; // Versions-ID für Wettbewerbsmeldungen
8686
public final static String PROGRAMMID_DRV = "EFADRV.251"; // Versions-ID für Wettbewerbsmeldungen

de/nmichael/efa/core/config/EfaConfig.java

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,6 @@ public class EfaConfig extends StorageObject implements IItemFactory {
342342
private ItemTypeColor efaGuiToolTipHeaderBackground;
343343
private ItemTypeColor efaGuiToolTipHeaderForeground;
344344

345-
private ItemTypeColor efaGuiErrorBackground;
346-
private ItemTypeColor efaGuiErrorForeground;
347-
private ItemTypeColor efaGuiErrorHeaderBackground;
348-
private ItemTypeColor efaGuiErrorHeaderForeground;
349-
350345
private ItemTypeStringList efaDirekt_bnrMsgToAdminDefaultRecipient;
351346
private ItemTypeBoolean efaDirekt_bnrError_admin;
352347
private ItemTypeBoolean efaDirekt_bnrError_bootswart;
@@ -1852,7 +1847,7 @@ private void iniParameters(CustSettings custSettings) {
18521847
crontab.setAppendPositionToEachElement(false);
18531848
crontab.setShortDescription("Task");
18541849
crontab.setRepeatTitle(true);
1855-
crontab.setShowUpDownButtons(false);
1850+
crontab.setShowUpDownButtons(true);
18561851

18571852
// ============================= DATA ACCESS =============================
18581853
addParameter(dataPreModifyRecordCallbackEnabled = new ItemTypeBoolean("DataPreModifyRecordCallbackEnabled",
@@ -3172,26 +3167,6 @@ public Color getToolTipHeaderForegroundColor() {
31723167
Color myColor = efaGuiToolTipHeaderForeground.getColor();
31733168
return (myColor != null ? myColor : standardToolTipHeaderForegroundColor);
31743169
}
3175-
3176-
public Color getErrorBackgroundColor() {
3177-
Color myColor = efaGuiErrorBackground.getColor();
3178-
return (myColor != null ? myColor : standardErrorBackgroundColor);
3179-
}
3180-
3181-
public Color getErrorForegroundColor() {
3182-
Color myColor = efaGuiErrorForeground.getColor();
3183-
return (myColor != null ? myColor : standardErrorForegroundColor);
3184-
}
3185-
3186-
public Color getErrorHeaderBackgroundColor() {
3187-
Color myColor = efaGuiErrorHeaderBackground.getColor();
3188-
return (myColor != null ? myColor : standardErrorHeaderBackgroundColor);
3189-
}
3190-
3191-
public Color getErrorHeaderForegroundColor() {
3192-
Color myColor = efaGuiErrorHeaderForeground.getColor();
3193-
return (myColor != null ? myColor : standardErrorHeaderForegroundColor);
3194-
}
31953170

31963171
public Boolean getHeaderUseHighlightColor() {
31973172
return efaHeaderUseHighlightColor.getValue();

de/nmichael/efa/core/items/ItemTypeCronEntry.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
package de.nmichael.efa.core.items;
1212

13-
import de.nmichael.efa.util.Dialog;
14-
import de.nmichael.efa.util.EfaUtil;
15-
import de.nmichael.efa.util.International;
1613
import java.awt.Color;
1714
import java.awt.Dimension;
1815
import java.awt.GridBagConstraints;
@@ -25,11 +22,16 @@
2522
import java.util.Calendar;
2623
import java.util.GregorianCalendar;
2724
import java.util.StringTokenizer;
25+
2826
import javax.swing.JComponent;
2927
import javax.swing.JLabel;
3028
import javax.swing.JPanel;
3129
import javax.swing.JTextField;
3230

31+
import de.nmichael.efa.util.Dialog;
32+
import de.nmichael.efa.util.EfaUtil;
33+
import de.nmichael.efa.util.International;
34+
3335
public class ItemTypeCronEntry extends ItemTypeLabelValue {
3436

3537
private static final String FIELD_SEPARATOR = ";";
@@ -232,8 +234,8 @@ protected JComponent initializeField() {
232234
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 2), 0, 0));
233235
fFrequency.setForeground(Color.blue);
234236
Dimension dim = p.getPreferredSize();
235-
p.validate();
236-
setFieldSize(Math.min(dim.width, 670), Math.min(dim.height, 7*24));
237+
p.revalidate();
238+
setFieldSize(Math.min(dim.width, 500), Math.min(dim.height, 7*23));
237239
return p;
238240
}
239241

de/nmichael/efa/core/items/ItemTypeItemList.java

Lines changed: 89 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import de.nmichael.efa.Daten;
3737
import de.nmichael.efa.gui.BaseDialog;
3838
import de.nmichael.efa.gui.BaseFrame;
39+
import de.nmichael.efa.gui.EfaGuiUtils;
3940
import de.nmichael.efa.gui.ImagesAndIcons;
4041
import de.nmichael.efa.gui.util.RoundedBorder;
4142
import de.nmichael.efa.gui.util.RoundedLabel;
@@ -124,6 +125,7 @@ public class ItemTypeItemList extends ItemType {
124125
private JScrollPane scrollPane;
125126
private JLabel titlelabel;
126127
private JButton addButton;
128+
private Hashtable<JButton,Integer> addButtons;
127129
private Hashtable<JButton,Integer> delButtons;
128130
private Hashtable<JButton,Integer> upButtons;
129131
private Hashtable<JButton,Integer> downButtons;
@@ -182,16 +184,29 @@ public IItemType copyOf() {
182184
return copy;
183185
}
184186

187+
/**
188+
* Add items at the end of the list.
189+
* @param items Items to be added.
190+
*/
185191
public void addItems(IItemType[] items) {
186-
int idx = this.items.size();
192+
addItems(items, this.items.size());
193+
}
194+
195+
/**
196+
* Add Items below an item on the list.
197+
* @param items Items to be added.
198+
* @param afterIndex
199+
*/
200+
public void addItems(IItemType[] items, int afterIndex) {
201+
int idxForName = this.items.size();
187202
lastItemFocus = null;
188203
for (IItemType item : items) {
189204
// check if the subitem's name already consists of the prefixes of the CURRENT itemlist.
190205
// only add them if neccessary. this avoids very long item names when additems is used
191206
// in the context of copyOf method.
192207
String internalName = item.getName();
193208
if (!item.getName().startsWith(this.getName())){
194-
internalName = getName() + "_" + idx + "_" + item.getName();
209+
internalName = getName() + "_" + idxForName + "_" + item.getName();
195210
}
196211
itemNameMapping.put(internalName, item.getName());
197212
item.setName(internalName);
@@ -201,7 +216,11 @@ public void addItems(IItemType[] items) {
201216
}
202217
}
203218
}
204-
this.items.add(items);
219+
if (afterIndex==0 || afterIndex>idxForName) {
220+
this.items.add(items);
221+
} else {
222+
this.items.add(afterIndex,items);
223+
}
205224
}
206225

207226
public void removeItems(int idx) {
@@ -293,7 +312,6 @@ protected void iniDisplay() {
293312
// not used, everything done in displayOnGui(...)
294313
}
295314

296-
297315
public int displayOnGui(Window dlg, JPanel panel, int x, int y) {
298316
this.dlg = dlg;
299317

@@ -316,7 +334,7 @@ public int displayOnGui(Window dlg, JPanel panel, int x, int y) {
316334
titlelabel.setOpaque(true);
317335
titlelabel.setFont(titlelabel.getFont().deriveFont(Font.BOLD));
318336
titlelabel.setText(" " + getDescription());
319-
337+
320338
// we use a roundedPanel as base element so that we can add the caption on the left,
321339
// and highlight the add button on the right with some prominent text "new" and an extra arrow icon.
322340
int curYPos = 0;
@@ -358,6 +376,7 @@ public int displayOnGui(Window dlg, JPanel panel, int x, int y) {
358376
addButton.addActionListener(new java.awt.event.ActionListener() {
359377
public void actionPerformed(ActionEvent e) { addButtonHit(e); }
360378
});
379+
EfaGuiUtils.enableAutoScrollOnFocus(addButton);
361380

362381
panel.add(addButton, new GridBagConstraints(x+xForAddDelButtons, y, 2, 1, 0.0, 0.0,
363382
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(padYbefore, 2, padYafter, padXafter), 0, 0));
@@ -368,6 +387,7 @@ public int displayOnGui(Window dlg, JPanel panel, int x, int y) {
368387
curYPos++;
369388
}
370389

390+
addButtons = new Hashtable<JButton, Integer>();
371391
delButtons = new Hashtable<JButton,Integer>();
372392
upButtons = new Hashtable<JButton,Integer>();
373393
downButtons = new Hashtable<JButton,Integer>();
@@ -395,6 +415,16 @@ public int displayOnGui(Window dlg, JPanel panel, int x, int y) {
395415
delButton.addActionListener(new java.awt.event.ActionListener() {
396416
public void actionPerformed(ActionEvent e) { delButtonHit(e); }
397417
});
418+
EfaGuiUtils.enableAutoScrollOnFocus(delButton);
419+
420+
JButton addButtonAtItem = new JButton();
421+
addButtonAtItem.setIcon(BaseFrame.getIcon("menu_plus.gif"));
422+
addButtonAtItem.setMargin(new Insets(0,0,0,0));
423+
Dialog.setPreferredSize(addButtonAtItem, 19, 19);
424+
addButtonAtItem.addActionListener(new java.awt.event.ActionListener() {
425+
public void actionPerformed(ActionEvent e) { addButtonAfterPositionHit(e); }
426+
});
427+
EfaGuiUtils.enableAutoScrollOnFocus(addButtonAtItem);
398428

399429
JButton upButton =null;
400430
JButton downButton = null;
@@ -407,13 +437,17 @@ public int displayOnGui(Window dlg, JPanel panel, int x, int y) {
407437
upButton.addActionListener(new java.awt.event.ActionListener() {
408438
public void actionPerformed(ActionEvent e) { upButtonHit(e); }
409439
});
440+
EfaGuiUtils.enableAutoScrollOnFocus(upButton);
441+
410442
downButton = new JButton();
411443
downButton.setIcon(ImagesAndIcons.getIcon(ImagesAndIcons.ARROW_DOWN));
412444
downButton.setMargin(new Insets(0,0,0,0));
413445
Dialog.setPreferredSize(downButton, 19, 19);
414446
downButton.addActionListener(new java.awt.event.ActionListener() {
415447
public void actionPerformed(ActionEvent e) { downButtonHit(e); }
416448
});
449+
EfaGuiUtils.enableAutoScrollOnFocus(downButton);
450+
417451
/*
418452
* [label] [upbutton][downbutton] [delete]
419453
*/
@@ -425,15 +459,19 @@ public int displayOnGui(Window dlg, JPanel panel, int x, int y) {
425459

426460
panel.add(delButton, new GridBagConstraints(x+xForAddDelButtons, y+curYPos, 1, 1, 0.0, 0.0,
427461
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets((label==null ? 0 : padYbetween), 2, (label==null ? 0 : padYbetween), 0), 0, 0));
462+
463+
panel.add(addButtonAtItem, new GridBagConstraints(x+(xForAddDelButtons*2), y+curYPos, 1, 1, 0.0, 0.0,
464+
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets((label==null ? 0 : padYbetween), 2, (label==null ? 0 : padYbetween), 0), 0, 0));
428465

429-
panel.add(upButton, new GridBagConstraints(x+xForAddDelButtons+xForAddDelButtons, y+curYPos, 1, 1, 0.0, 0.0,
466+
panel.add(upButton, new GridBagConstraints(x+(xForAddDelButtons*3), y+curYPos, 1, 1, 0.0, 0.0,
430467
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets((label==null ? 0 : padYbetween), 2, (label==null ? 0 : padYbetween), 0), 0, 0));
431468

432-
panel.add(downButton, new GridBagConstraints(x+xForAddDelButtons+xForAddDelButtons+xForAddDelButtons, y+curYPos, 1, 1, 0.0, 0.0,
469+
panel.add(downButton, new GridBagConstraints(x+(xForAddDelButtons*4), y+curYPos, 1, 1, 0.0, 0.0,
433470
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets((label==null ? 0 : padYbetween), 2, (label==null ? 0 : padYbetween), 0), 0, 0));
434471

435472

436473
delButtons.put(delButton, iCurrentItemListIndex);
474+
addButtons.put(addButtonAtItem, iCurrentItemListIndex);
437475
upButtons.put(upButton, iCurrentItemListIndex);
438476
downButtons.put(downButton, iCurrentItemListIndex);
439477

@@ -448,6 +486,11 @@ public int displayOnGui(Window dlg, JPanel panel, int x, int y) {
448486
panel.add(delButton, new GridBagConstraints(x+xForAddDelButtons, y+curYPos, 1, 1, 0.0, 0.0,
449487
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets((label==null ? 0 : padYbetween), 2, (label==null ? 0 : padYbetween), 0), 0, 0));
450488
delButtons.put(delButton, iCurrentItemListIndex);
489+
490+
panel.add(addButtonAtItem, new GridBagConstraints(x+(xForAddDelButtons*2), y+curYPos, 1, 1, 0.0, 0.0,
491+
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets((label==null ? 0 : padYbetween), 2, (label==null ? 0 : padYbetween), 0), 0, 0));
492+
addButtons.put(addButtonAtItem, iCurrentItemListIndex);
493+
451494
}
452495

453496
lastItemStart = (label != null ? label : delButton);
@@ -468,6 +511,7 @@ public int displayOnGui(Window dlg, JPanel panel, int x, int y) {
468511
item.setDescription(descr + " " + (iCurrentItemListIndex+1));
469512
}
470513
int plusY = item.displayOnGui(dlg, panel, myX, y+curYPos);
514+
EfaGuiUtils.enableAutoScrollOnFocus(item.getComponent());
471515
if (item instanceof ItemTypeLabelTextfield) { //neccessary for efaBaseFrameMultisession
472516
((ItemTypeLabelTextfield) item).restoreBackgroundColor();
473517
}
@@ -502,11 +546,12 @@ private void addButtonHit(ActionEvent e) {
502546
((BaseDialog)dlg).updateGui();
503547
if (lastItemStart != null) {
504548
((BaseDialog)dlg).getScrollPane().scrollRectToVisible(lastItemStart.getBounds());
505-
}
506-
if (lastItemFocus != null) {
507-
lastItemFocus.requestFocus();
549+
if (lastItemFocus != null) {
550+
lastItemFocus.requestFocus();
551+
}
508552
}
509553
}
554+
510555
}
511556

512557
private void delButtonHit(ActionEvent e) {
@@ -530,6 +575,34 @@ private void delButtonHit(ActionEvent e) {
530575
}
531576
}
532577

578+
private void addButtonAfterPositionHit(ActionEvent e) {
579+
//no up action neccessary if there is no element
580+
if (items.size()<1) {return;}
581+
582+
int idx = addButtons.get(e.getSource());
583+
if (idx < 0 || idx >= items.size()) {
584+
return;
585+
}
586+
587+
getValueFromGui(); //save the current element status
588+
589+
//add the new item at the bottom
590+
IItemType[] newitems = itemFactory.getDefaultItems(getName());
591+
addItems(newitems,idx+1);
592+
593+
changed = true;
594+
if (dlg instanceof BaseDialog) {
595+
((BaseDialog)dlg).updateGui();
596+
if (lastItemStart != null) {
597+
((BaseDialog)dlg).getScrollPane().scrollRectToVisible(lastItemStart.getBounds());
598+
if (lastItemFocus != null) {
599+
lastItemFocus.requestFocus();
600+
}
601+
}
602+
}
603+
}
604+
605+
533606
private void upButtonHit(ActionEvent e) {
534607
//no up action neccessary if there is only one element
535608
if (items.size()<=1) {return;}
@@ -547,6 +620,12 @@ private void upButtonHit(ActionEvent e) {
547620
((BaseDialog)dlg).updateGui();
548621
}
549622

623+
try {
624+
lastItemFocus = ((IItemType[])items.get(idx))[0];
625+
} catch (Exception e1) {
626+
Logger.logdebug(e1);
627+
lastItemFocus = null;
628+
}
550629
if (lastItemFocus != null) {
551630
lastItemFocus.requestFocus();
552631
}

de/nmichael/efa/gui/BaseDialog.java

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,36 @@
1010

1111
package de.nmichael.efa.gui;
1212

13-
import de.nmichael.efa.*;
14-
import de.nmichael.efa.util.*;
15-
import de.nmichael.efa.util.Dialog;
16-
import de.nmichael.efa.core.config.EfaConfig;
17-
import de.nmichael.efa.core.items.*;
13+
import java.awt.AWTEvent;
14+
import java.awt.BorderLayout;
15+
import java.awt.Component;
16+
import java.awt.Dimension;
17+
import java.awt.Frame;
18+
import java.awt.Window;
19+
import java.awt.event.ActionEvent;
20+
import java.awt.event.ActionListener;
21+
import java.awt.event.WindowEvent;
22+
23+
import javax.swing.AbstractButton;
24+
import javax.swing.BorderFactory;
25+
import javax.swing.ImageIcon;
26+
import javax.swing.JButton;
27+
import javax.swing.JComponent;
28+
import javax.swing.JDialog;
29+
import javax.swing.JPanel;
30+
import javax.swing.JScrollPane;
31+
import javax.swing.JTextField;
32+
33+
import de.nmichael.efa.Daten;
34+
import de.nmichael.efa.core.items.IItemType;
1835
import de.nmichael.efa.gui.util.AutoCompletePopupWindow;
19-
import de.nmichael.efa.gui.util.RoundedBorder;
20-
21-
import java.awt.*;
22-
import java.awt.event.*;
23-
import javax.swing.*;
36+
import de.nmichael.efa.util.ActionHandler;
37+
import de.nmichael.efa.util.Dialog;
38+
import de.nmichael.efa.util.EfaUtil;
39+
import de.nmichael.efa.util.Help;
40+
import de.nmichael.efa.util.International;
41+
import de.nmichael.efa.util.Logger;
42+
import de.nmichael.efa.util.Mnemonics;
2443

2544
// @i18n complete
2645
public abstract class BaseDialog extends JDialog implements ActionListener {
@@ -144,6 +163,7 @@ public boolean prepareDialog() {
144163
iniDialogCommonFinish();
145164
EfaUtil.pack(this);
146165
_prepared = true;
166+
EfaGuiUtils.enableAutoScrollOnFocus(this);
147167
return true;
148168
} catch (Exception e) {
149169
Logger.log(e);

0 commit comments

Comments
 (0)