Java Code Examples for org.eclipse.swt.widgets.Button#addSelectionListener()

The following examples show how to use org.eclipse.swt.widgets.Button#addSelectionListener() . 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: XYGraphConfigDialog.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
	((GridLayout) parent.getLayout()).numColumns++;
	Button button = new Button(parent, SWT.PUSH);
	button.setText("Apply");
	GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
	Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
	data.widthHint = Math.max(widthHint, minSize.x);
	button.setLayoutData(data);
	button.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			applyChanges();
		}
	});
	super.createButtonsForButtonBar(parent);
	Shell shell = parent.getShell();
	if (shell != null) {
		shell.setDefaultButton(button);
	}
}
 
Example 2
Source File: DataQualityShell.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void createButtons(Composite parent) {
	Composite composite = toolkit.createComposite(parent);
	UI.gridLayout(composite, 3);
	GridData gd = UI.gridData(composite, true, false);
	gd.horizontalAlignment = SWT.END;
	toolkit.paintBordersFor(composite);
	Button okBtn = toolkit.createButton(composite, M.OK, SWT.NONE);
	UI.gridData(okBtn, false, false).widthHint = 60;
	okBtn.addSelectionListener(new DataQualityFinishHandler(this, (s) -> onOk.accept(s)));
	if (dqEntry != null) {
		Button deleteBtn = toolkit.createButton(composite, M.Delete, SWT.NONE);
		UI.gridData(deleteBtn, false, false).widthHint = 60;
		deleteBtn.addSelectionListener(new DataQualityFinishHandler(this, (s) -> onDelete.accept(s)));
	}
	Button cancelBtn = toolkit.createButton(composite, M.Cancel, SWT.NONE);
	cancelBtn.addSelectionListener(new DataQualityFinishHandler(this, null));
	UI.gridData(cancelBtn, false, false).widthHint = 60;
}
 
Example 3
Source File: ContractPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private Button createGenerateButton(final Composite buttonsComposite) {
    final Button generateButton = createButton(buttonsComposite, Messages.generate);
    generateButton.setToolTipText(Messages.warningAddFromData_noDataAvailable);
    generateButton.addSelectionListener(new SelectionAdapter() {

        /*
         * (non-Javadoc)
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(final SelectionEvent e) {
            openAddInputWizardDialog();
        }
    });
    return generateButton;
}
 
Example 4
Source File: MarkerIconDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void switchToEmbeddedType( )
{
	Composite buttonBar = new Composite( inputArea, SWT.NONE );

	GridLayout gl = new GridLayout( );
	gl.marginWidth = 0;
	gl.marginHeight = 0;
	buttonBar.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	buttonBar.setLayout( gl );

	Label description = new Label( buttonBar, SWT.NONE );
	description.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING ) );
	description.setText( Messages.getString( "MarkerIconDialog.Label.Description.EmbeddedImage" ) ); //$NON-NLS-1$

	btnBrowse = new Button( buttonBar, SWT.PUSH );
	btnBrowse.setText( Messages.getString( "MarkerIconDialog.Lbl.Browse" ) ); //$NON-NLS-1$
	GridData gd = new GridData( GridData.HORIZONTAL_ALIGN_END );
	gd.grabExcessHorizontalSpace = true;
	btnBrowse.setLayoutData( gd );
	btnBrowse.addSelectionListener( this );
}
 
Example 5
Source File: SeriesYSheetImpl.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void createDifferenceSeriesButton( Composite cmp )
{
	ITaskPopupSheet popup;

	// Markers for Difference series
	popup = new LineSeriesMarkerSheet( Messages.getString( "SeriesYSheetImpl.Label.PositiveMarkers" ), //$NON-NLS-1$
			getContext( ),
			(DifferenceSeries) getCurrentDesignTimeSeries( ),
			true );
	Button btnPLineMarker = createToggleButton( cmp,
			BUTTON_POSITIVE_MARKERS,
			Messages.getString( "SeriesYSheetImpl.Label.PositiveMarkers&" ), //$NON-NLS-1$
			popup );
	btnPLineMarker.addSelectionListener( this );

	popup = new LineSeriesMarkerSheet( Messages.getString( "SeriesYSheetImpl.Label.NegativeMarkers" ), //$NON-NLS-1$
			getContext( ),
			(DifferenceSeries) getCurrentDesignTimeSeries( ),
			false );
	Button btnNLineMarker = createToggleButton( cmp,
			BUTTON_NEGATIVE_MARKERS,
			Messages.getString( "SeriesYSheetImpl.Label.NegativeMarkers&" ), //$NON-NLS-1$
			popup );
	btnNLineMarker.addSelectionListener( this );
}
 
Example 6
Source File: BasicFilterEditorControl.java    From depan with Apache License 2.0 6 votes vote down vote up
@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();
    }
  });
}
 
Example 7
Source File: ConversionWizardPage.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 创建分段规则选择组
 * @param contents
 *            ;
 */
private void createSegmentationGroup(Composite contents) {
	Group segmentation = new Group(contents, SWT.NONE);
	segmentation.setText(Messages.getString("ConversionWizardPage.10")); //$NON-NLS-1$
	segmentation.setLayout(new GridLayout(3, false));
	GridData data = new GridData(GridData.FILL_HORIZONTAL);
	data.widthHint = 500;
	segmentation.setLayoutData(data);

	Label segLabel = new Label(segmentation, SWT.NONE);
	segLabel.setText(Messages.getString("ConversionWizardPage.11")); //$NON-NLS-1$

	srxFile = new Text(segmentation, SWT.BORDER | SWT.READ_ONLY);
	srxFile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	srxFile.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent e) {
			for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
				conversionConfigBean.setInitSegmenter(srxFile.getText());
			}

			validate();
		}
	});

	final Button segBrowse = new Button(segmentation, SWT.PUSH);
	segBrowse.setText(Messages.getString("ConversionWizardPage.12")); //$NON-NLS-1$
	segBrowse.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent arg0) {
			IConversionItemDialog conversionItemDialog = FileDialogFactoryFacade.createFileDialog(getShell(),
					SWT.NONE);
			int result = conversionItemDialog.open();
			if (result == IDialogConstants.OK_ID) {
				IConversionItem conversionItem = conversionItemDialog.getConversionItem();
				srxFile.setText(conversionItem.getLocation().toOSString());
			}
		}
	});
}
 
Example 8
Source File: ConversionWizardPage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 创建分段规则选择组
 * @param contents
 *            ;
 */
private void createSegmentationGroup(Composite contents) {
	Group segmentation = new Group(contents, SWT.NONE);
	segmentation.setText(Messages.getString("ConversionWizardPage.10")); //$NON-NLS-1$
	segmentation.setLayout(new GridLayout(3, false));
	GridData data = new GridData(GridData.FILL_HORIZONTAL);
	data.widthHint = 500;
	segmentation.setLayoutData(data);

	Label segLabel = new Label(segmentation, SWT.NONE);
	segLabel.setText(Messages.getString("ConversionWizardPage.11")); //$NON-NLS-1$

	srxFile = new Text(segmentation, SWT.BORDER | SWT.READ_ONLY);
	srxFile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	srxFile.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent e) {
			for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
				conversionConfigBean.setInitSegmenter(srxFile.getText());
			}

			validate();
		}
	});

	final Button segBrowse = new Button(segmentation, SWT.PUSH);
	segBrowse.setText(Messages.getString("ConversionWizardPage.12")); //$NON-NLS-1$
	segBrowse.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent arg0) {
			IConversionItemDialog conversionItemDialog = FileDialogFactoryFacade.createFileDialog(getShell(),
					SWT.NONE);
			int result = conversionItemDialog.open();
			if (result == IDialogConstants.OK_ID) {
				IConversionItem conversionItem = conversionItemDialog.getConversionItem();
				srxFile.setText(conversionItem.getLocation().toOSString());
			}
		}
	});
}
 
