Java Code Examples for org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil#setWidthHint()

The following examples show how to use org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil#setWidthHint() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NewSourceFolderWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void createControl(Composite parent) {
	initializeDialogUnits(parent);

	Composite composite= new Composite(parent, SWT.NONE);

	GridLayout layout= new GridLayout();
	layout.numColumns= 3;
	composite.setLayout(layout);

	fProjectField.doFillIntoGrid(composite, 3);
	fRootDialogField.doFillIntoGrid(composite, 3);
	fExcludeInOthersFields.doFillIntoGrid(composite, 3);
	fIgnoreOptionalProblemsField.doFillIntoGrid(composite, 3);

	int maxFieldWidth= convertWidthInCharsToPixels(40);
	LayoutUtil.setWidthHint(fProjectField.getTextControl(null), maxFieldWidth);
	LayoutUtil.setHorizontalGrabbing(fProjectField.getTextControl(null));
	LayoutUtil.setWidthHint(fRootDialogField.getTextControl(null), maxFieldWidth);
	BidiUtils.applyBidiProcessing(fRootDialogField.getTextControl(null), StructuredTextTypeHandlerFactory.FILE);

	setControl(composite);
	Dialog.applyDialogFont(composite);
	PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.NEW_PACKAGEROOT_WIZARD_PAGE);
}
 
Example 2
Source File: PackageFragmentSelection.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public Control[] doFillIntoGrid(Composite parent, int nColumns, int textWidth) {
	Control[] res= super.doFillIntoGrid(parent, nColumns);

	final Text text= getTextControl(null);
	text.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent e) {
			updateListener();
		}
	});
	LayoutUtil.setWidthHint(text, textWidth);
	LayoutUtil.setHorizontalGrabbing(text);
	ControlContentAssistHelper.createTextContentAssistant(text, fCurrPackageCompletionProcessor);
	TextFieldNavigationHandler.install(text);

	return res;
}
 
Example 3
Source File: NewContainerDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite composite= (Composite)super.createDialogArea(parent);

	int widthHint= convertWidthInCharsToPixels(80);

	Composite inner= new Composite(composite, SWT.NONE);
	GridLayout layout= new GridLayout();
	layout.marginHeight= 0;
	layout.marginWidth= 0;
	layout.numColumns= 1;
	inner.setLayout(layout);

	fContainerDialogField.doFillIntoGrid(inner, 2);

	LayoutUtil.setWidthHint(fContainerDialogField.getLabelControl(null), widthHint);
	LayoutUtil.setWidthHint(fContainerDialogField.getTextControl(null), widthHint);
	LayoutUtil.setHorizontalGrabbing(fContainerDialogField.getTextControl(null));

	fContainerDialogField.postSetFocusOnDialogField(parent.getDisplay());
	applyDialogFont(composite);
	return composite;
}
 
Example 4
Source File: NLSAccessorConfigurationDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void createAccessorPart(Composite parent, final int nOfColumns, int textWidth) {
	createLabel(parent, NLSUIMessages.NLSAccessorConfigurationDialog_resourceBundle_title, nOfColumns);
	fAccessorPackage.createControl(parent, nOfColumns, textWidth);

	fAccessorClassName.doFillIntoGrid(parent, nOfColumns);
	Text accessorClassText= fAccessorClassName.getTextControl(null);
	LayoutUtil.setWidthHint(accessorClassText, convertWidthInCharsToPixels(60));
	TextFieldNavigationHandler.install(accessorClassText);

	fSubstitutionPattern.doFillIntoGrid(parent, nOfColumns);
	Text substitutionPatternText= fSubstitutionPattern.getTextControl(null);
	LayoutUtil.setWidthHint(substitutionPatternText, convertWidthInCharsToPixels(60));
	TextFieldNavigationHandler.install(substitutionPatternText);

	fSubstitutionPattern.setEnabled(!fRefactoring.isEclipseNLS());
}
 
Example 5
Source File: NewTypeWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the controls for the superclass name field. Expects a <code>GridLayout</code>
 * with at least 3 columns.
 *
 * @param composite the parent composite
 * @param nColumns number of columns to span
 */
