List of usage examples for org.eclipse.jface.resource JFaceResources getDialogFont
public static Font getDialogFont()
From source file:org.eclipse.lsp4e.debug.presentation.DSPDebugModelPresentation.java
License:Open Source License
private Font italic() { if (italic == null) { Font dialogFont = JFaceResources.getDialogFont(); FontData[] fontData = dialogFont.getFontData(); for (int i = 0; i < fontData.length; i++) { FontData data = fontData[i]; data.setStyle(SWT.ITALIC);/* w w w. j a va2s .co m*/ } Display display = getDisplay(); italic = new Font(display, fontData); } return italic; }
From source file:org.eclipse.ltk.internal.ui.refactoring.RefactoringStatusViewer.java
License:Open Source License
private void createTableViewer(Composite parent) { fTableViewer = new TableViewer(new Table(parent, SWT.SINGLE | SWT.H_SCROLL)); fTableViewer.setLabelProvider(new RefactoringStatusEntryLabelProvider()); fTableViewer.setContentProvider(new RefactoringStatusContentProvider()); fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { entrySelected(event.getSelection()); fNextProblem.update();// www . java2 s. c o m fPreviousProblem.update(); } }); fTableViewer.setComparator(new RefactoringStatusSorter()); Table tableControl = fTableViewer.getTable(); // must set the dialog font here since we pack the table and this // might otherwise happen with the wrong font resulting in clipped // messages. tableControl.setFont(JFaceResources.getDialogFont()); GridData gd = new GridData(GridData.FILL_BOTH); tableControl.setLayoutData(gd); SWTUtil.setAccessibilityText(tableControl, RefactoringUIMessages.RefactoringStatusViewer_Found_problems); }
From source file:org.eclipse.ltk.internal.ui.refactoring.util.SWTUtil.java
License:Open Source License
public static int getButtonWidthHint(Button button) { button.setFont(JFaceResources.getDialogFont()); return Math.max(new PixelConverter(button).convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:org.eclipse.m2e.core.ui.internal.wizards.LifecycleMappingPage.java
License:Open Source License
/** * Create contents of the wizard./*from www . j av a 2 s . c om*/ * * @param parent */ public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); setControl(container); container.setLayout(new GridLayout(1, false)); treeViewer = new TreeViewer(container, SWT.BORDER | SWT.FULL_SELECTION); Tree tree = treeViewer.getTree(); tree.setLinesVisible(true); tree.setHeaderVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); TreeViewerColumn treeViewerColumn = new TreeViewerColumn(treeViewer, SWT.NONE); TreeColumn trclmnNewColumn = treeViewerColumn.getColumn(); trclmnNewColumn.setText(Messages.LifecycleMappingPage_mavenBuildColumnTitle); TreeViewerColumn columnViewerAction = new TreeViewerColumn(treeViewer, SWT.NONE); TreeColumn columnAction = columnViewerAction.getColumn(); columnAction.setText(Messages.LifecycleMappingPage_actionColumnTitle); columnViewerAction.setEditingSupport(new EditingSupport(treeViewer) { @Override protected void setValue(Object element, Object value) { if (element instanceof ILifecycleMappingLabelProvider) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; int intVal = ((Integer) value).intValue(); List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); if (ignore.contains(element)) { ignore.remove(element); } else if (ignoreAtDefinition.contains(element)) { ignoreAtDefinition.remove(element); } else if (intVal == all.size() + NO_ACTION_IDX || shouldDeslectProposal(prov)) { IMavenDiscoveryProposal prop = mappingConfiguration.getSelectedProposal(prov.getKey()); mappingConfiguration.removeSelectedProposal(prop); } // Set new selection if (intVal < all.size()) { IMavenDiscoveryProposal sel = all.get(intVal); if (sel != null) { mappingConfiguration.addSelectedProposal(sel); } } else { switch (intVal - all.size()) { case IGNORE_IDX: ignore.add(prov); break; case IGNORE_PARENT_IDX: ignoreAtDefinition.add(prov); } } getViewer().refresh(true); updateErrorCount(); } } @Override protected Object getValue(Object element) { if (element instanceof ILifecycleMappingLabelProvider) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; IMavenDiscoveryProposal prop = mappingConfiguration.getSelectedProposal(prov.getKey()); List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); if (ignore.contains(element)) { return Integer.valueOf(all.size() + IGNORE_IDX); } else if (ignoreAtDefinition.contains(element)) { return Integer.valueOf(all.size() + IGNORE_PARENT_IDX); } else { int index = all.indexOf(prop); return index >= 0 ? Integer.valueOf(index) : Integer.valueOf(all.size() + NO_ACTION_IDX); } } return Integer.valueOf(0); } @Override protected CellEditor getCellEditor(Object element) { if (element instanceof ILifecycleMappingLabelProvider) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); List<String> values = new ArrayList<String>(); for (IMavenDiscoveryProposal prop : all) { values.add(NLS.bind(Messages.LifecycleMappingPage_installDescription, prop.toString())); } if (prov.isError(mappingConfiguration)) { values.add(Messages.LifecycleMappingPage_resolveLaterDescription); } else { values.add(EMPTY_STRING); } addIgnoreProposals(values, prov); ComboBoxCellEditor edit = new ComboBoxCellEditor(treeViewer.getTree(), values.toArray(new String[values.size()])); Control cont = edit.getControl(); //this attempts to disable text edits in the combo.. if (cont instanceof CCombo) { CCombo combo = (CCombo) cont; combo.setEditable(false); } return edit; } throw new IllegalStateException(); } @Override protected boolean canEdit(Object element) { if (element instanceof AggregateMappingLabelProvider) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); return all != null && !all.isEmpty() || prov.getKey() instanceof MojoExecutionMappingRequirement; } return false; } }); treeViewer.setContentProvider(new ITreeContentProvider() { public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public Object[] getElements(Object inputElement) { if (inputElement instanceof LifecycleMappingConfiguration) { Map<ILifecycleMappingRequirement, List<ILifecycleMappingLabelProvider>> packagings = new HashMap<ILifecycleMappingRequirement, List<ILifecycleMappingLabelProvider>>(); Map<ILifecycleMappingRequirement, List<ILifecycleMappingLabelProvider>> mojos = new HashMap<ILifecycleMappingRequirement, List<ILifecycleMappingLabelProvider>>(); Collection<ProjectLifecycleMappingConfiguration> projects = ((LifecycleMappingConfiguration) inputElement) .getProjects(); for (ProjectLifecycleMappingConfiguration prjconf : projects) { PackagingTypeMappingConfiguration pack = prjconf.getPackagingTypeMappingConfiguration(); if (pack != null) { ILifecycleMappingRequirement packReq = pack.getLifecycleMappingRequirement(); if (packReq != null && !mappingConfiguration.getProposals(packReq).isEmpty()) { List<ILifecycleMappingLabelProvider> val = packagings.get(packReq); if (val == null) { val = new ArrayList<ILifecycleMappingLabelProvider>(); packagings.put(packReq, val); } val.add(new PackagingTypeMappingLabelProvider(prjconf, pack)); } } List<MojoExecutionMappingConfiguration> mojoExecs = prjconf .getMojoExecutionConfigurations(); if (mojoExecs != null) { for (MojoExecutionMappingConfiguration mojoMap : mojoExecs) { ILifecycleMappingRequirement mojoReq = mojoMap.getLifecycleMappingRequirement(); // include mojo execution if it has available proposals or interesting phase not mapped locally if (mojoReq != null && !mappingConfiguration.getProposals(mojoReq).isEmpty() || (LifecycleMappingFactory .isInterestingPhase(mojoMap.getExecution().getLifecyclePhase()) && !mappingConfiguration.isRequirementSatisfied(mojoReq, true))) { List<ILifecycleMappingLabelProvider> val = mojos.get(mojoReq); if (val == null) { val = new ArrayList<ILifecycleMappingLabelProvider>(); mojos.put(mojoReq, val); } val.add(new MojoExecutionMappingLabelProvider(prjconf, mojoMap)); } } } } List<ILifecycleMappingLabelProvider> toRet = new ArrayList<ILifecycleMappingLabelProvider>(); for (Map.Entry<ILifecycleMappingRequirement, List<ILifecycleMappingLabelProvider>> ent : packagings .entrySet()) { toRet.add(new AggregateMappingLabelProvider(ent.getKey(), ent.getValue())); } for (Map.Entry<ILifecycleMappingRequirement, List<ILifecycleMappingLabelProvider>> ent : mojos .entrySet()) { toRet.add(new AggregateMappingLabelProvider(ent.getKey(), ent.getValue())); } return toRet.toArray(); } return null; } public Object[] getChildren(Object parentElement) { if (parentElement instanceof AggregateMappingLabelProvider) { return ((AggregateMappingLabelProvider) parentElement).getChildren(); } return new Object[0]; } public Object getParent(Object element) { return null; } public boolean hasChildren(Object element) { Object[] children = getChildren(element); return children != null && children.length > 0; } }); treeViewer.setLabelProvider(new ITableLabelProvider() { public void removeListener(ILabelProviderListener listener) { } public boolean isLabelProperty(Object element, String property) { return false; } public void dispose() { } public void addListener(ILabelProviderListener listener) { } public String getColumnText(Object element, int columnIndex) { if (element instanceof ILifecycleMappingLabelProvider) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; if (columnIndex == MAVEN_INFO_IDX) { String text = prov.getMavenText(); if (prov instanceof AggregateMappingLabelProvider && !isHandled(prov)) { text = NLS.bind(Messages.LifecycleMappingPage_errorMavenBuild, new String[] { text, String.valueOf(((AggregateMappingLabelProvider) prov).getChildren().length) }); } return text; } else if (columnIndex == ACTION_INFO_IDX && element instanceof AggregateMappingLabelProvider) { IMavenDiscoveryProposal proposal = mappingConfiguration.getSelectedProposal(prov.getKey()); if (ignore.contains(element)) { return Messages.LifecycleMappingPage_doNotExecutePom; } else if (ignoreAtDefinition.contains(element)) { return Messages.LifecycleMappingPage_doNotExecuteParent; } else if (proposal != null) { return NLS.bind(Messages.LifecycleMappingPage_installDescription, proposal.toString()); //not really feeling well here. } else if (loading || !prov.isError(mappingConfiguration)) { return EMPTY_STRING; } else { return Messages.LifecycleMappingPage_resolveLaterDescription; } } } return null; } public Image getColumnImage(Object element, int columnIndex) { if (columnIndex != 0) { return null; } if (element instanceof AggregateMappingLabelProvider) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; if (prov.isError(mappingConfiguration)) { if (!isHandled(prov)) { return MavenImages.IMG_ERROR; } } return MavenImages.IMG_PASSED; } return MavenImages.IMG_POM; } }); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection() instanceof IStructuredSelection && ((IStructuredSelection) event.getSelection()).size() == 1) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) ((IStructuredSelection) event .getSelection()).getFirstElement(); if (ignore.contains(prov)) { details.setText(Messages.LifecycleMappingPage_doNotExecutePomDescription); license.setText(EMPTY_STRING); } else if (ignoreAtDefinition.contains(prov)) { details.setText(Messages.LifecycleMappingPage_doNotExecuteParentDescription); license.setText(EMPTY_STRING); } else { IMavenDiscoveryProposal proposal = mappingConfiguration.getSelectedProposal(prov.getKey()); details.setText(proposal != null ? proposal.getDescription() : mappingConfiguration.getProposals(prov.getKey()).isEmpty() ? NLS.bind(Messages.LifecycleMappingPage_noMarketplaceEntryDescription, prov.getMavenText()) : EMPTY_STRING); license.setText(proposal == null ? EMPTY_STRING : proposal.getLicense()); } } else { details.setText(EMPTY_STRING); license.setText(EMPTY_STRING); } } }); treeViewer.setComparator(new ViewerComparator() { public int compare(Viewer viewer, Object e1, Object e2) { if (!(e1 instanceof ILifecycleMappingLabelProvider && e2 instanceof ILifecycleMappingLabelProvider)) { return super.compare(viewer, e1, e2); } int cat1 = category(e1); int cat2 = category(e2); if (cat1 != cat2) { return cat1 - cat2; } return ((ILifecycleMappingLabelProvider) e1).getMavenText() .compareTo(((ILifecycleMappingLabelProvider) e2).getMavenText()); } }); Composite composite = new Composite(container, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); composite.setLayout(new GridLayout(3, false)); errorCountLabel = new Label(composite, SWT.NONE); errorCountLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Button btnNewButton_1 = new Button(composite, SWT.NONE); btnNewButton_1.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mappingConfiguration.clearSelectedProposals(); ignore.clear(); ignoreAtDefinition.clear(); treeViewer.refresh(); getWizard().getContainer().updateButtons(); // needed to enable/disable Finish button updateErrorCount(); } }); btnNewButton_1.setText(Messages.LifecycleMappingPage_deselectAllButton); autoSelectButton = new Button(composite, SWT.NONE); autoSelectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ignore.clear(); ignoreAtDefinition.clear(); discoverProposals(); } }); autoSelectButton.setText(Messages.LifecycleMappingPage_autoSelectButton); // Provide a reasonable height for the details box GC gc = new GC(container); gc.setFont(JFaceResources.getDialogFont()); FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); Group grpDetails = new Group(container, SWT.NONE); grpDetails.setLayout(new GridLayout(1, false)); grpDetails.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); grpDetails.setText(Messages.LifecycleMappingPage_descriptionLabel); details = new Text(grpDetails, SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 3); gd.minimumHeight = Dialog.convertHeightInCharsToPixels(fontMetrics, 1); details.setLayoutData(gd); Group grpLicense = new Group(container, SWT.NONE); grpLicense.setLayout(new GridLayout(1, false)); grpLicense.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); grpLicense.setText(Messages.LifecycleMappingPage_licenseLabel); license = new Text(grpLicense, SWT.READ_ONLY); gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 1); gd.minimumHeight = Dialog.convertHeightInCharsToPixels(fontMetrics, 1); license.setLayoutData(gd); }
From source file:org.eclipse.m2e.editor.xml.internal.MarkerHoverControl.java
License:Open Source License
/** * Create content of the hover. This is called after the input has been set. *//* w ww .ja v a 2s. c om*/ protected void deferredCreateContent() { // fillToolbar(); if (region != null) { final ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); scrolledComposite.setLayoutData(gridData); scrolledComposite.setExpandVertical(false); scrolledComposite.setExpandHorizontal(false); Composite composite = new Composite(scrolledComposite, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); GridLayout layout = new GridLayout(1, false); composite.setLayout(layout); scrolledComposite.setContent(composite); for (IRegion reg : region.getRegions()) { if (reg instanceof PomHyperlinkDetector.MarkerRegion) { final PomHyperlinkDetector.MarkerRegion markerReg = (PomHyperlinkDetector.MarkerRegion) reg; createAnnotationInformation(composite, markerReg); final IMarker mark = markerReg.getAnnotation().getMarker(); IMarkerResolution[] resolutions = IDE.getMarkerHelpRegistry().getResolutions(mark); if (resolutions.length > 0) { createResolutionsControl(composite, mark, resolutions); } } if (reg instanceof ManagedArtifactRegion) { final ManagedArtifactRegion man = (ManagedArtifactRegion) reg; Composite comp = createTooltipComposite(composite, PomTextHover.getLabelForRegion(man)); //only create the hyperlink when the origin location for jumping is present. //in some cases (managed version comes from imported dependencies) we don't have the location and have nowhere to jump) if (PomHyperlinkDetector.canCreateHyperLink(man)) { Link link = createHyperlink(comp); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { dispose(); PomHyperlinkDetector.createHyperlink(man).open(); } }); } } if (reg instanceof ExpressionRegion) { final ExpressionRegion expr = (ExpressionRegion) reg; Composite tooltipComposite = createTooltipComposite(composite, PomTextHover.getLabelForRegion(expr)); if (PomHyperlinkDetector.canCreateHyperLink(expr)) { Link link = createHyperlink(tooltipComposite); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { dispose(); PomHyperlinkDetector.createHyperlink(expr).open(); } }); } } if (region.getRegions().indexOf(reg) < region.getRegions().size() - 1) { createSeparator(composite); } } Point constraints = getSizeConstraints(); Point contentSize = composite.computeSize(constraints != null ? constraints.x : SWT.DEFAULT, SWT.DEFAULT); composite.setSize(new Point(contentSize.x, contentSize.y)); //12 is the magic number for height of status line } setColorAndFont(parent, parent.getForeground(), parent.getBackground(), JFaceResources.getDialogFont()); parent.layout(true); }
From source file:org.eclipse.m2m.internal.qvt.oml.editor.ui.colorer.QVTColorsConfigurationBlock.java
License:Open Source License
private void initializeDialogUnits(Control testControl) { // Compute and store a font metric GC gc = new GC(testControl); gc.setFont(JFaceResources.getDialogFont()); fFontMetrics = gc.getFontMetrics();/* ww w. jav a2s . c o m*/ gc.dispose(); }
From source file:org.eclipse.mylyn.internal.tasks.ui.commands.ShowTasksConnectorDiscoveryWizardCommandHandler.java
License:Open Source License
public Object execute(ExecutionEvent event) throws ExecutionException { // check to make sure that the p2 install ui is enabled if (WorkbenchUtil.allowUseOf(ID_P2_INSTALL_UI)) { ConnectorDiscoveryWizard wizard = new ConnectorDiscoveryWizard(); WizardDialog dialog = new WizardDialog(WorkbenchUtil.getShell(), wizard) { @Override/*from w ww . j av a 2 s . c om*/ protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); ((GridLayout) parent.getLayout()).numColumns++; final Button button = new Button(parent, SWT.CHECK); button.setSelection(TasksUiPlugin.getDefault().getPreferenceStore() .getBoolean(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED)); button.setText( Messages.ShowTasksConnectorDiscoveryWizardCommandHandler_Notify_when_updates_are_available_Text); button.setFont(JFaceResources.getDialogFont()); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { TasksUiPlugin.getDefault().getPreferenceStore().setValue( ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED, button.getSelection()); } }); button.moveAbove(null); } }; dialog.open(); } else { MessageDialog.openWarning(WorkbenchUtil.getShell(), Messages.ShowTasksConnectorDiscoveryWizardCommandHandler_Install_Connectors, Messages.ShowTasksConnectorDiscoveryWizardCommandHandler_Unable_to_launch_connector_install); } return null; }
From source file:org.eclipse.mylyn.reviews.r4e.ui.internal.annotation.control.R4EAnnotationInformationControl.java
License:Open Source License
/** * Create content of the hover. This is called after the input has been set. * /* w w w . ja v a 2 s .c o m*/ * @see org.eclipse.mylyn.reviews.frame.ui.annotation.impl.ReviewAnnotationInformationControl#deferredCreateContent() */ @Override protected void deferredCreateContent() { //Set Delta/Selection annotations first, then anomalies addAnnotationsInformation(); setColorAndFont(fComposite, fComposite.getParent().getForeground(), fComposite.getParent().getBackground(), JFaceResources.getDialogFont()); fComposite.layout(true); }
From source file:org.eclipse.oomph.ui.OomphDialog.java
License:Open Source License
protected Button createCheckbox(Composite parent, String label) { ((GridLayout) parent.getLayout()).numColumns++; Button button = new Button(parent, SWT.CHECK); button.setText(label);/* w w w . j a va 2 s . c o m*/ button.setFont(JFaceResources.getDialogFont()); setButtonLayoutData(button); return button; }
From source file:org.eclipse.osee.framework.ui.data.model.editor.wizard.ODMSelectPage.java
License:Open Source License
protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { // increment the number of columns in the button bar ((GridLayout) parent.getLayout()).numColumns++; Button button = new Button(parent, SWT.PUSH); button.setText(label);//from w ww . ja v a2 s . com button.setFont(JFaceResources.getDialogFont()); button.setData(new Integer(id)); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { // buttonPressed(((Integer) event.widget.getData()).intValue()); } }); if (defaultButton) { Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } } // buttons.put(new Integer(id), button); setButtonLayoutData(button); return button; }