Java Code Examples for org.eclipse.swt.SWT#TIME

The following examples show how to use org.eclipse.swt.SWT#TIME . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void updateDate2Composite() {
   if (isBetweenDates()) {

      date2Widget = new DateTime(widgetComp, SWT.CALENDAR);
      date2Widget.addListener(SWT.Selection, e-> setDate2Selection());

      time2Widget = new DateTime(widgetComp, SWT.TIME);
      time2Widget.addListener(SWT.Selection, e-> setDate2Selection());
      time2Widget.setHours(0);
      time2Widget.setMinutes(0);
      time2Widget.setSeconds(0);
   } else {
      if (date2Widget != null) {
         date2Widget.dispose();
         date2Widget = null;
         time2Widget.dispose();
         time2Widget = null;
      }
   }
   widgetComp.layout(true, true);
   final Point newSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
   getShell().setSize(newSize);
}
 
Example 2
Source Project: gama   File: DateEditor.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public Control createCustomParameterControl(final Composite compo) {
	edit = new Composite(compo, SWT.NONE);
	final GridLayout pointEditorLayout = new GridLayout(2, true);
	pointEditorLayout.horizontalSpacing = 10;
	pointEditorLayout.verticalSpacing = 0;
	pointEditorLayout.marginHeight = 0;
	pointEditorLayout.marginWidth = 0;
	edit.setLayout(pointEditorLayout);
	date = new DateTime(edit, SWT.DROP_DOWN | SWT.BORDER | SWT.DATE | SWT.LONG);
	time = new DateTime(edit, SWT.DROP_DOWN | SWT.BORDER | SWT.TIME | SWT.LONG);
	date.setBackground(IGamaColors.PARAMETERS_BACKGROUND.color());
	date.addSelectionListener(this);
	time.setBackground(IGamaColors.PARAMETERS_BACKGROUND.color());
	time.addSelectionListener(this);
	edit.setBackground(IGamaColors.PARAMETERS_BACKGROUND.color());
	displayParameterValue();
	return edit;
}
 
Example 3
protected void createDatePicker( int style )
{
	btnDate = new Button( this, SWT.CHECK );
	btnDate.addListener( SWT.Selection, this );

	pickerDate = new DateTime( this, SWT.DATE | style );
	pickerDate.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	pickerDate.addListener( SWT.Selection, this );

	btnTime = new Button( this, SWT.CHECK );
	btnTime.addListener( SWT.Selection, this );

	pickerTime = new DateTime( this, SWT.TIME | style );
	pickerTime.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	pickerTime.addListener( SWT.Selection, this );
}
 
Example 4
private Composite createCalendarArea(Composite parent){
	Composite composite = new Composite(parent, SWT.NONE);
	GridLayout gd = new GridLayout(1, false);
	gd.marginLeft = 2; // SWT BUG 
	composite.setLayout(gd);
	dateSelection = new DateTime(composite, SWT.CALENDAR);
	dateSelection.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
	Composite dateComposite = new Composite(composite, SWT.NONE);
	dateComposite.setLayout(new GridLayout(2, true));
	dateComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	Label label = new Label(dateComposite, SWT.NONE);
	label.setText("Zeitpunkt");
	label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
	
	timeSelection = new DateTime(dateComposite, SWT.TIME);
	timeSelection.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	timeSelection.setTime(date.get(Calendar.HOUR_OF_DAY), date.get(Calendar.MINUTE),
		date.get(Calendar.SECOND));
	dateSelection.setDate(date.get(Calendar.YEAR), date.get(Calendar.MONTH),
		date.get(Calendar.DAY_OF_MONTH));
	
	getShell().setText(Messages.DateTimeSelectorDialog_enterDate); //$NON-NLS-1$
	return composite;
}
 
Example 5
private Composite createDefaultArea(Composite parent){
	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(new GridLayout(2, false));
	Label label = new Label(composite, SWT.NONE);
	label.setText("Zeitpunkt");
	label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
	Composite dateComposite = new Composite(composite, SWT.NONE);
	dateComposite.setLayout(new GridLayout(2, true));
	dateComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	timeSelection = new DateTime(dateComposite, SWT.TIME);
	timeSelection.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	dateSelection = new DateTime(dateComposite, SWT.CALENDAR);
	dateSelection.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	
	timeSelection.setTime(date.get(Calendar.HOUR_OF_DAY), date.get(Calendar.MINUTE),
		date.get(Calendar.SECOND));
	dateSelection.setDate(date.get(Calendar.YEAR), date.get(Calendar.MONTH),
		date.get(Calendar.DAY_OF_MONTH));

	getShell().setText(Messages.DateTimeSelectorDialog_enterDate); //$NON-NLS-1$
	return composite;
}
 