protected void createSuperClassControls(Composite composite, int nColumns) {
	fSuperClassDialogField.doFillIntoGrid(composite, nColumns);
	Text text= fSuperClassDialogField.getTextControl(null);
	LayoutUtil.setWidthHint(text, getMaxFieldWidth());
	BidiUtils.applyBidiProcessing(text, StructuredTextTypeHandlerFactory.JAVA);

	JavaTypeCompletionProcessor superClassCompletionProcessor= new JavaTypeCompletionProcessor(false, false, true);
	superClassCompletionProcessor.setCompletionContextRequestor(new CompletionContextRequestor() {
		@Override
		public StubTypeContext getStubTypeContext() {
			return getSuperClassStubTypeContext();
		}
	});

	ControlContentAssistHelper.createTextContentAssistant(text, superClassCompletionProcessor);
	TextFieldNavigationHandler.install(text);
}
 
Example 6
Source File: TodoTaskInputDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite composite= (Composite) super.createDialogArea(parent);

	Composite inner= new Composite(composite, SWT.NONE);
	GridLayout layout= new GridLayout();
	layout.marginHeight= 0;
	layout.marginWidth= 0;
	layout.numColumns= 2;
	inner.setLayout(layout);

	fNameDialogField.doFillIntoGrid(inner, 2);
	fPriorityDialogField.doFillIntoGrid(inner, 2);

	LayoutUtil.setHorizontalGrabbing(fNameDialogField.getTextControl(null));
	LayoutUtil.setWidthHint(fNameDialogField.getTextControl(null), convertWidthInCharsToPixels(45));

	fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());

	applyDialogFont(composite);

	PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.TASK_TAG_INPUT_DIALOG);

	return composite;
}
 
Example 7
Source File: NewPackageWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void createPackageControls(Composite composite, int nColumns) {
	fPackageDialogField.doFillIntoGrid(composite, nColumns - 1);
	Text text= fPackageDialogField.getTextControl(null);
	LayoutUtil.setWidthHint(text, getMaxFieldWidth());
	LayoutUtil.setHorizontalGrabbing(text);
	DialogField.createEmptySpace(composite);

	TextFieldNavigationHandler.install(text);
	
	fCreatePackageInfoJavaDialogField.doFillIntoGrid(composite, nColumns);
	BidiUtils.applyBidiProcessing(fPackageDialogField.getTextControl(null), StructuredTextTypeHandlerFactory.JAVA);
}
 
Example 8
Source File: NameConventionConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite composite= (Composite) super.createDialogArea(parent);
	Composite inner= new Composite(composite, SWT.NONE);
	inner.setFont(composite.getFont());
	GridLayout layout= new GridLayout();
	layout.marginHeight= 0;
	layout.marginWidth= 0;
	layout.numColumns= 2;
	inner.setLayout(layout);

	fMessageField.doFillIntoGrid(inner, 2);
	fPrefixField.doFillIntoGrid(inner, 2);
	fSuffixField.doFillIntoGrid(inner, 2);

	LayoutUtil.setHorizontalGrabbing(fPrefixField.getTextControl(null));
	LayoutUtil.setWidthHint(fPrefixField.getTextControl(null), convertWidthInCharsToPixels(45));
	LayoutUtil.setWidthHint(fSuffixField.getTextControl(null), convertWidthInCharsToPixels(45));

	fPrefixField.postSetFocusOnDialogField(parent.getDisplay());

	applyDialogFont(composite);

	PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.CODE_STYLE_EDIT_PREFIX_SUFFIX);

	return composite;
}
 
Example 9
Source File: SourceFirstPackageSelectionDialogField.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void createControl(Composite parent, int nOfColumns, int textWidth) {
	fShell= parent.getShell();
	PixelConverter converter= new PixelConverter(parent);
	fSourceFolderSelection.doFillIntoGrid(parent, nOfColumns, textWidth);
	LayoutUtil.setWidthHint(fSourceFolderSelection.getTextControl(null), converter.convertWidthInCharsToPixels(60));

	fPackageSelection.doFillIntoGrid(parent, nOfColumns, textWidth);
	LayoutUtil.setWidthHint(fPackageSelection.getTextControl(null), converter.convertWidthInCharsToPixels(60));
}
 
Example 10
Source File: NLSAccessorConfigurationDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void createPropertyPart(Composite parent, final int nOfColumns, final int textWidth) {
	createLabel(parent, NLSUIMessages.NLSAccessorConfigurationDialog_property_location, nOfColumns);
	fResourceBundlePackage.createControl(parent, nOfColumns, textWidth);

	fResourceBundleFile.doFillIntoGrid(parent, nOfColumns);
	LayoutUtil.setWidthHint(fResourceBundleFile.getTextControl(null), convertWidthInCharsToPixels(60));
}
 
Example 11
Source File: ExpandWithConstructorsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create a list dialog field.
 *
 * @param parent the composite
 */
