List of usage examples for org.eclipse.jface.layout PixelConverter convertHorizontalDLUsToPixels
public int convertHorizontalDLUsToPixels(int dlus)
From source file:ca.usask.cs.srlab.simclipse.ui.SWTUtil.java
License:Open Source License
/** * Returns a width hint for a button control. * @param button The button to calculate the width for * @return The width of the button//ww w .j av a2 s.co m */ public static int getButtonWidthHint(Button button) { button.setFont(JFaceResources.getDialogFont()); PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:ch.powerunit.poweruniteclipse.helper.SWTHelper.java
License:Open Source License
public static int getButtonWidthHint(Button button) { PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:com.aptana.formatter.ui.preferences.AddRemoveList.java
License:Open Source License
/** * Sets the <code>GridData</code> on the specified button to be one that is spaced for the current dialog page * units. The method <code>initializeDialogUnits</code> must be called once before calling this method for the first * time.//from w w w.j a va2 s . c o m * * @param button * the button to set the <code>GridData</code> * @return the <code>GridData</code> set on the specified button */ protected GridData setButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); return data; }
From source file:com.aptana.formatter.ui.preferences.FormatterModifyTabPage.java
License:Open Source License
protected static Label createLabel(int numColumns, Composite parent, String text, int gridDataStyle) { final Label label = new Label(parent, SWT.WRAP); label.setFont(parent.getFont());//from w ww .j a v a2 s.com label.setText(text); PixelConverter pixelConverter = new PixelConverter(parent); label.setLayoutData( createGridData(numColumns, gridDataStyle, pixelConverter.convertHorizontalDLUsToPixels(150))); return label; }
From source file:com.aptana.git.ui.internal.preferences.GithubAccountPageProvider.java
License:Open Source License
private static int getButtonWidthHint(Button button) { PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:com.aptana.ui.ftp.internal.FTPConnectionPropertyComposite.java
License:Open Source License
public FTPConnectionPropertyComposite(Composite parent, int style, IBaseRemoteConnectionPoint connectionPoint, IListener listener) {/* w w w . j a v a2s . c om*/ super(parent, style); setConnectionPoint(connectionPoint); this.listener = listener; PixelConverter converter = new PixelConverter(this); setLayout(GridLayoutFactory.swtDefaults() .margins(converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN), converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN)) .spacing(converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING), converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING)) .numColumns(2).create()); /* row 1 */ createSiteSection(this); Group group = new Group(this, SWT.NONE); group.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create()); group.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create()); group.setText(Messages.FTPConnectionPointPropertyDialog_LBL_GroupInfo); /* row 2 */ Label label = new Label(group, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(IDialogConstants.LABEL_WIDTH), SWT.DEFAULT) .create()); label.setText(StringUtil.makeFormLabel(Messages.FTPConnectionPointPropertyDialog_LBL_Server)); hostText = new Text(group, SWT.SINGLE | SWT.BORDER); hostText.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(hostText) .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT) .span(2, 1).create()); /* row 3 */ new Label(group, SWT.NONE).setLayoutData(GridDataFactory.swtDefaults().create()); label = new Label(group, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create()); smallFont = JFaceResources.getTextFontDescriptor().increaseHeight(-2).createFont(getDisplay()); label.setFont(smallFont); label.setText(Messages.FTPConnectionPointPropertyDialog_LBL_Example); /* row 4 */ label = new Label(group, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(IDialogConstants.LABEL_WIDTH), SWT.DEFAULT) .create()); label.setText(StringUtil.makeFormLabel(Messages.FTPConnectionPointPropertyDialog_LBL_Username)); loginCombo = new Combo(group, SWT.DROP_DOWN | SWT.BORDER); loginCombo.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(loginCombo) .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT) .grab(true, false).create()); loginCombo.add(IFTPConstants.LOGIN_ANONYMOUS); testButton = new Button(group, SWT.PUSH); testButton.setText(Messages.FTPConnectionPointPropertyDialog_LBL_Test); testButton.setLayoutData(GridDataFactory.fillDefaults() .hint(Math.max( new PixelConverter(testButton).convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), testButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x), SWT.DEFAULT) .create()); /* row 5 */ createPasswordSection(group); /* row 6 */ label = new Label(group, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(IDialogConstants.LABEL_WIDTH), SWT.DEFAULT) .create()); label.setText(StringUtil.makeFormLabel(Messages.FTPConnectionPointPropertyDialog_LBL_RemotePath)); remotePathText = new Text(group, SWT.SINGLE | SWT.BORDER); remotePathText.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(remotePathText) .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT) .grab(true, false).create()); browseButton = new Button(group, SWT.PUSH); browseButton.setText('&' + StringUtil.ellipsify(CoreStrings.BROWSE)); browseButton.setLayoutData(GridDataFactory.fillDefaults() .hint(Math.max( new PixelConverter(browseButton) .convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x), SWT.DEFAULT) .create()); /* row 7 */ optionsExpandable = new ExpandableComposite(this, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.FOCUS_TITLE); optionsExpandable.setText(Messages.FTPConnectionPointPropertyDialog_LBL_Options); optionsExpandable.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, true) .minSize(SWT.DEFAULT, SWT.DEFAULT).create()); Group optionsGroup = new Group(optionsExpandable, SWT.NONE); optionsGroup.setLayout(GridLayoutFactory.fillDefaults().create()); createAdvancedOptions(optionsGroup); optionsExpandable.setClient(optionsGroup); optionsExpandable.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { FTPConnectionPropertyComposite.this.listener.layoutShell(); } }); /* row 8 */ progressMonitorPart = new ProgressMonitorPart(this, GridLayoutFactory.fillDefaults().create()); progressMonitorPart .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).exclude(true).span(2, 1).create()); /* -- */ addListeners(); passwordText.addSelectionListener(new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent e) { e.doit = false; testConnection(); } }); testButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (testConnection()) { MessageDialog.openInformation(getShell(), Messages.FTPConnectionPointPropertyDialog_Succeed_Title, MessageFormat.format( Messages.FTPConnectionPointPropertyDialog_Succeed_Message, hostText.getText())); } } }); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { browseConnection(); } }); if (ftpConnectionPoint == null) { isNew = true; ftpConnectionPoint = getOrCreateConnectionPoint(getConnectionPointType()); ftpConnectionPoint.setName(DEFAULT_NAME); } else { originalFtpConnectionPoint = ftpConnectionPoint; } loadPropertiesFrom(ftpConnectionPoint); connectionTested = !isNew; }
From source file:com.aptana.ui.s3.internal.S3ConnectionPropertyComposite.java
License:Open Source License
public S3ConnectionPropertyComposite(Composite parent, int style, IBaseRemoteConnectionPoint connectionPoint, Listener listener) {//from w ww . ja va 2s .com super(parent, style); setConnectionPoint(connectionPoint); this.listener = listener; PixelConverter converter = new PixelConverter(this); setLayout(GridLayoutFactory.swtDefaults() .margins(converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN), converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN)) .spacing(converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING), converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING)) .numColumns(2).create()); /* row 1 */ createSiteSection(this); Group group = new Group(this, SWT.NONE); group.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create()); group.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create()); group.setText(Messages.S3ConnectionPointPropertyDialog_LBL_GroupInfo); /* row 2 */ Label label = new Label(group, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create()); label.setText(StringUtil.makeFormLabel(Messages.S3ConnectionPointPropertyDialog_LBL_Server)); hostText = new Text(group, SWT.SINGLE | SWT.BORDER); hostText.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(hostText) .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT) .span(2, 1).create()); hostText.setText(S3ConnectionPoint.DEFAULT_HOST); /* row 3 */ new Label(group, SWT.NONE).setLayoutData(GridDataFactory.swtDefaults().create()); label = new Label(group, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create()); smallFont = JFaceResources.getTextFontDescriptor().increaseHeight(-2).createFont(getDisplay()); label.setFont(smallFont); label.setText(Messages.S3ConnectionPointPropertyDialog_LBL_Example); /* row 4 */ label = new Label(group, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create()); label.setText(StringUtil.makeFormLabel(Messages.S3ConnectionPointPropertyDialog_LBL_AccessKeyID)); accessKeyText = new Text(group, SWT.SINGLE | SWT.BORDER); accessKeyText.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(accessKeyText) .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT) .grab(true, false).create()); testButton = new Button(group, SWT.PUSH); testButton.setText(Messages.S3ConnectionPointPropertyDialog_LBL_Test); testButton.setLayoutData(GridDataFactory.fillDefaults() .hint(Math.max( new PixelConverter(testButton).convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), testButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x), SWT.DEFAULT) .create()); /* row 5 */ createPasswordSection(group); /* row 6 */ label = new Label(group, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create()); label.setText(StringUtil.makeFormLabel(Messages.S3ConnectionPointPropertyDialog_LBL_RemotePath)); remotePathText = new Text(group, SWT.SINGLE | SWT.BORDER); remotePathText.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(remotePathText) .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT) .grab(true, false).create()); browseButton = new Button(group, SWT.PUSH); browseButton.setText('&' + StringUtil.ellipsify(CoreStrings.BROWSE)); browseButton.setLayoutData(GridDataFactory.fillDefaults() .hint(Math.max( new PixelConverter(browseButton) .convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x), SWT.DEFAULT) .create()); /* row 7 */ progressMonitorPart = new ProgressMonitorPart(this, GridLayoutFactory.fillDefaults().create()); progressMonitorPart .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).exclude(true).span(2, 1).create()); /* -- */ addListeners(); passwordText.addSelectionListener(new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent e) { e.doit = false; testConnection(); } }); testButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (testConnection()) { MessageDialog.openInformation(getShell(), Messages.S3ConnectionPointPropertyDialog_Succeed_Title, MessageFormat.format( Messages.S3ConnectionPointPropertyDialog_Succeed_Message, hostText.getText())); } } }); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { browseConnection(); } }); if (s3ConnectionPoint == null) { isNew = true; s3ConnectionPoint = getOrCreateConnectionPoint(getConnectionPointType()); s3ConnectionPoint.setName(DEFAULT_NAME); } else { originalS3ConnectionPoint = s3ConnectionPoint; } loadPropertiesFrom(s3ConnectionPoint); connectionTested = !isNew; }
From source file:com.aptana.webserver.ui.internal.ExternalWebServerPropertyDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite dialogArea = (Composite) super.createDialogArea(parent); setTitle(Messages.SimpleWebServerPropertyDialog_Title); getShell().setText(Messages.SimpleWebServerPropertyDialog_ShellTitle); Composite composite = new Composite(dialogArea, SWT.NONE); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); PixelConverter converter = new PixelConverter(composite); composite.setLayout(GridLayoutFactory.swtDefaults() .margins(converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN), converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN)) .spacing(converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING), converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING)) .numColumns(3).create());/*from ww w .jav a 2s . co m*/ /* row 1 */ Label label = new Label(composite, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create()); label.setText(StringUtil.makeFormLabel(Messages.SimpleWebServerPropertyDialog_Name_Label)); nameText = new Text(composite, SWT.SINGLE | SWT.BORDER); nameText.setLayoutData(GridDataFactory.fillDefaults() .hint(convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT).span(2, 1) .grab(true, false).create()); /* row 1 */ label = new Label(composite, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create()); label.setText(StringUtil.makeFormLabel(Messages.SimpleWebServerPropertyDialog_BaseURL_Label)); baseUrlText = new Text(composite, SWT.SINGLE | SWT.BORDER); baseUrlText.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(baseUrlText) .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT) .span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).create()); baseUrlText.setText("http://"); //$NON-NLS-1$ /* row 2 */ label = new Label(composite, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create()); label.setText(StringUtil.makeFormLabel(Messages.SimpleWebServerPropertyDialog_DocRoot_Label)); documentRootText = new Text(composite, SWT.SINGLE | SWT.BORDER); documentRootText.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(documentRootText) .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT) .grab(true, false).create()); Button browseButton = new Button(composite, SWT.PUSH); browseButton.setText('&' + StringUtil.ellipsify(CoreStrings.BROWSE)); browseButton.setLayoutData(GridDataFactory.fillDefaults() .hint(Math.max( new PixelConverter(browseButton) .convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x), SWT.DEFAULT) .create()); /* -- */ browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { browseFileSystem(); } }); /* row 3 - start command */ label = new Label(composite, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create()); label.setText(StringUtil.makeFormLabel(Messages.ExternalWebServerPropertyDialog_StartCommandLabel)); startCommandText = new Text(composite, SWT.SINGLE | SWT.BORDER); startCommandText.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(baseUrlText) .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT) .span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).create()); /* row 4 - stop command */ label = new Label(composite, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create()); label.setText(StringUtil.makeFormLabel(Messages.ExternalWebServerPropertyDialog_StopCommandLabel)); stopCommandText = new Text(composite, SWT.SINGLE | SWT.BORDER); stopCommandText.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(baseUrlText) .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT) .span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).create()); // Set up existing values... if (source != null) { String name = source.getName(); nameText.setText((name != null) ? name : StringUtil.EMPTY); URL url = source.getBaseURL(); if (url != null) { baseUrlText.setText(url.toExternalForm()); } IPath path = source.getDocumentRootPath(); if (path != null) { documentRootText.setText(path.toOSString()); } String startCommand = source.getStartCommand(); startCommandText.setText((startCommand != null) ? startCommand : StringUtil.EMPTY); String stopCommand = source.getStopCommand(); stopCommandText.setText((stopCommand != null) ? stopCommand : StringUtil.EMPTY); } addListeners(); return dialogArea; }
From source file:com.aptana.webserver.ui.internal.SimpleWebServerPropertyDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite dialogArea = (Composite) super.createDialogArea(parent); setTitle(Messages.SimpleWebServerPropertyDialog_Title); getShell().setText(Messages.SimpleWebServerPropertyDialog_ShellTitle); Composite composite = new Composite(dialogArea, SWT.NONE); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); PixelConverter converter = new PixelConverter(composite); composite.setLayout(GridLayoutFactory.swtDefaults() .margins(converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN), converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN)) .spacing(converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING), converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING)) .numColumns(3).create());/*from w w w .ja v a 2 s .c om*/ /* row 1 */ Label label = new Label(composite, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create()); label.setText(StringUtil.makeFormLabel(Messages.SimpleWebServerPropertyDialog_Name_Label)); nameText = new Text(composite, SWT.SINGLE | SWT.BORDER); nameText.setLayoutData(GridDataFactory.fillDefaults() .hint(convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT).span(2, 1) .grab(true, false).create()); /* row 1 */ label = new Label(composite, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create()); label.setText(StringUtil.makeFormLabel(Messages.SimpleWebServerPropertyDialog_BaseURL_Label)); baseUrlText = new Text(composite, SWT.SINGLE | SWT.BORDER); baseUrlText.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(baseUrlText) .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT) .span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).create()); baseUrlText.setText("http://"); //$NON-NLS-1$ /* row 2 */ label = new Label(composite, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(label).convertHorizontalDLUsToPixels(LABEL_WIDTH), SWT.DEFAULT).create()); label.setText(StringUtil.makeFormLabel(Messages.SimpleWebServerPropertyDialog_DocRoot_Label)); documentRootText = new Text(composite, SWT.SINGLE | SWT.BORDER); documentRootText.setLayoutData(GridDataFactory.swtDefaults() .hint(new PixelConverter(documentRootText) .convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH), SWT.DEFAULT) .grab(true, false).create()); Button browseButton = new Button(composite, SWT.PUSH); browseButton.setText('&' + StringUtil.ellipsify(CoreStrings.BROWSE)); browseButton.setLayoutData(GridDataFactory.fillDefaults() .hint(Math.max( new PixelConverter(browseButton) .convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x), SWT.DEFAULT) .create()); /* -- */ browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { browseFileSystem(); } }); if (source != null) { String name = source.getName(); nameText.setText((name != null) ? name : StringUtil.EMPTY); URL url = source.getBaseURL(); if (url != null) { baseUrlText.setText(url.toExternalForm()); } IPath path = source.getDocumentRootPath(); if (path != null) { documentRootText.setText(path.toOSString()); } } addListeners(); return dialogArea; }
From source file:com.axmor.eclipse.typescript.core.ui.SWTFactory.java
License:Open Source License
/** * Returns a width hint for a button control. * /*ww w . j a v a 2s. c om*/ * @param button * button * @return width */ public static int getButtonWidthHint(Button button) { /* button.setFont(JFaceResources.getDialogFont()); */ PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }