Java Code Examples for org.eclipse.jface.layout.PixelConverter#convertWidthInCharsToPixels()

The following examples show how to use org.eclipse.jface.layout.PixelConverter#convertWidthInCharsToPixels() . 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: TaskTagConfigurationBlock.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected Control doCreateContents(Composite parent) {
	GridLayout layout = new GridLayout();
	layout.marginHeight = 0;
	layout.marginWidth = 0;
	layout.numColumns = 2;

	PixelConverter conv = new PixelConverter(parent);

	Composite markersComposite = new Composite(parent, SWT.NULL);
	markersComposite.setLayout(layout);
	markersComposite.setFont(parent.getFont());

	GridData data = new GridData(GridData.FILL_BOTH);
	data.widthHint = conv.convertWidthInCharsToPixels(50);
	Control listControl = taskTags.getListControl(markersComposite);
	listControl.setLayoutData(data);

	Control buttonsControl = taskTags.getButtonBox(markersComposite);
	buttonsControl.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING));

	caseSensitiveCheckBox.doFillIntoGrid(markersComposite, 2);

	return markersComposite;
}
 
Example 2
Source File: SWTFactory.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param parent
 * @param min
 * @param max
 * @param hspan
 * @param style
 * @return
 */
public static Spinner createSpinner(Composite parent, int min, int max, int hspan, int style)
{
	Spinner spinner = new Spinner(parent, SWT.BORDER | style);
	spinner.setMinimum(min);
	spinner.setMaximum(max);

	GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false, hspan, 1);
	PixelConverter pc = new PixelConverter(spinner);
	// See http://jira.appcelerator.org/browse/APSTUD-3215
	// We need to add some extra spacing to the MacOSX spinner in order to adjust the size to the way Mac draws
	// spinners.
	int extraWidth = Platform.OS_MACOSX.equals(Platform.getOS()) ? 25 : 0;
	gd.widthHint = pc.convertWidthInCharsToPixels(2) + extraWidth;
	spinner.setLayoutData(gd);
	return spinner;
}
 
Example 3
Source File: TodoTaskConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private Composite createMarkersTabContent(Composite folder) {
	GridLayout layout= new GridLayout();
	layout.marginHeight= 0;
	layout.marginWidth= 0;
	layout.numColumns= 2;

	PixelConverter conv= new PixelConverter(folder);

	Composite markersComposite= new Composite(folder, SWT.NULL);
	markersComposite.setLayout(layout);
	markersComposite.setFont(folder.getFont());

	GridData data= new GridData(GridData.FILL_BOTH);
	data.widthHint= conv.convertWidthInCharsToPixels(50);
	Control listControl= fTodoTasksList.getListControl(markersComposite);
	listControl.setLayoutData(data);

	Control buttonsControl= fTodoTasksList.getButtonBox(markersComposite);
	buttonsControl.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING));

	fCaseSensitiveCheckBox.doFillIntoGrid(markersComposite, 2);

	return markersComposite;
}
 
Example 4
Source File: CodeAssistAdvancedConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void createKeysLink(Composite composite, int h_span) {
   Link link= new Link(composite, SWT.NONE | SWT.WRAP);
link.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_key_binding_hint);
link.addSelectionListener(new SelectionAdapter() {
	@Override
	public void widgetSelected(SelectionEvent e) {
		PreferencesUtil.createPreferenceDialogOn(getShell(), e.text, null, null);
	}
});

PixelConverter pixelConverter= new PixelConverter(composite);
int width= pixelConverter.convertWidthInCharsToPixels(40);

// limit the size of the Link as it would take all it can get
GridData gd= new GridData(GridData.FILL, GridData.FILL, false, false, h_span, 1);
gd.widthHint= width;
link.setLayoutData(gd);
  }
 
Example 5
Source File: HintTextGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public Composite createControl(Composite parent) {
    fTopComposite= new Composite(parent, SWT.NONE);
    fTopComposite.setFont(parent.getFont());

    GridData gridData= new GridData(GridData.FILL_BOTH);
    PixelConverter converter= new PixelConverter(parent);
    gridData.heightHint= converter.convertHeightInCharsToPixels(12);
    gridData.widthHint= converter.convertWidthInCharsToPixels(25);
    GridLayout gridLayout= new GridLayout();
    gridLayout.marginWidth= 0;//-converter.convertWidthInCharsToPixels(2);
    gridLayout.marginHeight= 0;//= -4;
    fTopComposite.setLayout(gridLayout);
    fTopComposite.setLayoutData(gridData);
    fTopComposite.setData(null);
    fTopComposite.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            Collection<Image> collection= fImageMap.values();
            Iterator<Image> iterator= collection.iterator();
            while(iterator.hasNext()) {
                Image image= iterator.next();
                image.dispose();
            }
        }
    });
    return fTopComposite;
}
 
Example 6
Source File: ClassPathBlock.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public Control createContents( Composite parent )
{
	setShell( parent.getShell( ) );
	PixelConverter converter = new PixelConverter( parent );

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

	LayoutUtil.doDefaultLayout( composite, new DialogField[]{
		fLibrariesList
	}, true, SWT.DEFAULT, SWT.DEFAULT );
	LayoutUtil.setHorizontalGrabbing( fLibrariesList.getTreeControl( null ) );

	int buttonBarWidth = converter.convertWidthInCharsToPixels( 24 );
	fLibrariesList.setButtonsMinWidth( buttonBarWidth );

	return composite;
}
 