Example 9
Source File: DataWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createTypeChooser(final Composite parent) {
    final Label typeLabel = new Label(parent, SWT.NONE);
    typeLabel.setText(Messages.datatypeLabel);
    typeLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());

    typeCombo = new ComboViewer(parent, SWT.BORDER | SWT.READ_ONLY);
    typeCombo.setContentProvider(new ArrayContentProvider());
    typeCombo.setLabelProvider(new DataTypeLabelProvider());
    typeCombo.addFilter(typeViewerFilter);
    typeCombo.setSorter(new ViewerSorter());
    typeCombo.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(10, 0).create());

    typeDescriptionDecorator = new ControlDecoration(typeCombo.getCombo(), SWT.LEFT);
    typeDescriptionDecorator.setImage(Pics.getImage(PicsConstants.hint));

    if (allowEnum) {
        final Button createOptionButton = new Button(parent, SWT.PUSH);
        createOptionButton.setText(Messages.listOfOptions);
        createOptionButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent e) {
                final EnumDataTypeDialog dialog = new EnumDataTypeDialog(Display.getDefault().getActiveShell(),
                        ModelHelper.getMainProcess(container));
                if (dialog.open() == Window.OK) {
                    final EnumType type = dialog.getSelectedEnum();
                    updateDatabinding();
                    typeCombo.setSelection(new StructuredSelection(type));
                }
            }
        });
    } else {
        typeCombo.getCombo()
                .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).indent(10, 0).create());
    }
}
 
Example 10
Source File: WizardFolderImportPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private Button createButton(String text, Composite parent)
{
	Button button = new Button(parent, SWT.PUSH);
	button.setText(text);
	button.setLayoutData(GridDataFactory.fillDefaults().create());
	button.addSelectionListener(this);
	return button;
}
 
Example 11
Source File: MarkerIconDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void swtichToURIType( )
{
	Label title = new Label( inputArea, SWT.NONE );
	title.setLayoutData( new GridData( GridData.VERTICAL_ALIGN_BEGINNING ) );
	title.setText( Messages.getString( "MarkerIconDialog.Lbl.EnterURL" ) ); //$NON-NLS-1$

	uriEditor = new Text( inputArea, SWT.SINGLE | SWT.BORDER );
	uriEditor.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	uriEditor.addModifyListener( this );

	Composite innerComp = new Composite( inputArea, SWT.NONE );
	innerComp.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_END ) );

	GridLayout gl = new GridLayout( 2, false );
	gl.marginWidth = 0;
	gl.marginHeight = 0;
	gl.verticalSpacing = 2;
	innerComp.setLayout( gl );
	
	btnPreview = new Button( innerComp, SWT.PUSH );
	btnPreview.setText( Messages.getString( "MarkerIconDialog.Lbl.Preview" ) ); //$NON-NLS-1$
	btnPreview.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_END ) );
	btnPreview.setEnabled( false );
	btnPreview.addSelectionListener( this );

	if ( icon != null )
	{
		String url = ( (Image) icon ).getURL( );
		uriEditor.setText( url == null ? "" : url ); //$NON-NLS-1$
	}
}
 
Example 12
Source File: GitlabQueryPage.java    From mylyn-gitlab with Eclipse Public License 1.0 5 votes vote down vote up
private void createOptionsArea(Composite parent) {
	Composite optionsArea = new Composite(parent, SWT.NONE);
	GridLayoutFactory.fillDefaults().numColumns(2).applyTo(optionsArea);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(optionsArea);

	Composite statusArea = new Composite(optionsArea, SWT.NONE);
	GridLayoutFactory.fillDefaults().numColumns(4).equalWidth(false).applyTo(statusArea);
	GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(statusArea);

	new Label(statusArea, SWT.NONE).setText(Strings.QUERY_STATE);

	openButton = new Button(statusArea, SWT.CHECK);
	openButton.setSelection(true);
	openButton.setText(GitlabIssue.STATE_OPENED);
	openButton.addSelectionListener(completeListener);

	closedButton = new Button(statusArea, SWT.CHECK);
	closedButton.setSelection(true);
	closedButton.setText(GitlabIssue.STATE_CLOSED);
	closedButton.addSelectionListener(completeListener);

	Label milestonesLabel = new Label(optionsArea, SWT.NONE);
	milestonesLabel.setText(Strings.QUERY_MILESTONE);

	milestoneCombo = new Combo(optionsArea, SWT.DROP_DOWN | SWT.READ_ONLY);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(milestoneCombo);
	GitlabConnection connection = ConnectionManager.getSafe(getTaskRepository());
	if(connection != null) {
		milestoneCombo.add("");
		for(GitlabMilestone s : connection.getMilestones()) {
			milestoneCombo.add(s.getTitle());
		}
	}

	Label assigneeLabel = new Label(optionsArea, SWT.NONE);
	assigneeLabel.setText(Strings.QUERY_ASSIGNEE);

	assigneeText = new Text(optionsArea, SWT.BORDER | SWT.SINGLE);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(assigneeText);
}
 
