mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 07:25:23 +02:00
Bug 374544 - Adjust spacing on Symbol/Value columns
Change-Id: I8db4d6e7108812a6a377e8a96ecbd6622272f6b6 Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewed-on: https://git.eclipse.org/r/14297 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
2ac00ea300
commit
56a7de8fa8
1 changed files with 51 additions and 19 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2010 Intel Corporation and others.
|
* Copyright (c) 2007, 2013 Intel Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Intel Corporation - initial API and implementation
|
* Intel Corporation - initial API and implementation
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
|
* Marc-Andre Laperle (Ericsson) - Adjust the columns width
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.newui;
|
package org.eclipse.cdt.ui.newui;
|
||||||
|
|
||||||
|
@ -16,6 +17,8 @@ import java.util.Collections;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.accessibility.AccessibleAdapter;
|
import org.eclipse.swt.accessibility.AccessibleAdapter;
|
||||||
import org.eclipse.swt.accessibility.AccessibleEvent;
|
import org.eclipse.swt.accessibility.AccessibleEvent;
|
||||||
|
import org.eclipse.swt.events.ControlAdapter;
|
||||||
|
import org.eclipse.swt.events.ControlEvent;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.TableColumn;
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
|
|
||||||
|
@ -30,24 +33,24 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
|
||||||
* @noextend This class is not intended to be subclassed by clients.
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
*/
|
*/
|
||||||
public class SymbolTab extends AbstractLangsListTab {
|
public class SymbolTab extends AbstractLangsListTab {
|
||||||
|
private TableColumn symbolColumn;
|
||||||
|
private TableColumn valueColumn;
|
||||||
|
private ControlAdapter listener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void additionalTableSet() {
|
public void additionalTableSet() {
|
||||||
TableColumn tc = new TableColumn(table, SWT.LEFT);
|
symbolColumn = new TableColumn(table, SWT.LEFT);
|
||||||
tc.setText(Messages.SymbolTab_0);
|
symbolColumn.setText(Messages.SymbolTab_0);
|
||||||
tc.setWidth(80);
|
symbolColumn.setToolTipText(Messages.SymbolTab_0);
|
||||||
tc.setToolTipText(Messages.SymbolTab_0);
|
valueColumn = new TableColumn(table, SWT.LEFT);
|
||||||
tc = new TableColumn(table, SWT.LEFT);
|
valueColumn.setText(Messages.SymbolTab_1);
|
||||||
tc.setText(Messages.SymbolTab_1);
|
valueColumn.setToolTipText(Messages.SymbolTab_1);
|
||||||
tc.setWidth(130);
|
table.getAccessible().addAccessibleListener(new AccessibleAdapter() {
|
||||||
tc.setToolTipText(Messages.SymbolTab_1);
|
|
||||||
table.getAccessible().addAccessibleListener(
|
|
||||||
new AccessibleAdapter() {
|
|
||||||
@Override
|
@Override
|
||||||
public void getName(AccessibleEvent e) {
|
public void getName(AccessibleEvent e) {
|
||||||
e.result = Messages.SymbolTab_0;
|
e.result = Messages.SymbolTab_0;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -99,11 +102,40 @@ public class SymbolTab extends AbstractLangsListTab {
|
||||||
updateButtons();
|
updateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void adjustColumnsWidth() {
|
||||||
|
// Do the adjustment only once
|
||||||
|
table.removeControlListener(listener);
|
||||||
|
|
||||||
|
symbolColumn.pack();
|
||||||
|
valueColumn.pack();
|
||||||
|
|
||||||
|
int symbolColumnWidth = symbolColumn.getWidth();
|
||||||
|
int valueColumnWidth = valueColumn.getWidth();
|
||||||
|
int tableWidth = table.getClientArea().width;
|
||||||
|
int excessWidth = tableWidth - symbolColumnWidth - valueColumnWidth;
|
||||||
|
if (excessWidth > 0) {
|
||||||
|
// Distribute excess width evenly
|
||||||
|
symbolColumn.setWidth(symbolColumnWidth + excessWidth / 2);
|
||||||
|
valueColumn.setWidth(valueColumnWidth + excessWidth / 2);
|
||||||
|
} else if (excessWidth < 0) {
|
||||||
|
// Content too large, split in two
|
||||||
|
symbolColumn.setWidth(tableWidth / 2);
|
||||||
|
valueColumn.setWidth(tableWidth / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createControls(final Composite parent) {
|
public void createControls(final Composite parent) {
|
||||||
super.createControls(parent);
|
super.createControls(parent);
|
||||||
showBIButton.setSelection(true);
|
showBIButton.setSelection(true);
|
||||||
ImportExportWizardButtons.addWizardLaunchButtons(usercomp, page.getElement());
|
ImportExportWizardButtons.addWizardLaunchButtons(usercomp, page.getElement());
|
||||||
|
|
||||||
|
listener = new ControlAdapter() {
|
||||||
|
@Override
|
||||||
|
public void controlResized(ControlEvent e) {
|
||||||
|
adjustColumnsWidth();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
table.addControlListener(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue