Search in sources :

Example 1 with DateTime

use of org.eclipse.swt.widgets.DateTime in project translationstudio8 by heartsome.

the class ExportFilterComposite method handlerFilterChangedEvent.

/**
	 * 处理过滤条件发生变化时动态创建组件 ;
	 */
private void handlerFilterChangedEvent() {
    String optionName = baseDataBean.getOptionName();
    String value = baseDataBean.getFilterVlaue();
    if (optionName.equals(Messages.getString("dialog.ExportFilterComposite.creationDate")) || optionName.equals(Messages.getString("dialog.ExportFilterComposite.changeDate"))) {
        if (!valueText.isDisposed()) {
            valueText.dispose();
        }
        DateTime valueTextDateTime = new DateTime(dynaComposite, SWT.DATE | SWT.BORDER);
        if (value != null) {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            try {
                Calendar c = Calendar.getInstance();
                c.setTime(df.parse(value));
                valueTextDateTime.setDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DATE));
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        valueText = valueTextDateTime;
    } else {
        if (!valueText.isDisposed()) {
            valueText.dispose();
        }
        valueText = new Text(dynaComposite, SWT.BORDER);
        if (value != null) {
            ((Text) valueText).setText(value);
        }
    }
    valueText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    dynaComposite.layout(true);
}
Also used : Calendar(java.util.Calendar) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) SimpleDateFormat(java.text.SimpleDateFormat) DateTime(org.eclipse.swt.widgets.DateTime)

Example 2 with DateTime

use of org.eclipse.swt.widgets.DateTime in project cubrid-manager by CUBRID.

the class HistoryComposite method loadTimeSelection.

/**
	 * Load time selection composite on the parent composite
	 *
	 * @param parent the parent composite
	 * @return the instance of Composite
	 */
public Composite loadTimeSelection(Composite parent) {
    final Composite composite = new Composite(parent, SWT.RESIZE);
    composite.setLayout(new GridLayout(7, false));
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Label dateLbl = new Label(composite, SWT.NONE);
    dateLbl.setText(Messages.historySelectDate);
    dateChooser = new DateTime(composite, SWT.DATE | SWT.BORDER);
    dateChooser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Label fromTimeLbl = new Label(composite, SWT.NONE);
    fromTimeLbl.setText(Messages.historySelectStartTime);
    fromTimeTxt = new DateTime(composite, SWT.TIME | SWT.BORDER);
    fromTimeTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Label toTimeLbl = new Label(composite, SWT.NONE);
    toTimeLbl.setText(Messages.historySelectEndTime);
    toTimeTxt = new DateTime(composite, SWT.TIME | SWT.BORDER);
    toTimeTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Calendar calendar = Calendar.getInstance();
    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DAY_OF_MONTH);
    int hours = calendar.get(Calendar.HOUR_OF_DAY);
    int minutes = calendar.get(Calendar.MINUTE);
    int seconds = calendar.get(Calendar.SECOND);
    dateChooser.setDate(year, month, day);
    toTimeTxt.setTime(hours, minutes, seconds);
    if (hours > 0) {
        hours = hours - 1;
    }
    fromTimeTxt.setTime(hours, minutes, seconds);
    queryBtn = new Button(composite, SWT.PUSH);
    queryBtn.setText(Messages.btnHistoryQuery);
    return parent;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) Calendar(java.util.Calendar) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) DateTime(org.eclipse.swt.widgets.DateTime)

Example 3 with DateTime

use of org.eclipse.swt.widgets.DateTime in project sling by apache.

the class DateTimeEditor method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    GridData parentLayoutData = new GridData(GridData.FILL_BOTH);
    parentLayoutData.widthHint = 280;
    parentLayoutData.heightHint = 280;
    composite.setLayoutData(parentLayoutData);
    GridLayout parentLayout = (GridLayout) composite.getLayout();
    parentLayout.numColumns = 2;
    Label label = new Label(composite, SWT.WRAP);
    label.setText("Modify property " + property.getName() + ":");
    GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
    data.horizontalSpan = 2;
    data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    label.setLayoutData(data);
    label.setFont(parent.getFont());
    Label hline = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.horizontalSpan = 2;
    hline.setLayoutData(layoutData);
    Label dateLabel = new Label(composite, SWT.WRAP);
    dateLabel.setText("Date:");
    layoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    layoutData.widthHint = 80;
    dateLabel.setLayoutData(layoutData);
    dateLabel.setFont(parent.getFont());
    calendar = new DateTime(composite, SWT.CALENDAR);
    layoutData = new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_BEGINNING);
    layoutData.horizontalSpan = 1;
    calendar.setLayoutData(layoutData);
    calendar.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateSelection();
        }
    });
    Label timeLabel = new Label(composite, SWT.WRAP);
    timeLabel.setText("Time:");
    layoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    layoutData.widthHint = 80;
    timeLabel.setLayoutData(layoutData);
    timeLabel.setFont(parent.getFont());
    time = new DateTime(composite, SWT.TIME);
    layoutData = new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_BEGINNING);
    layoutData.horizontalSpan = 1;
    time.setLayoutData(layoutData);
    time.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateSelection();
        }
    });
    hline = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.horizontalSpan = 2;
    hline.setLayoutData(layoutData);
    result = new Label(composite, SWT.WRAP);
    result.setText("Foo");
    data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
    data.horizontalSpan = 2;
    result.setLayoutData(data);
    result.setFont(parent.getFont());
    // initialize value
    dateAsString = property.getValueAsString();
    c = DateTimeSupport.parseAsCalendar(dateAsString);
    calendar.setDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH));
    time.setTime(c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), c.get(Calendar.SECOND));
    updateSelection();
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DateTime(org.eclipse.swt.widgets.DateTime)

Example 4 with DateTime

use of org.eclipse.swt.widgets.DateTime in project cubrid-manager by CUBRID.

the class TimeCellPopuoDialog method createDialogArea.

/**
	 * Create dialog area
	 * 
	 * @param parent Composite
	 * @return Control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    composite.setLayout(layout);
    timeComposite = new DateTime(composite, SWT.TIME | SWT.CALENDAR | SWT.BORDER);
    timeComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    setNullBtn = new Button(composite, SWT.CHECK);
    setNullBtn.setText(Messages.btnSetNull);
    setNullBtn.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    setNullBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            changeBtnStatus();
        }
    });
    initValue();
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DateTime(org.eclipse.swt.widgets.DateTime)

Example 5 with DateTime

use of org.eclipse.swt.widgets.DateTime in project cubrid-manager by CUBRID.

the class DateCellPopupDialog method createDialogArea.

/**
	 * Create dialog area
	 * 
	 * @param parent Composite
	 * @return Control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    composite.setLayout(layout);
    dateComposite = new DateTime(composite, SWT.CALENDAR | SWT.BORDER);
    dateComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
    setNullBtn = new Button(composite, SWT.CHECK);
    setNullBtn.setText(Messages.btnSetNull);
    setNullBtn.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    setNullBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            changeBtnStatus();
        }
    });
    initValue();
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DateTime(org.eclipse.swt.widgets.DateTime)

Aggregations

GridData (org.eclipse.swt.layout.GridData)6 DateTime (org.eclipse.swt.widgets.DateTime)6 GridLayout (org.eclipse.swt.layout.GridLayout)5 Composite (org.eclipse.swt.widgets.Composite)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Button (org.eclipse.swt.widgets.Button)4 Calendar (java.util.Calendar)2 Label (org.eclipse.swt.widgets.Label)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Spinner (org.eclipse.swt.widgets.Spinner)1 Text (org.eclipse.swt.widgets.Text)1