Example 13
Source File: JFaceTooltipExample.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	Display d = new Display();
	Shell shell = new Shell(d);
	shell.setLayout(new FillLayout(SWT.VERTICAL));
	shell.setSize(400, 400);
	Button button = new Button(shell, SWT.PUSH);
	button.setText("Reload");
	button.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent e) {
			viewer.setInput(null);
			viewer.setInput(new Object());
		}
	});

	viewer = new ZestContentViewer(new ZestFxJFaceModule());
	viewer.createControl(shell, SWT.NONE);
	viewer.setContentProvider(new MyContentProvider());
	viewer.setLabelProvider(new MyLabelProvider());
	viewer.setLayoutAlgorithm(new SpringLayoutAlgorithm());
	viewer.addSelectionChangedListener(new ISelectionChangedListener() {
		public void selectionChanged(SelectionChangedEvent event) {
			System.out.println(
					"Selection changed: " + (event.getSelection()));
		}
	});
	viewer.setInput(new Object());

	shell.open();
	while (!shell.isDisposed()) {
		while (!d.readAndDispatch()) {
			d.sleep();
		}
	}
}
 
Example 14
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 15
Source File: PrintDialogExample.java    From http4e with Apache License 2.0 4 votes vote down vote up
PrintDialogExample() {
  d = new Display();
  s = new Shell(d);
  s.setSize(400, 400);
  
  s.setText("A PrintDialog Example");
  s.setLayout(new FillLayout(SWT.VERTICAL));
  final Text t = new Text(s, SWT.BORDER | SWT.MULTI);
  final Button b = new Button(s, SWT.PUSH | SWT.BORDER);
  b.setText("Print");
  b.addSelectionListener(new SelectionAdapter() {
    public void widgetSelected(SelectionEvent e) {
      PrintDialog printDialog = new PrintDialog(s, SWT.NONE);
      printDialog.setText("Print");
      PrinterData printerData = printDialog.open();
      if (!(printerData == null)) {
        Printer p = new Printer(printerData);
        p.startJob("PrintJob");
        p.startPage();
        Rectangle trim = p.computeTrim(0, 0, 0, 0);
        Point dpi = p.getDPI();
        int leftMargin = dpi.x + trim.x;
        int topMargin = dpi.y / 2 + trim.y;
        GC gc = new GC(p);
        Font font = gc.getFont();
        String printText = t.getText();
        Point extent = gc.stringExtent(printText);
        gc.drawString(printText, leftMargin, topMargin
            + font.getFontData()[0].getHeight());
        p.endPage();
        gc.dispose();
        p.endJob();
        p.dispose();
      }
    }
  });
  s.open();

  while (!s.isDisposed()) {
    if (!d.readAndDispatch())
      d.sleep();
  }
  d.dispose();
}
 
