public class AdminIP2LocationPanel extends VirtualComponentAdapter implements IServiceStatusListener
This class provides a comprehensive administration interface for the IP2Location geolocation service, allowing administrators to configure, monitor, and manage the service through a NetPhantom-based UI panel.
The panel is organized into three main sections:
NetPhantom control IDs follow these rules:
| ID | Type | Description |
|---|---|---|
| Configuration Controls | ||
| ENABLED | CheckBox | Enable/disable service |
| TOKEN | TextField | API download token |
| DBPATH | TextField | Database directory path |
| DBLIST | ComboBox | Database type selection |
| IPV4 | RadioButton | IPv4 only mode |
| IPV6 | RadioButton | IPv4+IPv6 mode |
| MEMMAP | CheckBox | Memory-mapped file access |
| Status Display Controls | ||
| STATUS | Label | Service status text |
| NEXT | Label | Next scheduled update time |
| LAST | Label | Last successful update month |
| IP4DATE | Label | IPv4 database date |
| IP6DATE | Label | IPv6 database date |
| INITFAIL | Label | Init failure count |
| LOOKUPER | Label | Lookup error count |
| DLFAIL | Label | Download failure count |
| RECSTAT | Label | Recovery status (colored) |
| Action Buttons | ||
| RECONFIG | Button | Apply configuration changes |
| UPDATE | Button | Trigger immediate update |
| SETTINGS | Button | Open recovery settings |
| Context Menu Items | ||
| M_UPDATE | MenuItem | "Update Databases Now" |
| M_RECOV | MenuItem | "Trigger Recovery" |
| M_CLEAR | MenuItem | "Clear Recovery Alert" |
| M_HIST | MenuItem | "View Event History" |
| M_CLRERR | MenuItem | "Clear All Errors" |
| M_CLINIT | MenuItem | "Clear Init Errors" |
| M_CLLKUP | MenuItem | "Clear Lookup Errors" |
| M_CLDL | MenuItem | "Clear Download Error" |
| M_SET | MenuItem | "Recovery Settings..." |
Right-clicking on the recovery status indicator (RECSTAT) shows a context menu with the following options:
Note: The context menu provides duplicate access to some toolbar button functions (Update Now, Settings) for convenience when the mouse is already over the status area.
Configuration is stored in the server.ini file under the [IP2Location] section:
[IP2Location] enabled=1 token=YOUR_TOKEN dbPath=IP2Location dbName=DB11_LITE enableIPv6=0 memoryMappedFile=1
This class implements IServiceStatusListener to receive callbacks from
background threads. All VirtualPanel methods are thread-safe and can be
called from any thread.
// In a NetPhantom notebook page initialization:
VirtualPanel page = notebook.getPage("IP2Location");
AdminIP2LocationPanel admin = new AdminIP2LocationPanel(page);
page.setVirtualComponentListener(admin);
AdminIP2LocationSettingsPanel,
IP2LocationManager,
IServiceStatusListenerIServiceStatusListener.ErrorTypeICON_CRITICAL, ICON_INFORMATION, ICON_NOICON, ICON_QUERY, ICON_QUESTION, ICON_WARNING, MB_ABORTRETRYIGNORE, MB_CANCEL, MB_ENTER, MB_ENTERCANCEL, MB_OK, MB_OKCANCEL, MB_RETRYCANCEL, MB_YESNO, MB_YESNOCANCEL, MBID_CANCEL, MBID_DEFAULT, MBID_ENTER, MBID_IGNORE, MBID_NO, MBID_OK, MBID_RETRY, MBID_YES| Constructor and Description |
|---|
AdminIP2LocationPanel(VirtualPanel page)
Constructs the panel controller and initializes the UI.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
doReconfigure()
Validates and applies configuration changes.
|
void |
onAction(VirtualPanel panel,
String controlID)
Handles button clicks and menu item selections.
|
void |
onCheckedChange(VirtualPanel panel,
VirtualControl control,
String controlID,
int state)
Handles checkbox and radio button state changes.
|
void |
onDatabaseLoaded(LocalDate date,
boolean isIPv6)
Called when a database file has been loaded into memory.
|
void |
onDatabaseUpdated(boolean ipv4Updated,
boolean ipv6Updated)
Called when databases are reloaded into memory.
|
void |
onDownloadCompleted(boolean success)
Called when a database download completes.
|
void |
onDownloadStarted()
Called when a database download starts.
|
void |
onError(IServiceStatusListener.ErrorType type,
String message,
Throwable error)
Called when an error occurs in the service.
|
void |
onPanelDestroy(VirtualPanel vp)
Called when the panel is being destroyed.
|
void |
onRecoveryCompleted(boolean success,
Throwable error)
Called when automatic recovery completes.
|
void |
onRecoveryRecommended(String reason,
boolean autoRecoveryTriggered)
Called when recovery is recommended.
|
void |
onStatusChanged(String newStatus)
Called when the service status description changes.
|
void |
refreshStatus()
Refreshes all status displays from the current service state.
|
onAction, onAction, onContentChanged, onContentChanged, onControlEvent, onFocusGained, onFocusLost, onMenuAction, onPropertyChange, onSelectionChangedonModalPanelCreate, onModalPanelProcessing, onPageActivated, onPanelClose, onPanelClosing, onPanelCreateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonInitialized, onReconfigurationCompleted, onReconfigurationStarted, onServiceDisposed, onUpdateCheckPerformedonPageActivated, onPanelClose, onPanelClosing, onPanelCreatepublic AdminIP2LocationPanel(VirtualPanel page)
This constructor performs the following initialization:
page - The VirtualPanel for this administration page (not null)public void refreshStatus()
Updates the following displays:
This method is called during initialization and whenever the service status changes.
public void onCheckedChange(VirtualPanel panel, VirtualControl control, String controlID, int state)
Called by NetPhantom when the user changes a checkbox or radio button. Currently handles the service enable checkbox to enable/disable other controls.
onCheckedChange in interface VirtualComponentListeneronCheckedChange in class VirtualComponentAdapterpanel - The panel containing the control (same as this.page)control - The control that changedcontrolID - The control's ID stringstate - The new state: 0=unchecked, 1=checked, 2=indeterminatepublic void onAction(VirtualPanel panel, String controlID)
Called by NetPhantom when the user clicks a button or selects a context menu item. Routes to the appropriate action method.
onAction in class VirtualComponentAdapterpanel - The panel containing the control (same as this.page)controlID - The button or menu item ID stringpublic boolean doReconfigure()
This method performs the following steps:
IP2LocationService.Builder with the settingsIP2LocationManagerIf validation fails, an error message box is shown and focus is set to the offending field.
true if configuration was applied successfully,
false if validation failedpublic void onPanelDestroy(VirtualPanel vp)
Unregisters from service status updates to prevent memory leaks and callbacks to a disposed panel.
onPanelDestroy in interface VirtualPanelListeneronPanelDestroy in class VirtualPanelAdaptervp - The panel being destroyed (same as this.page)public void onStatusChanged(String newStatus)
Updates the status label in the UI. This is called from a background
thread, but VirtualPanel methods are thread-safe.
onStatusChanged in interface IServiceStatusListenernewStatus - The new status description stringIP2LocationManager.getStatusDescription(),
IP2LocationService.getStatusDescription()public void onDownloadStarted()
Updates the recovery status indicator to show "working" state.
onDownloadStarted in interface IServiceStatusListenerpublic void onDownloadCompleted(boolean success)
Refreshes all status displays to show new database information.
onDownloadCompleted in interface IServiceStatusListenersuccess - true if the download succeededpublic void onDatabaseLoaded(LocalDate date, boolean isIPv6)
Updates the corresponding database date field in the UI.
onDatabaseLoaded in interface IServiceStatusListenerdate - The publication date of the loaded databaseisIPv6 - true for IPv6, false for IPv4public void onDatabaseUpdated(boolean ipv4Updated,
boolean ipv6Updated)
Refreshes status to show new database dates.
onDatabaseUpdated in interface IServiceStatusListeneripv4Updated - true if IPv4 database was reloadedipv6Updated - true if IPv6 database was reloadedpublic void onRecoveryRecommended(String reason, boolean autoRecoveryTriggered)
Updates the status display and shows a notification message if automatic recovery was not triggered.
onRecoveryRecommended in interface IServiceStatusListenerreason - The reason recovery is recommendedautoRecoveryTriggered - true if automatic recovery was initiatedIP2LocationManager.isRecoveryRecommended(),
IP2LocationManager.triggerRecovery()public void onRecoveryCompleted(boolean success,
Throwable error)
Refreshes status and shows result to user.
onRecoveryCompleted in interface IServiceStatusListenersuccess - true if recovery succeedederror - The error that occurred, or null if successfulpublic void onError(IServiceStatusListener.ErrorType type, String message, Throwable error)
Updates error counters display. Severe errors may trigger recovery
recommendation which is handled separately by
onRecoveryRecommended(String, boolean).
onError in interface IServiceStatusListenertype - The category of errormessage - A human-readable error messageerror - The underlying exception, or null if not applicableIServiceStatusListener.ErrorTypePhantom® and NetPhantom® are registered trademarks of Mindus SARL.
© 2026 Mindus SARL. All rights reserved.