forked from External/mage
GUI: fixed that server's lobby do not remember divider position after app restart (tables, matches and chat sizes)
This commit is contained in:
parent
f78177a540
commit
f0c38cdb87
7 changed files with 36 additions and 32 deletions
|
|
@ -30,8 +30,6 @@ import org.apache.log4j.Logger;
|
|||
import org.mage.card.arcane.CardRendererUtils;
|
||||
import org.ocpsoft.prettytime.Duration;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import org.ocpsoft.prettytime.TimeFormat;
|
||||
import org.ocpsoft.prettytime.units.JustNow;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
|
@ -645,8 +643,24 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
btnQuickStartMCTS.setFont(GUISizeHelper.menuFont);
|
||||
}
|
||||
|
||||
private void restoreDividerLocations() {
|
||||
Rectangle currentBounds = MageFrame.getDesktop().getBounds();
|
||||
if (currentBounds != null) {
|
||||
String firstDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_1, null);
|
||||
String tableDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_2, null);
|
||||
String chatDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_3, null);
|
||||
GuiDisplayUtil.restoreDividerLocations(currentBounds, firstDivider, jSplitPane1);
|
||||
GuiDisplayUtil.restoreDividerLocations(currentBounds, tableDivider, jSplitPaneTables);
|
||||
GuiDisplayUtil.restoreDividerLocations(currentBounds, chatDivider, chatPanelMain);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveDividerLocations() {
|
||||
// save divider locations and divider saveDividerLocations
|
||||
// save divider locations
|
||||
if (this.jSplitPane1.getDividerLocation() == -1) {
|
||||
// server lobby hidden by default, so ignore that settings
|
||||
return;
|
||||
}
|
||||
GuiDisplayUtil.saveCurrentBoundsToPrefs();
|
||||
GuiDisplayUtil.saveDividerLocationToPrefs(KEY_TABLES_DIVIDER_LOCATION_1, this.jSplitPane1.getDividerLocation());
|
||||
GuiDisplayUtil.saveDividerLocationToPrefs(KEY_TABLES_DIVIDER_LOCATION_2, this.jSplitPaneTables.getDividerLocation());
|
||||
|
|
@ -663,18 +677,6 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
TableUtil.saveColumnWidthAndOrderToPrefs(tableTables, KEY_TABLES_COLUMNS_WIDTH, KEY_TABLES_COLUMNS_ORDER);
|
||||
}
|
||||
|
||||
private void restoreDividers() {
|
||||
Rectangle currentBounds = MageFrame.getDesktop().getBounds();
|
||||
if (currentBounds != null) {
|
||||
String firstDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_1, null);
|
||||
String tableDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_2, null);
|
||||
String chatDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_3, null);
|
||||
GuiDisplayUtil.restoreDividerLocations(currentBounds, firstDivider, jSplitPane1);
|
||||
GuiDisplayUtil.restoreDividerLocations(currentBounds, tableDivider, jSplitPaneTables);
|
||||
GuiDisplayUtil.restoreDividerLocations(currentBounds, chatDivider, chatPanelMain);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, JComponent> getUIComponents() {
|
||||
Map<String, JComponent> components = new HashMap<>();
|
||||
|
||||
|
|
@ -778,12 +780,9 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
//tableModel.setSession(session);
|
||||
|
||||
reloadServerMessages();
|
||||
|
||||
MageFrame.getUI().addButton(MageComponents.NEW_GAME_BUTTON, btnNewTable);
|
||||
|
||||
// divider locations have to be set with delay else values set are overwritten with system defaults
|
||||
Executors.newSingleThreadScheduledExecutor().schedule(() -> restoreDividers(), 300, TimeUnit.MILLISECONDS);
|
||||
|
||||
restoreDividerLocations();
|
||||
}
|
||||
|
||||
protected void reloadServerMessages() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue