org.eclipse.swt.widgets.Button#addListener ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Button#addListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: nebula   文件: DateChooserComboExampleTab.java
private void createStyleGroup(Composite parent) {
		Group gp = new Group(parent, SWT.NONE);
		gp.setText("Style");
		gp.setLayout(new RowLayout());
		GridData data = new GridData(SWT.FILL, SWT.FILL, false, false);
//		data.horizontalSpan = 2;
		gp.setLayoutData(data);

		borderStyle = new Button(gp, SWT.CHECK);
		borderStyle.setText("SWT.BORDER");
		borderStyle.addListener(SWT.Selection, recreateListener);

		readOnlyStyle = new Button(gp, SWT.CHECK);
		readOnlyStyle.setText("SWT.READ_ONLY");
		readOnlyStyle.addListener(SWT.Selection, recreateListener);

		flatStyle = new Button(gp, SWT.CHECK);
		flatStyle.setText("SWT.FLAT");
		flatStyle.addListener(SWT.Selection, recreateListener);
	}
 
源代码2 项目: thym   文件: HybridProjectImportPage.java
private void createOptionsGroup(Composite workArea) {
	final Group optionsGroup = new Group(workArea, SWT.NULL);
	optionsGroup.setText("Options:");
	GridLayoutFactory.fillDefaults().margins(10,10).applyTo(optionsGroup);
	GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(optionsGroup);
	
	
	copyCheckbox = new Button(optionsGroup, SWT.CHECK);
	copyCheckbox.setText("Copy into workspace");
	GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL);
	copyCheckbox.addListener(SWT.Selection, new Listener() {
		@Override
		public void handleEvent(Event event) {
			copyFiles = copyCheckbox.getSelection();
			setPageComplete(validatePage());
		}
	});
}
 
源代码3 项目: typescript.java   文件: TSLintWizardPage.java
private void createEmbeddedTslintField(Composite parent) {
	useEmbeddedTslintRuntimeButton = new Button(parent, SWT.RADIO);
	useEmbeddedTslintRuntimeButton.setText(TypeScriptUIMessages.TSLintWizardPage_useEmbeddedTslintRuntime_label);
	useEmbeddedTslintRuntimeButton.addListener(SWT.Selection, this);
	useEmbeddedTslintRuntimeButton.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			updateTslintRuntimeMode();
		}
	});

	embeddedTslintRuntime = new Combo(parent, SWT.READ_ONLY);
	embeddedTslintRuntime.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	ComboViewer viewer = new ComboViewer(embeddedTslintRuntime);
	viewer.setContentProvider(ArrayContentProvider.getInstance());
	viewer.setLabelProvider(new TypeScriptRepositoryLabelProvider(true, false));
	List<ITypeScriptRepository> repositories = Arrays
			.stream(TypeScriptCorePlugin.getTypeScriptRepositoryManager().getRepositories())
			.filter(r -> r.getTslintFile() != null).collect(Collectors.toList());
	viewer.setInput(repositories);
}
 
源代码4 项目: pentaho-kettle   文件: CommonStepDialog.java
protected Button buildCancelButton() {

    wCancel = new Button( shell, SWT.PUSH );
    wCancel.setText( BaseMessages.getString( PKG, "System.Button.Cancel" ) ); //$NON-NLS-1$
    wCancel.setLayoutData( new FormDataBuilder().bottom().right( 100, 0 ).result() );
    wCancel.addListener( SWT.Selection, lsCancel );
    return wCancel;
  }
 
源代码5 项目: Rel   文件: Summarize.java
protected void buildPerOrByPanel(Composite container) {
	container.setLayout(new RowLayout(SWT.VERTICAL));

	Group perOrByGroup = new Group(container, SWT.SHADOW_IN);
	perOrByGroup.setLayout(new RowLayout(SWT.VERTICAL));

	Button btnPer = new Button(perOrByGroup, SWT.RADIO);
	btnPer.setText("PER");
	btnPer.setSelection(perArgument.isVisible());
	btnPer.addListener(SWT.Selection, e -> {
		buildPer(container);
		controlPanel.getShell().pack();
	});

	Button btnBy = new Button(perOrByGroup, SWT.RADIO);
	btnBy.setText("BY");
	btnBy.setSelection(!perArgument.isVisible());
	btnBy.addListener(SWT.Selection, e -> {
		buildBy(container);
		controlPanel.getShell().pack();
	});

	if (perArgument.isVisible())
		buildPer(container);
	else
		buildBy(container);
}
 
源代码6 项目: nebula   文件: DateChooser.java
/**
 * Creates the header of the calendar. The header contains the label
 * displaying the current month and year, and the two buttons for navigation :
 * previous and next month.
 */
private void createHeader() {
	monthPanel = new Composite(this, SWT.NONE);
	GridLayoutFactory.fillDefaults().numColumns(3).spacing(HEADER_SPACING, 0).margins(HEADER_SPACING, 2).applyTo(monthPanel);
	GridDataFactory.fillDefaults().applyTo(monthPanel);
	monthPanel.addListener(SWT.MouseDown, listener);

	prevMonth = new Button(monthPanel, SWT.ARROW | SWT.LEFT | SWT.FLAT);
	prevMonth.addListener(SWT.MouseUp, listener);
	prevMonth.addListener(SWT.FocusIn, listener);

	currentMonth = new Label(monthPanel, SWT.CENTER);
	currentMonth.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	currentMonth.addListener(SWT.MouseDown, listener);

	nextMonth = new Button(monthPanel, SWT.ARROW | SWT.RIGHT | SWT.FLAT);
	nextMonth.addListener(SWT.MouseUp, listener);
	nextMonth.addListener(SWT.FocusIn, listener);

	monthsMenu = new Menu(getShell(), SWT.POP_UP);
	currentMonth.setMenu(monthsMenu);
	for (int i = 0; i < 12; i++) {
		final MenuItem item = new MenuItem(monthsMenu, SWT.PUSH);
		item.addListener(SWT.Selection, listener);
		item.setData(new Integer(i));
	}
	monthsMenu.addListener(SWT.Show, listener);
}
 
源代码7 项目: hop   文件: CommonTransformDialog.java
protected Button buildOkButton() {

    wOk = new Button( shell, SWT.PUSH );
    wOk.setText( BaseMessages.getString( PKG, "System.Button.OK" ) ); //$NON-NLS-1$
    wOk.setLayoutData( new FormDataBuilder().bottom().right(
      wCancel, Const.isOSX() ? 0 : -BaseDialog.LABEL_SPACING ).result() );
    wOk.addListener( SWT.Selection, lsOk );
    return wOk;
  }
 
源代码8 项目: nebula   文件: Snippet5.java
/**
 * Executes the snippet.
 *
 * @param args
 *            command-line args.
 */
public static void main(String[] args) {
	Display display = Display.getDefault();
	final Shell shell = new Shell(display);
	shell.setText("Snippet5.java");
	shell.setBounds(100, 100, 640, 480);
	shell.setLayout(new GridLayout());

	Button button = new Button(shell, SWT.PUSH);
	button.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
	button.setText("Print");

	PrintViewer viewer = new PrintViewer(shell, SWT.BORDER);
	viewer.getControl()
			.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	final Print print = createPrint();
	viewer.setPrint(print);

	button.addListener(SWT.Selection, event -> {
		PrintDialog dialog = new PrintDialog(shell, SWT.NONE);
		PrinterData printerData = dialog.open();
		if (printerData != null)
			PaperClips.print(
					new PrintJob("Snippet5.java", print).setMargins(72),
					printerData);
	});

	shell.setVisible(true);

	while (!shell.isDisposed())
		if (!display.readAndDispatch())
			display.sleep();

	display.dispose();
}
 
/**
 * Create the export destination specification widgets
 * @param parent
 *            org.eclipse.swt.widgets.Composite
 */
protected void createDestinationGroup(Composite parent) {

	Font font = parent.getFont();
	// destination specification group
	Composite destinationSelectionGroup = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.numColumns = 3;
	destinationSelectionGroup.setLayout(layout);
	destinationSelectionGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
			| GridData.VERTICAL_ALIGN_FILL));
	destinationSelectionGroup.setFont(font);

	Label destinationLabel = new Label(destinationSelectionGroup, SWT.NONE);
	destinationLabel.setText(getDestinationLabel());
	destinationLabel.setFont(font);

	// destination name entry field
	destinationNameField = new Text(destinationSelectionGroup, SWT.BORDER);
	destinationNameField.addListener(SWT.Modify, this);
	destinationNameField.addListener(SWT.Selection, this);
	GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
	data.widthHint = SIZING_TEXT_FIELD_WIDTH;
	destinationNameField.setLayoutData(data);
	destinationNameField.setFont(font);

	// destination browse button
	destinationBrowseButton = new Button(destinationSelectionGroup, SWT.PUSH);
	destinationBrowseButton.setText(DataTransferMessages.DataTransfer_browse);
	destinationBrowseButton.addListener(SWT.Selection, this);
	destinationBrowseButton.setFont(font);
	setButtonLayoutData(destinationBrowseButton);

	new Label(parent, SWT.NONE); // vertical spacer
}
 
源代码10 项目: nebula   文件: TipOfTheDay.java
/**
 * Build the "show on startup" checkbox
 *
 * @param composite parent composite
 * @param gridData associated grid data
 */
private void buildShowOnStartup(final Composite composite, final GridData gridData) {
	final Button checkBox = new Button(composite, SWT.CHECK);
	checkBox.setLayoutData(gridData);
	checkBox.setText(ResourceManager.getLabel(ResourceManager.SHOW_TIP_AT_STARTUP));
	checkBox.setSelection(showOnStartup);
	checkBox.addListener(SWT.Selection, event -> {
		showOnStartup = checkBox.getSelection();
	});

}
 
private void addOutputMappingControl(final Composite parent) {
    final Composite composite = getWidgetFactory().createComposite(parent);
    composite.setLayout(GridLayoutFactory.fillDefaults().create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    outputMappingControl = new MagicComposite(composite, SWT.NONE);
    outputMappingControl.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    getWidgetFactory().adapt(outputMappingControl);
    outputMappingControl.setLayout(GridLayoutFactory.fillDefaults().numColumns(4).margins(0, 0).create());

    final Label targetParameterLabel = getWidgetFactory().createLabel(outputMappingControl,
            Messages.dataFromCalledProcess);
    targetParameterLabel.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).indent(15, 0).create());
    final Control sourceParameterLabel = getWidgetFactory().createLabel(outputMappingControl,
            Messages.dataInRootProcess);
    sourceParameterLabel.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create());

    final IObservableValue inputMappibngsObservable = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(),
            ViewersObservables.observeSingleSelection(selectionProvider),
            ProcessPackage.Literals.CALL_ACTIVITY__OUTPUT_MAPPINGS);
    dbc.bindValue(SWTObservables.observeVisible(sourceParameterLabel), inputMappibngsObservable,
            neverUpdateValueStrategy().create(), updateValueStrategy().withConverter(hideIfEmpty()).create());
    dbc.bindValue(SWTObservables.observeVisible(targetParameterLabel), inputMappibngsObservable,
            neverUpdateValueStrategy().create(), updateValueStrategy().withConverter(hideIfEmpty()).create());

    final Button addLineButton = getWidgetFactory().createButton(composite, Messages.Add, SWT.FLAT);
    addLineButton.setLayoutData(
            GridDataFactory.swtDefaults().hint(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).indent(15, 0).create());
    addLineButton.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY,
            SWTBotConstants.SWTBOT_ID_CALLACTIVITY_MAPPING_ADD_OUTPUT);
    addLineButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            createOutputMapping(null, null);
            refreshScrolledComposite(parent);
        }
    });

}
 
源代码12 项目: nebula   文件: AbstractExampleTab.java
private void createListeners(Composite parent) {
	parent.setLayout(new GridLayout(4, false));

	ButtonFactory.create(parent, SWT.PUSH, "Select Listeners", event -> {
		ListenersDialog dialog = new ListenersDialog(Display.getCurrent().getActiveShell());

		if (dialog.open(selectedEvents) == Window.OK) {
			updateListeners();
		}
	});

	listen = ButtonFactory.create(parent, SWT.CHECK, "Listen", event -> updateListeners());

	Label spacer = new Label(parent, SWT.NONE);
	spacer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	Button clear = new Button(parent, SWT.PUSH);
	clear.setText("Clear");

	final Text eventText = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
	GridData gd = new GridData(GridData.FILL_HORIZONTAL);
	gd.heightHint = 120;
	gd.horizontalSpan = 4;
	eventText.setLayoutData(gd);

	clear.addListener(SWT.Selection, event -> eventText.setText(""));

	listenerThatPrints = event -> {
		TypedEvent typedEvent = getTypedEvent(event);
		eventText.append("\n" + typedEvent.toString());
	};
}
 
源代码13 项目: Rel   文件: Sorter.java
private void createPopup() {
	popup = new PopupComposite(getShell());
	popup.setLayout(new GridLayout(1, false));
	
	SorterPanel orderer = new SorterPanel(popup, SWT.NONE);
	orderer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
	orderer.setAvailableAttributeNames(filterSorter.getAttributeNames());
	
	Composite buttonPanel = new Composite(popup, SWT.NONE);
	buttonPanel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
	buttonPanel.setLayout(new GridLayout(2, false));
	
	Button okButton = new Button(buttonPanel, SWT.PUSH);
	okButton.setText("Ok");
	okButton.addListener(SWT.Selection, e -> {
		String spec = orderer.getText().trim();
		if (spec.length() == 0)
			sortSpec.setText(emptySortPrompt);
		else
			sortSpec.setText(spec);
		popup.hide();
		filterSorter.refresh();
	});
	
	Button cancelButton = new Button(buttonPanel, SWT.PUSH);
	cancelButton.setText("Cancel");
	cancelButton.addListener(SWT.Selection, e -> {
		popup.hide();
	});
	
	String sortSpecText = sortSpec.getText();
	if (!sortSpecText.equals(emptySortPrompt))
		orderer.setText(sortSpecText);
	
	popup.pack();		
}
 
源代码14 项目: Rel   文件: UngroupOrUnwrap.java
private void addRow(Composite parent, String name) {
	Label lblNewLabel = new Label(parent, SWT.NONE);
	lblNewLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	lblNewLabel.setText(name);

	Button radioButton = new Button(parent, SWT.RADIO);
	radioButton.setSelection(name.equals(operatorLabel.getText()));
	radioButton.addListener(SWT.Selection, e -> operatorLabel.setText(name));
}
 
源代码15 项目: nebula   文件: Snippet7.java
private Button createButton(Composite parent, String toolTipText,
		Listener selectionListener) {
	Button button = new Button(parent, SWT.PUSH);
	button.setToolTipText(toolTipText);
	button.setLayoutData(
			new GridData(SWT.FILL, SWT.FILL, false, false));
	button.addListener(SWT.Selection, selectionListener);
	return button;
}
 
源代码16 项目: nebula   文件: DualList.java
private void createButtonDeselectAll() {
	final Button buttonDeselectAll = createButton(DOUBLE_LEFT_IMAGE, false, GridData.BEGINNING);
	buttonDeselectAll.addListener(SWT.Selection, e -> {
		deselectAll();
	});
}
 
源代码17 项目: atdl4j   文件: SWTRadioButtonListener.java
public void addButton(Button button)
{
	buttons.add( button );
	button.addListener( SWT.Selection, this );
}
 
源代码18 项目: Universal-FE-Randomizer   文件: CONAffinityView.java
public CONAffinityView(Composite parent, int style) {
	super(parent, style);
	
	FillLayout layout = new FillLayout();
	setLayout(layout);
	
	container = new Group(this, SWT.NONE);
	
	container.setText("Other Character Settings");
	
	FormLayout mainLayout = new FormLayout();
	mainLayout.marginLeft = 5;
	mainLayout.marginRight = 5;
	mainLayout.marginTop = 5;
	mainLayout.marginBottom = 5;
	container.setLayout(mainLayout);
	
	randomizeCONButton = new Button(container, SWT.CHECK);
	randomizeCONButton.setText("Randomize Constitution");
	randomizeCONButton.setToolTipText("Randomizes Constitution, which affects weight, and therefore, the ability to\nto shove/rescue and to be shoved/rescued.");
	
	FormData conData = new FormData();
	conData.left = new FormAttachment(0, 0);
	conData.top = new FormAttachment(0, 0);
	randomizeCONButton.setLayoutData(conData);
	
	conVarianceSpinner = new Spinner(container, SWT.NONE);
	conVarianceSpinner.setValues(3, 1, 8, 0, 1, 1);
	conVarianceSpinner.setToolTipText("Determines how far in each direction Constitution is allowed to adjust.");
	
	FormData spinnerData = new FormData();
	spinnerData.right = new FormAttachment(100, -12);
	spinnerData.top = new FormAttachment(randomizeCONButton, 5);
	conVarianceSpinner.setLayoutData(spinnerData);
	
	conVarianceLabel = new Label(container, SWT.NONE);
	conVarianceLabel.setText("Variance:");
	
	FormData labelData = new FormData();
	labelData.right = new FormAttachment(conVarianceSpinner, -5);
	labelData.top = new FormAttachment(conVarianceSpinner, 0, SWT.CENTER);
	conVarianceLabel.setLayoutData(labelData);
	
	conVarianceLabel.setEnabled(false);
	conVarianceSpinner.setEnabled(false);
	
	randomizeCONButton.addListener(SWT.Selection, new Listener() {
		@Override
		public void handleEvent(Event event) {
			conVarianceLabel.setEnabled(randomizeCONButton.getSelection());
			conVarianceSpinner.setEnabled(randomizeCONButton.getSelection());
		}
	});
	
	randomizeAffinityButton = new Button(container, SWT.CHECK);
	randomizeAffinityButton.setText("Randomize Affinity");
	randomizeAffinityButton.setToolTipText("Randomizes affinity, which affects support bonuses.");
	
	FormData affinityData = new FormData();
	affinityData.left = new FormAttachment(randomizeCONButton, 0, SWT.LEFT);
	affinityData.top = new FormAttachment(conVarianceSpinner, 5);
	randomizeAffinityButton.setLayoutData(affinityData);
}
 
