Skip to content

Commit

Permalink
Apply Mac Item height workaround to Mac Intel as well as Silicon
Browse files Browse the repository at this point in the history
- The latest version of "java" binary is compiled with Mac SDK 11.1 so we have the same problem when running Archi from Eclipse
- So add UIUtils#fixMacItemHeight() and use on Mac Intel and Silicon
- UIUtils#fixMacSiliconItemHeight() is deprecated. Use UIUtils#fixMacItemHeight()
  • Loading branch information
Phillipus committed Jan 7, 2024
1 parent b5a2eef commit 85e10d0
Show file tree
Hide file tree
Showing 21 changed files with 66 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ private class RelationsTableViewer extends TableViewer {
RelationsTableViewer(Composite parent, int style) {
super(parent, SWT.FULL_SELECTION | style);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(getTable());
// Mac Item height
UIUtils.fixMacItemHeight(getTable());

setColumns();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ private class RelationsTableViewer extends TableViewer {
RelationsTableViewer(Composite parent, int style) {
super(parent, SWT.FULL_SELECTION | style);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(getTable());
// Mac Item height
UIUtils.fixMacItemHeight(getTable());

setColumns();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ private class RelationsTableViewer extends TableViewer {
RelationsTableViewer(Composite parent, int style) {
super(parent, SWT.FULL_SELECTION | style);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(getTable());
// Mac Item height
UIUtils.fixMacItemHeight(getTable());

setColumns(getTable());
setContentProvider(new RelationsTableViewerContentProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ protected Control createDialogArea(Composite parent) {
viewer = new TableViewer(tableComp, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(viewer.getTable());
// Mac Item height
UIUtils.fixMacItemHeight(viewer.getTable());

viewer.getTable().setHeaderVisible(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ protected Control createDialogArea(Composite parent) {
viewer = new TableViewer(tableComp, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(viewer.getTable());
// Mac Item height
UIUtils.fixMacItemHeight(viewer.getTable());

viewer.getTable().setHeaderVisible(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ protected Control createContents(Composite parent) {
fTreeViewer = new TreeViewer(client);
GridDataFactory.create(GridData.FILL_BOTH).hint(SWT.DEFAULT, 200).applyTo(fTreeViewer.getTree());

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(fTreeViewer.getTree());
// Mac Item height
UIUtils.fixMacItemHeight(fTreeViewer.getTree());

// Tree Double-click listener
fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ public Composite createContents(Composite parent) {
private void createTable(Composite parent) {
fTableViewer = new TableViewer(parent);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(fTableViewer.getTable());
// Mac Item height
UIUtils.fixMacItemHeight(fTableViewer.getTable());

GridDataFactory.create(GridData.FILL_BOTH).hint(SWT.DEFAULT, 200).applyTo(fTableViewer.getTable());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ private class ModelsViewer extends TableViewer {
public ModelsViewer(Composite parent) {
super(parent, SWT.FULL_SELECTION);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(getTable());
// Mac Item height
UIUtils.fixMacItemHeight(getTable());

setColumns();
setContentProvider(new ModelsViewerContentProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ private void createTableControl(Composite parent) {
// Font
UIUtils.setFontFromPreferences(fTableViewer.getTable(), IPreferenceConstants.ANALYSIS_TABLE_FONT, true);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(fTableViewer.getTable());
// Mac Item height
UIUtils.fixMacItemHeight(fTableViewer.getTable());

// Column
TableViewerColumn column = new TableViewerColumn(fTableViewer, SWT.NONE, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ private void createTableControl(Composite parent) {
// Font
UIUtils.setFontFromPreferences(fTableViewer.getTable(), IPreferenceConstants.ANALYSIS_TABLE_FONT, true);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(fTableViewer.getTable());
// Mac Item height
UIUtils.fixMacItemHeight(fTableViewer.getTable());

// Column
TableViewerColumn column = new TableViewerColumn(fTableViewer, SWT.NONE, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ private void createTableControl(Composite parent) {
fTableViewer = new TableViewer(tableComp, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
fTableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(fTableViewer.getTable());
// Mac Item height
UIUtils.fixMacItemHeight(fTableViewer.getTable());

// Edit cell on double-click and add Tab key traversal
TableViewerEditor.create(fTableViewer, new ColumnViewerEditorActivationStrategy(fTableViewer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ private void createTableControl(Composite parent) {
// Font
UIUtils.setFontFromPreferences(fTableViewer.getTable(), IPreferenceConstants.PROPERTIES_TABLE_FONT, true);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(fTableViewer.getTable());
// Mac Item height
UIUtils.fixMacItemHeight(fTableViewer.getTable());

// Edit cell on double-click and add Tab key traversal
TableViewerEditor.create(fTableViewer, new ColumnViewerEditorActivationStrategy(fTableViewer) {
Expand Down Expand Up @@ -1409,8 +1409,8 @@ private void createTableControl(Composite parent) {
tableViewer = new TableViewer(tableComp, SWT.FULL_SELECTION | SWT.VIRTUAL);
tableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(tableViewer.getControl());
// Mac Item height
UIUtils.fixMacItemHeight(tableViewer.getControl());

tableViewer.getTable().setLinesVisible(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ private void createTableControl(Composite parent) {
fTableViewer = new TableViewer(tableComp, SWT.MULTI | SWT.FULL_SELECTION);
GridDataFactory.create(GridData.FILL_BOTH).applyTo(fTableViewer.getControl());

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(fTableViewer.getTable());
// Mac Item height
UIUtils.fixMacItemHeight(fTableViewer.getTable());

// Edit cell on single-click and add Tab key traversal
TableViewerEditor.create(fTableViewer, new ColumnViewerEditorActivationStrategy(fTableViewer),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,32 @@ public static String shortenText(String text, Control control, int margin) {


/**
* For some reason this will ensure that Table/Tree/List Item height is normal on Apple Silicon
* @param control
* Deprecated Use {@link UIUtils#fixMacItemHeight(Control)}
*/
public static void fixMacSiliconItemHeight(Control control) {
if(PlatformUtils.isAppleSilicon()) {
fixMacItemHeight(control);
}

/**
* Table/Tree/List Item heights on binaries built with Mac SDK 11.1 and later are taller than when using an earlier Mac SDK.
* However, if we change the font of a Table/Tree/List it will revert to the smaller item height.
* See https://github.com/eclipse-platform/eclipse.platform.swt/issues/677
*
* It depends on what binary is being run and what version Mac SDK that binary was compiled against:
*
* Archi executable binary on Intel SDK 10.14 - smaller height
* Archi executable binary on Silicon SDK 11.1 - bigger height
* Java on Intel/Silicon (launch from Eclipse) SDK 11.1 - bigger height
*
* To determine which Mac SDK is used to create the binary run:
* otool -l /path/to/binary
* and inspect the LC_VERSION_MIN_MACOSX or LC_BUILD_VERSION entry (look for "sdk")
*
* So call this method in all cases when running on Mac
* For some reason this will ensure that Table/Tree/List Item height is normal on Mac
*/
public static void fixMacItemHeight(Control control) {
if(PlatformUtils.isMac()) {
control.setFont(control.getFont());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public NavigatorViewer(Composite parent, int style) {

UIUtils.setFontFromPreferences(getTree(), IPreferenceConstants.NAVIGATOR_TREE_FONT, true);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(getTree());
// Mac Item height
UIUtils.fixMacItemHeight(getTree());

setContentProvider(new NavigatorViewerContentProvider());
setLabelProvider(new NavigatorViewerLabelProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public TreeModelViewer(Composite parent, int style) {
// Font
UIUtils.setFontFromPreferences(getTree(), IPreferenceConstants.MODEL_TREE_FONT, true);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(getTree());
// Mac Item height
UIUtils.fixMacItemHeight(getTree());

setContentProvider(new ModelTreeViewerContentProvider());
setLabelProvider(new ModelTreeViewerLabelProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public class ValidatorViewer extends TreeViewer {
public ValidatorViewer(Composite parent, int style) {
super(parent, style | SWT.MULTI | SWT.FULL_SELECTION);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(getTree());
// Mac Item height
UIUtils.fixMacItemHeight(getTree());

setContentProvider(new ValidatorViewerContentProvider());
setLabelProvider(new ValidatorViewerLabelProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class TemplatesTableViewer extends TableViewer {
public TemplatesTableViewer(Composite parent, int style) {
super(parent, SWT.FULL_SELECTION | style);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(getTable());
// Mac Item height
UIUtils.fixMacItemHeight(getTable());

setColumns();
setContentProvider(new TemplatesTableViewerContentProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class TemplatesTreeViewer extends TreeViewer {
public TemplatesTreeViewer(Composite parent, int style) {
super(parent, style);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(getTree());
// Mac Item height
UIUtils.fixMacItemHeight(getTree());

setContentProvider(new TemplatesTreeViewerContentProvider());
setLabelProvider(new TemplatesTreeViewerLabelProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class ModelViewsTreeViewer extends TreeViewer {
public ModelViewsTreeViewer(Composite parent, int style) {
super(parent, style | SWT.BORDER);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(getTree());
// Mac Item height
UIUtils.fixMacItemHeight(getTree());

setContentProvider(new ModelViewsTreeViewerContentProvider());
setLabelProvider(new ModelViewsTreeViewerLabelProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class TemplateGroupsTableViewer extends TableViewer {
public TemplateGroupsTableViewer(Composite parent, int style) {
super(parent, SWT.FULL_SELECTION | style);

// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(getTable());
// Mac Item height
UIUtils.fixMacItemHeight(getTable());

setColumns();
setContentProvider(new CategoriesTableViewerContentProvider());
Expand Down

0 comments on commit 85e10d0

Please sign in to comment.