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());
}
});
}
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 eclipse.platform.text by eclipse.
the class SpellingConfigurationBlock method createControl.
/**
* Creates page for spelling preferences.
*
* @param parent the parent composite
* @return the control for the preference page
*/
@Override
public Control createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
// assume parent page uses grid-data
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL);
composite.setLayoutData(gd);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
PixelConverter pc = new PixelConverter(composite);
layout.verticalSpacing = pc.convertHeightInCharsToPixels(1) / 2;
composite.setLayout(layout);
if (EditorsUI.getSpellingService().getSpellingEngineDescriptors().length == 0) {
Label label = new Label(composite, SWT.NONE);
label.setText(TextEditorMessages.SpellingConfigurationBlock_error_not_installed);
return composite;
}
/* check box for new editors */
fEnablementCheckbox = new Button(composite, SWT.CHECK);
fEnablementCheckbox.setText(TextEditorMessages.SpellingConfigurationBlock_enable);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
fEnablementCheckbox.setLayoutData(gd);
fEnablementCheckbox.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean enabled = fEnablementCheckbox.getSelection();
fStore.setValue(SpellingService.PREFERENCE_SPELLING_ENABLED, enabled);
updateCheckboxDependencies();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
Label label = new Label(composite, SWT.CENTER);
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
label.setLayoutData(gd);
if (fProviderDescriptors.size() > 1) {
fComboGroup = new Composite(composite, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
gd.horizontalIndent = 10;
fComboGroup.setLayoutData(gd);
GridLayout gridLayout = new GridLayout(2, false);
gridLayout.marginWidth = 0;
fComboGroup.setLayout(gridLayout);
Label comboLabel = new Label(fComboGroup, SWT.CENTER);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER);
comboLabel.setLayoutData(gd);
comboLabel.setText(TextEditorMessages.SpellingConfigurationBlock_combo_caption);
label = new Label(composite, SWT.CENTER);
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
label.setLayoutData(gd);
fProviderCombo = new Combo(fComboGroup, SWT.READ_ONLY | SWT.DROP_DOWN);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER);
fProviderCombo.setLayoutData(gd);
fProviderViewer = createProviderViewer();
}
Composite groupComp = new Composite(composite, SWT.NONE);
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
groupComp.setLayoutData(gd);
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.marginWidth = 0;
groupComp.setLayout(gridLayout);
/* contributed provider preferences. */
fGroup = new Composite(groupComp, SWT.NONE);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.horizontalIndent = 10;
fGroup.setLayoutData(gd);
fStackLayout = new StackLayout();
fGroup.setLayout(fStackLayout);
return composite;
}
use of org.eclipse.jface.layout.PixelConverter in project eclipse.platform.text by eclipse.
the class HyperlinkDetectorsConfigurationBlock method createControl.
@Override
public Control createControl(Composite parent) {
PixelConverter pixelConverter = new PixelConverter(parent);
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
composite.setLayout(layout);
addFiller(composite, 2);
String label = TextEditorMessages.HyperlinksEnabled_label;
fHyperlinksEnabledCheckBox = addCheckBox(composite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED, 0);
fHyperlinksEnabledCheckBox.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean state = fHyperlinksEnabledCheckBox.getSelection();
fHyperlinkDefaultKeyModifierText.setEnabled(state);
fHyperlinkKeyModifierText.setEnabled(state && getSelectedItem() != null);
fHyperlinkDetectorsViewer.getTable().setEnabled(state);
handleHyperlinkKeyModifierModified();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
// Text field for default modifier string
label = TextEditorMessages.HyperlinkDefaultKeyModifier_label;
fHyperlinkDefaultKeyModifierText = (Text) addTextField(composite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_KEY_MODIFIER, 15, 20, pixelConverter)[1];
fHyperlinkDefaultKeyModifierText.addKeyListener(new KeyListener() {
private boolean isModifierCandidate;
@Override
public void keyPressed(KeyEvent e) {
isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
}
@Override
public void keyReleased(KeyEvent e) {
if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {
// && e.time -time < 1000) {
String modifierString = fHyperlinkDefaultKeyModifierText.getText();
Point selection = fHyperlinkDefaultKeyModifierText.getSelection();
int i = selection.x - 1;
while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
i--;
}
boolean needsPrefixDelimiter = i > -1 && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
i = selection.y;
while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) {
i++;
}
boolean needsPostfixDelimiter = i < modifierString.length() && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
String insertString;
if (needsPrefixDelimiter && needsPostfixDelimiter)
insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifierAndDelimiter, Action.findModifierString(e.stateMask));
else if (needsPrefixDelimiter)
insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifier, Action.findModifierString(e.stateMask));
else if (needsPostfixDelimiter)
insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertModifierAndDelimiter, Action.findModifierString(e.stateMask));
else
insertString = Action.findModifierString(e.stateMask);
fHyperlinkDefaultKeyModifierText.insert(insertString);
}
}
});
fHyperlinkDefaultKeyModifierText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
handleHyperlinkDefaultKeyModifierModified();
}
});
addFiller(composite, 2);
Composite editorComposite = new Composite(composite, SWT.NONE);
GridData gd;
gd = new GridData(SWT.FILL, SWT.TOP, true, false);
gd.horizontalSpan = 2;
gd.horizontalIndent = 20;
editorComposite.setLayoutData(gd);
TableColumnLayout tableColumnlayout = new TableColumnLayout();
editorComposite.setLayout(tableColumnlayout);
// Hyperlink detector table
Table hyperlinkDetectorTable = new Table(editorComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
hyperlinkDetectorTable.setHeaderVisible(true);
hyperlinkDetectorTable.setLinesVisible(true);
hyperlinkDetectorTable.setFont(parent.getFont());
hyperlinkDetectorTable.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
handleListSelection();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
ColumnLayoutData columnLayoutData = new ColumnWeightData(1);
TableColumn nameColumn = new TableColumn(hyperlinkDetectorTable, SWT.NONE, 0);
nameColumn.setText(TextEditorMessages.HyperlinkDetectorTable_nameColumn);
tableColumnlayout.setColumnData(nameColumn, columnLayoutData);
TableColumn modifierKeysColumn = new TableColumn(hyperlinkDetectorTable, SWT.NONE, 1);
modifierKeysColumn.setText(TextEditorMessages.HyperlinkDetectorTable_modifierKeysColumn);
tableColumnlayout.setColumnData(modifierKeysColumn, columnLayoutData);
TableColumn targetNameColumn = new TableColumn(hyperlinkDetectorTable, SWT.NONE, 2);
targetNameColumn.setText(TextEditorMessages.HyperlinkDetectorTable_targetNameColumn);
tableColumnlayout.setColumnData(targetNameColumn, columnLayoutData);
fHyperlinkDetectorsViewer = new CheckboxTableViewer(hyperlinkDetectorTable);
fHyperlinkDetectorsViewer.setUseHashlookup(true);
fHyperlinkDetectorsViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
String id = ((ListItem) event.getElement()).id;
if (id == null)
return;
fStore.setValue(id, !event.getChecked());
}
});
fHyperlinkDetectorsViewer.setLabelProvider(new ItemLabelProvider());
fHyperlinkDetectorsViewer.setContentProvider(new ItemContentProvider());
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.heightHint = pixelConverter.convertHeightInCharsToPixels(10);
fHyperlinkDetectorsViewer.getControl().setLayoutData(gd);
// addFiller(composite, 2);
// Text field for modifier string
label = TextEditorMessages.HyperlinkKeyModifier_label;
fHyperlinkKeyModifierText = (Text) addTextField(composite, label, null, 15, 20, pixelConverter)[1];
fHyperlinkKeyModifierText.addKeyListener(new KeyListener() {
private boolean isModifierCandidate;
@Override
public void keyPressed(KeyEvent e) {
isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
}
@Override
public void keyReleased(KeyEvent e) {
if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {
// && e.time -time < 1000) {
String modifierString = fHyperlinkKeyModifierText.getText();
Point selection = fHyperlinkKeyModifierText.getSelection();
int i = selection.x - 1;
while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
i--;
}
boolean needsPrefixDelimiter = i > -1 && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
i = selection.y;
while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) {
i++;
}
boolean needsPostfixDelimiter = i < modifierString.length() && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
String insertString;
if (needsPrefixDelimiter && needsPostfixDelimiter)
insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifierAndDelimiter, Action.findModifierString(e.stateMask));
else if (needsPrefixDelimiter)
insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifier, Action.findModifierString(e.stateMask));
else if (needsPostfixDelimiter)
insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertModifierAndDelimiter, Action.findModifierString(e.stateMask));
else
insertString = Action.findModifierString(e.stateMask);
fHyperlinkKeyModifierText.insert(insertString);
}
}
});
fHyperlinkKeyModifierText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
handleHyperlinkKeyModifierModified();
}
});
return composite;
}
Aggregations