Example 7
Source File: IDEClassPathBlock.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public Control createContents( Composite parent )
{
	setShell( parent.getShell( ) );
	PixelConverter converter = new PixelConverter( parent );

	Composite composite = new Composite( parent, SWT.NONE );
	if ( getProject( ) == null )
	{
		fLibrariesList.removeButton( IDX_ADDPROJECT );
	}
	LayoutUtil.doDefaultLayout( composite, new DialogField[]{
		fLibrariesList
	}, true, SWT.DEFAULT, SWT.DEFAULT );
	LayoutUtil.setHorizontalGrabbing( fLibrariesList.getTreeControl( null ) );

	int buttonBarWidth = converter.convertWidthInCharsToPixels( 24 );
	fLibrariesList.setButtonsMinWidth( buttonBarWidth );

	//fSWTControl = composite;

	return composite;
}
 
Example 8
Source File: CodeAssistAdvancedConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void createSeparateLabel(Composite composite, int h_span) {
	PixelConverter pixelConverter= new PixelConverter(composite);
	int width= pixelConverter.convertWidthInCharsToPixels(40);

	Label label= new Label(composite, SWT.NONE | SWT.WRAP);
	label.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_separate_table_description);
	GridData gd= new GridData(GridData.FILL, GridData.FILL, false, false, h_span, 1);
	gd.widthHint= width;
	label.setLayoutData(gd);
}
 
Example 9
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 10
Source File: SourceContainerWorkbookPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Control getControl(Composite parent) {
	PixelConverter converter= new PixelConverter(parent);
	Composite composite= new Composite(parent, SWT.NONE);

	LayoutUtil.doDefaultLayout(composite, new DialogField[] { fFoldersList, fUseFolderOutputs , fOutputLocationField}, true, SWT.DEFAULT, SWT.DEFAULT);
	BidiUtils.applyBidiProcessing(fOutputLocationField.getTextControl(null), StructuredTextTypeHandlerFactory.FILE);
	LayoutUtil.setHorizontalGrabbing(fFoldersList.getTreeControl(null));

	int buttonBarWidth= converter.convertWidthInCharsToPixels(24);
	fFoldersList.setButtonsMinWidth(buttonBarWidth);

	fSWTControl= composite;

	// expand
	List<CPListElement> elements= fFoldersList.getElements();
	for (int i= 0; i < elements.size(); i++) {
		CPListElement elem= elements.get(i);
		IPath[] exclusionPatterns= (IPath[]) elem.getAttribute(CPListElement.EXCLUSION);
		IPath[] inclusionPatterns= (IPath[]) elem.getAttribute(CPListElement.INCLUSION);
		IPath output= (IPath) elem.getAttribute(CPListElement.OUTPUT);
		if (exclusionPatterns.length > 0 || inclusionPatterns.length > 0 || output != null) {
			fFoldersList.expandElement(elem, 3);
		}
	}
	return composite;
}
 
Example 11
Source File: ClasspathOrderingWorkbookPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Control getControl(Composite parent) {
	PixelConverter converter= new PixelConverter(parent);

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

	LayoutUtil.doDefaultLayout(composite, new DialogField[] { fClassPathList }, true, SWT.DEFAULT, SWT.DEFAULT);
	LayoutUtil.setHorizontalGrabbing(fClassPathList.getListControl(null));

	int buttonBarWidth= converter.convertWidthInCharsToPixels(24);
	fClassPathList.setButtonsMinWidth(buttonBarWidth);

	return composite;
}
 
Example 12
Source File: TextFieldExt.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void createContents_layout() {
	SWTLayoutUtil.layoutControls(array(label, text), null, text);
	
	GridData textGD = (GridData) text.getLayoutData();
	PixelConverter pixelConverter = new PixelConverter(text.getParent());
	textGD.widthHint = pixelConverter.convertWidthInCharsToPixels(textLimit + 1);
}
 
Example 13
Source File: LibrariesWorkbookPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Control getControl(Composite parent) {
	PixelConverter converter= new PixelConverter(parent);

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

	LayoutUtil.doDefaultLayout(composite, new DialogField[] { fLibrariesList }, true, SWT.DEFAULT, SWT.DEFAULT);
	LayoutUtil.setHorizontalGrabbing(fLibrariesList.getTreeControl(null));

	int buttonBarWidth= converter.convertWidthInCharsToPixels(24);
	fLibrariesList.setButtonsMinWidth(buttonBarWidth);

	fLibrariesList.setViewerComparator(new CPListElementSorter());

	fSWTControl= composite;

	return composite;
}
 
Example 14
Source File: ProjectsWorkbookPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Control getControl(Composite parent) {
	PixelConverter converter= new PixelConverter(parent);

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

	LayoutUtil.doDefaultLayout(composite, new DialogField[] { fProjectsList }, true, SWT.DEFAULT, SWT.DEFAULT);
	LayoutUtil.setHorizontalGrabbing(fProjectsList.getTreeControl(null));

	int buttonBarWidth= converter.convertWidthInCharsToPixels(24);
	fProjectsList.setButtonsMinWidth(buttonBarWidth);

	fSWTControl= composite;

	return composite;
}