* TablesPanel - Fixed that restoring of divider positions did not work properly.

This commit is contained in:
LevelX2 2014-07-23 12:07:42 +02:00
parent 50d6a84ad9
commit 84f67f1fcd

View file

@ -40,6 +40,8 @@ import java.awt.HeadlessException;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import java.io.File; import java.io.File;
import java.text.DateFormat; import java.text.DateFormat;
@ -51,6 +53,10 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -59,6 +65,7 @@ import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane; import javax.swing.JLayeredPane;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import javax.swing.JSplitPane;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import mage.cards.decks.importer.DeckImporterUtil; import mage.cards.decks.importer.DeckImporterUtil;
@ -82,6 +89,7 @@ import mage.view.MatchView;
import mage.view.TableView; import mage.view.TableView;
import mage.view.UsersView; import mage.view.UsersView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.mage.plugins.card.dl.beans.PropertyChangeSupport;
/** /**
* *
@ -104,7 +112,10 @@ public class TablesPanel extends javax.swing.JPanel {
private Session session; private Session session;
private List<String> messages; private List<String> messages;
private int currentMessage; private int currentMessage;
private static final ScheduledExecutorService timeoutExecutor = Executors.newScheduledThreadPool(1);
private ScheduledFuture<?> setDividerLocation;
/** Creates new form TablesPanel */ /** Creates new form TablesPanel */
public TablesPanel() { public TablesPanel() {
@ -198,8 +209,7 @@ public class TablesPanel extends javax.swing.JPanel {
} }
}; };
Action closedTableAction; Action closedTableAction;
closedTableAction = new AbstractAction() closedTableAction = new AbstractAction()
{ {
@Override @Override
@ -229,8 +239,8 @@ public class TablesPanel extends javax.swing.JPanel {
} }
} }
}; };
// adds action buttons to the table panel (don't delete this) // adds action buttons to the table panel (don't delete this)
new ButtonColumn(tableTables, openTableAction, TableTableModel.ACTION_COLUMN); new ButtonColumn(tableTables, openTableAction, TableTableModel.ACTION_COLUMN);
new ButtonColumn(tableCompleted, closedTableAction, MatchesTableModel.ACTION_COLUMN); new ButtonColumn(tableCompleted, closedTableAction, MatchesTableModel.ACTION_COLUMN);
@ -269,6 +279,7 @@ public class TablesPanel extends javax.swing.JPanel {
} }
} }
} }
public Map<String, JComponent> getUIComponents() { public Map<String, JComponent> getUIComponents() {
Map<String, JComponent> components = new HashMap<>(); Map<String, JComponent> components = new HashMap<>();
@ -368,7 +379,15 @@ public class TablesPanel extends javax.swing.JPanel {
reloadMessages(); reloadMessages();
MageFrame.getUI().addButton(MageComponents.NEW_GAME_BUTTON, btnNewTable); MageFrame.getUI().addButton(MageComponents.NEW_GAME_BUTTON, btnNewTable);
this.restoreDividerLocations();
// divider locations have to be set with delay else values set are overwritten with system defaults
setDividerLocation = timeoutExecutor.schedule(new Runnable() {
@Override
public void run() {
restoreDividerLocations();
}
}, 300, TimeUnit.MILLISECONDS);
} }
protected void reloadMessages() { protected void reloadMessages() {
@ -680,7 +699,7 @@ private void chkShowCompletedActionPerformed(java.awt.event.ActionEvent evt) {//
private javax.swing.JTable tableCompleted; private javax.swing.JTable tableCompleted;
private javax.swing.JTable tableTables; private javax.swing.JTable tableTables;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }
class TableTableModel extends AbstractTableModel { class TableTableModel extends AbstractTableModel {