From 6fc614e9d86407b46334c31d2a1a8f0ace4d9cd0 Mon Sep 17 00:00:00 2001 From: Oleg Krasilnikov Date: Tue, 6 Mar 2007 14:21:28 +0000 Subject: [PATCH] Minor UI changes (resize etc) --- .../actions/ChangeBuildConfigActionBase.java | 2 +- .../cdt/ui/newui/AbstractLangsListTab.java | 46 +++++++++++++++++-- .../eclipse/cdt/ui/newui/AbstractPage.java | 7 ++- .../eclipse/cdt/ui/newui/IncludeDialog.java | 1 - .../eclipse/cdt/ui/newui/LibraryPathTab.java | 4 +- .../org/eclipse/cdt/ui/newui/LibraryTab.java | 4 +- 6 files changed, 56 insertions(+), 8 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java index c6f395abdbb..d753091146c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java @@ -91,7 +91,7 @@ public class ChangeBuildConfigActionBase { for (; i < cfgDescs.length; i++) { if (cfgDescs[i].getName().equals(sName)) { String sNewDesc = cfgDescs[i].getDescription(); - if (sNewDesc.equals("")) { //$NON-NLS-1$ + if (sNewDesc != null && sNewDesc.length() == 0) { sNewDesc = null; } if (commonDesc) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java index c607dab71ef..dfe12a818b5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java @@ -24,16 +24,20 @@ 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.custom.SashForm; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; 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.Listener; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeColumn; @@ -64,22 +68,58 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { protected ICLanguageSetting lang; protected List incs; protected List exported; + protected SashForm sashForm; private final static Image IMG_FS = CPluginImages.get(CPluginImages.IMG_FILESYSTEM); private final static Image IMG_WS = CPluginImages.get(CPluginImages.IMG_WORKSPACE); private final static Image IMG_MK = CPluginImages.get(CPluginImages.IMG_OBJS_MACRO); + private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 10, 30 }; public void createControls(Composite parent) { super.createControls(parent); - usercomp.setLayout(new GridLayout(2, false)); - addTree(usercomp).setLayoutData(new GridData(GridData.FILL_VERTICAL)); - table = new Table(usercomp, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION); + usercomp.setLayout(new GridLayout(1, false)); + + // Create the sash form + sashForm = new SashForm(usercomp, SWT.NONE); + sashForm.setOrientation(SWT.HORIZONTAL); + sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); + + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.marginHeight = 5; + sashForm.setLayout(layout); + + addTree(sashForm).setLayoutData(new GridData(GridData.FILL_VERTICAL)); + table = new Table(sashForm, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION); GridData gd = new GridData(GridData.FILL_BOTH); gd.widthHint = 255; table.setLayoutData(gd); table.setHeaderVisible(true); table.setLinesVisible(true); + sashForm.setWeights(DEFAULT_SASH_WEIGHTS); + + sashForm.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event event) { + if (event.detail == SWT.DRAG) return; + int shift = event.x - sashForm.getBounds().x; + GridData data = (GridData) langTree.getLayoutData(); + if ((data.widthHint + shift) < 20) return; + Point computedSize = usercomp.getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT); + Point currentSize = usercomp.getShell().getSize(); + boolean customSize = !computedSize.equals(currentSize); + data.widthHint = data.widthHint; + sashForm.layout(true); + computedSize = usercomp.getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT); + if (customSize) + computedSize.x = Math.max(computedSize.x, currentSize.x); + computedSize.y = Math.max(computedSize.y, currentSize.y); + if (computedSize.equals(currentSize)) { + return; + } + } + }); + tv = new TableViewer(table); tv.setContentProvider(new IStructuredContentProvider() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java index 1da4e2d80fd..9d1c91c9c2f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java @@ -404,6 +404,7 @@ implements */ public boolean performOk() { if (doneOK || noContentOnPage || !displayedConfig) return true; + forEach(ICPropertyTab.OK, null); doneOK = true; // further pages need not to do anything try { CoreModel.getDefault().setProjectDescription(getProject(), prjd); @@ -555,13 +556,17 @@ implements * @param p - project to check * @returns true if it's new-style project. */ - public boolean isCDTProject(IProject p) { + public static boolean isCDTPrj(IProject p) { ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); if (prjd == null) return false; ICConfigurationDescription[] cfgs = prjd.getConfigurations(); return (cfgs != null && cfgs.length > 0); } + public boolean isCDTProject(IProject p) { + return isCDTPrj(p); + } + public ICResourceDescription getResDesc() { if (resd == null) { if (cfgDescs == null) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java index e28d8c49239..fa654e7a6b7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.ui.newui; //import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java index 8aefca012c8..04e6d0bbab6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java @@ -24,6 +24,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry; public class LibraryPathTab extends AbstractLangsListTab implements IPathEntryStoreListener { IPathEntryStore fStore; + private static final int[] PRIVATE_SASH_WEIGHTS = new int[] { 0, 30 }; public void additionalTableSet() { TableColumn c = new TableColumn(table, SWT.NONE); @@ -33,7 +34,8 @@ public class LibraryPathTab extends AbstractLangsListTab implements IPathEntrySt public void createControls(Composite parent) { super.createControls(parent); - ((GridData)langTree.getLayoutData()).widthHint = 0; +// ((GridData)langTree.getLayoutData()).widthHint = 0; + sashForm.setWeights(PRIVATE_SASH_WEIGHTS); langTree.setVisible(false); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java index c9c8d0b6c7a..98ee9b6b9e1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java @@ -24,6 +24,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry; public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreListener { IPathEntryStore fStore; + private static final int[] PRIVATE_SASH_WEIGHTS = new int[] { 0, 30 }; public void additionalTableSet() { TableColumn c = new TableColumn(table, SWT.NONE); @@ -33,7 +34,8 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL public void createControls(Composite parent) { super.createControls(parent); - ((GridData)langTree.getLayoutData()).widthHint = 0; +// ((GridData)langTree.getLayoutData()).widthHint = 0; + sashForm.setWeights(PRIVATE_SASH_WEIGHTS); langTree.setVisible(false); }