List of usage examples for org.eclipse.jface.resource JFaceResources getDialogFont
public static Font getDialogFont()
From source file:org.eclipse.wst.common.snippets.internal.VariableInsertionDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { parent.getShell().setText(getDialogTitle()); SnippetsPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(parent, IHelpContextIds.DIALOG_INSERT_VARITEM); Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2;//from w w w . j a v a2s . com layout.makeColumnsEqualWidth = true; layout.horizontalSpacing += 2; layout.verticalSpacing += 2; composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(parent.getFont()); GridData doubleWide = new GridData(GridData.FILL_BOTH); doubleWide.horizontalSpan = 2; Text instructions = new Text(composite, SWT.WRAP | SWT.LEFT); instructions.setBackground(composite.getBackground()); doubleWide.heightHint = instructions.getFont().getFontData()[0].getHeight() * 3; instructions.setLayoutData(doubleWide); instructions.setText(SnippetsMessages.Edit_Instruction); instructions.setEditable(false); Text tableLabel = new Text(composite, SWT.NONE); tableLabel.setBackground(composite.getBackground()); tableLabel.setText(SnippetsMessages.Variables__4); tableLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); tableLabel.setEditable(false); Text descriptionBoxLabel = new Text(composite, SWT.NONE); descriptionBoxLabel.setBackground(composite.getBackground()); descriptionBoxLabel.setText(SnippetsMessages.Description_of_variable__5); descriptionBoxLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); descriptionBoxLabel.setEditable(false); // pity we can't just use a PropertySheetPage, but the column headers // aren't customizable fTableViewer = new StringPropertyTableViewer(); fTableViewer.setColumnNames(new String[] { SnippetsMessages.Variable_Name_6, SnippetsMessages.Value_7 }); fTableViewer.setEditFirstColumn(false); fTableViewer.createContents(composite); GridData data = new GridData(GridData.FILL_BOTH); data.heightHint = fTableViewer.getTable().getItemHeight() * 5; fTableViewer.getControl().setLayoutData(data); fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ISnippetVariable variable = null; if (fTableViewer.getSelection() != null) { variable = getVariable(fTableViewer.getSelection()); } fDescriptionPane.setText(variable != null ? variable.getDescription() : ""); //$NON-NLS-1$ fDescriptionPane.setHorizontalPixel(2); fDescriptionPane.redraw(); } }); fTableViewer.addValueChangedListener(new ValueChangedListener() { public void valueChanged(String key, String property, String oldValue, String newValue) { update(); } }); fDescriptionPane = new StyledText(composite, SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP); fDescriptionPane.setLayoutData(new GridData(GridData.FILL_BOTH)); fDescriptionPane.setEnabled(true); fDescriptionPane.setEditable(false); fDescriptionPane.addVerifyKeyListener(createVerifyListener(fDescriptionPane)); fDescriptionPane.setFont(JFaceResources.getDialogFont()); setAccessible(fDescriptionPane, SnippetsMessages.Description_of_variable__5); doubleWide = new GridData(GridData.FILL_BOTH); doubleWide.horizontalSpan = 2; Text previewLabel = new Text(composite, SWT.NULL); previewLabel.setBackground(composite.getBackground()); previewLabel.setText(SnippetsMessages.Preview__9); previewLabel.setEditable(false); doubleWide = new GridData(GridData.FILL_BOTH); doubleWide.horizontalSpan = 2; doubleWide.heightHint = parent.getDisplay().getClientArea().height / 6; doubleWide.widthHint = parent.getDisplay().getClientArea().width / 8; fPreviewPane = new StyledText(composite, SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); fPreviewPane.addVerifyKeyListener(createVerifyListener(fPreviewPane)); fPreviewPane.addLineStyleListener(new LineStyleListener() { public void lineGetStyle(LineStyleEvent event) { // System.out.println("hilight: " + event.lineOffset); } }); fPreviewPane.setEnabled(true); fPreviewPane.setEditable(false); fPreviewPane.setFont(JFaceResources.getTextFont()); fPreviewPane.setLayoutData(doubleWide); setAccessible(fPreviewPane, SnippetsMessages.Preview__9); if (fItem != null) { fTableViewer.clear(); populateTableViewer(); fTableViewer.refresh(); } addContents(composite); update(); fTableViewer.getControl().setFocus(); return composite; }
From source file:org.eclipse.wst.jsdt.internal.ui.javadocexport.JavadocWizard.java
License:Open Source License
public static void openJavadocWizard(JavadocWizard wizard, Shell shell, IStructuredSelection selection) { wizard.init(PlatformUI.getWorkbench(), selection); WizardDialog dialog = new WizardDialog(shell, wizard); PixelConverter converter = new PixelConverter(JFaceResources.getDialogFont()); dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(100), converter.convertHeightInCharsToPixels(20)); dialog.open();/*from ww w.j av a2 s . c o m*/ }
From source file:org.eclipse.wst.jsdt.internal.ui.text.correction.NewCUCompletionUsingWizardProposal.java
License:Open Source License
public void apply(IDocument document) { NewElementWizard wizard = null;/*from w ww . j a v a 2 s .com*/ wizard.init(JavaScriptPlugin.getDefault().getWorkbench(), new StructuredSelection(fCompilationUnit)); IType createdType = null; if (fShowDialog) { Shell shell = JavaScriptPlugin.getActiveWorkbenchShell(); WizardDialog dialog = new WizardDialog(shell, wizard); PixelConverter converter = new PixelConverter(JFaceResources.getDialogFont()); dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20)); dialog.create(); dialog.getShell().setText(CorrectionMessages.NewCUCompletionUsingWizardProposal_dialogtitle); configureWizardPage(wizard); if (dialog.open() == Window.OK) { createdType = (IType) wizard.getCreatedElement(); } } else { wizard.addPages(); try { NewTypeWizardPage page = configureWizardPage(wizard); page.createType(null); createdType = page.getCreatedType(); } catch (CoreException e) { JavaScriptPlugin.log(e); } catch (InterruptedException e) { } } if (createdType != null) { IJavaScriptElement container = createdType.getParent(); if (container instanceof IJavaScriptUnit) { container = container.getParent(); } if (!container.equals(fTypeContainer)) { // add import try { ImportRewrite rewrite = StubUtility.createImportRewrite(fCompilationUnit, true); rewrite.addImport(createdType.getFullyQualifiedName('.')); JavaModelUtil.applyEdit(fCompilationUnit, rewrite.rewriteImports(null), false, null); } catch (CoreException e) { } } fCreatedType = createdType; } }
From source file:org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.JsGlobalScopeContainerWizard.java
License:Open Source License
public static int openWizard(Shell shell, JsGlobalScopeContainerWizard wizard) { WizardDialog dialog = new WizardDialog(shell, wizard); PixelConverter converter = new PixelConverter(JFaceResources.getDialogFont()); dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20)); dialog.create();//from ww w.ja v a2 s . c o m return dialog.open(); }
From source file:org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.newsourcepage.CreateLinkedSourceFolderAction.java
License:Open Source License
public void run() { Shell shell = getShell();//from w ww .j a va 2 s.c om try { IJavaScriptProject javaProject = (IJavaScriptProject) getSelectedElements().get(0); CPListElement newEntrie = new CPListElement(javaProject, IIncludePathEntry.CPE_SOURCE); CPListElement[] existing = CPListElement.createFromExisting(javaProject); boolean isProjectSrcFolder = CPListElement.isProjectSourceFolder(existing, javaProject); AddSourceFolderWizard wizard = new AddSourceFolderWizard(existing, newEntrie, true, false, false, isProjectSrcFolder, isProjectSrcFolder); wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(javaProject)); 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(); if (res == Window.OK) { BuildpathDelta delta = new BuildpathDelta(getToolTipText()); ArrayList newEntries = wizard.getExistingEntries(); delta.setNewEntries((CPListElement[]) newEntries.toArray(new CPListElement[newEntries.size()])); IResource resource = wizard.getCreatedElement().getCorrespondingResource(); delta.addCreatedResource(resource); informListeners(delta); selectAndReveal(new StructuredSelection(wizard.getCreatedElement())); } notifyResult(res == Window.OK); } catch (CoreException e) { String title = NewWizardMessages.AbstractOpenWizardAction_createerror_title; String message = NewWizardMessages.AbstractOpenWizardAction_createerror_message; ExceptionHandler.handle(e, shell, title, message); } }
From source file:org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.newsourcepage.CreateSourceFolderAction.java
License:Open Source License
public void run() { Shell shell = getShell();/*w ww . j a v a 2 s . c om*/ try { IJavaScriptProject javaProject = (IJavaScriptProject) getSelectedElements().get(0); CPListElement newEntrie = new CPListElement(javaProject, IIncludePathEntry.CPE_SOURCE); CPListElement[] existing = CPListElement.createFromExisting(javaProject); boolean isProjectSrcFolder = CPListElement.isProjectSourceFolder(existing, javaProject); AddSourceFolderWizard wizard = new AddSourceFolderWizard(existing, newEntrie, false, false, false, isProjectSrcFolder, isProjectSrcFolder); wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(javaProject)); 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(); if (res == Window.OK) { BuildpathDelta delta = new BuildpathDelta(getToolTipText()); ArrayList newEntries = wizard.getExistingEntries(); delta.setNewEntries((CPListElement[]) newEntries.toArray(new CPListElement[newEntries.size()])); IResource resource = wizard.getCreatedElement().getCorrespondingResource(); delta.addCreatedResource(resource); informListeners(delta); selectAndReveal(new StructuredSelection(wizard.getCreatedElement())); } notifyResult(res == Window.OK); } catch (CoreException e) { String title = NewWizardMessages.AbstractOpenWizardAction_createerror_title; String message = NewWizardMessages.AbstractOpenWizardAction_createerror_message; ExceptionHandler.handle(e, shell, title, message); } }
From source file:org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.newsourcepage.EditFilterAction.java
License:Open Source License
public void run() { Shell shell = getShell();/* w ww. j a va 2 s. c om*/ try { EditFilterWizard wizard = createWizard(); wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(getSelectedElements().get(0))); 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(); if (res == Window.OK) { BuildpathDelta delta = new BuildpathDelta(getToolTipText()); ArrayList newEntries = wizard.getExistingEntries(); delta.setNewEntries((CPListElement[]) newEntries.toArray(new CPListElement[newEntries.size()])); IResource resource = wizard.getCreatedElement().getCorrespondingResource(); delta.addCreatedResource(resource); informListeners(delta); selectAndReveal(new StructuredSelection(wizard.getCreatedElement())); } notifyResult(res == Window.OK); } catch (CoreException e) { String title = NewWizardMessages.AbstractOpenWizardAction_createerror_title; String message = NewWizardMessages.AbstractOpenWizardAction_createerror_message; ExceptionHandler.handle(e, shell, title, message); } }
From source file:org.eclipse.wst.jsdt.ui.actions.AbstractOpenWizardAction.java
License:Open Source License
public void run() { Shell shell = getShell();// w w w . j av a2 s . c o m if (!doCreateProjectFirstOnEmptyWorkspace(shell)) { return; } 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(); if (res == Window.OK && wizard instanceof NewElementWizard) { fCreatedElement = ((NewElementWizard) wizard).getCreatedElement(); } notifyResult(res == Window.OK); } catch (CoreException e) { String title = NewWizardMessages.AbstractOpenWizardAction_createerror_title; String message = NewWizardMessages.AbstractOpenWizardAction_createerror_message; ExceptionHandler.handle(e, shell, title, message); } }
From source file:org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferenceTab.java
License:Open Source License
/** * Returns the number of pixels corresponding to the width of the given * number of characters. This method was copied from * org.eclipse.jface.dialogs.DialogPage/*w w w . j av a 2 s . com*/ * <p> * * @param a * control in the page * @param chars * the number of characters * @return the number of pixels */ private int convertWidthInCharsToPixels(Control testControl, int chars) { // Compute and store a font metric GC gc = new GC(testControl); gc.setFont(JFaceResources.getDialogFont()); FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); // test for failure to initialize for backward compatibility if (fontMetrics == null) return 0; return Dialog.convertWidthInCharsToPixels(fontMetrics, chars); }
From source file:org.eclipse.wst.xquery.internal.ui.preferences.PropertyPageUtility.java
License:Open Source License
public static Combo addComboBox(Composite parent, String label, String[] values) { Label labelControl = new Label(parent, SWT.LEFT); labelControl.setFont(JFaceResources.getDialogFont()); labelControl.setText(label);// ww w .j a va 2 s. c o m Combo comboBox = newComboControl(parent, values); return comboBox; }