Example 6
protected Control createCalendarEditor(final Composite stackedComposite) {
    final Composite calendarControl = new Composite(stackedComposite, SWT.NONE);
    calendarControl.setLayout(GridLayoutFactory.fillDefaults().numColumns(4).margins(15, 15).create());
    calendarControl.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final Label selectDateLabel = new Label(calendarControl, SWT.NONE);
    selectDateLabel.setText(Messages.selectDateLabel);

    final DateTime dateChooser = new DateTime(calendarControl, SWT.DATE | SWT.DROP_DOWN | SWT.BORDER);

    final Label atLabel = new Label(calendarControl, SWT.NONE);
    atLabel.setText(Messages.at);

    final DateTime timeChooser = new DateTime(calendarControl, SWT.TIME | SWT.BORDER);

    final Button generateFixedDate = new Button(calendarControl, SWT.PUSH);
    generateFixedDate.setLayoutData(GridDataFactory.swtDefaults().span(4, 1).create());
    generateFixedDate.setText(Messages.generateFixedDateLabel);
    generateFixedDate.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final String displayDate = DateUtil.getWidgetDisplayDate(dateChooser, timeChooser);
            condition.setName(displayDate);
            condition.setContent(DateUtil.getDateExpressionContent(dateChooser.getYear(),
                    dateChooser.getMonth(),
                    dateChooser.getDay(),
                    timeChooser.getHours(),
                    timeChooser.getMinutes(),
                    timeChooser.getSeconds()));
            condition.setType(ExpressionConstants.SCRIPT_TYPE);
            condition.setInterpreter(ExpressionConstants.GROOVY);
            condition.setReturnType(Date.class.getName());
            conditionViewer.setSelection(new StructuredSelection(condition));
        }
    });

    return calendarControl;
}
 
Example 7
@Override
protected void createExtendedArea(Composite parent) {
   super.createExtendedArea(parent);
   if (column.getSortDataType() == SortDataType.Date) {

      widgetComp = new Composite(parent, SWT.NONE);
      widgetComp.setLayout(new GridLayout(6, false));
      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalSpan = 2;
      widgetComp.setLayoutData(gd);

      Label label = new Label(widgetComp, SWT.NONE);
      label.setText("Date Match: ");

      dateRangeTypeCombo = new ComboViewer(widgetComp, SWT.NONE);
      dateRangeTypeCombo.setContentProvider(new ArrayContentProvider());
      dateRangeTypeCombo.setLabelProvider(new LabelProvider() {

         @Override
         public String getText(Object element) {
            return ((DateRangeType) element).getDisplayName();
         }

      });
      dateRangeTypeCombo.setInput(DateRangeType.values());
      dateRangeTypeCombo.addSelectionChangedListener(event -> {
            String text2 = dateRangeTypeCombo.getCombo().getText();
            dateRangeType = DateRangeType.get(text2);
            updateDate2Composite();
      });

      date1Widget = new DateTime(widgetComp, SWT.CALENDAR);
      date1Widget.addListener(SWT.Selection, e-> setDate1Selection());

      // set initial date
      Calendar cal = Calendar.getInstance();
      cal.set(date1Widget.getYear(), date1Widget.getMonth(), date1Widget.getDay(), 0, 0);
      date1 = cal.getTime();

      time1Widget = new DateTime(widgetComp, SWT.TIME);
      time1Widget.addListener(SWT.Selection, e-> setDate1Selection());
      time1Widget.setHours(0);
      time1Widget.setMinutes(0);
      time1Widget.setSeconds(0);

   }
}
 
Example 8
public DateTimeControl(final Composite parent) {
    super(parent, SWT.NONE);
    setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
    dateControl = new DateTime(this, SWT.BORDER | SWT.DATE | SWT.DROP_DOWN);
    timeControl = new DateTime(this, SWT.BORDER | SWT.TIME);
}