Search in sources :

Example 1 with DatePicker

use of net.sf.ecl.datepicker.DatePicker in project mdw-designer by CenturyLinkCloud.

the class PropertyEditor method createDatePicker.

private DatePicker createDatePicker(Composite parent) {
    createLabel(parent);
    int lStyle = SWT.BORDER | this.style;
    if (isReadOnly())
        lStyle = lStyle | SWT.READ_ONLY;
    final DatePicker datePicker = new DatePicker(parent, lStyle);
    datePicker.setEnabled(!isReadOnly());
    GridData gd = new GridData(SWT.LEFT);
    gd.widthHint = getWidth();
    gd.heightHint = getHeight();
    gd.horizontalSpan = COLUMNS - 1;
    gd.horizontalIndent = indent;
    datePicker.setLayoutData(gd);
    if (getValue() != null)
        updateWidget(getValue());
    datePicker.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
            String oldValue = value;
            String newValue = "";
            if (datePicker.getSelection() != null)
                newValue = dateFormat.format(datePicker.getSelection().getTime());
            value = newValue;
            if (oldValue != null) {
                boolean changed = !oldValue.equals(newValue);
                if (changed)
                    fireValueChanged(newValue);
            }
        }
    });
    return datePicker;
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DatePicker(net.sf.ecl.datepicker.DatePicker) SimpleDateFormat(java.text.SimpleDateFormat) Point(org.eclipse.swt.graphics.Point)

Example 2 with DatePicker

use of net.sf.ecl.datepicker.DatePicker in project mdw-designer by CenturyLinkCloud.

the class PropertyEditor method updateWidget.