Example 16
Source File: ImportClonesWizardPage.java    From JDeodorant with MIT License 4 votes vote down vote up
public void createControl(Composite parent) {
	Composite resultComposite = new Composite(parent, SWT.NONE);
	setControl(resultComposite);
	GridLayout layout = new GridLayout(2, false);
	resultComposite.setLayout(layout);

	Group cloneInputGroup = new Group(resultComposite, SWT.SHADOW_ETCHED_IN);
	cloneInputGroup.setText("Select clone detection tool");
	GridLayoutFactory.fillDefaults().applyTo(cloneInputGroup);
	GridDataFactory.fillDefaults().grab(false, true).applyTo(cloneInputGroup);
	GridLayout grid = new GridLayout();
	grid.marginLeft = 2;
	grid.marginTop = 2;
	cloneInputGroup.setLayout(grid);
	
	Group fileInputGroup = new Group(resultComposite, SWT.SHADOW_ETCHED_IN);
	fileInputGroup.setText("Select input files");
	
	final Composite composite = new Composite(fileInputGroup, SWT.NONE);
	GridData gridData = new GridData();
	gridData.horizontalAlignment = GridData.FILL;
	gridData.grabExcessHorizontalSpace = true;
	composite.setLayoutData(gridData);
	composite.setLayout(new GridLayout(2, false));
	
	for (final CloneDetectorType type : CloneDetectorType.values()) {
		final Button button = new Button(cloneInputGroup, SWT.RADIO);
		button.setText(type.toString());
		button.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent event) {
				if (((Button)event.getSource()).getSelection()) {
					if (selectedCloneDetectorType == null || selectedCloneDetectorType != type) {
						selectedCloneDetectorType = type;
						initializeBasicFileInput(composite);
						//secondary directory input - only for CCFinder
						initializeSecondaryFileInput(composite);
					}
				} else {
					for (Control control : composite.getChildren()) {
						control.dispose();
					}
				}
			}
		});
	}
	
	GridLayoutFactory.fillDefaults().applyTo(fileInputGroup);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(fileInputGroup);
}
 
Example 17
Source File: BaseTransformDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
public static final void positionBottomButtons( Composite composite, Button[] buttons, int margin, int alignment,
                                                Control lastControl ) {
  // Determine the largest button in the array
  Rectangle largest = null;
  for ( int i = 0; i < buttons.length; i++ ) {
    buttons[ i ].pack( true );
    Rectangle r = buttons[ i ].getBounds();
    if ( largest == null || r.width > largest.width ) {
      largest = r;
    }

    // Also, set the tooltip the same as the name if we don't have one...
    if ( buttons[ i ].getToolTipText() == null ) {
      buttons[ i ].setToolTipText( Const.replace( buttons[ i ].getText(), "&", "" ) );
    }
  }

  // Make buttons a bit larger... (nicer)
  largest.width += 10;
  if ( ( largest.width % 2 ) == 1 ) {
    largest.width++;
  }

  // Compute the left side of the 1st button
  switch ( alignment ) {
    case BUTTON_ALIGNMENT_CENTER:
      centerButtons( buttons, largest.width, margin, lastControl );
      break;
    case BUTTON_ALIGNMENT_LEFT:
      leftAlignButtons( buttons, largest.width, margin, lastControl );
      break;
    case BUTTON_ALIGNMENT_RIGHT:
      rightAlignButtons( buttons, largest.width, margin, lastControl );
      break;
    default:
      break;
  }
  if ( Const.isOSX() ) {
    Shell parentShell = composite.getShell();
    final List<TableView> tableViews = new ArrayList<TableView>();
    getTableViews( parentShell, tableViews );
    for ( final Button button : buttons ) {
      // We know the table views
      // We also know that if a button is hit, the table loses focus
      // In that case, we can apply the content of an open text editor...
      //
      button.addSelectionListener( new SelectionAdapter() {

        public void widgetSelected( SelectionEvent e ) {
          for ( TableView view : tableViews ) {
            view.applyOSXChanges();
          }
        }
      } );
    }
  }
}
 
Example 18
Source File: IOSSimOptionsTab.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @wbp.parser.entryPoint
 */
