下面列出了org.eclipse.swt.widgets.Layout#org.eclipse.swt.events.SelectionEvent 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
FilterTraceTypeNodeComposite(Composite parent, TmfFilterTraceTypeNode node) {
super(parent, node);
fNode = node;
fTraceTypeMap = getTraceTypeMap(fNode.getTraceTypeId());
Label label = new Label(this, SWT.NONE);
label.setText(Messages.FilterViewer_TypeLabel);
fTypeCombo = new CCombo(this, SWT.DROP_DOWN | SWT.READ_ONLY);
fTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fTypeCombo.setItems(fTraceTypeMap.keySet().toArray(new String[0]));
if (fNode.getTraceTypeId() != null) {
fTypeCombo.setText(fNode.getName());
}
fTypeCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TraceTypeHelper helper = checkNotNull(fTraceTypeMap.get(fTypeCombo.getText()));
fNode.setTraceTypeId(helper.getTraceTypeId());
fNode.setTraceClass(helper.getTraceClass());
fNode.setName(fTypeCombo.getText());
fViewer.refresh(fNode);
}
});
}
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
createNewExperimentNameGroup(composite);
fDeepCopyButton = new Button(composite, SWT.CHECK);
fDeepCopyButton.setText(Messages.CopyExperimentDialog_DeepCopyButton);
fDeepCopyButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
validateNewExperimentName();
}
});
return composite;
}
private void initialize(Composite parent) {
final Button button = new Button(parent, SWT.NONE);
button.setText(DisplayMessages.getMessage("action.title.manage.global.group"));
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final ColumnGroupSet columnGroups = GlobalColumnGroupSet.load();
final ERDiagram diagram = new ERDiagram(columnGroups.getDatabase());
final ColumnGroupManageDialog dialog = new ColumnGroupManageDialog(
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), columnGroups, diagram, true, -1);
if (dialog.open() == IDialogConstants.OK_ID) {
final List<CopyColumnGroup> newColumnGroups = dialog.getCopyColumnGroups();
columnGroups.clear();
for (final CopyColumnGroup copyColumnGroup : newColumnGroups) {
columnGroups.add(copyColumnGroup.restructure(null));
}
GlobalColumnGroupSet.save(columnGroups);
}
}
});
}
public static final SelectionAdapter getSelectionAdapter( final Shell shell, final Text destination ) {
// Listen to the Browse... button
return new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
DirectoryDialog dialog = new DirectoryDialog( shell, SWT.OPEN );
if ( destination.getText() != null ) {
String fpath = destination.getText();
// String fpath = StringUtil.environmentSubstitute(destination.getText());
dialog.setFilterPath( fpath );
}
if ( dialog.open() != null ) {
String str = dialog.getFilterPath();
destination.setText( str );
}
}
};
}
@Override
public void widgetSelected(final SelectionEvent e) {
final int i = categoryList.getSelectionIndex();
if (i > -1) {
final String name = categoryList.getItem(i);
categoryList.remove(i);
categoryFiles.remove(name);
namesList.setItems(new String[0]);
bAddFile.setEnabled(false);
final TabItem ti = folder.getItem(i + 1);
final Object o = ti.getData();
ti.dispose();
if (o instanceof BoxSettingsTab) {
((BoxSettingsTab) o).dispose();
}
BoxProviderRegistry.getInstance().removeProvider(name);
providersChanged = true;
}
}
@SuppressWarnings("unused")
public BasicFilterEditorControl(FilterEditorControl<?> parent) {
super(parent, SWT.NONE);
setLayout(Widgets.buildContainerLayout(5));
Label nameLabel = Widgets.buildCompactLabel(this, "Name: ");
nameText = Widgets.buildGridBoxedText(this);
updateNameText();
Label summaryLabel = Widgets.buildCompactLabel(this, "Summary: ");
summaryText = Widgets.buildGridBoxedText(this);
updateSummaryText();
Button inferButton = Widgets.buildTrailPushButton(this, "Infer");
inferButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
inferFilterSummary();
}
});
}
/**
* {@inheritDoc}
*/
@Override
protected void addListener() {
super.addListener();
environmentCombo.addSelectionListener(new SelectionAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void widgetSelected(final SelectionEvent e) {
validate();
}
});
}
private void createLinks(Composite parent) {
parent.setLayout(new GridLayout());
String[] links = createLinks();
if (links == null) {
return;
}
for (String link2 : links) {
Link link = new Link(parent, SWT.NONE);
link.setText(link2);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Program.launch(e.text);
}
});
}
}
/**
* Creates the main window's contents
*
* @param parent the main window
* @return Control
*/
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, true));
// Create the button
Button show = new Button(composite, SWT.NONE);
show.setText("Show");
final Shell shell = parent.getShell();
// Display the dialog
show.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
// Create and show the dialog
DumbMessageDialog dlg = new DumbMessageDialog(shell);
dlg.open();
}
});
parent.pack();
return composite;
}
private Composite createBaseControl(Composite parent) {
Composite result = Widgets.buildGridContainer(parent, 3);
// Row 1) Container selection
Label label = new Label(result, SWT.NULL);
label.setText("&Base:");
baseText = new Text(result, SWT.BORDER | SWT.SINGLE);
baseText.setLayoutData(Widgets.buildHorzFillData());
if (null != baseContainer) {
baseText.setText(baseContainer.getFullPath().toString());
}
Button button = new Button(result, SWT.PUSH);
button.setText("Browse...");
// Install listeners after initial value assignments
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleBaseBrowse();
}
});
return result;
}
private ToolItem createHistoryToolItem(ToolBar toolbar, final String preferenceName)
{
ToolItem historyToolItem = new ToolItem(toolbar, SWT.DROP_DOWN);
historyToolItem.setImage(FindBarPlugin.getImage(FindBarPlugin.ICON_SEARCH_HISTORY));
historyToolItem.setToolTipText(Messages.FindBarDecorator_TOOLTIP_History);
historyToolItem.addSelectionListener(new SelectionAdapter()
{
Menu menu = null;
/*
* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e)
{
ToolItem toolItem = (ToolItem) e.widget;
menu = createHistoryMenu(toolItem, preferenceName, menu);
}
});
return historyToolItem;
}
/**
* Creates the bottom controls.
*/
private void createBottomControls(Composite parent) {
Composite bottomControls = new Composite(parent, SWT.NONE);
bottomControls
.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).align(SWT.RIGHT, SWT.CENTER).create());
bottomControls.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(0, 5, 0, 0).create());
previewToggleButton = new Button(bottomControls, SWT.PUSH);
previewToggleButton.setText(HIDE_PREVIEW_TEXT);
previewToggleButton.setSelection(true);
previewToggleButton.setLayoutData(GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.BOTTOM).create());
previewToggleButton.setToolTipText(PREVIEW_BUTTON_TOOLTIP);
previewToggleButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (!previewVisible) {
showContentPreview();
} else {
hideContentPreview();
}
}
});
}
public void widgetSelected(SelectionEvent e)
{
Object source = e.getSource();
if (source == fSetPrimaryMenuItem || source == fMakePrimaryButton)
{
ISelection selection = fTableViewer.getSelection();
if (!selection.isEmpty() && selection instanceof StructuredSelection)
{
Object firstElement = ((StructuredSelection) selection).getFirstElement();
// make the element checked
fTableViewer.setChecked(firstElement, true);
// make it as primary
updatePrimaryNature(firstElement.toString());
fTableViewer.refresh();
updateButtons();
}
}
}
/**
* {@inheritDoc}
*/
@Override
protected void addListener() {
environmentCombo.addSelectionListener(new SelectionAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void widgetSelected(final SelectionEvent e) {
perfomeOK();
setPropertiesData();
}
});
}
private Combo createTypeCombo(final NormalColumn targetColumn) {
final GridData gridData = new GridData();
gridData.widthHint = 100;
final Combo typeCombo = new Combo(attributeTable, SWT.READ_ONLY);
initializeTypeCombo(typeCombo);
typeCombo.setLayoutData(gridData);
typeCombo.addSelectionListener(new SelectionAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void widgetSelected(final SelectionEvent event) {
validate();
}
});
final SqlType sqlType = targetColumn.getType();
final String database = diagram.getDatabase();
if (sqlType != null && sqlType.getAlias(database) != null) {
typeCombo.setText(sqlType.getAlias(database));
}
return typeCombo;
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
if (e.widget != listView) {
return;
}
executeCommandFromList(-1);
}
private void configSorters(Table table) {
int index = 0;
for (TableColumn column : table.getColumns()) {
final int colIndex = index++;
column.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
updateSortColumn((TableColumn) event.widget, colIndex);
}
});
}
}
/**
* Tell the user that the pipeline is not running or that there is no monitoring configured.
*/
private void showEmptyGraph() {
if ( perfComposite.isDisposed() ) {
return;
}
emptyGraph = true;
Label label = new Label( perfComposite, SWT.CENTER );
label.setText( BaseMessages.getString( PKG, "PipelineLog.Dialog.PerformanceMonitoringNotEnabled.Message" ) );
label.setBackground( perfComposite.getBackground() );
label.setFont( GuiResource.getInstance().getFontMedium() );
FormData fdLabel = new FormData();
fdLabel.left = new FormAttachment( 5, 0 );
fdLabel.right = new FormAttachment( 95, 0 );
fdLabel.top = new FormAttachment( 5, 0 );
label.setLayoutData( fdLabel );
Button button = new Button( perfComposite, SWT.CENTER );
button.setText( BaseMessages.getString( PKG, "PipelineLog.Dialog.PerformanceMonitoring.Button" ) );
button.setBackground( perfComposite.getBackground() );
button.setFont( GuiResource.getInstance().getFontMedium() );
button.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent event ) {
pipelineGraph.editProperties( pipelineGraph.getPipelineMeta(), hopGui, true, PipelineDialog.Tabs.MONITOR_TAB );
}
} );
FormData fdButton = new FormData();
fdButton.left = new FormAttachment( 40, 0 );
fdButton.right = new FormAttachment( 60, 0 );
fdButton.top = new FormAttachment( label, 5 );
button.setLayoutData( fdButton );
perfComposite.layout( true, true );
}
@Override
public void widgetSelected(SelectionEvent e) {
if(e.getSource() == bubbleScale) {
lblBubbles.setText("Bubbles Scaling Factor: "+ String.format("%.2f", getScalingFactor()));
}
}
public void widgetSelected(SelectionEvent e)
{
Object source = e.getSource();
if (source == buttonAdd)
{
doAdd();
} else if (source == buttonRemove)
{
doRemove();
} else if (source == buttonEdit)
{
doEdit();
}
}
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
container.setLayout(new GridLayout(3, false));
Label dropperJarLabel = new Label(container, SWT.NONE);
dropperJarLabel.setText("Payload Dropper Jar: ");
dropperJarText = new Text(container, SWT.BORDER);
dropperJarText.setEditable(false);
dropperJarText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
final FileDialog fileChooser = new FileDialog(container.getShell(), SWT.SAVE);
fileChooser.setFilterExtensions(new String[] { "*.jar" });
fileChooser.setFileName("dropper.jar");
Button browseButton = new Button(container, SWT.NONE);
browseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String path = fileChooser.open();
if (path != null){
jarPath = path;
setPageComplete(true);
}
dropperJarText.setText(jarPath);
}
});
browseButton.setText("Browse...");
setPageComplete(false);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
if (!updating) {
Date newSelection = CDateTimeObservableValue.this.dateTime.getSelection();
if (((newSelection != null) && !newSelection.equals(currentSelection))
|| ((currentSelection != null) && !currentSelection.equals(newSelection))) {
fireValueChange(Diffs.createValueDiff(currentSelection, newSelection));
}
currentSelection = newSelection;
}
}
public SWTToolActionMenuItem(ToolItem item, SWTToolBar parent) {
super(item, parent);
this.selectionListener = new SWTSelectionListenerManager(this);
this.menu = new SWTPopupMenu(this.getParent().getControl().getShell());
this.getControl().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
SWTToolActionMenuItem.this.onSelect(event);
}
});
}
private void createRecentAudiosMenu() {
for (MenuItem mi : recentAudiosM.getItems())
mi.dispose();
CacheList<File> audioFilesCache = pmTrans.getRecentAudios();
for (int i = 0; i < audioFilesCache.size(); i++)
addMenuItem(recentAudiosM, audioFilesCache.get(i).getName(),
SWT.NONE, audioFilesCache.get(i), new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
pmTrans.openAudioFile((File) ((MenuItem) e
.getSource()).getData());
}
});
}
@Override
protected List<Control> renderControls() {
List<Control> controls = new LinkedList<>();
List<String> existingAnswers = getAnswersNullSafe();
for (String choice : question.getChoices()) {
Button btn = new Button(root, SWT.CHECK);
controls.add(btn);
btn.setText(choice);
btn.setSelection(existingAnswers.contains(choice));
btn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
List<String> answers = getAnswersNullSafe();
boolean checked = btn.getSelection();
boolean contained = answers.contains(choice);
if (checked && !contained)
answers.add(choice);
else if (!checked && contained)
answers.remove(choice);
else
throw new IllegalStateException();
question.addAnswer(document, answers);
onQuestionChanged.accept(question);
}
});
}
return controls;
}
public DirectoryText(Composite parent, int style) {
this.text = new Text(parent, style);
openBrowseButton = new Button(parent, SWT.NONE);
openBrowseButton.setText(JFaceResources.getString("openBrowse"));
openBrowseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final String filePath = Activator.showDirectoryDialog(text.getText());
text.setText(filePath);
}
});
}
/**
* Create a radio button for the disk image format list.
*/
protected void createRadioButton(Composite composite, String label,
final int format, String helpText) {
Button button = new Button(composite, SWT.RADIO);
button.setText(label);
button.setSelection(wizard.getFormat() == format);
button.setToolTipText(helpText);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getWizard().setFormat(format);
}
});
}
public TimeShiftActionController ( final ControllerManager controllerManager, final ChartContext chartContext, final TimeShiftAction controller )
{
super ( controllerManager.getContext (), chartContext, controller );
final DataBindingContext ctx = controllerManager.getContext ();
final Composite space = chartContext.getExtensionSpaceProvider ().getExtensionSpace ();
if ( space != null )
{
this.button = new Button ( space, SWT.PUSH );
this.button.addSelectionListener ( new SelectionAdapter () {
@Override
public void widgetSelected ( final SelectionEvent e )
{
action ();
};
} );
addBinding ( ctx.bindValue ( PojoObservables.observeValue ( this, "milliseconds" ), EMFObservables.observeValue ( controller, ChartPackage.Literals.TIME_SHIFT_ACTION__DIFF ) ) ); //$NON-NLS-1$
addBinding ( ctx.bindValue ( SWTObservables.observeText ( this.button ), EMFObservables.observeValue ( controller, ChartPackage.Literals.TIME_SHIFT_ACTION__LABEL ) ) );
addBinding ( ctx.bindValue ( SWTObservables.observeTooltipText ( this.button ), EMFObservables.observeValue ( controller, ChartPackage.Literals.TIME_SHIFT_ACTION__DESCRIPTION ) ) );
this.layoutListener = new IValueChangeListener () {
@Override
public void handleValueChange ( final ValueChangeEvent event )
{
space.layout ();
}
};
this.labelProperty = EMFObservables.observeValue ( controller, ChartPackage.Literals.TIME_SHIFT_ACTION__LABEL );
this.labelProperty.addValueChangeListener ( this.layoutListener );
space.layout ();
}
else
{
this.button = null;
}
}
/**
*
*/
private void createMarkToggle(final Menu menu) {
final MenuItem mark = new MenuItem(menu, SWT.CHECK);
mark.setText(" Mark occurences of symbols");
mark.setImage(GamaIcons.create("toggle.mark").image());
mark.setSelection(markPref.getValue());
mark.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
markPref.set(mark.getSelection()).save();
}
});
}
protected Button createSpecialButton(
Composite parent,
int id,
String label,
boolean defaultButton, boolean enabled) {
Button button = new Button(parent, SWT.PUSH);
button.setText(label);
button.setData(new Integer(id));
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
buttonPressed(((Integer) event.widget.getData()).intValue());
}
});
if (defaultButton) {
Shell shell = parent.getShell();
if (shell != null) {
shell.setDefaultButton(button);
}
}
button.setFont(parent.getFont());
if (!enabled){
button.setEnabled(false);
}
setButtonLayoutData(button);
specialButtonList.add(button);
return button;
}