List of usage examples for org.eclipse.jface.layout PixelConverter convertHeightInCharsToPixels
public int convertHeightInCharsToPixels(int chars)
From source file:com.cisco.yangide.editor.preferences.YangEditorColoringConfigurationBlock.java
License:Open Source License
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;// ww w . j av a 2 s.c o m gd.heightHint = pixelConverter.convertHeightInCharsToPixels(1) / 2; filler.setLayoutData(gd); }
From source file:com.google.dart.tools.ui.actions.AbstractOpenWizardAction.java
License:Open Source License
@Override public void run() { EmitInstrumentationCommand();// w ww . ja va 2s . c o m Shell shell = getShell(); try { INewWizard wizard = createWizard(); wizard.init(PlatformUI.getWorkbench(), getSelection()); WizardDialog dialog = new WizardDialog(shell, wizard); PixelConverter converter = new PixelConverter(JFaceResources.getDialogFont()); dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20)); dialog.create(); int res = dialog.open(); notifyResult(res == Window.OK); } catch (CoreException e) { String title = ActionMessages.AbstractOpenWizardAction_createerror_title; String message = ActionMessages.AbstractOpenWizardAction_createerror_message; ExceptionHandler.handle(e, shell, title, message); } }
From source file:com.google.dart.tools.ui.internal.cleanup.preference.DartEditorAppearanceConfigurationBlock.java
License:Open Source License
private void addFiller(Composite composite) { PixelConverter pixelConverter = new PixelConverter(composite); Label filler = new Label(composite, SWT.LEFT); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 2;//from ww w . j a v a 2s .co m gd.heightHint = pixelConverter.convertHeightInCharsToPixels(1) / 2; filler.setLayoutData(gd); }
From source file:com.google.dart.tools.ui.internal.refactoring.ExtractMethodInputPage.java
License:Open Source License
private void createSignaturePreview(Composite composite, RowLayouter layouter) { Label previewLabel = new Label(composite, SWT.NONE); previewLabel.setText(RefactoringMessages.ExtractMethodInputPage_signature_preview); layouter.perform(previewLabel);/*from w ww . j av a 2 s . c o m*/ IPreferenceStore store = DartToolsPlugin.getDefault().getCombinedPreferenceStore(); fSignaturePreview = new DartSourceViewer(composite, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP /*| SWT.BORDER*/, store); fSignaturePreview.configure(new DartSourceViewerConfiguration( DartToolsPlugin.getDefault().getDartTextTools().getColorManager(), store, null, null)); fSignaturePreview.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); fSignaturePreview.adaptBackgroundColor(composite); fSignaturePreview.setDocument(fSignaturePreviewDocument); fSignaturePreview.setEditable(false); Control signaturePreviewControl = fSignaturePreview.getControl(); PixelConverter pixelConverter = new PixelConverter(signaturePreviewControl); GridData gdata = new GridData(GridData.FILL_BOTH); gdata.widthHint = pixelConverter.convertWidthInCharsToPixels(50); gdata.heightHint = pixelConverter.convertHeightInCharsToPixels(2); signaturePreviewControl.setLayoutData(gdata); layouter.perform(signaturePreviewControl); }
From source file:com.liferay.ide.project.ui.action.NewWizardAction.java
License:Open Source License
public void run() { Shell shell = getShell();// w w w .j a v a2 s . c om try { INewWizard wizard = createWizard(); wizard.init(PlatformUI.getWorkbench(), getSelection()); WizardDialog dialog = new WizardDialog(shell, wizard); PixelConverter converter = new PixelConverter(JFaceResources.getDialogFont()); dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20)); dialog.create(); int res = dialog.open(); notifyResult(res == Window.OK); } catch (CoreException e) { } }
From source file:de.byteholder.geoclipse.map.DialogManageOfflineImages.java
License:Open Source License
private void createUI20PartViewer(final Composite parent) { final PixelConverter pixelConverter = new PixelConverter(parent); final TableColumnLayout tableLayout = new TableColumnLayout(); final Composite layoutContainer = new Composite(parent, SWT.NONE); layoutContainer.setLayout(tableLayout); GridDataFactory.fillDefaults()// .grab(true, true).hint(SWT.DEFAULT, pixelConverter.convertHeightInCharsToPixels(13)) .applyTo(layoutContainer);// w w w. ja va 2 s.c om /* * create table */ final Table table = new Table(layoutContainer, SWT.FULL_SELECTION | SWT.BORDER); table.setLayout(new TableLayout()); table.setHeaderVisible(true); table.setLinesVisible(true); _partViewer = new TableViewer(table); /* * create columns */ TableViewerColumn tvc; TableColumn tvcColumn; // column: map provider tvc = new TableViewerColumn(_partViewer, SWT.LEAD); tvcColumn = tvc.getColumn(); tvcColumn.setText(Messages.Dialog_OfflineArea_Column_MapProvider); tvc.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final PartMP partMp = (PartMP) cell.getElement(); cell.setText(partMp.partMp.getName()); } }); tableLayout.setColumnData(tvcColumn, new ColumnWeightData(100)); // column: existing images tvc = new TableViewerColumn(_partViewer, SWT.TRAIL); tvcColumn = tvc.getColumn(); tvcColumn.setText(Messages.Dialog_OfflineArea_Column_ExistingImages); tvcColumn.setToolTipText(Messages.Dialog_OfflineArea_Column_ExistingImages_Tooltip); tvc.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final PartMP partMp = (PartMP) cell.getElement(); cell.setText(Integer.toString(partMp.existingImages)); } }); tableLayout.setColumnData(tvcColumn, new ColumnPixelData(pixelConverter.convertWidthInCharsToPixels(12), true)); // column: missing images tvc = new TableViewerColumn(_partViewer, SWT.TRAIL); tvcColumn = tvc.getColumn(); tvcColumn.setText(Messages.Dialog_OfflineArea_Column_MissingImages); tvcColumn.setToolTipText(Messages.Dialog_OfflineArea_Column_MissingImages_Tooltip); tvc.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final PartMP partMp = (PartMP) cell.getElement(); cell.setText(Integer.toString(partMp.missingImages)); } }); tableLayout.setColumnData(tvcColumn, new ColumnPixelData(pixelConverter.convertWidthInCharsToPixels(12), true)); /* * create table viewer */ _partViewer.setContentProvider(new PartViewerContentProvicer()); _partViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { final StructuredSelection selection = (StructuredSelection) event.getSelection(); if (selection != null) { enableControls(true); } } }); }
From source file:de.walware.ecommons.ui.util.ViewerUtil.java
License:Open Source License
public static Point calculateTreeSizeHint(final Control treeControl, final Node[] rootNodes, final int rows) { final Point pixels = new Point(0, 0); final PixelConverter tool = new PixelConverter(treeControl); float factor = tool.convertWidthInCharsToPixels(2); final ScrollBar vBar = ((Scrollable) treeControl).getVerticalBar(); if (vBar != null) { factor = vBar.getSize().x * 1.1f; // scrollbars and tree indentation guess }/* w w w . j a v a2 s.c o m*/ pixels.x = measureNodes(tool, factor, rootNodes, 1) + ((int) factor); pixels.y = tool.convertHeightInCharsToPixels(rows); return pixels; }
From source file:de.walware.statet.r.internal.debug.ui.preferences.RInteractionPreferencePage.java
License:Open Source License
private Composite createConnectorComponent(final Composite parent) { final String[] connectorLabels = new String[fConnectors.length]; for (int i = 0; i < fConnectors.length; i++) { connectorLabels[i] = fConnectors[i].fName; }/* ww w . j a va 2 s .c o m*/ final Group group = new Group(parent, SWT.NONE); group.setText(Messages.RInteraction_RConnector); final Layouter layouter = new Layouter(group, 2); fConnectorsSelector = layouter.addComboControl(connectorLabels, 2); // Description layouter.addLabel(Messages.RInteraction_RConnector_Description_label, 0, 1, true); final ScrolledComposite scrolled = new ScrolledComposite(layouter.composite, SWT.V_SCROLL); fConnectorsDescription = addLinkControl(scrolled, ""); //$NON-NLS-1$ scrolled.addControlListener(new ControlListener() { @Override public void controlMoved(final org.eclipse.swt.events.ControlEvent e) { }; @Override public void controlResized(final org.eclipse.swt.events.ControlEvent e) { updateDescriptionSize(); }; }); final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false); final PixelConverter pixelConverter = new PixelConverter(fConnectorsDescription); gd.horizontalSpan = 1; gd.widthHint = pixelConverter.convertWidthInCharsToPixels(40); gd.heightHint = pixelConverter.convertHeightInCharsToPixels(5); scrolled.setLayoutData(gd); scrolled.setContent(fConnectorsDescription); fConnectorsSelector.addModifyListener(new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { final int idx = fConnectorsSelector.getSelectionIndex(); if (idx >= 0) { setPrefValue(RRunDebugPreferenceConstants.PREF_R_CONNECTOR, fConnectors[idx].fId); updateDescription(idx); } }; }); return group; }
From source file:ext.org.eclipse.jdt.internal.ui.callhierarchy.ExpandWithConstructorsConfigurationBlock.java
License:Open Source License
/** * Create a list dialog field.// w ww . jav a 2 s . c o m * * @param parent the composite */ private void createPreferenceList(Composite parent) { String[] buttonLabels = new String[] { CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_newType_button, CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_newMember_button, CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_edit_button, CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_remove_button, CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_restoreDefaults_button }; ListAdapter adapter = new ListAdapter(); fList = new ListDialogField<String>(adapter, buttonLabels, new ListLabelProvider()); fList.setDialogFieldListener(adapter); fList.setLabelText(CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_description); fList.setRemoveButtonIndex(IDX_REMOVE); fList.enableButton(IDX_EDIT, false); fList.setViewerComparator(new ViewerComparator()); PixelConverter pixelConverter = new PixelConverter(parent); fList.doFillIntoGrid(parent, 3); LayoutUtil.setHorizontalSpan(fList.getLabelControl(null), 2); LayoutUtil.setWidthHint(fList.getLabelControl(null), pixelConverter.convertWidthInCharsToPixels(60)); LayoutUtil.setHorizontalGrabbing(fList.getListControl(null)); Control listControl = fList.getListControl(null); GridData gd = (GridData) listControl.getLayoutData(); gd.verticalAlignment = GridData.FILL; gd.grabExcessVerticalSpace = true; gd.heightHint = pixelConverter.convertHeightInCharsToPixels(10); }
From source file:ext.org.eclipse.jdt.internal.ui.fix.CleanUpSaveParticipantPreferenceConfiguration.java
License:Open Source License
/** * {@inheritDoc}/*from w ww . j a va 2 s .c om*/ */ @Override public void createConfigControl(final Composite parent, IPreferencePageContainer container) { fContainer = container; fShell = parent.getShell(); fCleanUpOptionsComposite = new Composite(parent, SWT.NONE); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); gridData.horizontalIndent = INDENT; fCleanUpOptionsComposite.setLayoutData(gridData); GridLayout gridLayout = new GridLayout(1, false); gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; fCleanUpOptionsComposite.setLayout(gridLayout); fFormatCodeButton = new Button(fCleanUpOptionsComposite, SWT.CHECK); fFormatCodeButton.setText( SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_SaveActionPreferencePage_FormatSource_Checkbox); fFormatCodeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); fFormatCodeButton.addSelectionListener(new SelectionAdapter() { /** * {@inheritDoc} */ @Override public void widgetSelected(SelectionEvent e) { changeSettingsValue(CleanUpConstants.FORMAT_SOURCE_CODE, fFormatCodeButton.getSelection()); } }); Composite regionFormatingCombo = new Composite(fCleanUpOptionsComposite, SWT.NONE); gridData = new GridData(SWT.FILL, SWT.TOP, true, false); gridData.horizontalIndent = 20; regionFormatingCombo.setLayoutData(gridData); gridLayout = new GridLayout(1, false); gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; regionFormatingCombo.setLayout(gridLayout); fFormatAllButton = new Button(regionFormatingCombo, SWT.RADIO); fFormatAllButton.setText( SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_SaveActionPreferencePAge_FormatAllLines_Radio); gridData = new GridData(SWT.FILL, SWT.TOP, true, false); fFormatAllButton.setLayoutData(gridData); fFormatAllButton.addSelectionListener(new SelectionAdapter() { /** * {@inheritDoc} */ @Override public void widgetSelected(SelectionEvent e) { changeSettingsValue(CleanUpConstants.FORMAT_SOURCE_CODE_CHANGES_ONLY, !fFormatAllButton.getSelection()); } }); fFormatChangedOnlyButton = new Button(regionFormatingCombo, SWT.RADIO); fFormatChangedOnlyButton.setText( SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_SaveActionPreferencePage_FormatOnlyChangedRegions_Radio); gridData = new GridData(SWT.FILL, SWT.TOP, true, false); fFormatChangedOnlyButton.setLayoutData(gridData); fFormatChangedOnlyButton.addSelectionListener(new SelectionAdapter() { /** * {@inheritDoc} */ @Override public void widgetSelected(SelectionEvent e) { changeSettingsValue(CleanUpConstants.FORMAT_SOURCE_CODE_CHANGES_ONLY, fFormatChangedOnlyButton.getSelection()); } }); PixelConverter pixelConverter = new PixelConverter(parent); int heightOneHalf = (int) Math.round(pixelConverter.convertHeightInCharsToPixels(1) * 1.5); fFormatConfigLink = new Link(fCleanUpOptionsComposite, SWT.NONE); fFormatConfigLink.setText( SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_ConfigureFormatter_Link); GridData gridData2 = new GridData(SWT.LEFT, SWT.TOP, false, false); gridData2.horizontalIndent = 20; gridData2.minimumHeight = heightOneHalf; fFormatConfigLink.setLayoutData(gridData2); fOrganizeImportsButton = new Button(fCleanUpOptionsComposite, SWT.CHECK); fOrganizeImportsButton.setText( SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_SaveActionPreferencePage_OrganizeImports_Checkbox); fOrganizeImportsButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); fOrganizeImportsButton.addSelectionListener(new SelectionAdapter() { /** * {@inheritDoc} */ @Override public void widgetSelected(SelectionEvent e) { changeSettingsValue(CleanUpConstants.ORGANIZE_IMPORTS, fOrganizeImportsButton.getSelection()); } }); fOrganizeImportsConfigLink = new Link(fCleanUpOptionsComposite, SWT.NONE); fOrganizeImportsConfigLink.setText( SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_ConfigureImports_Link); GridData gridData3 = new GridData(SWT.LEFT, SWT.TOP, false, false); gridData3.horizontalIndent = 20; gridData3.minimumHeight = heightOneHalf; fOrganizeImportsConfigLink.setLayoutData(gridData3); fAdditionalActionButton = new Button(fCleanUpOptionsComposite, SWT.CHECK); fAdditionalActionButton.setText( SaveParticipantMessages.CleanUpSaveParticipantPreferenceConfiguration_AdditionalActions_Checkbox); createAdvancedComposite(fCleanUpOptionsComposite); fAdditionalActionButton.addSelectionListener(new SelectionAdapter() { /** * {@inheritDoc} */ @Override public void widgetSelected(SelectionEvent e) { changeSettingsValue(CleanUpConstants.CLEANUP_ON_SAVE_ADDITIONAL_OPTIONS, fAdditionalActionButton.getSelection()); } }); }