From: <fu...@us...> - 2009-07-31 18:53:45
|
Revision: 910 http://cishell.svn.sourceforge.net/cishell/?rev=910&view=rev Author: fugu13 Date: 2009-07-31 18:53:20 +0000 (Fri, 31 Jul 2009) Log Message: ----------- Add scrolling to parameter dialogue boxes. Reviewed by Micah. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGui.java trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGuiComposite.java trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGui.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGui.java 2009-07-31 15:24:24 UTC (rev 909) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGui.java 2009-07-31 18:53:20 UTC (rev 910) @@ -25,6 +25,7 @@ import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -41,6 +42,8 @@ * @author Bruce Herr (bh...@bh...) */ public class SWTGui implements GUI, UpdateListener { + private static final int MAXIMUM_INITIAL_DIALOGUE_HEIGHT = 400; + public static final int TEXT_WRAP_LENGTH = 350; private Shell shell; @@ -60,7 +63,9 @@ ObjectClassDefinition ocd = provider.getObjectClassDefinition(id, null); shell.setText(ocd.getName()); - + + + GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1; shell.setLayout(gridLayout); @@ -76,9 +81,7 @@ GridData labelData = new GridData(); labelData.horizontalAlignment = GridData.CENTER; labelData.grabExcessHorizontalSpace = true; - System.out.println(msg.getSize().x); if (msg.getSize().x > TEXT_WRAP_LENGTH) { - System.out.println(msg.getSize().x); labelData.widthHint = TEXT_WRAP_LENGTH; } msg.setLayoutData(labelData); @@ -163,8 +166,18 @@ shell.getDisplay().syncExec(new Runnable() { public void run() { shell.pack(); + resizeShell(shell); shell.open(); - }}); + } + + private void resizeShell(Shell shell) { + Point shellSize = shell.getSize(); + shell.setSize(shellSize.x, calculateNewDialogHeight(shellSize.y)); + } + + private int calculateNewDialogHeight(int proposedHeight) { + return Math.min(MAXIMUM_INITIAL_DIALOGUE_HEIGHT, proposedHeight); + }}); } /** Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGuiComposite.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGuiComposite.java 2009-07-31 15:24:24 UTC (rev 909) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGuiComposite.java 2009-07-31 18:53:20 UTC (rev 910) @@ -26,6 +26,7 @@ import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @@ -45,8 +46,8 @@ protected Set listeners; private Composite parent; - private Composite userArea; - private ScrolledComposite userScroll; + private Composite parameterArea; + private ScrolledComposite scroll; private int style; public SWTGuiComposite(Composite parent, int style, @@ -69,7 +70,7 @@ GUIComponent component = ComponentProvider.getInstance().createComponent(attrs[i]); component.setAttributeDefinition(attrs[i]); - component.createGUI(userArea, style); + component.createGUI(parameterArea, style); idToComponentMap.put(attrs[i].getID(), component); component.addUpdateListener(this); @@ -81,24 +82,32 @@ } } - userArea.addDisposeListener(new DisposeListener() { + setScrollDimensions(scroll, parameterArea); + + parameterArea.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { enteredResponses = getEnteredResponses(); }}); } + + private void setScrollDimensions(ScrolledComposite scroll, Composite innards) { + Point parameterAreaSize = innards.computeSize(SWT.DEFAULT, SWT.DEFAULT); + scroll.setMinWidth(parameterAreaSize.x); + scroll.setMinHeight(parameterAreaSize.y); + } private void setupGUI() { - userScroll = new ScrolledComposite(parent, style); - userScroll.setLayout(new GridLayout(1, true)); - userScroll.setExpandHorizontal(true); - userScroll.setExpandVertical(true); - userScroll.setAlwaysShowScrollBars(false); + scroll = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); + scroll.setLayout(new GridLayout(1, true)); + scroll.setExpandHorizontal(true); + scroll.setExpandVertical(true); + scroll.setAlwaysShowScrollBars(false); - userArea = new Composite(userScroll, SWT.NONE); - userArea.setLayout(new GridLayout(GUIComponent.MAX_SPAN+1,false)); + parameterArea = new Composite(scroll, SWT.NONE); + parameterArea.setLayout(new GridLayout(GUIComponent.MAX_SPAN+1,false)); GridData gd = new GridData(SWT.FILL,SWT.FILL,true,true); - userArea.setLayoutData(gd); + parameterArea.setLayoutData(gd); GridData userData = new GridData(); userData.grabExcessVerticalSpace = true; @@ -106,8 +115,8 @@ userData.verticalAlignment = SWT.FILL; userData.horizontalAlignment = SWT.FILL; - userScroll.setLayoutData(userData); - userScroll.setContent(userArea); + scroll.setLayoutData(userData); + scroll.setContent(parameterArea); } @@ -138,11 +147,11 @@ * @return the composite */ public Composite getUserArea() { - return userArea; + return parameterArea; } public Composite getComposite() { - return userScroll; + return scroll; } public String validate() { Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java 2009-07-31 15:24:24 UTC (rev 909) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java 2009-07-31 18:53:20 UTC (rev 910) @@ -13,8 +13,6 @@ * ***************************************************************************/ package org.cishell.reference.gui.guibuilder.swt.builder.components; -import java.util.Arrays; - import org.cishell.reference.gui.guibuilder.swt.builder.AbstractComponent; import org.cishell.reference.gui.guibuilder.swt.builder.StringConverter; import org.eclipse.swt.SWT; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |