Java Code Examples for org.eclipse.swt.SWT#PUSH

The following examples show how to use org.eclipse.swt.SWT#PUSH . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FindBarDecorator.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Create a default button (find, replace, replace/find, replace all).
 */
private Button createButton(Composite parent, String image, boolean enabled)
{
	GridData layoutData = createdDefaultGridData();
	Button button = new Button(parent, SWT.PUSH);
	button.setEnabled(enabled);
	if (image != null)
	{
		button.setImage(FindBarPlugin.getImage(image));
	}
	button.addSelectionListener(this);
	button.setLayoutData(layoutData);
	setDefaultFocusListener(button);

	return button;
}
 
Example 2
Source File: SelectionButtonDialogField.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void changeValue(boolean newState) {
	if (fIsSelected != newState) {
		fIsSelected= newState;
		if (fAttachedDialogFields != null) {
			boolean focusSet= false;
			for (int i= 0; i < fAttachedDialogFields.length; i++) {
				fAttachedDialogFields[i].setEnabled(fIsSelected);
				if (fIsSelected && !focusSet) {
					focusSet= fAttachedDialogFields[i].setFocus();
				}
			}
		}
		dialogFieldChanged();
	} else if (fButtonStyle == SWT.PUSH) {
		dialogFieldChanged();
	}
}
 
Example 3
Source File: SWTUtil.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates and returns a new push button with the given label and/or image.
 * 
 * @param parent
 *            parent control
 * @param label
 *            button label or <code>null</code>
 * @param image
 *            image of <code>null</code>
 * @return a new push button
 */
public static Button createPushButton(Composite parent, String label, Image image)
{
	Button button = new Button(parent, SWT.PUSH);
	button.setFont(parent.getFont());
	if (image != null)
	{
		button.setImage(image);
	}
	if (label != null)
	{
		button.setText(label);
	}
	GridData gd = new GridData();
	button.setLayoutData(gd);
	SWTUtil.setButtonDimensionHint(button);
	return button;
}
 
Example 4
Source File: XViewerCustomizeDialog.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void createFilterTextBlock(final Composite composite) {
   // Filter text block
   final Composite composite_7 = new Composite(composite, SWT.NONE);
   composite_7.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));
   final GridLayout gridLayout_13 = new GridLayout();
   gridLayout_13.numColumns = 5;
   composite_7.setLayout(gridLayout_13);

   final Label filterLabel = new Label(composite_7, SWT.NONE);
   filterLabel.setText(XViewerText.get("XViewerCustomizeDialog.filter.text")); //$NON-NLS-1$

   filterText = new Text(composite_7, SWT.BORDER);
   filterText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

   Label filterLabel2 = new Label(composite_7, SWT.NONE);
   filterLabel2.setText(XViewerText.get("XViewerCustomizeDialog.filter.expression")); //$NON-NLS-1$

   filterRegExCheckBox = new Button(composite_7, SWT.CHECK);
   filterRegExCheckBox.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false));

   final Label clearFilterLabel = new Label(composite_7, SWT.PUSH);
   clearFilterLabel.setImage(XViewerLib.getImage("clear.gif")); //$NON-NLS-1$
   clearFilterLabel.addListener(SWT.MouseUp, e -> filterText.setText("")); //$NON-NLS-1$

}
 
Example 5
Source File: MenuItemProviders.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider clearAllFiltersMenuItemProvider(final String menuLabel) {
	return new IMenuItemProvider() {

		public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
			MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
			menuItem.setText(menuLabel);
			menuItem.setImage(GUIHelper.getImage("remove_filter"));
			menuItem.setEnabled(true);

			menuItem.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					natTable.doCommand(new ClearAllFiltersCommand());
				}
			});
		}
	};
}
 
Example 6
Source File: SamplePart.java    From codeexamples-eclipse with Eclipse Public License 1.0 6 votes vote down vote up
@PostConstruct
public void createComposite(Composite parent) {
	parent.setLayout(new GridLayout(1, false));

	Button button = new Button(parent, SWT.PUSH);
	button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false,
			false));
	button.setText("Show Sample Wizard");
	button.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			WizardDialog wizardDialog = new WizardDialog(shell,
					new SampleWizard());
			wizardDialog.open();
		}
	});
	
}
 
Example 7
Source File: DataFileOption.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create the user interface for the option
 */
public void createControl(Composite parent, int span) {
	// Create the descriptive layer
	locationLabel = new Label(parent, SWT.NONE);
	locationLabel.setText(description);

	// Create the text entry area where the path to the file will be displayed
	locationPathField = new Text(parent, SWT.BORDER);
	GridData data = new GridData(GridData.FILL_HORIZONTAL);
	data.widthHint = 250;
	data.horizontalSpan = 2;
	locationPathField.setLayoutData(data);

	// Create the browse button and add a listener to open a file chooser
	browseButton = new Button(parent, SWT.PUSH);
	browseButton.setText("Browse");
	browseButton.addSelectionListener(new SelectionListener() {
		@Override
		public void widgetSelected(SelectionEvent event) {
			fileChooser = new FileDialog(parent.getShell());
			fileChooser.setText("Select File");
			fileChooser.setFilterExtensions(new String[] {"*.*"});
			chosenFile = fileChooser.open();
			locationPathField.setText(chosenFile);
			setValue(chosenFile);
		}

		@Override public void widgetDefaultSelected(SelectionEvent e) {}
	});
}
 
Example 8
Source File: ImporterPage.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public ODBCBasedImporter(final Composite parent, final ImporterPage home){
	super(parent, SWT.NONE);
	setLayout(new GridLayout());
	final Label lSource = new Label(this, SWT.NONE);
	tSource = new Text(this, SWT.BORDER);
	lSource.setText(Messages.ImporterPage_source); //$NON-NLS-1$
	tSource.setEditable(false);
	lSource.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	tSource.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	tSource.setText(CoreHub.localCfg.get(
		"ImporterPage/" + home.getTitle() + "/ODBC-Source", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	home.results = new String[1];
	home.results[0] = tSource.getText();
	Button bSource = new Button(this, SWT.PUSH);
	bSource.setText(Messages.ImporterPage_enter); //$NON-NLS-1$
	bSource.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(final SelectionEvent e){
			InputDialog in =
				new InputDialog(parent.getShell(), Messages.ImporterPage_odbcSource, //$NON-NLS-1$
					Messages.ImporterPage_pleaseEnterODBC, null, null); //$NON-NLS-1$
			if (in.open() == Dialog.OK) {
				tSource.setText(in.getValue());
				home.results[0] = in.getValue();
				CoreHub.localCfg.set(
					"ImporterPage/" + home.getTitle() + "/ODBC-Source", home.results[0]); //$NON-NLS-1$ //$NON-NLS-2$
			}
			
		}
		
	});
	
}
 
Example 9
Source File: FileViewerWindow.java    From AppleCommander with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the print tool item (button).
 */
protected ToolItem createPrintToolItem() {
	ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH);
	toolItem.setImage(imageManager.get(ImageManager.ICON_PRINT_FILE));
	toolItem.setText(textBundle.get("PrintButton")); //$NON-NLS-1$
	toolItem.setToolTipText(textBundle.get("FileViewerWindow.PrintTooltip")); //$NON-NLS-1$
	toolItem.setEnabled(true);
	toolItem.addSelectionListener(new SelectionAdapter () {
		public void widgetSelected(SelectionEvent e) {
			getContentTypeAdapter().print();
		}
	});
	return toolItem;
}
 
Example 10
Source File: GWTCompileDialog.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
  super.createButtonsForButtonBar(parent);
  compileButton = getButton(IDialogConstants.OK_ID);

  // Re-label the OK button and set it as default
  compileButton.setText("Compile");
  getShell().setDefaultButton(compileButton);

  ((GridLayout) parent.getLayout()).numColumns++;
  applyButton = new Button(parent, SWT.PUSH);
  applyButton.setText("Apply");
  applyButton.setEnabled(false);
  setButtonLayoutData(applyButton);
}
 
Example 11
Source File: PaperclipsExampleTab.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public Control createControl(Composite parent) {
	Composite shell = new Composite(parent, SWT.None);

	final PrintJob job = new PrintJob("GridPrintVerticalAlignmentExample.java", createPrint());
	shell.setLayout(new org.eclipse.swt.layout.GridLayout());

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

	final PrintPreview preview = new PrintPreview(shell, SWT.BORDER);

	Button prev = new Button(buttonPanel, SWT.PUSH);
	prev.setText("<< Prev");
	prev.addListener(SWT.Selection, event -> {
		preview.setPageIndex(Math.max(preview.getPageIndex() - 1, 0));
	});

	Button next = new Button(buttonPanel, SWT.PUSH);
	next.setText("Next >>");
	next.addListener(SWT.Selection, event -> {
		preview.setPageIndex(Math.min(preview.getPageIndex() + 1, preview.getPageCount() - 1));
	});

	Button print = new Button(buttonPanel, SWT.PUSH);
	print.setText("Print");
	print.addListener(SWT.Selection, event -> {
		PaperClips.print(job, new PrinterData());
	});

	preview.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	preview.setFitHorizontal(true);
	preview.setFitVertical(true);
	preview.setPrintJob(job);
	return shell;
}
 
Example 12
Source File: ExtractMethodComposite.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private Button createButton(Composite parent, String name) {
    Button button = new Button(parent, SWT.PUSH | SWT.CENTER);
    GridData buttonLData = new GridData();
    buttonLData.horizontalAlignment = GridData.FILL;
    buttonLData.grabExcessHorizontalSpace = true;
    button.setLayoutData(buttonLData);
    button.setText(name);
    return button;
}
 
Example 13
Source File: CDatePanel.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void createHeader() {
	header = new VPanel(panel, SWT.NONE);
	VGridLayout layout = new VGridLayout(3, true);
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	header.setLayout(layout);
	header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));

	VButton b = new VButton(header, SWT.ARROW | SWT.LEFT | SWT.NO_FOCUS);
	b.setFill(getDisplay().getSystemColor(SWT.COLOR_GRAY));
	b.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
	b.addListener(SWT.Selection, event -> {
		calendar.add(Calendar.MONTH, -1);
		updateMonths();
	});

	b = new VButton(header, SWT.PUSH | SWT.NO_FOCUS);
	b.setText("Today");
	b.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
	b.addListener(SWT.Selection, event -> {
		calendar.setTimeInMillis(System.currentTimeMillis());
		updateMonths();
	});

	b = new VButton(header, SWT.ARROW | SWT.RIGHT | SWT.NO_FOCUS);
	b.setFill(getDisplay().getSystemColor(SWT.COLOR_GRAY));
	b.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
	b.addListener(SWT.Selection, event -> {
		calendar.add(Calendar.MONTH, 1);
		updateMonths();
	});

	headerSize = header.computeSize(-1, -1).y;
}
 
Example 14
Source File: Snippet8.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
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;
}
 
Example 15
Source File: SearchAdvanced.java    From Rel with Apache License 2.0 5 votes vote down vote up
public SearchAdvanced(FilterSorter filterSorter, Composite contentPanel) {
	super(contentPanel, SWT.NONE);
	
	this.filterSorter = filterSorter;
	
	GridLayout layout = new GridLayout(2, false);
	layout.horizontalSpacing = 0;
	layout.verticalSpacing = 0;
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	setLayout(layout);

	filterSpec = new Label(this, SWT.NONE);
	filterSpec.setText(emptyFilterPrompt);
	filterSpec.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
	
	filterSpec.addListener(SWT.MouseUp, e -> popup());		
	
	ToolBar toolBar = new ToolBar(this, SWT.NONE);
	
	ToolItem clear = new ToolItem(toolBar, SWT.PUSH);
	clear.addListener(SWT.Selection, e -> {
		filterSpec.setText(emptyFilterPrompt);
		filterSorter.refresh();
	});
	clear.setText("Clear");
	
	toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	
	this.addListener(SWT.Show, e -> {
		if (filterSpec.getText().equals(emptyFilterPrompt))
			popup();
	});
	
	constructPopup();
}
 
Example 16
Source File: MListEditor.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Helper method to create a push button.
 * 
 * @param parent the parent control
 * @param key the resource name used to supply the button's label text
 * @return Button
 */
private Button createPushButton(Composite parent, String key) {
    Button button = new Button(parent, SWT.PUSH);
    String buttonText = JFaceResources.getString(key);
    button.setText(buttonText);
    button.setFont(parent.getFont());
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    int widthHint = convertHorizontalDLUsToPixels(button,
            IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT,
            SWT.DEFAULT, true).x);
    button.setLayoutData(data);
    button.addSelectionListener(getSelectionListener());
    return button;
}
 
Example 17
Source File: RemoteProfilesPreferencePage.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
private static Button createVerticalButton(Composite parent, String text) {
    Button button = new Button(parent, SWT.PUSH);
    button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    button.setText(text);
    return button;
}
 
Example 18
Source File: SwtXYChartViewer.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Constructor for the chart. Any final class that derives this class must
 * call the {@link #populate()} method to create the rest of the chart.
 *
 * @param parent
 *            A parent composite
 * @param data
 *            A configured data series for the chart
 * @param model
 *            A chart model to use
 */
public SwtXYChartViewer(Composite parent, ChartData data, ChartModel model) {
    fParent = parent;
    fData = data;
    fModel = model;
    fSeriesMap = new HashMap<>(data.getChartSeries().size());
    fObjectMap = new HashMap<>(data.getChartSeries().size());
    fXInformation = DescriptorsInformation.create(getXDescriptors());
    fYInformation = DescriptorsInformation.create(getYDescriptors());

    validateChartData();

    fChart = new Chart(parent, SWT.NONE);

    /*
     * Temporarily generate titles, they may be modified once the data has
     * been parsed (with formatting information, units, etc)
     */
    fXTitle = generateTitle(getXDescriptors(), getChart().getAxisSet().getXAxis(0));
    fYTitle = generateTitle(getYDescriptors(), getChart().getAxisSet().getYAxis(0));

    /* Set all titles and labels font color to black */
    fChart.getTitle().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
    fChart.getAxisSet().getXAxis(0).getTitle().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
    fChart.getAxisSet().getYAxis(0).getTitle().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
    fChart.getAxisSet().getXAxis(0).getTick().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
    fChart.getAxisSet().getYAxis(0).getTick().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));

    /* Set X label 90 degrees */
    fChart.getAxisSet().getXAxis(0).getTick().setTickLabelAngle(90);

    /* Set the legend position if necessary */
    if (getData().getChartSeries().size() > 1) {
        fChart.getLegend().setPosition(SWT.BOTTOM);
    } else {
        fChart.getLegend().setVisible(false);
    }

    /* Refresh the titles to fit the current chart size */
    refreshDisplayTitles();

    /* Create the close button */
    Image close = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_REMOVE);
    fCloseButton = new Button(fChart, SWT.PUSH);
    fCloseButton.setSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE);
    fCloseButton.setLocation(fChart.getSize().x - fCloseButton.getSize().x - CLOSE_BUTTON_MARGIN, CLOSE_BUTTON_MARGIN);
    fCloseButton.setImage(close);
    fCloseButton.addSelectionListener(new CloseButtonEvent());

    /* Add listeners for the visibility of the close button and resizing */
    Listener mouseEnter = new MouseEnterEvent();
    Listener mouseExit = new MouseExitEvent();
    fChart.getDisplay().addFilter(SWT.MouseEnter, mouseEnter);
    fChart.getDisplay().addFilter(SWT.MouseExit, mouseExit);
    fChart.addDisposeListener(event -> {
        fChart.getDisplay().removeFilter(SWT.MouseEnter, mouseEnter);
        fChart.getDisplay().removeFilter(SWT.MouseExit, mouseExit);
    });
    fChart.addControlListener(new ResizeEvent());
}
 
Example 19
Source File: LayerSideControls.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
private void fillCameraParameters(final ParameterExpandBar viewer, final LayeredDisplayView view) {
	final Composite contents = createContentsComposite(viewer);
	final IDisplaySurface ds = view.getDisplaySurface();
	final IScope scope = ds.getScope();
	final LayeredDisplayData data = ds.getData();

	EditorFactory.create(scope, contents, "FreeFly Camera", !data.isArcBallCamera(),
			(EditorListener<Boolean>) val -> {
				ds.runAndUpdate(() -> {
					data.setArcBallCamera(!val);
				});

			});
	final boolean cameraLocked = data.cameraInteractionDisabled();
	EditorFactory.create(scope, contents, "Lock camera:", cameraLocked, (EditorListener<Boolean>) newValue -> {
		preset.setActive(!newValue);
		cameraPos.setActive(!newValue);
		cameraTarget.setActive(!newValue);
		cameraUp.setActive(!newValue);
		zoom.setActive(!newValue);
		data.disableCameraInteractions(newValue);
	});

	preset = EditorFactory.choose(scope, contents, "Preset camera:", "Choose...", true, view.getCameraNames(),
			(EditorListener<String>) newValue -> {
				if (newValue.isEmpty()) { return; }
				data.setPresetCamera(newValue);
				ds.updateDisplay(true);
			});

	cameraPos = EditorFactory.create(scope, contents, "Position:", data.getCameraPos(),
			(EditorListener<ILocation>) newValue -> {
				data.setCameraPos((GamaPoint) newValue);
				ds.updateDisplay(true);
			});
	cameraTarget = EditorFactory.create(scope, contents, "Target:", data.getCameraLookPos(),
			(EditorListener<ILocation>) newValue -> {
				data.setCameraLookPos((GamaPoint) newValue);
				ds.updateDisplay(true);
			});
	cameraUp = EditorFactory.create(scope, contents, "Orientation:", data.getCameraUpVector(),
			(EditorListener<ILocation>) newValue -> {
				data.setCameraUpVector((GamaPoint) newValue);
				ds.updateDisplay(true);
			});
	preset.setActive(!cameraLocked);
	cameraPos.setActive(!cameraLocked);
	cameraTarget.setActive(!cameraLocked);
	cameraUp.setActive(!cameraLocked);
	zoom.setActive(!cameraLocked);
	data.addListener((p, v) -> {
		switch (p) {
			case CAMERA_POS:
				cameraPos.getParam().setValue(scope, data.getCameraPos());
				cameraPos.forceUpdateValueAsynchronously();
				copyCameraAndKeystoneDefinition(scope, data);
				break;
			case CAMERA_TARGET:
				cameraTarget.getParam().setValue(scope, data.getCameraLookPos());
				cameraTarget.forceUpdateValueAsynchronously();
				copyCameraAndKeystoneDefinition(scope, data);
				break;
			case CAMERA_UP:
				cameraUp.getParam().setValue(scope, data.getCameraUpVector());
				cameraUp.forceUpdateValueAsynchronously();
				copyCameraAndKeystoneDefinition(scope, data);
				break;
			case CAMERA_PRESET:
				preset.getParam().setValue(scope, "Choose...");
				preset.forceUpdateValueAsynchronously();
				copyCameraAndKeystoneDefinition(scope, data);
				break;

			default:
				;
		}
	});
	final Label l = new Label(contents, SWT.None);
	l.setText("");
	final Button copy = new Button(contents, SWT.PUSH);
	copy.setText("Copy as facets");
	copy.setLayoutData(new GridData(SWT.END, SWT.FILL, false, false));
	copy.setToolTipText(
			"Copy the definition of the camera properties to the clipboard in a format suitable for pasting them in the definition of a display in GAML");
	copy.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(final SelectionEvent e) {
			final String text = cameraDefinitionToCopy();
			WorkbenchHelper.copy(text);
		}

	});
	createItem(viewer, "Camera", null, contents);

}
 
Example 20
Source File: OptionsDesign.java    From ldparteditor with MIT License 4 votes vote down vote up
private void registerColour(TreeItem parent, String description, ColourType type, Object[] colourObj) {
    TreeItem trtm_newKey = new TreeItem(parent, SWT.PUSH);
    trtm_newKey.setText(new String[] { description, "" }); //$NON-NLS-1$
    trtm_newKey.setVisible(true);
    trtm_newKey.setData(new Object[]{type, colourObj});
}