Search in sources :

Example 51 with Spinner

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));
}
Also used : Spinner(org.eclipse.swt.widgets.Spinner)

Example 52 with 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);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) FormDataFactory.startingWith(name.abuchen.portfolio.ui.util.FormDataFactory.startingWith) UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) DatePicker(name.abuchen.portfolio.ui.util.DatePicker) ISWTObservableValue(org.eclipse.jface.databinding.swt.ISWTObservableValue) Spinner(org.eclipse.swt.widgets.Spinner) DataBindingContext(org.eclipse.core.databinding.DataBindingContext) ComboViewer(org.eclipse.jface.viewers.ComboViewer) MessageFormat(java.text.MessageFormat) ValidationStatus(org.eclipse.core.databinding.validation.ValidationStatus) WidgetProperties(org.eclipse.jface.databinding.swt.WidgetProperties) AbstractWizardPage(name.abuchen.portfolio.ui.wizards.AbstractWizardPage) IStatus(org.eclipse.core.runtime.IStatus) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) SimpleDateTimeDateSelectionProperty(name.abuchen.portfolio.ui.util.SimpleDateTimeDateSelectionProperty) BindingHelper(name.abuchen.portfolio.ui.util.BindingHelper) SWTHelper.widest(name.abuchen.portfolio.ui.util.SWTHelper.widest) FormLayout(org.eclipse.swt.layout.FormLayout) Security(name.abuchen.portfolio.model.Security) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator) List(java.util.List) ViewersObservables(org.eclipse.jface.databinding.viewers.ViewersObservables) BeanProperties(org.eclipse.core.databinding.beans.BeanProperties) SWT(org.eclipse.swt.SWT) Label(org.eclipse.swt.widgets.Label) LabelProvider(org.eclipse.jface.viewers.LabelProvider) Composite(org.eclipse.swt.widgets.Composite) SimpleDateTimeDateSelectionProperty(name.abuchen.portfolio.ui.util.SimpleDateTimeDateSelectionProperty) Spinner(org.eclipse.swt.widgets.Spinner) Label(org.eclipse.swt.widgets.Label) DataBindingContext(org.eclipse.core.databinding.DataBindingContext) Security(name.abuchen.portfolio.model.Security) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ISWTObservableValue(org.eclipse.jface.databinding.swt.ISWTObservableValue) DatePicker(name.abuchen.portfolio.ui.util.DatePicker) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 53 with Spinner

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;
}
Also used : VuzeMessageBoxListener(com.biglybt.ui.swt.views.skin.VuzeMessageBoxListener) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) SWTSkinCheckboxListener(com.biglybt.ui.swt.skin.SWTSkinCheckboxListener) ImageDownloaderListener(com.biglybt.ui.swt.imageloader.ImageLoader.ImageDownloaderListener) TableViewSWTMenuFillListener(com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener) ResultListener(com.biglybt.core.metasearch.ResultListener) TableColumnCreationListener(com.biglybt.pif.ui.tables.TableColumnCreationListener) Listener(org.eclipse.swt.widgets.Listener) SWTSkinToggleListener(com.biglybt.ui.swt.skin.SWTSkinToggleListener) CoreRunningListener(com.biglybt.core.CoreRunningListener) MetaSearchListener(com.biglybt.core.metasearch.MetaSearchListener) SWTSkinObjectToggle(com.biglybt.ui.swt.skin.SWTSkinObjectToggle) Spinner(org.eclipse.swt.widgets.Spinner) Label(org.eclipse.swt.widgets.Label) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) SWTSkinObjectTextbox(com.biglybt.ui.swt.skin.SWTSkinObjectTextbox) RowLayout(org.eclipse.swt.layout.RowLayout) CoreRunningListener(com.biglybt.core.CoreRunningListener) SWTSkinToggleListener(com.biglybt.ui.swt.skin.SWTSkinToggleListener) Core(com.biglybt.core.Core) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) Text(org.eclipse.swt.widgets.Text) MessageText(com.biglybt.core.internat.MessageText) SWTSkinObjectText(com.biglybt.ui.swt.skin.SWTSkinObjectText) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Example 54 with Spinner

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;
}
Also used : Spinner(org.eclipse.swt.widgets.Spinner) GridData(org.eclipse.swt.layout.GridData)

Example 55 with Spinner

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();
}
Also used : ModifyURLPrefixCommand(org.eclipse.wst.server.http.core.internal.command.ModifyURLPrefixCommand) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) Spinner(org.eclipse.swt.widgets.Spinner) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ServerEditorSection(org.eclipse.wst.server.ui.editor.ServerEditorSection) Section(org.eclipse.ui.forms.widgets.Section) ModifyPortCommand(org.eclipse.wst.server.http.core.internal.command.ModifyPortCommand) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ModifyPublishingCommand(org.eclipse.wst.server.http.core.internal.command.ModifyPublishingCommand)

Aggregations

Spinner (org.eclipse.swt.widgets.Spinner)159 Composite (org.eclipse.swt.widgets.Composite)108 GridData (org.eclipse.swt.layout.GridData)105 GridLayout (org.eclipse.swt.layout.GridLayout)103 Label (org.eclipse.swt.widgets.Label)102 Button (org.eclipse.swt.widgets.Button)86 SelectionEvent (org.eclipse.swt.events.SelectionEvent)59 Group (org.eclipse.swt.widgets.Group)58 Text (org.eclipse.swt.widgets.Text)43 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)40 ModifyListener (org.eclipse.swt.events.ModifyListener)33 SelectionListener (org.eclipse.swt.events.SelectionListener)31 ModifyEvent (org.eclipse.swt.events.ModifyEvent)30 Combo (org.eclipse.swt.widgets.Combo)27 SWT (org.eclipse.swt.SWT)18 Point (org.eclipse.swt.graphics.Point)12 FormLayout (org.eclipse.swt.layout.FormLayout)11 RowLayout (org.eclipse.swt.layout.RowLayout)11 LabeledText (org.netxms.ui.eclipse.widgets.LabeledText)11 FormAttachment (org.eclipse.swt.layout.FormAttachment)9