use of org.eclipse.swt.widgets.Spinner in project portfolio by buchen.
the class SecurityTaxonomyPage method addSpinner.
private void addSpinner(Composite block, ClassificationLink link, List<IObservableValue> observables) {
final Spinner spinner = new Spinner(block, SWT.BORDER);
spinner.setDigits(2);
spinner.setMinimum(0);
spinner.setValues(link.getWeight(), 0, Classification.ONE_HUNDRED_PERCENT, 2, 100, 1000);
GridDataFactory.fillDefaults().applyTo(spinner);
observables.add(WidgetProperties.selection().observe(spinner));
}
use of org.eclipse.swt.widgets.Spinner in project portfolio by buchen.
the class SelectSplitPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
setControl(container);
container.setLayout(new FormLayout());
Label labelSecurity = new Label(container, SWT.NONE);
labelSecurity.setText(Messages.ColumnSecurity);
List<Security> securities = model.getClient().getActiveSecurities();
if (model.getSecurity() != null && !securities.contains(model.getSecurity()))
securities.add(0, model.getSecurity());
ComboViewer comboSecurity = new ComboViewer(container, SWT.READ_ONLY);
comboSecurity.setContentProvider(ArrayContentProvider.getInstance());
comboSecurity.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((Security) element).getName();
}
});
comboSecurity.setInput(securities);
Label labelExDate = new Label(container, SWT.NONE);
labelExDate.setText(Messages.ColumnExDate);
DatePicker boxExDate = new DatePicker(container);
Label labelSplit = new Label(container, SWT.NONE);
labelSplit.setText(Messages.SplitWizardLabelSplit);
Spinner spinnerNewShares = new Spinner(container, SWT.BORDER);
spinnerNewShares.setMinimum(1);
spinnerNewShares.setMaximum(1000000);
spinnerNewShares.setSelection(1);
spinnerNewShares.setIncrement(1);
spinnerNewShares.setFocus();
Label labelColon = new Label(container, SWT.NONE);
labelColon.setText(Messages.SplitWizardLabelNewForOld);
Spinner spinnerOldShares = new Spinner(container, SWT.BORDER);
spinnerOldShares.setMinimum(1);
spinnerOldShares.setMaximum(1000000);
spinnerOldShares.setSelection(1);
spinnerOldShares.setIncrement(1);
// form layout data
int labelWidth = widest(labelSecurity, labelExDate, labelSplit);
//
startingWith(comboSecurity.getControl(), labelSecurity).thenBelow(boxExDate.getControl()).label(//
labelExDate).thenBelow(spinnerNewShares).label(labelSplit).thenRight(labelColon).thenRight(spinnerOldShares);
startingWith(labelSecurity).width(labelWidth);
// model binding
DataBindingContext context = bindings.getBindingContext();
context.bindValue(ViewersObservables.observeSingleSelection(comboSecurity), BeanProperties.value("security").observe(model), null, // $NON-NLS-1$
null);
//
context.bindValue(//
new SimpleDateTimeDateSelectionProperty().observe(boxExDate.getControl()), // $NON-NLS-1$
BeanProperties.value("exDate").observe(model), //
new UpdateValueStrategy().setAfterConvertValidator(value -> {
return value != null ? ValidationStatus.ok() : ValidationStatus.error(MessageFormat.format(Messages.MsgDialogInputRequired, Messages.ColumnExDate));
}), null);
final ISWTObservableValue observeNewShares = WidgetProperties.selection().observe(spinnerNewShares);
// $NON-NLS-1$
context.bindValue(observeNewShares, BeanProperties.value("newShares").observe(model));
final ISWTObservableValue observeOldShares = WidgetProperties.selection().observe(spinnerOldShares);
// $NON-NLS-1$
context.bindValue(observeOldShares, BeanProperties.value("oldShares").observe(model));
MultiValidator validator = new MultiValidator() {
@Override
protected IStatus validate() {
Object newShares = observeNewShares.getValue();
Object oldShares = observeOldShares.getValue();
return newShares.equals(oldShares) ? ValidationStatus.error(Messages.SplitWizardErrorNewAndOldMustNotBeEqual) : ValidationStatus.ok();
}
};
context.addValidationStatusProvider(validator);
}
use of org.eclipse.swt.widgets.Spinner in project BiglyBT by BiglySoftware.
the class SBC_SearchResultsView method skinObjectInitialShow.
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
image_loader = new ImageLoader(null, null);
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
initColumns(core);
}
});
SWTSkinObjectTextbox soFilterBox = (SWTSkinObjectTextbox) getSkinObject("filterbox");
if (soFilterBox != null) {
txtFilter = soFilterBox.getTextControl();
}
if (vitality_images == null) {
ImageLoader loader = ImageLoader.getInstance();
vitality_images = loader.getImages("image.sidebar.vitality.dots");
ok_image = loader.getImage("tick_mark");
fail_image = loader.getImage("progress_cancel");
auth_image = loader.getImage("image.sidebar.vitality.auth");
}
final SWTSkinObject soFilterArea = getSkinObject("filterarea");
if (soFilterArea != null) {
SWTSkinObjectToggle soFilterButton = (SWTSkinObjectToggle) getSkinObject("filter-button");
if (soFilterButton != null) {
boolean toggled = COConfigurationManager.getBooleanParameter("Search View Filter Options Expanded", false);
if (toggled) {
soFilterButton.setToggled(true);
soFilterArea.setVisible(true);
}
soFilterButton.addSelectionListener(new SWTSkinToggleListener() {
@Override
public void toggleChanged(SWTSkinObjectToggle so, boolean toggled) {
COConfigurationManager.setParameter("Search View Filter Options Expanded", toggled);
soFilterArea.setVisible(toggled);
Utils.relayout(soFilterArea.getControl().getParent());
}
});
}
Composite parent = (Composite) soFilterArea.getControl();
Composite filter_area = new Composite(parent, SWT.NONE);
FormData fd = Utils.getFilledFormData();
filter_area.setLayoutData(fd);
GridLayout layout = new GridLayout();
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
filter_area.setLayout(layout);
Label label;
int sepHeight = 20;
Composite cRow = new Composite(filter_area, SWT.NONE);
cRow.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
rowLayout.spacing = 5;
rowLayout.marginBottom = rowLayout.marginTop = rowLayout.marginLeft = rowLayout.marginRight = 0;
rowLayout.center = true;
cRow.setLayout(rowLayout);
// with/without keywords
ImageLoader imageLoader = ImageLoader.getInstance();
for (int i = 0; i < 2; i++) {
final boolean with = i == 0;
if (!with) {
label = new Label(cRow, SWT.VERTICAL | SWT.SEPARATOR);
label.setLayoutData(new RowData(-1, sepHeight));
}
Composite cWithKW = new Composite(cRow, SWT.NONE);
layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
cWithKW.setLayout(layout);
// Label lblWithKW = new Label(cWithKW, SWT.NONE);
// lblWithKW.setText(MessageText.getString(with?"SubscriptionResults.filter.with.words":"SubscriptionResults.filter.without.words"));
Label lblWithKWImg = new Label(cWithKW, SWT.NONE);
lblWithKWImg.setImage(imageLoader.getImage(with ? "icon_filter_plus" : "icon_filter_minus"));
final Text textWidget = new Text(cWithKW, SWT.BORDER);
if (with) {
textWithKW = textWidget;
} else {
textWithoutKW = textWidget;
}
textWidget.setMessage(MessageText.getString(with ? "SubscriptionResults.filter.with.words" : "SubscriptionResults.filter.without.words"));
GridData gd = new GridData();
gd.widthHint = Utils.adjustPXForDPI(100);
textWidget.setLayoutData(gd);
textWidget.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String text = textWidget.getText().toLowerCase(Locale.US);
String[] bits = text.split("\\s+");
Set<String> temp = new HashSet<>();
for (String bit : bits) {
bit = bit.trim();
if (bit.length() > 0) {
temp.add(bit);
}
}
String[] words = temp.toArray(new String[temp.size()]);
synchronized (filter_lock) {
if (with) {
with_keywords = words;
} else {
without_keywords = words;
}
}
refilter_dispatcher.dispatch();
}
});
}
// min size
label = new Label(cRow, SWT.VERTICAL | SWT.SEPARATOR);
label.setLayoutData(new RowData(-1, sepHeight));
Composite cMinSize = new Composite(cRow, SWT.NONE);
layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
cMinSize.setLayout(layout);
Label lblMinSize = new Label(cMinSize, SWT.NONE);
lblMinSize.setText(MessageText.getString("SubscriptionResults.filter.min_size"));
spinMinSize = new Spinner(cMinSize, SWT.BORDER);
spinMinSize.setMinimum(0);
// 100 TB should do...
spinMinSize.setMaximum(100 * 1024 * 1024);
spinMinSize.setSelection(minSize);
spinMinSize.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
minSize = ((Spinner) event.widget).getSelection();
refilter();
}
});
// max size
label = new Label(cRow, SWT.VERTICAL | SWT.SEPARATOR);
label.setLayoutData(new RowData(-1, sepHeight));
Composite cMaxSize = new Composite(cRow, SWT.NONE);
layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
cMaxSize.setLayout(layout);
Label lblMaxSize = new Label(cMaxSize, SWT.NONE);
lblMaxSize.setText(MessageText.getString("SubscriptionResults.filter.max_size"));
spinMaxSize = new Spinner(cMaxSize, SWT.BORDER);
spinMaxSize.setMinimum(0);
// 100 TB should do...
spinMaxSize.setMaximum(100 * 1024 * 1024);
spinMaxSize.setSelection(maxSize);
spinMaxSize.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
maxSize = ((Spinner) event.widget).getSelection();
refilter();
}
});
engine_area = new Composite(filter_area, SWT.NONE);
engine_area.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buildEngineArea(null);
parent.layout(true);
}
return null;
}
use of org.eclipse.swt.widgets.Spinner in project webtools.servertools by eclipse.
the class MonitorDialog method createSpinner.
protected Spinner createSpinner(Composite comp, int v, final IntModifyListener listener) {
final Spinner s = new Spinner(comp, SWT.BORDER);
s.setMinimum(0);
s.setMaximum(Integer.MAX_VALUE);
if (v != -1)
s.setSelection(v);
GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
data.widthHint = 150;
s.setLayoutData(data);
if (listener != null)
s.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
listener.valueChanged(s.getSelection());
}
});
return s;
}
use of org.eclipse.swt.widgets.Spinner in project webtools.servertools by eclipse.
the class HttpSection method createSection.
public void createSection(Composite parent) {
super.createSection(parent);
FormToolkit toolkit = getFormToolkit(parent.getDisplay());
Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
section.setText(Messages.editorSectionTitle);
section.setDescription(Messages.editorSectionDescription);
section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
Composite composite = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.marginHeight = 8;
layout.marginWidth = 8;
layout.numColumns = 2;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL));
toolkit.paintBordersFor(composite);
section.setClient(composite);
// URL prefix
Label label = createLabel(toolkit, composite, Messages.editorURLPrefix);
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
// data.horizontalSpan = 2;
label.setLayoutData(data);
urlPrefixText = toolkit.createText(composite, "");
data = new GridData(GridData.FILL_HORIZONTAL);
// data.horizontalSpan = 2;
urlPrefixText.setLayoutData(data);
urlPrefixText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (updating)
return;
updating = true;
execute(new ModifyURLPrefixCommand(httpServer, urlPrefixText.getText()));
updating = false;
}
});
// port
createLabel(toolkit, composite, Messages.editorPort);
portSpinner = new Spinner(composite, SWT.BORDER);
portSpinner.setMinimum(0);
portSpinner.setMaximum(MAXIMUM_PORT);
portSpinner.setTextLimit((Integer.toString(MAXIMUM_PORT)).length());
data = new GridData(GridData.FILL_HORIZONTAL);
portSpinner.setLayoutData(data);
portSpinner.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (updating)
return;
updating = true;
execute(new ModifyPortCommand(httpServer, portSpinner.getSelection()));
updating = false;
}
});
// is publishing
publishCheckBox = new Button(composite, SWT.CHECK);
publishCheckBox.setText(Messages.editorShouldPublish);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
publishCheckBox.setLayoutData(data);
publishCheckBox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
Button b = (Button) se.getSource();
if (updating)
return;
updating = true;
execute(new ModifyPublishingCommand(httpServer, b.getSelection()));
updating = false;
}
});
initialize();
}
Aggregations