public void updateWidget(String value) {
    String newValue = value == null ? "" : value;
    if (type.equals(TYPE_TEXT))
        ((Text) widget).setText(newValue);
    else if (type.equals(TYPE_COMBO))
        ((Combo) widget).setText(newValue);
    else if (type.equals(TYPE_IMAGE_COMBO))
        ((ImageCombo) widget).setText(newValue);
    else if (type.equals(TYPE_INFO))
        ((Label) widget).setText(newValue);
    else if (type.equals(TYPE_PICKLIST))
        ((ListComposer) widget).setInput(newValue);
    else if (type.equals(TYPE_RADIO))
        updateRadioButtons(newValue);
    else if (type.equals(TYPE_TIMER))
        updateTimerInterval(newValue);
    else if (type.equals(TYPE_SPINNER))
        ((Spinner) widget).setSelection(newValue.length() == 0 ? 0 : Integer.parseInt(newValue));
    else if (type.equals(TYPE_CHECKBOX))
        ((Button) widget).setSelection(Boolean.parseBoolean(newValue));
    else if (type.equals(TYPE_SWITCH))
        ((SwitchButton) widget).setSelection(Boolean.parseBoolean(newValue));
    else if (type.equals(TYPE_DATE_PICKER)) {
        try {
            Calendar calendar = Calendar.getInstance();
            if (newValue.length() == 0) {
                ((DatePicker) widget).setSelection(null);
            } else {
                calendar.setTime(new SimpleDateFormat(DATE_FORMAT).parse(newValue));
                ((DatePicker) widget).setSelection(calendar);
            }
        } catch (ParseException ex) {
            throw new RuntimeException(ex.getMessage(), ex);
        }
    } else if (type.equals(TYPE_BAM_MESSAGE)) {
        BamEventComposer bamComposer = (BamEventComposer) widget;
        bamComposer.setElement(getElement());
        bamComposer.setInput(valueConverter.toModelValue(newValue));
    } else if (type.equals(TYPE_PARAMETERIZED_COMBO)) {
        ((ParameterizedCombo) widget).setInput(valueConverter.toModelValue(newValue));
    } else if (type.equals(TYPE_WEB)) {
        Composite c = (Composite) widget;
        Browser browser = (Browser) c.getChildren()[0];
        if (newValue.startsWith("http://") || newValue.startsWith("https://"))
            browser.setUrl(newValue);
        else
            browser.setText(newValue);
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Spinner(org.eclipse.swt.widgets.Spinner) Calendar(java.util.Calendar) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) DatePicker(net.sf.ecl.datepicker.DatePicker) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Browser(org.eclipse.swt.browser.Browser)

Example 3 with DatePicker

use of net.sf.ecl.datepicker.DatePicker in project mdw-designer by CenturyLinkCloud.

the class ProcessInstanceFilterDialog method createProcessTabItem.

private TabItem createProcessTabItem(TabFolder tabFolder) {
    TabItem processTabItem = new TabItem(tabFolder, SWT.NULL);
    processTabItem.setText("Process");
    Composite composite = new Composite(tabFolder, SWT.NONE);
    GridLayout gl = new GridLayout();
    gl.numColumns = 5;
    composite.setLayout(gl);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    // process label
    new Label(composite, SWT.NONE).setText("Process:");
    Label processLabel = new Label(composite, SWT.NONE);
    if (process != null)
        processLabel.setText(process.getName());
    GridData gd = new GridData(SWT.BEGINNING);
    gd.horizontalSpan = 2;
    processLabel.setLayoutData(gd);
    // process version
    new Label(composite, SWT.NONE).setText("Version:");
    versionCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
    versionCombo.removeAll();
    versionCombo.add("");
    for (WorkflowProcess pv : process.getAllProcessVersions()) versionCombo.add(pv.getVersionString());
    if (process.getId() == 0)
        versionCombo.setText("");
    else
        versionCombo.setText(process.getVersionString());
    versionCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            filter.setProcess(versionCombo.getText().trim());
        }
    });
    Label vSpacer = new Label(composite, SWT.NONE);
    gd = new GridData(SWT.BEGINNING);
    gd.heightHint = 1;
    gd.horizontalSpan = 5;
    vSpacer.setLayoutData(gd);
    // instance id
    new Label(composite, SWT.NONE).setText("Instance ID:");
    instanceIdText = new Text(composite, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(SWT.BEGINNING);
    gd.widthHint = 100;
    instanceIdText.setLayoutData(gd);
    if (filter.getProcessInstanceId() != null)
        instanceIdText.setText(filter.getProcessInstanceId().toString());
    instanceIdText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            try {
                if (instanceIdText.getText().trim().length() == 0)
                    filter.setProcessInstanceId(null);
                else
                    filter.setProcessInstanceId(Long.parseLong(instanceIdText.getText().trim()));
            } catch (NumberFormatException ex) {
                if (filter.getProcessInstanceId() == null)
                    instanceIdText.setText("");
                else
                    instanceIdText.setText(filter.getProcessInstanceId().toString());
            }
        }
    });
    new Label(composite, SWT.NONE).setText("");
    // master request id
    new Label(composite, SWT.NONE).setText("Master Request ID:");
    masterRequestIdText = new Text(composite, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(SWT.BEGINNING);
    gd.widthHint = 100;
    masterRequestIdText.setLayoutData(gd);
    if (filter.getMasterRequestId() != null)
        masterRequestIdText.setText(filter.getMasterRequestId());
    masterRequestIdText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (masterRequestIdText.getText().trim().length() == 0)
                filter.setMasterRequestId(null);
            else
                filter.setMasterRequestId(masterRequestIdText.getText().trim());
        }
    });
    // owner
    new Label(composite, SWT.NONE).setText("Owner Type:");
    ownerCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
    ownerCombo.removeAll();
    ownerCombo.add("");
    for (String ownerType : ownerTypes.keySet()) ownerCombo.add(ownerType);
    if (filter.getOwner() != null)
        ownerCombo.setText(getOwnerType(filter.getOwner()));
    ownerCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (ownerCombo.getText().trim().length() == 0)
                filter.setOwner(null);
            else
                filter.setOwner(ownerTypes.get(ownerCombo.getText().trim()));
        }
    });
    Label spacer = new Label(composite, SWT.NONE);
    gd = new GridData(SWT.BEGINNING);
    gd.widthHint = 20;
    spacer.setLayoutData(gd);
    // owner id
    new Label(composite, SWT.NONE).setText("Owner ID:");
    ownerIdText = new Text(composite, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(SWT.BEGINNING);
    gd.widthHint = 100;
    ownerIdText.setLayoutData(gd);
    if (filter.getOwnerId() != null)
        ownerIdText.setText(filter.getOwnerId().toString());
    ownerIdText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            try {
                if (ownerIdText.getText().trim().length() == 0)
                    filter.setOwnerId(null);
                else
                    filter.setOwnerId(Long.parseLong(ownerIdText.getText().trim()));
            } catch (NumberFormatException ex) {
                if (filter.getOwnerId() == null)
                    ownerIdText.setText("");
                else
                    ownerIdText.setText(filter.getOwnerId().toString());
            }
        }
    });
    // status
    new Label(composite, SWT.NONE).setText("Status:");
    statusCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
    statusCombo.removeAll();
    statusCombo.add("");
    for (String status : statuses.keySet()) statusCombo.add(status);
    gd = new GridData(SWT.BEGINNING);
    gd.horizontalSpan = 4;
    statusCombo.setLayoutData(gd);
    if (filter.getStatusCode() != null)
        statusCombo.setText(getStatus(filter.getStatusCode()));
    statusCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (statusCombo.getText().trim().length() == 0)
                filter.setStatusCode(null);
            else
                filter.setStatusCode(statuses.get(statusCombo.getText().trim()));
        }
    });
    // start date range
    new Label(composite, SWT.NONE).setText("Start Date:");
    Group startDateGroup = new Group(composite, SWT.NONE);
    gl = new GridLayout();
    gl.numColumns = 7;
    startDateGroup.setLayout(gl);
    gd = new GridData(SWT.BEGINNING);
    gd.horizontalSpan = 4;
    startDateGroup.setLayoutData(gd);
    // start date from
    new Label(startDateGroup, SWT.NONE).setText("From:");
    startFromDatePicker = new DatePicker(startDateGroup, SWT.BORDER);
    Calendar startFrom = null;
    if (filter.getStartDateFrom() != null) {
        startFrom = Calendar.getInstance();
        startFrom.setTime(filter.getStartDateFrom());
    }
    startFromDatePicker.setSelection(startFrom);
    startFromDatePicker.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (startFromDatePicker.getSelection() == null)
                filter.setStartDateFrom(null);
            else
                filter.setStartDateFrom(startFromDatePicker.getSelection().getTime());
        }
    });
    spacer = new Label(startDateGroup, SWT.NONE);
    gd = new GridData(SWT.BEGINNING);
    gd.widthHint = 10;
    spacer.setLayoutData(gd);
    // start date to
    new Label(startDateGroup, SWT.NONE).setText("To:");
    startToDatePicker = new DatePicker(startDateGroup, SWT.BORDER);
    Calendar startTo = null;
    if (filter.getStartDateTo() != null) {
        startTo = Calendar.getInstance();
        startTo.setTime(filter.getStartDateTo());
    }
    startToDatePicker.setSelection(startTo);
    startToDatePicker.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (startToDatePicker.getSelection() == null)
                filter.setStartDateTo(null);
            else
                filter.setStartDateTo(startToDatePicker.getSelection().getTime());
        }
    });
    spacer = new Label(startDateGroup, SWT.NONE);
    gd = new GridData(SWT.BEGINNING);
    gd.widthHint = 10;
    spacer.setLayoutData(gd);
    // start date clear
    Button startDateClearButton = new Button(startDateGroup, SWT.PUSH);
    startDateClearButton.setImage(MdwPlugin.getImageDescriptor("icons/clear.gif").createImage());
    startDateClearButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            startToDatePicker.setSelection(null);
            startFromDatePicker.setSelection(null);
        }
    });
    // end date range
    new Label(composite, SWT.NONE).setText("End Date:");
    Group endDateGroup = new Group(composite, SWT.NONE);
    gl = new GridLayout();
    gl.numColumns = 7;
    endDateGroup.setLayout(gl);
    gd = new GridData(SWT.BEGINNING);
    gd.horizontalSpan = 4;
    endDateGroup.setLayoutData(gd);
    // end date from
    new Label(endDateGroup, SWT.NONE).setText("From:");
    endFromDatePicker = new DatePicker(endDateGroup, SWT.BORDER);
    Calendar endFrom = null;
    if (filter.getEndDateFrom() != null) {
        endFrom = Calendar.getInstance();
        endFrom.setTime(filter.getEndDateFrom());
    }
    endFromDatePicker.setSelection(endFrom);
    endFromDatePicker.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (endFromDatePicker.getSelection() == null)
                filter.setEndDateFrom(null);
            else
                filter.setEndDateFrom(endFromDatePicker.getSelection().getTime());
            if (filter.getEndDateFrom() != null && endToDatePicker.getSelection() == null) {
                Calendar endTo = endFromDatePicker.getSelection();
                endTo.add(Calendar.DATE, 7);
                endToDatePicker.setSelection(endTo);
            }
        }
    });
    spacer = new Label(endDateGroup, SWT.NONE);
    gd = new GridData(SWT.BEGINNING);
    gd.widthHint = 10;
    spacer.setLayoutData(gd);
    // end date to
    new Label(endDateGroup, SWT.NONE).setText("To:");
    endToDatePicker = new DatePicker(endDateGroup, SWT.BORDER);
    Calendar endTo = null;
    if (filter.getEndDateTo() != null) {
        endTo = Calendar.getInstance();
        endTo.setTime(filter.getEndDateTo());
    }
    endToDatePicker.setSelection(endTo);
    endToDatePicker.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (endToDatePicker.getSelection() == null)
                filter.setEndDateTo(null);
            else
                filter.setEndDateTo(endToDatePicker.getSelection().getTime());
        }
    });
    spacer = new Label(endDateGroup, SWT.NONE);
    gd = new GridData(SWT.BEGINNING);
    gd.widthHint = 10;
    spacer.setLayoutData(gd);
    // end date clear
    Button endDateClearButton = new Button(endDateGroup, SWT.PUSH);
    endDateClearButton.setImage(MdwPlugin.getImageDescriptor("icons/clear.gif").createImage());
    endDateClearButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            endToDatePicker.setSelection(null);
            endFromDatePicker.setSelection(null);
        }
    });
    vSpacer = new Label(composite, SWT.NONE);
    gd = new GridData(SWT.BEGINNING);
    gd.heightHint = 1;
    gd.horizontalSpan = 5;
    vSpacer.setLayoutData(gd);
    // max rows
    new Label(composite, SWT.NONE).setText("Page Size:");
    pageSizeSpinner = new Spinner(composite, SWT.BORDER);
    pageSizeSpinner.setMinimum(10);
    pageSizeSpinner.setMaximum(100);
    pageSizeSpinner.setIncrement(10);
    if (filter.getPageSize() != null)
        pageSizeSpinner.setSelection(filter.getPageSize().intValue());
    pageSizeSpinner.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            filter.setPageSize(pageSizeSpinner.getSelection());
        }
    });
    processTabItem.setControl(composite);
    return processTabItem;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Spinner(org.eclipse.swt.widgets.Spinner) Calendar(java.util.Calendar) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) TabItem(org.eclipse.swt.widgets.TabItem) 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) DatePicker(net.sf.ecl.datepicker.DatePicker) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Aggregations

DatePicker (net.sf.ecl.datepicker.DatePicker)3 SimpleDateFormat (java.text.SimpleDateFormat)2 Calendar (java.util.Calendar)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 Combo (org.eclipse.swt.widgets.Combo)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 Spinner (org.eclipse.swt.widgets.Spinner)2 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)1 DateFormat (java.text.DateFormat)1 ParseException (java.text.ParseException)1 Browser (org.eclipse.swt.browser.Browser)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 Point (org.eclipse.swt.graphics.Point)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Group (org.eclipse.swt.widgets.Group)1