Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2020-03-17 19:56:50 +0000
committerEugene Tarassov2020-03-17 19:56:50 +0000
commitfa512a8f0085c79ddb6d65af6013a61727481acb (patch)
treea2aade05fdd0114ee0463124569dca1ce4a035f7 /plugins
parent39eb05c0ffbfd62bff27703d4acc59f7dc1a128a (diff)
downloadorg.eclipse.tcf-fa512a8f0085c79ddb6d65af6013a61727481acb.tar.gz
org.eclipse.tcf-fa512a8f0085c79ddb6d65af6013a61727481acb.tar.xz
org.eclipse.tcf-fa512a8f0085c79ddb6d65af6013a61727481acb.zip
TCF Debugger: save table column widths on Resize event instead of Dispose
On Linux GTK, col.getWidth() fails when called from Dispose handler
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/MemoryMapWidget.java17
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/SignalsDialog.java33
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/PeerListControl.java15
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/TCFPathMapTab.java18
4 files changed, 59 insertions, 24 deletions
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/MemoryMapWidget.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/MemoryMapWidget.java
index 878aaa3a9..779dbaae8 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/MemoryMapWidget.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/MemoryMapWidget.java
@@ -359,10 +359,6 @@ public class MemoryMapWidget {
disposed = true;
if (prefs != null) {
- for (int i = 0; i < COL_WIDTH.length; i++) {
- TreeColumn col = map_table.getColumn(i);
- prefs.putInt("w" + i, col.getWidth());
- }
try {
prefs.flush();
}
@@ -523,12 +519,21 @@ public class MemoryMapWidget {
TableLayout layout = new TableLayout();
for (int i = 0; i < COL_WIDTH.length; i++) {
- TreeColumn col = new TreeColumn(table, i);
+ final TreeColumn col = new TreeColumn(table, i);
col.setResizable(true);
col.setAlignment(SWT.LEFT);
col.setText(getColumnText(i));
int w = COL_WIDTH[i];
- if (prefs != null) w = prefs.getInt("w" + i, w);
+ if (prefs != null) {
+ final String id = "w" + i;
+ w = prefs.getInt(id, w);
+ col.addListener(SWT.Resize, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ prefs.putInt(id, col.getWidth());
+ }
+ });
+ }
layout.addColumnData(new ColumnPixelData(w));
}
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/SignalsDialog.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/SignalsDialog.java
index d1a0fea90..d83992a03 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/SignalsDialog.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/SignalsDialog.java
@@ -29,6 +29,8 @@ import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.graphics.Font;
@@ -37,7 +39,9 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
@@ -56,6 +60,7 @@ import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.services.IProcesses;
import org.eclipse.tcf.util.TCFDataCache;
import org.eclipse.tcf.util.TCFTask;
+import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
class SignalsDialog extends Dialog {
@@ -107,6 +112,7 @@ class SignalsDialog extends Dialog {
private final TCFModel model;
private final IChannel channel;
private final TCFNode selection;
+ private final Preferences prefs;
private TCFNodeExecContext node;
@@ -167,6 +173,8 @@ class SignalsDialog extends Dialog {
SignalsDialog(Shell parent, TCFNode node) {
super(parent);
+ Preferences prefs = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+ this.prefs = prefs.node(SignalsDialog.class.getCanonicalName());
model = node.getModel();
channel = node.getChannel();
selection = node;
@@ -232,25 +240,40 @@ class SignalsDialog extends Dialog {
signal_table.setLayoutData(data);
int w = SIZING_TABLE_WIDTH / (column_names.length + 5);
- Preferences prefs = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
- prefs = prefs.node(SignalsDialog.class.getCanonicalName());
for (int i = 0; i < column_names.length; i++) {
final TableColumn column = new TableColumn(signal_table, SWT.LEAD, i);
column.setMoveable(false);
column.setText(column_names[i]);
+ final String id = "w" + i;
switch (i) {
case 0:
- column.setWidth(prefs.getInt("w" + i, w * 2));
+ column.setWidth(prefs.getInt(id, w * 2));
break;
case 1:
case 2:
- column.setWidth(prefs.getInt("w" + i, w * 3));
+ column.setWidth(prefs.getInt(id, w * 3));
break;
default:
- column.setWidth(prefs.getInt("w" + i, w));
+ column.setWidth(prefs.getInt(id, w));
break;
}
+ column.addListener(SWT.Resize, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ prefs.putInt(id, column.getWidth());
+ }
+ });
}
+ signal_table.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ try {
+ prefs.flush();
+ }
+ catch (BackingStoreException x) {
+ Activator.log(x);
+ }
+ }
+ });
signal_table.setHeaderVisible(true);
signal_table.setLinesVisible(true);
signal_table.addMouseListener(new MouseListener() {
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/PeerListControl.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/PeerListControl.java
index fbe9553b8..2f78f2109 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/PeerListControl.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/PeerListControl.java
@@ -240,10 +240,17 @@ public class PeerListControl implements ISelectionProvider {
peer_tree.setLayoutData(gd);
for (int i = 0; i < COL_WIDTH.length; i++) {
- TreeColumn column = new TreeColumn(peer_tree, SWT.LEAD, i);
+ final TreeColumn column = new TreeColumn(peer_tree, SWT.LEAD, i);
column.setMoveable(true);
- column.setWidth(prefs.getInt("w" + i, COL_WIDTH[i]));
column.setText(COL_TEXT[i]);
+ final String id = "w" + i;
+ column.setWidth(prefs.getInt(id, COL_WIDTH[i]));
+ column.addListener(SWT.Resize, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ prefs.putInt(id, column.getWidth());
+ }
+ });
}
peer_tree.setHeaderVisible(true);
@@ -308,10 +315,6 @@ public class PeerListControl implements ISelectionProvider {
private void handleDispose() {
if (prefs != null) {
- for (int i = 0; i < COL_WIDTH.length; i++) {
- TreeColumn col = peer_tree.getColumn(i);
- prefs.putInt("w" + i, col.getWidth());
- }
try {
prefs.flush();
}
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/TCFPathMapTab.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/TCFPathMapTab.java
index 55703a5c6..6f5aa9f50 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/TCFPathMapTab.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/TCFPathMapTab.java
@@ -54,7 +54,9 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Table;
@@ -296,7 +298,7 @@ public class TCFPathMapTab extends AbstractLaunchConfigurationTab {
TableLayout layout = new TableLayout();
for (int i = 0; i < COL_WIDTH.length; i++) {
if (i == 3 && !showContextQuery()) continue;
- TableColumn col = new TableColumn(table, i);
+ final TableColumn col = new TableColumn(table, i);
if (i == 0) {
col.setResizable(false);
col.setAlignment(SWT.CENTER);
@@ -306,15 +308,17 @@ public class TCFPathMapTab extends AbstractLaunchConfigurationTab {
col.setAlignment(SWT.LEFT);
}
col.setText(getColumnText(i));
- layout.addColumnData(new ColumnPixelData(prefs.getInt("w" + i, COL_WIDTH[i])));
+ final String id = "w" + i;
+ layout.addColumnData(new ColumnPixelData(prefs.getInt(id, COL_WIDTH[i])));
+ col.addListener(SWT.Resize, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ prefs.putInt(id, col.getWidth());
+ }
+ });
}
table.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
- int n = table.getColumnCount();
- for (int i = 0; i < n; i++) {
- TableColumn col = table.getColumn(i);
- prefs.putInt("w" + i, col.getWidth());
- }
try {
prefs.flush();
}

Back to the top