public static void main(String[] args) {
	final Display display = new Display();

	final Shell shell = new Shell(display, SWT.SHELL_TRIM);
	shell.setLayout(new GridLayout());
	shell.setSize(600, 600);

	final PrintJob job = new PrintJob(
			"GridPrintCellClippingAllowClipFirstRow", createPrint());

	Composite buttons = new Composite(shell, SWT.NONE);
	buttons.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
	buttons.setLayout(new RowLayout(SWT.HORIZONTAL));

	final Button prev = new Button(buttons, SWT.PUSH);
	prev.setText("<< Prev");
	prev.setEnabled(false);

	final Button next = new Button(buttons, SWT.PUSH);
	next.setText("Next >>");

	final Button print = new Button(buttons, SWT.PUSH);
	print.setText("Print..");

	final PrintPreview preview = new PrintPreview(shell, SWT.BORDER);
	preview.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	preview.setPrintJob(job);
	next.setEnabled(preview.getPageCount() > 1);

	Listener listener = event -> {
		int newIndex = preview.getPageIndex();
		if (event.widget == prev)
			newIndex--;
		else
			newIndex++;
		preview.setPageIndex(newIndex);
		prev.setEnabled(newIndex > 0);
		next.setEnabled(newIndex < preview.getPageCount() - 1);
	};
	prev.addListener(SWT.Selection, listener);
	next.addListener(SWT.Selection, listener);

	print.addListener(SWT.Selection, event -> {
		PrinterData printerData = new PrintDialog(shell).open();
		if (printerData != null) {
			PaperClips.print(job, printerData);
		}
	});

	shell.open();

	while (!shell.isDisposed())
		if (!display.readAndDispatch())
			display.sleep();
}
 
源代码20 项目: nebula   文件: NotifierSnippet.java
/**
 * @param args
 */
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setText("Notifier Snippet");
	shell.setSize(200, 200);
	shell.setLayout(new FillLayout(SWT.VERTICAL));

	final int[] counter = new int[1];
	counter[0] = 0;

	// Yellow theme (default)
	final Button testerYellow = new Button(shell, SWT.PUSH);
	testerYellow.setText("Push me [Yellow theme]!");
	testerYellow.addListener(SWT.Selection, event -> {
		Notifier.notify("New Mail message", "Laurent CARON ([email protected])<br/><br/>Test message #" + counter[0] + "...");
		counter[0]++;
	});

	// Blue theme
	final Button testerBlue = new Button(shell, SWT.PUSH);
	testerBlue.setText("Push me [Blue theme]!");
	testerBlue.addListener(SWT.Selection, event -> {
		Notifier.notify("New Mail message", "Laurent CARON ([email protected])<br/><br/>Test message #" + counter[0] + "...", NotifierTheme.BLUE_THEME);
		counter[0]++;
	});

	// Grey theme
	final Button testerGrey = new Button(shell, SWT.PUSH);
	testerGrey.setText("Push me [Gray theme]!");
	testerGrey.addListener(SWT.Selection, event -> {
		Notifier.notify("New Mail message", "Laurent CARON ([email protected])<br/><br/>Test message #" + counter[0] + "...", NotifierTheme.GRAY_THEME);
		counter[0]++;
	});

	shell.open();

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();
}