use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.
the class BusinessRulersAndGridComposite method initializeControls.
/**
*
* Sets up controls with proper layouts and groups
*
* @param parent
*/
private void initializeControls(Composite parent) {
parent.setLayout(new GridLayout(1, false));
// Top row composite
Composite topComposite = widgetFactory.createComposite(parent);
topComposite.setLayout(new GridLayout(2, false));
// Create the groups for this section
createDisplayGroup(topComposite);
createMeasurementGroup(topComposite);
// Bottom row composite
Composite bottomComposite = widgetFactory.createComposite(parent);
bottomComposite.setLayout(new GridLayout(2, false));
// Create grid line settings
createGridlineGroup(bottomComposite);
Composite extraComposite = widgetFactory.createComposite(bottomComposite);
extraComposite.setLayout(new GridLayout(1, false));
// Create snap to grid checkbox
snapToGridButton = widgetFactory.createButton(extraComposite, SNAP_TO_GRID_LABEL, SWT.CHECK);
snapToGridButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
// Set the snap to grid workspace property
setWorkspaceProperty(WorkspaceViewerProperties.SNAPTOGRID, snapToGridButton.getSelection());
}
});
// Create snap to geometry checkbox
snapToGeometryButton = widgetFactory.createButton(extraComposite, SNAP_TO_GEOMETRY_LABEL, SWT.CHECK);
snapToGeometryButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
// Set the snap to geometry workspace property
setWorkspaceProperty(WorkspaceViewerProperties.SNAPTOGEOMETRY, snapToGeometryButton.getSelection());
}
});
// Create restore to preferences defaults
restoreButton = widgetFactory.createButton(extraComposite, RESTORE_LABEL, SWT.PUSH);
restoreButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
restorePreferenceValues();
}
private void restorePreferenceValues() {
IPreferenceStore preferenceStore = getPreferenceStore();
// The workspace properties will always exist because it is set
//
IPreferenceStore wsPrefStore = getWorkspaceViewerProperties();
if (wsPrefStore.getBoolean(WorkspaceViewerProperties.GRIDORDER) == false) {
wsPrefStore.setValue(WorkspaceViewerProperties.GRIDORDER, true);
}
if (wsPrefStore.getInt(WorkspaceViewerProperties.GRIDLINECOLOR) != LIGHT_GRAY_RGB) {
wsPrefStore.setValue(WorkspaceViewerProperties.GRIDLINECOLOR, LIGHT_GRAY_RGB);
}
if (wsPrefStore.getInt(WorkspaceViewerProperties.GRIDLINESTYLE) != SWT.LINE_CUSTOM) {
wsPrefStore.setValue(WorkspaceViewerProperties.GRIDLINESTYLE, SWT.LINE_CUSTOM);
}
if (wsPrefStore.getBoolean(WorkspaceViewerProperties.VIEWRULERS) != preferenceStore.getBoolean(IPreferenceConstants.PREF_SHOW_RULERS)) {
wsPrefStore.setValue(WorkspaceViewerProperties.VIEWRULERS, preferenceStore.getBoolean(IPreferenceConstants.PREF_SHOW_RULERS));
}
if (wsPrefStore.getBoolean(WorkspaceViewerProperties.VIEWGRID) != preferenceStore.getBoolean(IPreferenceConstants.PREF_SHOW_GRID)) {
wsPrefStore.setValue(WorkspaceViewerProperties.VIEWGRID, preferenceStore.getBoolean(IPreferenceConstants.PREF_SHOW_GRID));
}
if (wsPrefStore.getBoolean(WorkspaceViewerProperties.SNAPTOGRID) != preferenceStore.getBoolean(IPreferenceConstants.PREF_SNAP_TO_GRID)) {
wsPrefStore.setValue(WorkspaceViewerProperties.SNAPTOGRID, preferenceStore.getBoolean(IPreferenceConstants.PREF_SNAP_TO_GRID));
}
if (wsPrefStore.getBoolean(WorkspaceViewerProperties.SNAPTOGEOMETRY) != preferenceStore.getBoolean(IPreferenceConstants.PREF_SNAP_TO_GEOMETRY)) {
wsPrefStore.setValue(WorkspaceViewerProperties.SNAPTOGEOMETRY, preferenceStore.getBoolean(IPreferenceConstants.PREF_SNAP_TO_GEOMETRY));
}
if ((wsPrefStore.getInt(WorkspaceViewerProperties.RULERUNIT) != preferenceStore.getInt(IPreferenceConstants.PREF_RULER_UNITS)) || (wsPrefStore.getDouble(WorkspaceViewerProperties.GRIDSPACING) != preferenceStore.getDouble(IPreferenceConstants.PREF_GRID_SPACING))) {
wsPrefStore.setValue(WorkspaceViewerProperties.RULERUNIT, preferenceStore.getInt(IPreferenceConstants.PREF_RULER_UNITS));
wsPrefStore.setValue(WorkspaceViewerProperties.GRIDSPACING, preferenceStore.getDouble(IPreferenceConstants.PREF_GRID_SPACING));
}
// reset the input values
setInput();
}
});
setInput();
}
use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.
the class BusinessRulersAndGridComposite method createMeasurementGroup.
/**
* Creates group with ruler units and grid spacing controls
*
* @param composite
*/
private void createMeasurementGroup(Composite composite) {
measurementGroup = widgetFactory.createGroup(composite, MEASUREMENT_LABEL);
measurementGroup.setLayout(new GridLayout(2, false));
// Create ruler unit combo
widgetFactory.createLabel(measurementGroup, RULER_UNITS_LABEL);
rulerUnitCombo = widgetFactory.createCCombo(measurementGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
rulerUnitCombo.setItems(getUnits());
rulerUnitCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
int oldUnits = getWorkspacePropertyInt(WorkspaceViewerProperties.RULERUNIT);
int newUnits = rulerUnitCombo.getSelectionIndex();
// interim point with a 1 pixel grid spacing
if (oldUnits < newUnits) {
updateSpacing(oldUnits, newUnits);
updateRulerUnits();
} else {
updateRulerUnits();
updateSpacing(oldUnits, newUnits);
}
}
private void updateSpacing(int fromUnits, int toUnits) {
String currentUnits = convertUnits(fromUnits, toUnits);
setWorkspaceProperty(WorkspaceViewerProperties.GRIDSPACING, convertStringToDouble(currentUnits).doubleValue());
}
private void updateRulerUnits() {
int units = getCurrentRulerUnit();
setWorkspaceProperty(WorkspaceViewerProperties.RULERUNIT, units);
}
});
// Create grid spacing text field
widgetFactory.createLabel(measurementGroup, GRID_SPACING_LABEL);
textWidget = widgetFactory.createText(measurementGroup, StringStatics.BLANK, SWT.BORDER);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
textWidget.setLayoutData(data);
startTextWidgetEventListener();
}
use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.
the class ProjectSelectionDialog method createDialogArea.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
protected Control createDialogArea(final Composite parent) {
Composite loginComposite = new Composite(parent, SWT.NONE);
loginComposite.setLayout(new GridLayout(9, false));
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = 350;
loginComposite.setLayoutData(data);
Label label = new Label(loginComposite, SWT.None);
GridData gridData = new GridData();
gridData.horizontalSpan = 2;
label.setLayoutData(gridData);
//$NON-NLS-1$
label.setText(Messages.getString("ProjectSelectionDialog.ComponentProject"));
directoryText = new Text(loginComposite, SWT.BORDER);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 6;
directoryText.setLayoutData(gridData);
Button browserButton = new Button(loginComposite, SWT.None);
gridData = new GridData();
gridData.horizontalSpan = 1;
browserButton.setLayoutData(gridData);
browserButton.setText(PluginConstant.BROWSER_LABEL);
browserButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
directoryText.setText(getPathFromDialog());
}
});
//$NON-NLS-1$
this.setTitle(Messages.getString("ProjectSelectionDialog.ChooseFolder"));
return loginComposite;
}
use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.
the class UseResourceAction method setButton.
/**
* Sets the button that invokes this action.
*/
public void setButton(Button button) {
fButton = button;
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
run();
}
});
// fButton.setEnabled(false);
}
use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.
the class ImportComponentDialog method createDialogArea.
/*
* (non-Javadoc) Method declared on Dialog.
*/
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
GridLayout gl = new GridLayout(5, true);
composite.setLayout(gl);
if (message != null) {
Label label = new Label(composite, SWT.WRAP);
label.setText(message);
GridData data = new GridData(GridData.GRAB_HORIZONTAL);
data.horizontalSpan = 5;
label.setLayoutData(data);
label.setFont(parent.getFont());
}
Label label1 = new Label(composite, SWT.NONE);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
gd.horizontalSpan = 2;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.SelectDirectoryLabel"));
text = new Text(composite, SWT.BORDER);
text.setEditable(false);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
text.setLayoutData(gd);
if (paletteComponentsPath == null) {
//$NON-NLS-1$
paletteComponentsPath = "";
}
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateInput(true);
}
});
Button button = new Button(composite, SWT.NONE);
//$NON-NLS-1$
button.setText(Messages.getString("ImportComponentDialog.Browser"));
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 1;
button.setLayoutData(gd);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dd = new DirectoryDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
String path = dd.open();
if (path != null) {
text.setText(path);
}
}
});
Button showPaletteComponents = new Button(composite, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 2;
showPaletteComponents.setLayoutData(gd);
//$NON-NLS-1$
showPaletteComponents.setText(Messages.getString("ImportComponentDialog.ShowPaletteComponents"));
showPaletteComponents.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
text.setText(paletteComponentsPath);
}
});
label1 = new Label(composite, SWT.LEFT);
gd = new GridData();
gd.horizontalSpan = 1;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.Filter"));
filterText = new Text(composite, SWT.BORDER);
filterText.setEditable(true);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
filterText.setLayoutData(gd);
filterText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateInput(false);
}
});
label1 = new Label(composite, SWT.LEFT);
gd = new GridData();
gd.horizontalSpan = 5;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.ChooseComponentsLabel"));
componentList = new List(composite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 5;
componentList.setLayoutData(gd);
componentList.addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
validateSelected();
}
public void mouseUp(MouseEvent e) {
validateSelected();
}
});
errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.CENTER);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 5;
label1.setLayoutData(gd);
errorMessageText.setLayoutData(gd);
errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
applyDialogFont(composite);
//$NON-NLS-1$
text.setText("");
return composite;
}
Aggregations