@Override
public void createControl(Composite parent) {
	Composite comp = new Composite(parent, SWT.NONE);
	setControl(comp);
	comp.setLayout(new GridLayout(1, false));
	
	Group grpProject = new Group(comp, SWT.NONE);
	grpProject.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	grpProject.setText("Project");
	grpProject.setLayout(new GridLayout(3, false));
	
	Label lblProject = new Label(grpProject, SWT.NONE);
	lblProject.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	lblProject.setText("Project:");
	
	textProject = new Text(grpProject, SWT.BORDER);
	textProject.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	textProject.addListener(SWT.Modify, dirtyFlagListener);
	
	
	Button btnProjectBrowse = new Button(grpProject, SWT.NONE);
	btnProjectBrowse.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			ElementListSelectionDialog es = new ElementListSelectionDialog(getShell(), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
			es.setElements(HybridCore.getHybridProjects().toArray());
			es.setTitle("Project Selection");
			es.setMessage("Select a project to run");
			if (es.open() == Window.OK) {			
				HybridProject project = (HybridProject) es.getFirstResult();
				textProject.setText(project.getProject().getName());
			}		
		}
	});
	btnProjectBrowse.setText("Browse...");
	
	Group grpSimulator = new Group(comp, SWT.NONE);
	grpSimulator.setLayout(new GridLayout(2, false));
	grpSimulator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	grpSimulator.setText("Simulator");
	
	Label lblSdkVersion = new Label(grpSimulator, SWT.NONE);
	lblSdkVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	lblSdkVersion.setText("Device:");
	
	comboSDKVer = new Combo(grpSimulator, SWT.READ_ONLY);
	
	comboSDKVer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	comboSDKVer.addListener(SWT.Selection, dirtyFlagListener);

	comboViewer = new ComboViewer(comboSDKVer);
	comboViewer.setContentProvider(new SDKContentProvider());
	comboViewer.setLabelProvider( new LabelProvider() {
		@Override
		public String getText(Object element) {
			IOSDevice device = (IOSDevice) element;
			return NLS.bind("{0} ({1})", new String[]{device.getDeviceName(), device.getiOSName()});
		}
	});
	comboViewer.setInput(getSimulatorDevices());
}
 
Example 19
Source File: ChartLegendSheetImpl.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected void createButtonGroup( Composite parent )
{
	Composite cmp = new Composite( parent, SWT.NONE );
	{
		cmp.setLayout( new GridLayout( 5, false ) );
		GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
		gridData.horizontalSpan = 2;
		gridData.grabExcessVerticalSpace = true;
		gridData.verticalAlignment = SWT.END;
		cmp.setLayoutData( gridData );
	}

	// Title
	ITaskPopupSheet popup = new LegendTitleSheet( Messages.getString( "ChartLegendSheetImpl.Title.LegendTitle" ),//$NON-NLS-1$
			getContext( ) );
	Button btnLegendTitle = createToggleButton( cmp,
			BUTTON_TITLE,
			Messages.getString( "ChartLegendSheetImpl.Label.LegendTitle&" ),//$NON-NLS-1$
			popup,
			getTitleVisibleSelection( ) );
	btnLegendTitle.addSelectionListener( this );

	// Layout
	popup = new LegendLayoutSheet( Messages.getString( "ChartLegendSheetImpl.Title.LegendLayout" ), getContext( ) ); //$NON-NLS-1$
	Button btnAreaProp = createToggleButton( cmp,
			BUTTON_LAYOUT,
			Messages.getString( "ChartLegendSheetImpl.Label.Layout" ), popup ); //$NON-NLS-1$
	btnAreaProp.addSelectionListener( this );

	// Entries
	createLegendEntriesUI( cmp );

	// Interactivity
	if ( getContext( ).isInteractivityEnabled( ) )
	{
		popup = new InteractivitySheet( Messages.getString( "ChartLegendSheetImpl.Label.Interactivity" ), //$NON-NLS-1$
				getContext( ),
				getChart( ).getLegend( ).getTriggers( ),
				getChart( ).getLegend( ),
				TriggerSupportMatrix.TYPE_LEGEND,
				TriggerDataComposite.ENABLE_URL_PARAMETERS
						| TriggerDataComposite.DISABLE_CATEGORY_SERIES
						| TriggerDataComposite.DISABLE_VALUE_SERIES
						| TriggerDataComposite.ENABLE_SHOW_TOOLTIP_VALUE );
		Button btnInteractivity = createToggleButton( cmp,
				BUTTON_INTERACTIVITY,
				Messages.getString( "SeriesYSheetImpl.Label.Interactivity&" ), //$NON-NLS-1$
				popup,
				getChart( ).getInteractivity( ).isEnable( ) );
		btnInteractivity.addSelectionListener( this );
	}
}
 
