下面列出了org.eclipse.swt.widgets.Group#setFont ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void createNote(final Composite parent, final Question question) {
final Group notePanel = new Group(parent, SWT.NONE);
notePanel.setText("Note:");
final Font boldFont = new Font(notePanel.getDisplay(), new FontData(Constants.ARIAL, 10, SWT.BOLD));
notePanel.setFont(boldFont);
this.note = new Text(notePanel, SWT.MULTI | SWT.WRAP);
this.note.setLayoutData(new GridData(GridData.FILL_BOTH));
this.note.setText(Constants.DESCRIPTION_KEYSIZES);
this.note.setBounds(10, 20, 585, 60);
this.note.setSize(this.note.computeSize(585, SWT.DEFAULT));
setControl(notePanel);
this.note.setEditable(false);
this.note.setEnabled(true);
new Label(parent, SWT.NULL);
}
public Control createContent(Composite composite) {
fGroup= new Group(composite, SWT.NONE);
fGroup.setFont(composite.getFont());
fGroup.setLayout(initGridLayout(new GridLayout(3, false), true));
fGroup.setText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_title);
fStdRadio.doFillIntoGrid(fGroup, 3);
LayoutUtil.setHorizontalGrabbing(fStdRadio.getSelectionButton(null));
fSrcBinRadio.doFillIntoGrid(fGroup, 2);
fPreferenceLink= new Link(fGroup, SWT.NONE);
fPreferenceLink.setText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_link_description);
fPreferenceLink.setLayoutData(new GridData(GridData.END, GridData.END, false, false));
fPreferenceLink.addSelectionListener(this);
updateEnableState();
return fGroup;
}
@Override
protected void createPageBody(Composite parent) {
super.createPageBody(parent);
Group group = new Group(parent, SWT.NONE);
group.setFont(parent.getFont());
group.setText(TypeScriptUIMessages.WizardNewTypeScriptProjectCreationPage_typescript_group_label);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
int nColumns = 2;
GridLayout layout = new GridLayout();
layout.numColumns = nColumns;
group.setLayout(layout);
ITypeScriptRepository[] repositories = TypeScriptCorePlugin.getTypeScriptRepositoryManager().getRepositories();
hasEmbeddedTsRuntime = repositories.length > 0;
if (hasEmbeddedTsRuntime) {
// Embedded TypeScript
createEmbeddedTypeScriptField(group, repositories);
}
// Install TypeScript
createInstallScriptField(group);
}
/** Creates the Body for selecting the Node.js configuration. */
private void createNodejsBody(Composite parent) {
Group group = new Group(parent, SWT.NONE);
group.setFont(parent.getFont());
group.setText(TypeScriptUIMessages.AbstractWizardNewTypeScriptProjectCreationPage_nodejs_group_label);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
int nColumns = 2;
GridLayout layout = new GridLayout();
layout.numColumns = nColumns;
group.setLayout(layout);
IEmbeddedNodejs[] installs = TypeScriptCorePlugin.getNodejsInstallManager().getNodejsInstalls();
hasEmbeddedNodeJs = installs.length > 0;
if (hasEmbeddedNodeJs) {
// Embedded node.js
createEmbeddedNodejsField(group, installs);
}
// Installed node.js
createInstalledNodejsField(group);
// Path info.
createNodePathInfo(group);
}
protected void createBody(Composite parent) {
int nColumns = 2;
GridLayout layout = new GridLayout();
layout.numColumns = nColumns;
Group group = new Group(parent, SWT.NONE);
group.setFont(parent.getFont());
group.setText(getTypeScriptGroupLabel());
group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
group.setLayout(layout);
// Embedded TypeScript
createEmbeddedTypeScriptField(group);
// Installed TypeScript
createInstalledTypeScriptField(group);
updateComboBoxes();
}
public Group createGroupCommand(Composite parent) {
Font font = parent.getFont();
Group pageGroupCommand = new Group(parent, SWT.SHADOW_ETCHED_IN);
pageGroupCommand.setText(Activator.getResourceString("easyshell.command.editor.dialog.title.group1"));
pageGroupCommand.setToolTipText(Activator.getResourceString("easyshell.command.editor.dialog.tooltip.group1"));
GridLayout layoutCommand = new GridLayout();
layoutCommand.numColumns = 3;
layoutCommand.makeColumnsEqualWidth = false;
layoutCommand.marginWidth = 5;
layoutCommand.marginHeight = 4;
pageGroupCommand.setLayout(layoutCommand);
GridData dataCommand = new GridData(GridData.FILL_HORIZONTAL);
pageGroupCommand.setLayoutData(dataCommand);
pageGroupCommand.setFont(font);
return pageGroupCommand;
}
private void createVariablesOverview(Composite parent) {
Font font = parent.getFont();
Group pageGroup2 = new Group(parent, SWT.SHADOW_ETCHED_IN);
pageGroup2.setText(Activator.getResourceString("easyshell.command.editor.dialog.title.group2"));
pageGroup2.setToolTipText(Activator.getResourceString("easyshell.command.editor.dialog.tooltip.group2"));
GridLayout layout2 = new GridLayout();
layout2.numColumns = 2;
layout2.makeColumnsEqualWidth = false;
layout2.marginWidth = 5;
layout2.marginHeight = 4;
pageGroup2.setLayout(layout2);
GridData data2 = new GridData(GridData.FILL_HORIZONTAL);
pageGroup2.setLayoutData(data2);
pageGroup2.setFont(font);
// create variable labels
for(int i=Variable.getFirstIndex();i<Variable.values().length;i++) {
Variable var = Variable.values()[i];
if (var.isVisible()) {
createVariableLabel(pageGroup2, var.getFullVariableName(), ": " + var.getDescription());
}
}
}
protected Group Group(Composite parent, Procedure1<? super Group> config) {
Group group = new Group(parent, SWT.NONE);
group.setFont(parent.getFont());
group.setLayout(new GridLayout(1, false));
group.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
config.apply(group);
return group;
}
/**
* Creates a Group widget
* @param parent the parent composite to add this group to
* @param text the text for the heading of the group
* @param columns the number of columns within the group
* @param hspan the horizontal span the group should take up on the parent
* @param fill the style for how this composite should fill into its parent
* @return the new group
*/
public static Group createGroup(Composite parent, String text, int columns, int hspan, int fill) {
Group g = new Group(parent, SWT.NONE);
g.setLayout(new GridLayout(columns, false));
g.setText(text);
g.setFont(parent.getFont());
GridData gd = new GridData(fill);
gd.horizontalSpan = hspan;
g.setLayoutData(gd);
return g;
}
public Control createControl(Composite composite) {
final Group workingSetGroup = new Group(composite, SWT.NONE);
workingSetGroup.setFont(composite.getFont());
workingSetGroup.setText(NewWizardMessages.NewJavaProjectWizardPageOne_WorkingSets_group);
workingSetGroup.setLayout(new GridLayout(1, false));
this.workingSetBlock.createContent(workingSetGroup);
return workingSetGroup;
}
public static Group createGroup(Composite parent, String text, int columns, GridData data)
{
Group g = new Group(parent, SWT.NONE);
g.setLayout(new GridLayout(columns, false));
g.setText(text);
g.setFont(parent.getFont());
g.setLayoutData(data);
return g;
}
/**
* Creates a field editor group for use in grouping items on a page
*
* @param appearanceComposite
* @param string
* @return Composite
*/
public static Composite createGroup(Composite appearanceComposite, String string)
{
Group group = new Group(appearanceComposite, SWT.NONE);
group.setFont(appearanceComposite.getFont());
group.setText(string);
group.setLayout(GridLayoutFactory.fillDefaults().margins(5, 5).numColumns(2).create());
group.setLayoutData(GridDataFactory.fillDefaults().span(2, 0).grab(true, false).create());
Composite c = new Composite(group, SWT.NONE);
c.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
return c;
}
/**
* Creates a Group widget
* @param parent the parent composite to add this group to
* @param text the text for the heading of the group
* @param columns the number of columns within the group
* @param hspan the horizontal span the group should take up on the parent
* @param fill the style for how this composite should fill into its parent
* Can be one of <code>GridData.FILL_HORIZONAL</code>, <code>GridData.FILL_BOTH</code> or <code>GridData.FILL_VERTICAL</code>
* @return the new group
*/
private static Group createGroup(Composite parent, String text, int columns, int hspan, int fill) {
Group g = new Group(parent, SWT.NONE);
g.setLayout(new GridLayout(columns, false));
g.setText(text);
g.setFont(parent.getFont());
GridData gd = new GridData(fill);
gd.horizontalSpan = hspan;
g.setLayoutData(gd);
return g;
}
/**
* Creates the group
*
* @param parent
* @param text
* @param columns
* @param hspan
* @param fill
* @return
*/
public static Group createGroup( Composite parent, String text,
int columns, int hspan, int fill )
{
Group g = new Group( parent, SWT.NONE );
g.setLayout( new GridLayout( columns, false ) );
g.setText( text );
g.setFont( parent.getFont( ) );
GridData gd = new GridData( fill );
gd.horizontalSpan = hspan;
g.setLayoutData( gd );
return g;
}
private void createAdditionalControls(Composite parent) {
Group dartGroup = new Group(parent, SWT.NONE);
dartGroup.setFont(parent.getFont());
dartGroup.setText(Messages.NewProject_Group_Label);
dartGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
dartGroup.setLayout(new GridLayout(2, false));
Label labelSdkLocation = new Label(dartGroup, SWT.NONE);
labelSdkLocation.setText(Messages.Preference_SDKLocation_Dart);
GridDataFactory.swtDefaults().applyTo(labelSdkLocation);
Label sdkLocation = new Label(dartGroup, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(sdkLocation);
sdkLocation.setText(preferences.getString(GlobalConstants.P_SDK_LOCATION_DART));
// ------------------------------------------
Group stagehandGroup = new Group(parent, SWT.NONE);
stagehandGroup.setFont(parent.getFont());
stagehandGroup.setText(Messages.NewProject_Stagehand_Title);
stagehandGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
stagehandGroup.setLayout(new GridLayout(1, false));
useStagehandButton = new Button(stagehandGroup, SWT.CHECK);
GridDataFactory.fillDefaults().grab(true, false).applyTo(useStagehandButton);
useStagehandButton.setEnabled(false);
stagehandTemplates = new Combo(stagehandGroup, SWT.READ_ONLY);
stagehandTemplates.setEnabled(useStagehandButton.getSelection());
GridDataFactory.fillDefaults().grab(true, false).applyTo(stagehandTemplates);
useStagehandButton.setText(Messages.NewProject_Stagehand_UseStagehandButtonText);
useStagehandButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// Enable/Disable the stagehand templates list if the button is
// checked/unchecked
stagehandTemplates.setEnabled(useStagehandButton.getSelection());
if (stagehandTemplates.getSelectionIndex() == -1) {
stagehandTemplates.select(0);
}
}
});
ProgressIndicator indicator = new ProgressIndicator(stagehandGroup);
GridDataFactory.fillDefaults().grab(true, false).applyTo(indicator);
indicator.beginAnimatedTask();
Job.create(Messages.NewProject_Stagehand_FetchStagehand, monitor -> {
templates = StagehandService.getStagehandTemplates();
Display.getDefault().asyncExec(() -> {
if (!indicator.isDisposed()) {
indicator.done();
}
if (!stagehandTemplates.isDisposed()) {
templates.forEach(str -> stagehandTemplates.add(str.getDisplayName()));
useStagehandButton.setEnabled(true);
}
});
}).schedule();
}
@Override
protected void createUnzipOptionGroup(Composite parent) {
// options group
Group optionsGroup = new Group(parent, SWT.NONE);
GridLayout layout = new GridLayout();
optionsGroup.setLayout(layout);
optionsGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
optionsGroup.setText(Messages.getString("JavaJobScriptsExportWSWizardPage.BuildType")); //$NON-NLS-1$
optionsGroup.setFont(parent.getFont());
optionsGroup.setLayout(new GridLayout(2, false));
Label label = new Label(optionsGroup, SWT.NONE);
label.setText(Messages.getString("JavaJobScriptsExportWSWizardPage.BuildLabel")); //$NON-NLS-1$
boolean canESBMicroServiceDockerImage = PluginChecker.isDockerPluginLoaded();
exportTypeCombo = new Combo(optionsGroup, SWT.PUSH);
// TESB-5328
exportTypeCombo.add(EXPORTTYPE_KAR);
if (PluginChecker.isTIS()) {
exportTypeCombo.add(EXPORTTYPE_SPRING_BOOT);
if (canESBMicroServiceDockerImage) {
exportTypeCombo.add(EXPORTTYPE_SPRING_BOOT_DOCKER_IMAGE);
}
}
// exportTypeCombo.setEnabled(false); // only can export kar file
exportTypeCombo.setText(EXPORTTYPE_KAR);
exportTypeCombo.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
Widget source = e.widget;
if (source instanceof Combo) {
String destination = ((Combo) source).getText();
boolean isMS = destination.equals(EXPORTTYPE_SPRING_BOOT)
|| destination.equals(EXPORTTYPE_SPRING_BOOT_DOCKER_IMAGE);
if (isMS) {
contextButton.dispose();
addBSButton.dispose();
exportAsZipButton.dispose();
optionsDockerGroupComposite.dispose();
if (destination.equals(EXPORTTYPE_SPRING_BOOT)) {
updateDestinationGroup(false);
createOptionsForKar(optionsGroupComposite, optionsGroupFont);
optionsGroupComposite.layout(true, true);
} else {
updateDestinationGroup(true);
createOptionsForDocker(optionsGroupComposite, optionsGroupFont);
createDockerOptions(parent);
restoreWidgetValuesForImage();
optionsGroupComposite.layout(true, true);
}
parent.layout();
} else {
if(contextButton != null) contextButton.setEnabled(false);
if(exportAsZipButton != null) exportAsZipButton.setEnabled(false);
}
String destinationValue = getDestinationValue();
if (isMS) {
if (exportAsZip) {
destinationValue = destinationValue.substring(0, destinationValue.lastIndexOf("."))
+ FileConstants.ZIP_FILE_SUFFIX;
} else {
destinationValue = destinationValue.substring(0, destinationValue.lastIndexOf("."))
+ FileConstants.JAR_FILE_SUFFIX;
}
} else {
destinationValue = destinationValue.substring(0, destinationValue.lastIndexOf(".")) + getOutputSuffix();
}
setDestinationValue(destinationValue);
}
}
});
}
public Control createDialogArea(Composite parent) {
Composite pageComponent = new Composite(parent,SWT.NULL);
GridLayout layout0 = new GridLayout();
layout0.numColumns = 1;
layout0.makeColumnsEqualWidth = true;
layout0.marginWidth = 5;
layout0.marginHeight = 4;
pageComponent.setLayout(layout0);
GridData data0 = new GridData(GridData.FILL_HORIZONTAL);
pageComponent.setLayoutData(data0);
pageComponent.setFont(parent.getFont());
// define group1
Group pageGroup1 = new Group(pageComponent, SWT.SHADOW_ETCHED_IN);
pageGroup1.setText(LogViewerPlugin.getResourceString("preferences.ruleseditor.dialog.lineselection.title"));
GridLayout layout1 = new GridLayout();
layout1.numColumns = 2;
layout1.makeColumnsEqualWidth = true;
layout1.marginWidth = 5;
layout1.marginHeight = 4;
pageGroup1.setLayout(layout1);
GridData data1 = new GridData(GridData.FILL_HORIZONTAL);
pageGroup1.setLayoutData(data1);
pageGroup1.setFont(parent.getFont());
// create priority valueText
// createPriorityText(pageComponent);
// create activity checkbox
createEnabledCheckBox(pageGroup1);
// create rule type combo
createRuleCombo(pageGroup1);
// create input valueText field
createValueTextField(pageGroup1);
// create case insensitive checkbox
createCaseInsensitiveCheckBox(pageGroup1);
// create match mode combo
createMatchModeCombo(pageGroup1);
// define group2
Group pageGroup2 = new Group(pageComponent, SWT.SHADOW_ETCHED_IN);
pageGroup2.setText(LogViewerPlugin.getResourceString("preferences.ruleseditor.dialog.actions.title"));
GridLayout layout2 = new GridLayout();
layout2.numColumns = 1;
layout2.makeColumnsEqualWidth = true;
layout2.marginWidth = 5;
layout2.marginHeight = 4;
pageGroup2.setLayout(layout2);
GridData data2 = new GridData(GridData.FILL_HORIZONTAL);
pageGroup2.setLayoutData(data2);
pageGroup2.setFont(parent.getFont());
// define group2.1
Group pageGroup21 = new Group(pageGroup2, SWT.SHADOW_ETCHED_IN);
pageGroup21.setText(LogViewerPlugin.getResourceString("preferences.ruleseditor.dialog.highlighting.title"));
GridLayout layout21 = new GridLayout();
layout21.numColumns = 2;
layout21.makeColumnsEqualWidth = true;
layout21.marginWidth = 5;
layout21.marginHeight = 4;
pageGroup21.setLayout(layout21);
GridData data21 = new GridData(GridData.FILL_HORIZONTAL);
pageGroup21.setLayoutData(data21);
pageGroup21.setFont(parent.getFont());
// enabled
createColoringEnabledCheckBox(pageGroup21);
// create background color button
createBackgroundColorSelector(pageGroup21);
// create foreground color button
createForegroundColorSelector(pageGroup21);
// define group2.2
/*
Group pageGroup22 = new Group(pageGroup2, SWT.SHADOW_ETCHED_IN);
pageGroup22.setText("Filter");
GridLayout layout22 = new GridLayout();
layout22.numColumns = 2;
layout22.makeColumnsEqualWidth = true;
layout22.marginWidth = 5;
layout22.marginHeight = 4;
pageGroup22.setLayout(layout22);
GridData data22 = new GridData(GridData.FILL_HORIZONTAL);
pageGroup22.setLayoutData(data22);
pageGroup22.setFont(parent.getFont());
*/
//if (edit) {
// send event to refresh matchMode
Event event = new Event();
event.item = null;
ruleTypeCombo.notifyListeners(SWT.Selection, event);
//}
return pageComponent;
}
/**
* Creates the project location specification controls.
*
* @param parent
* the parent composite
*/
private final void createFileLocationGroup( Composite parent )
{
Font font = parent.getFont( );
Group locationGroup = new Group( parent, SWT.NONE );
GridLayout layout = new GridLayout( );
layout.numColumns = 3;
locationGroup.setLayout( layout );
locationGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
locationGroup.setFont( font );
locationGroup.setText( LABEL_FILE_LOCATION );
final Button useDefaultsButton = new Button( locationGroup, SWT.CHECK
| SWT.RIGHT );
useDefaultsButton.setText( LABEL_USE_DEFAULT );
useDefaultsButton.setSelection( useDefaults );
useDefaultsButton.setFont( font );
GridData buttonData = new GridData( );
buttonData.horizontalSpan = 3;
useDefaultsButton.setLayoutData( buttonData );
createUserSpecifiedProjectLocationGroup( locationGroup, !useDefaults );
SelectionListener listener = new SelectionAdapter( ) {
public void widgetSelected( SelectionEvent e )
{
useDefaults = useDefaultsButton.getSelection( );
browseButton.setEnabled( !useDefaults );
locationPathField.setEnabled( !useDefaults );
locationLabel.setEnabled( !useDefaults );
if ( useDefaults )
{
customLocationFieldValue = locationPathField.getText( );
setLocationForSelection( );
}
else
{
locationPathField.setText( customLocationFieldValue );
}
}
};
useDefaultsButton.addSelectionListener( listener );
}
/**
* Creates a Group widget
*
* @param parent
* the parent composite to add this group to
* @param text
* the text for the heading of the group
* @param columns
* the number of columns within the group
* @param hspan
* the horizontal span the group should take up on the parent
* @param fill
* the style for how this composite should fill into its parent
* @return the new group
* @since 3.2
*/
public static Group createGroup(Composite parent, String text, int columns, int hspan, int fill)
{
Group g = new Group(parent, SWT.NONE);
g.setLayout(new GridLayout(columns, false));
g.setText(text);
g.setFont(parent.getFont());
GridData gd = new GridData(fill);
gd.horizontalSpan = hspan;
g.setLayoutData(gd);
return g;
}
/**
* Creates a Group widget
* @param parent the parent composite to add this group to
* @param text the text for the heading of the group
* @param columns the number of columns within the group
* @param hspan the horizontal span the group should take up on the parent
* @param fill the style for how this composite should fill into its parent
* @return the new group
* @since 3.2
*
*/
public static Group createGroup(Composite parent, String text, int columns, int hspan, int fill) {
Group g = new Group(parent, SWT.NONE);
g.setLayout(new GridLayout(columns, false));
g.setText(text);
g.setFont(parent.getFont());
GridData gd = new GridData(fill);
gd.horizontalSpan = hspan;
g.setLayoutData(gd);
return g;
}