private void createPreferenceList(Composite parent) {
	String[] buttonLabels= new String[] {
			CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_newType_button,
			CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_newMember_button,
			CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_edit_button,
			CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_remove_button,
			CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_restoreDefaults_button
	};

	ListAdapter adapter= new ListAdapter();

	fList= new ListDialogField<String>(adapter, buttonLabels, new ListLabelProvider());
	fList.setDialogFieldListener(adapter);
	fList.setLabelText(CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_description);
	fList.setRemoveButtonIndex(IDX_REMOVE);
	fList.enableButton(IDX_EDIT, false);
	fList.setViewerComparator(new ViewerComparator());

	PixelConverter pixelConverter= new PixelConverter(parent);

	fList.doFillIntoGrid(parent, 3);
	LayoutUtil.setHorizontalSpan(fList.getLabelControl(null), 2);
	LayoutUtil.setWidthHint(fList.getLabelControl(null), pixelConverter.convertWidthInCharsToPixels(60));
	LayoutUtil.setHorizontalGrabbing(fList.getListControl(null));

	Control listControl= fList.getListControl(null);
	GridData gd= (GridData)listControl.getLayoutData();
	gd.verticalAlignment= GridData.FILL;
	gd.grabExcessVerticalSpace= true;
	gd.heightHint= pixelConverter.convertHeightInCharsToPixels(10);
}
 
Example 12
Source File: NewTypeWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the controls for the package name field. Expects a <code>GridLayout</code> with at
 * least 4 columns.
 *
 * @param composite the parent composite
 * @param nColumns number of columns to span
 */
protected void createPackageControls(Composite composite, int nColumns) {
	fPackageDialogField.doFillIntoGrid(composite, nColumns);
	Text text= fPackageDialogField.getTextControl(null);
	BidiUtils.applyBidiProcessing(text, StructuredTextTypeHandlerFactory.JAVA);
	LayoutUtil.setWidthHint(text, getMaxFieldWidth());
	LayoutUtil.setHorizontalGrabbing(text);
	ControlContentAssistHelper.createTextContentAssistant(text, fCurrPackageCompletionProcessor);
	TextFieldNavigationHandler.install(text);
}
 
Example 13
Source File: AddResourcesToClientBundleDialog.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private void createProjectControls(Composite parent, int nColumns) {
  projectField = new StringButtonDialogField(fieldAdapter);
  projectField.setLabelText("Project:");
  projectField.setButtonLabel("Browse...");
  projectField.doFillIntoGrid(parent, nColumns);
  Text text = projectField.getTextControl(null);
  LayoutUtil.setWidthHint(text, getMaxFieldWidth());
  LayoutUtil.setHorizontalGrabbing(projectField.getTextControl(null));
}
 
Example 14
Source File: AddResourcesToClientBundleDialog.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private void createClientBundleTypeControls(Composite parent, int nColumns) {
  clientBundleTypeField = new StringButtonDialogField(fieldAdapter);
  clientBundleTypeField.setLabelText("ClientBundle:");
  clientBundleTypeField.setButtonLabel("Browse...");
  clientBundleTypeField.doFillIntoGrid(parent, nColumns);
  Text text = clientBundleTypeField.getTextControl(null);
  LayoutUtil.setWidthHint(text, getMaxFieldWidth());

  // Set up auto-completion
  resourceTypeCompletionProcessor = new JavaTypeCompletionProcessorWithAutoActivation();
  ControlContentAssistHelper.createTextContentAssistant(text,
      resourceTypeCompletionProcessor);
  TextFieldNavigationHandler.install(text);
}
 
Example 15
Source File: NativeLibrariesConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public Control createContents(Composite parent) {
	fShell= parent.getShell();

	Composite inner= new Composite(parent, SWT.NONE);
	inner.setFont(parent.getFont());
	inner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

	int nColumns= 3;

	GridLayout layout= new GridLayout(nColumns, false);
	layout.marginWidth= 0;
	layout.marginWidth= 0;
	inner.setLayout(layout);

	PixelConverter converter= new PixelConverter(parent);

	Label desc= new Label(inner, SWT.WRAP);
	desc.setFont(inner.getFont());
	desc.setText(Messages.format(NewWizardMessages.NativeLibrariesDialog_description, new String[] { BasicElementLabels.getResourceName(fEntry.getPath().lastSegment()) }));
	GridData gridData= new GridData(GridData.FILL, GridData.CENTER, false, false, 3, 1);
	gridData.widthHint= converter.convertWidthInCharsToPixels(80);
	desc.setLayoutData(gridData);

	fPathField.doFillIntoGrid(inner, 2);
	LayoutUtil.setHorizontalGrabbing(fPathField.getTextControl(null));
	LayoutUtil.setWidthHint(fPathField.getTextControl(null), converter.convertWidthInCharsToPixels(50));

	fBrowseExternal.doFillIntoGrid(inner, 1);

	DialogField.createEmptySpace(inner, 2);
	fBrowseWorkspace.doFillIntoGrid(inner, 1);

	fPathField.setFocus();

	return parent;
}
 