Example 20
Source File: TopicSelection.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void layoutUI() {
  FormLayout topicSelectionLayout = new FormLayout();
  this.setLayout( topicSelectionLayout );

  wTopicGroup = new Group( this, SWT.SHADOW_ETCHED_IN );
  props.setLook( wTopicGroup );
  wTopicGroup.setText( topicGroupLabel );

  FormLayout topicGroupLayout = new FormLayout();
  topicGroupLayout.marginHeight = 15;
  topicGroupLayout.marginWidth = 15;
  wTopicGroup.setLayout( topicGroupLayout );

  wTopicGroup.setLayoutData( new FormDataBuilder().top( 0, ConstUI.MEDUIM_MARGIN ).fullWidth().bottom().result() );

  wTopicFromText = new Button( wTopicGroup, SWT.RADIO );
  wTopicFromField = new Button( wTopicGroup, SWT.RADIO );
  props.setLook( wTopicFromText );
  props.setLook( wTopicFromField );

  SelectionAdapter selectionListener = new SelectionAdapter() {
    @Override
    public void widgetSelected( SelectionEvent selectionEvent ) {
      super.widgetSelected( selectionEvent );
      setTopicWidgetVisibility( wTopicFromField );
    }
  };

  wTopicFromField.addSelectionListener( selectionListener );
  wTopicFromText.addSelectionListener( selectionListener );

  wTopicFromField.setSelection( topicInField );
  wTopicFromText.setSelection( !topicInField );

  wTopicFromText.setText( textTopicRadioLabel );
  wTopicFromField.setText( fieldTopicRadioLabel );

  wTopicFromText.setLayoutData( new FormDataBuilder().left().top().result() );

  wTopicFromField.setLayoutData( new FormDataBuilder().left().top( wTopicFromText ).result() );
  wTopicFromField.addSelectionListener( selectionListener );
  wTopicFromText.addSelectionListener( selectionListener );

  Label separator = new Label( wTopicGroup, SWT.SEPARATOR | SWT.VERTICAL );
  separator.setLayoutData( new FormDataBuilder().top().left( wTopicFromField, 15 ).bottom().result() );

  wlTopic = new Label( wTopicGroup, SWT.LEFT );
  props.setLook( wlTopic );

  if ( displayTopicErrorIcon ) {
    //Connection Error Icon label
    wlTopic.setLayoutData( new FormDataBuilder().top().left( separator, 15 ).result() );

    wlConnectionError = new Label( wTopicGroup, SWT.LEFT );
    wlConnectionError.setToolTipText( fieldTopicErrorToolTip );
    wlConnectionError.setImage( SwtSvgImageUtil.getImage(
      this.getDisplay(), getClass().getClassLoader(), "error.svg", ConstUI.SMALL_ICON_SIZE,
      ConstUI.SMALL_ICON_SIZE ) );
    props.setLook( wlConnectionError );

    wlConnectionError.setLayoutData( new FormDataBuilder().top().left( wlTopic, MARGIN ).result() );
    wlConnectionError.setVisible( false );
  } else {
    wlTopic.setLayoutData( new FormDataBuilder().top().left( separator, 15 ).right().result() );
  }

  FormData fdTopic = new FormDataBuilder().top( wlTopic ).left( separator, 15 ).right().result();

  wTopicTextCombo = new ComboVar( transMeta, wTopicGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
  props.setLook( wTopicTextCombo );
  wTopicTextCombo.setLayoutData( fdTopic );
  wTopicTextCombo.addModifyListener( lsMod );

  wTopicText = new TextVar( transMeta, wTopicGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
  props.setLook( wTopicText );
  wTopicText.setLayoutData( fdTopic );
  wTopicText.addModifyListener( lsMod );

  wTopicField = createFieldDropDown( wTopicGroup, props, stepMeta, fdTopic );
  props.setLook( wTopicField );
  wTopicField.setLayoutData( fdTopic );
  setTopicWidgetVisibility( wTopicFromField );
  wTopicField.addModifyListener( lsMod );
}