use of org.eclipse.jface.layout.PixelConverter in project eclipse.platform.text by eclipse.
the class ScopePart method createPart.
/**
* Creates this scope part.
*
* @param parent a widget which will be the parent of the new instance (cannot be null)
* @return Returns the created part control
*/
public Composite createPart(Composite parent) {
fPart = new Group(parent, SWT.NONE);
fPart.setText(SearchMessages.ScopePart_group_text);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
fPart.setLayout(layout);
fPart.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fUseWorkspace = new Button(fPart, SWT.RADIO);
fUseWorkspace.setData(Integer.valueOf(ISearchPageContainer.WORKSPACE_SCOPE));
fUseWorkspace.setText(SearchMessages.ScopePart_workspaceScope_text);
fUseSelection = new Button(fPart, SWT.RADIO);
fUseSelection.setData(Integer.valueOf(ISearchPageContainer.SELECTION_SCOPE));
fUseSelection.setText(getSelectedResurcesButtonText());
boolean canSearchInSelection = canSearchInSelection();
fUseSelection.setEnabled(canSearchInSelection);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalIndent = 8;
fUseSelection.setLayoutData(gd);
fUseProject = new Button(fPart, SWT.RADIO);
fUseProject.setData(Integer.valueOf(ISearchPageContainer.SELECTED_PROJECTS_SCOPE));
fUseProject.setText(getEnclosingProjectsButtonText());
fUseProject.setEnabled(fSearchDialog.getEnclosingProjectNames().length > 0);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 2;
gd.horizontalIndent = 8;
fUseProject.setLayoutData(gd);
if (!fCanSearchEnclosingProjects)
fUseProject.setVisible(false);
fUseWorkingSet = new Button(fPart, SWT.RADIO);
fUseWorkingSet.setData(Integer.valueOf(ISearchPageContainer.WORKING_SET_SCOPE));
fUseWorkingSet.setText(SearchMessages.ScopePart_workingSetScope_text);
fWorkingSetText = new Text(fPart, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
fWorkingSetText.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = SearchMessages.ScopePart_workingSetText_accessible_label;
}
});
Button chooseWorkingSet = new Button(fPart, SWT.PUSH);
chooseWorkingSet.setLayoutData(new GridData());
chooseWorkingSet.setText(SearchMessages.ScopePart_workingSetChooseButton_text);
SWTUtil.setButtonDimensionHint(chooseWorkingSet);
chooseWorkingSet.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (handleChooseWorkingSet()) {
setSelectedScope(ISearchPageContainer.WORKING_SET_SCOPE);
}
}
});
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent = 8;
gd.horizontalSpan = 2;
gd.widthHint = new PixelConverter(fWorkingSetText).convertWidthInCharsToPixels(30);
fWorkingSetText.setLayoutData(gd);
// Add scope change listeners
SelectionAdapter scopeChangedLister = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleScopeChanged(e);
}
};
fUseWorkspace.addSelectionListener(scopeChangedLister);
fUseSelection.addSelectionListener(scopeChangedLister);
fUseProject.addSelectionListener(scopeChangedLister);
fUseWorkingSet.addSelectionListener(scopeChangedLister);
// Set initial scope
setSelectedScope(fScope);
// Set initial working set
if (fWorkingSets != null)
fWorkingSetText.setText(toString(fWorkingSets));
return fPart;
}
use of org.eclipse.jface.layout.PixelConverter in project eclipse.platform.text by eclipse.
the class AbstractTemplatesPage method createTemplateTree.
/**
* Create the tree to display templates.
*
* @param parent the parent composite
*/
private void createTemplateTree(Composite parent) {
Composite treeComposite = new Composite(parent, SWT.NONE);
GridData data = new GridData(GridData.FILL_BOTH);
treeComposite.setLayoutData(data);
TreeColumnLayout columnLayout = new TreeColumnLayout();
treeComposite.setLayout(columnLayout);
fTemplatesTree = new Tree(treeComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
fTemplatesTree.setHeaderVisible(true);
fTemplatesTree.setLinesVisible(true);
PixelConverter pixelConverter = new PixelConverter(fTemplatesTree);
TreeColumn columnName = new TreeColumn(fTemplatesTree, SWT.NONE);
columnName.setText(TemplatesMessages.TemplatesPage_column_name);
int minWidth = fPreferenceStore.getInt(COLUMN_NAME_WIDTH_PREF_ID);
if (minWidth == 0) {
minWidth = pixelConverter.convertWidthInCharsToPixels(30);
}
columnLayout.setColumnData(columnName, new ColumnPixelData(minWidth, true));
columnName.addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
int nameWidth = ((TreeColumn) e.getSource()).getWidth();
fPreferenceStore.setValue(COLUMN_NAME_WIDTH_PREF_ID, nameWidth);
}
});
TreeColumn columnDescription = new TreeColumn(fTemplatesTree, SWT.NONE);
columnDescription.setText(TemplatesMessages.TemplatesPage_column_description);
minWidth = fPreferenceStore.getInt(COLUMN_DESCRIPTION_WIDTH_PREF_ID);
if (minWidth == 0) {
minWidth = pixelConverter.convertWidthInCharsToPixels(45);
}
columnLayout.setColumnData(columnDescription, new ColumnPixelData(minWidth, false));
columnDescription.addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
int descriptionWidth = ((TreeColumn) e.getSource()).getWidth();
fPreferenceStore.setValue(COLUMN_DESCRIPTION_WIDTH_PREF_ID, descriptionWidth);
}
});
createTreeViewer(fTemplatesTree);
}
use of org.eclipse.jface.layout.PixelConverter in project eclipse.platform.text by eclipse.
the class TextEditorDefaultsPreferencePage method addFiller.
private void addFiller(Composite composite, int horizontalSpan) {
PixelConverter pixelConverter = new PixelConverter(composite);
Label filler = new Label(composite, SWT.LEFT);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = horizontalSpan;
gd.heightHint = pixelConverter.convertHeightInCharsToPixels(1) / 2;
filler.setLayoutData(gd);
}
use of org.eclipse.jface.layout.PixelConverter in project eclipse.platform.text by eclipse.
the class SWTUtil method getButtonWidthHint.
/**
* Returns a width hint for the given button.
*
* @param button the button
* @return the width hint for the button
*/
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 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;
}
Aggregations