Example 16
Source File: NewTypeWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the controls for the type name field. Expects a <code>GridLayout</code> with at
 * least 2 columns.
 *
 * @param composite the parent composite
 * @param nColumns number of columns to span
 */
protected void createTypeNameControls(Composite composite, int nColumns) {
	fTypeNameDialogField.doFillIntoGrid(composite, nColumns - 1);
	DialogField.createEmptySpace(composite);

	Text text= fTypeNameDialogField.getTextControl(null);
	LayoutUtil.setWidthHint(text, getMaxFieldWidth());
	TextFieldNavigationHandler.install(text);
	
	text.addVerifyListener(new VerifyListener() {
		public void verifyText(VerifyEvent e) {
			if (fCanModifyPackage && ! fEnclosingTypeSelection.isSelected() && e.start == 0 && e.end == ((Text) e.widget).getCharCount()) {
				String typeNameWithoutParameters= getTypeNameWithoutParameters(e.text);
				int lastDot= typeNameWithoutParameters.lastIndexOf('.');
				if (lastDot == -1 || lastDot == typeNameWithoutParameters.length() - 1)
					return;
				
				String pack= typeNameWithoutParameters.substring(0, lastDot);
				if (validatePackageName(pack, null).getSeverity() == IStatus.ERROR)
					return;
				
				fPackageDialogField.setText(pack);
				e.text= e.text.substring(lastDot + 1);
			}
		}
	});
}
 
Example 17
Source File: NewModuleWizardPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
protected void createModuleNameControls(Composite composite, int nColumns) {
  moduleNameField.doFillIntoGrid(composite, nColumns - 1);
  DialogField.createEmptySpace(composite);

  Text moduleNameText = moduleNameField.getTextControl(null);
  LayoutUtil.setWidthHint(moduleNameText, getMaxFieldWidth());
  LayoutUtil.setHorizontalGrabbing(moduleNameText);
}
 
Example 18
Source File: ImportOrganizeInputDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite composite= (Composite) super.createDialogArea(parent);
	initializeDialogUnits(parent);

	GridLayout layout= (GridLayout) composite.getLayout();
	layout.numColumns= 2;

	fNameDialogField.doFillIntoGrid(composite, 3);

	LayoutUtil.setHorizontalSpan(fNameDialogField.getLabelControl(null), 2);

	int fieldWidthHint= convertWidthInCharsToPixels(60);
	Text text= fNameDialogField.getTextControl(null);
	LayoutUtil.setWidthHint(text, fieldWidthHint);
	LayoutUtil.setHorizontalGrabbing(text);
	BidiUtils.applyBidiProcessing(text, StructuredTextTypeHandlerFactory.JAVA);
	TextFieldNavigationHandler.install(text);

	DialogField.createEmptySpace(composite, 1);
	fBrowseTypeButton.doFillIntoGrid(composite, 1);

	fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());

	applyDialogFont(composite);
	return composite;
}
 
Example 19
Source File: NewHostPageWizardPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
private void setFieldWidthHint(StringDialogField field) {
  Text text = field.getTextControl(null);
  LayoutUtil.setWidthHint(text, convertWidthInCharsToPixels(40));
}
 
Example 20
Source File: NewContainerWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Creates the necessary controls (label, text field and browse button) to edit
 * the source folder location. The method expects that the parent composite
 * uses a <code>GridLayout</code> as its layout manager and that the
 * grid layout has at least 3 columns.
 *
 * @param parent the parent composite
 * @param nColumns the number of columns to span. This number must be
 *  greater or equal three
 */
protected void createContainerControls(Composite parent, int nColumns) {
	fContainerDialogField.doFillIntoGrid(parent, nColumns);
	LayoutUtil.setWidthHint(fContainerDialogField.getTextControl(null), getMaxFieldWidth());
	BidiUtils.applyBidiProcessing(fContainerDialogField.getTextControl(null), StructuredTextTypeHandlerFactory.FILE);
}