use of org.eclipse.jface.layout.PixelConverter in project eclipse.platform.text by eclipse.
the class QuickDiffConfigurationBlock method addFiller.
private void addFiller(Composite composite) {
PixelConverter pixelConverter = new PixelConverter(composite);
Label filler = new Label(composite, SWT.LEFT);
GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false);
gd.horizontalSpan = 2;
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 a button control.
* @param button The button to calculate the width for
* @return The width of 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 linuxtools by eclipse.
the class LaunchConfigurationUtils method getButtonWidthHint.
/**
* Computes the size of the given {@link Button} and returns the width.
*
* @param button
* the button for which the size must be computed.
* @return the width hint for the given button
*/
public static int getButtonWidthHint(final Button button) {
/* button.setFont(JFaceResources.getDialogFont()); */
final PixelConverter converter = new PixelConverter(button);
final 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 knime-core by knime.
the class SubnodeLayoutJSONEditorPage method createJSONEditorComposite.
private Composite createJSONEditorComposite(final Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, true));
composite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
if (isWindows()) {
Composite embedComposite = new Composite(composite, SWT.EMBEDDED | SWT.NO_BACKGROUND);
final GridLayout gridLayout = new GridLayout();
gridLayout.verticalSpacing = 0;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
gridLayout.horizontalSpacing = 0;
embedComposite.setLayout(gridLayout);
embedComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Frame frame = SWT_AWT.new_Frame(embedComposite);
Panel heavyWeightPanel = new Panel();
heavyWeightPanel.setLayout(new BoxLayout(heavyWeightPanel, BoxLayout.Y_AXIS));
frame.add(heavyWeightPanel);
frame.setFocusTraversalKeysEnabled(false);
// Use JApplet with JRootPane as layer in between heavyweightPanel and RTextScrollPane
// This reduces flicker on resize in RSyntaxTextArea
JApplet applet = new JApplet();
JRootPane root = applet.getRootPane();
Container contentPane = root.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
heavyWeightPanel.add(applet);
m_textArea = new RSyntaxTextArea(10, 60);
m_textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JSON);
m_textArea.setCodeFoldingEnabled(true);
m_textArea.setAntiAliasingEnabled(true);
RTextScrollPane sp = new RTextScrollPane(m_textArea);
sp.setDoubleBuffered(true);
m_textArea.setText(m_jsonDocument);
m_textArea.setEditable(true);
m_textArea.setEnabled(true);
contentPane.add(sp);
Dimension size = sp.getPreferredSize();
embedComposite.setSize(size.width, size.height);
// forward focus to RSyntaxTextArea
embedComposite.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(final FocusEvent e) {
ViewUtils.runOrInvokeLaterInEDT(new Runnable() {
@Override
public void run() {
m_textArea.requestFocus();
m_textArea.setCaretPosition(m_caretPosition);
}
});
}
@Override
public void focusLost(final FocusEvent e) {
// do nothing
}
});
// delete content of status line, when something is inserted or deleted
m_textArea.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(final DocumentEvent arg0) {
if (!composite.isDisposed()) {
composite.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (m_statusLine != null && !m_statusLine.isDisposed()) {
m_statusLine.setText("");
updateModelFromJson();
}
}
});
}
}
@Override
public void insertUpdate(final DocumentEvent arg0) {
/* do nothing */
}
@Override
public void removeUpdate(final DocumentEvent arg0) {
/* do nothing */
}
});
// remember caret position
m_textArea.addCaretListener(new CaretListener() {
@Override
public void caretUpdate(final CaretEvent arg0) {
m_caretPosition = arg0.getDot();
}
});
} else {
m_text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
GridData layoutData = new GridData(GridData.FILL_BOTH);
layoutData.widthHint = 600;
layoutData.heightHint = 400;
m_text.setLayoutData(layoutData);
m_text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
m_jsonDocument = m_text.getText();
if (m_statusLine != null && !m_statusLine.isDisposed()) {
m_statusLine.setText("");
updateModelFromJson();
}
}
});
m_text.setText(m_jsonDocument);
}
// add status line
m_statusLine = new Label(composite, SWT.SHADOW_NONE | SWT.WRAP);
GridData statusGridData = new GridData(SWT.LEFT | SWT.FILL, SWT.BOTTOM, true, false);
int maxHeight = new PixelConverter(m_statusLine).convertHeightInCharsToPixels(3);
statusGridData.heightHint = maxHeight + 5;
// seems to have no impact on the layout. The height will still be 3 rows (at least on Windows 8)
statusGridData.minimumHeight = new PixelConverter(m_statusLine).convertHeightInCharsToPixels(1);
m_statusLine.setLayoutData(statusGridData);
compareNodeIDs();
return composite;
}
Aggregations