use of org.eclipse.jface.layout.PixelConverter in project ow by vtst.
the class SWTFactory method getButtonWidthHint.
/**
* Returns a width hint for a button control.
*/
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);
}
use of org.eclipse.jface.layout.PixelConverter in project bndtools by bndtools.
the class SWTUtil method getButtonWidthHint.
// Shamelessly stolen from JDT
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);
}
use of org.eclipse.jface.layout.PixelConverter in project translationstudio8 by heartsome.
the class SelectGrantFileDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginWidth = 10;
layout.marginTop = 10;
tparent.setLayout(layout);
GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);
Composite compNav = new Composite(tparent, SWT.NONE);
GridLayout navLayout = new GridLayout();
compNav.setLayout(navLayout);
createNavigation(compNav);
Group groupFile = new Group(tparent, SWT.NONE);
groupFile.setText(Messages.getString("license.SelectGrantFileDialog.grantfile"));
GridDataFactory.fillDefaults().grab(true, true).applyTo(groupFile);
GridLayout layoutGroup = new GridLayout(3, false);
layoutGroup.marginWidth = 5;
layoutGroup.marginHeight = 100;
groupFile.setLayout(layoutGroup);
Label label = new Label(groupFile, SWT.NONE);
label.setText(Messages.getString("license.SelectGrantFileDialog.grantfile1"));
textPath = new Text(groupFile, SWT.BORDER);
textPath.setEditable(false);
GridData pathData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
pathData.widthHint = new PixelConverter(textPath).convertWidthInCharsToPixels(25);
textPath.setLayoutData(pathData);
// browse button
btnScan = new Button(groupFile, SWT.PUSH);
btnScan.setText(Messages.getString("license.SelectGrantFileDialog.scan"));
setButtonLayoutData(btnScan);
btnScan.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse .swt.events.SelectionEvent)
*/
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(textPath.getShell(), SWT.SHEET);
dialog.setFilterExtensions(FILE_IMPORT_MASK);
dialog.setText(Messages.getString("license.SelectGrantFileDialog.selectgrantfile"));
String fileName = textPath.getText().trim();
if (fileName.length() != 0) {
File path = new File(fileName).getParentFile();
if (path != null && path.exists()) {
dialog.setFilterPath(path.toString());
}
}
String path = dialog.open();
if (path != null) {
textPath.setText(path);
}
}
});
return tparent;
}
use of org.eclipse.jface.layout.PixelConverter in project translationstudio8 by heartsome.
the class ImportProjectWizardPage method createProjectsList.
/**
* Create the checkbox list for the found projects.
*
* @param workArea
*/
private void createProjectsList(Composite workArea) {
Label title = new Label(workArea, SWT.NONE);
title.setText(DataTransferMessages.WizardProjectsImportPage_ProjectsListTitle);
Composite listComposite = new Composite(workArea, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
layout.makeColumnsEqualWidth = false;
listComposite.setLayout(layout);
listComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
projectsList = new CheckboxTreeViewer(listComposite, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
projectsList.getControl().setLayoutData(gridData);
projectsList.setContentProvider(new ITreeContentProvider() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java
* .lang.Object)
*/
public Object[] getChildren(Object parentElement) {
return null;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.IStructuredContentProvider#getElements
* (java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
return getProjectRecords();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java
* .lang.Object)
*/
public boolean hasChildren(Object element) {
return false;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#getParent(java
* .lang.Object)
*/
public Object getParent(Object element) {
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse
* .jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
projectsList.setLabelProvider(new ProjectLabelProvider());
projectsList.addCheckStateListener(new ICheckStateListener() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged
* (org.eclipse.jface.viewers.CheckStateChangedEvent)
*/
public void checkStateChanged(CheckStateChangedEvent event) {
ProjectRecord element = (ProjectRecord) event.getElement();
if (element.hasConflicts) {
projectsList.setChecked(element, false);
}
setPageComplete(projectsList.getCheckedElements().length > 0);
}
});
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
createSelectionButtons(listComposite);
}
use of org.eclipse.jface.layout.PixelConverter in project translationstudio8 by heartsome.
the class ImportProjectWizardPage method createProjectsRoot.
/**
* Create the area where you select the root directory for the projects.
*
* @param workArea
* Composite
*/
private void createProjectsRoot(Composite workArea) {
// project specification group
Composite projectGroup = new Composite(workArea, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
layout.makeColumnsEqualWidth = false;
layout.marginWidth = 0;
projectGroup.setLayout(layout);
projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// new project from archive radio button
projectFromArchiveRadio = new Label(projectGroup, SWT.None);
projectFromArchiveRadio.setText(DataTransferMessages.WizardProjectsImportPage_ArchiveSelectTitle);
// project location entry field
archivePathField = new Text(projectGroup, SWT.BORDER);
GridData archivePathData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
archivePathData.widthHint = new PixelConverter(archivePathField).convertWidthInCharsToPixels(25);
// browse button
archivePathField.setLayoutData(archivePathData);
browseArchivesButton = new Button(projectGroup, SWT.PUSH);
browseArchivesButton.setText(DataTransferMessages.DataTransfer_browse);
setButtonLayoutData(browseArchivesButton);
browseArchivesButton.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
public void widgetSelected(SelectionEvent e) {
handleLocationArchiveButtonPressed();
}
});
archivePathField.addTraverseListener(new TraverseListener() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse
* .swt.events.TraverseEvent)
*/
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
updateProjectsList(archivePathField.getText().trim());
}
}
});
archivePathField.addFocusListener(new FocusAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt
* .events.FocusEvent)
*/
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
updateProjectsList(archivePathField.getText().trim());
}
});
}
Aggregations