Java Examples for org.eclipse.swt.widgets.DateTime

The following java examples will help you to understand the usage of org.eclipse.swt.widgets.DateTime. These source code samples are taken from different open source projects.

Example 1
Project: nebula-master  File: ColumnFilterDialog.java View source code
@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(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                String text2 = dateRangeTypeCombo.getCombo().getText();
                dateRangeType = DateRangeType.get(text2);
                updateDate2Composite();
            }
        });
        date1Widget = new DateTime(widgetComp, SWT.CALENDAR);
        date1Widget.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent 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.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                setDate1Selection();
            }
        });
        time1Widget.setHours(0);
        time1Widget.setMinutes(0);
        time1Widget.setSeconds(0);
    }
}
Example 2
Project: jenkow-plugin-master  File: CustomPropertyDatePickerField.java View source code
@Override
public Composite render(final Composite parent, final TabbedPropertySheetWidgetFactory factory, final FocusListener listener) {
    final Composite result = factory.createFlatFormComposite(parent);
    FormData data;
    int controlStyle = SWT.CALENDAR;
    final DatePickerProperty datePickerPropertyAnnotation = getField().getAnnotation(DatePickerProperty.class);
    if (datePickerPropertyAnnotation != null) {
        sdf = new SimpleDateFormat(datePickerPropertyAnnotation.dateTimePattern());
        controlStyle = datePickerPropertyAnnotation.swtStyle();
    } else {
        sdf = new SimpleDateFormat(DatePickerProperty.DEFAULT_DATE_TIME_PATTERN);
        controlStyle = DatePickerProperty.DEFAULT_DATE_TIME_CONTROL_STYLE;
    }
    calendarControl = new DateTime(result, controlStyle | SWT.BORDER_SOLID);
    calendarControl.setEnabled(true);
    if (getPropertyAnnotation().required()) {
        addFieldValidator(calendarControl, RequiredFieldValidator.class);
    }
    if (getPropertyAnnotation().fieldValidator() != null) {
        addFieldValidator(calendarControl, getPropertyAnnotation().fieldValidator());
    }
    calendarControl.addFocusListener(listener);
    data = new FormData();
    data.left = new FormAttachment(0);
    data.top = new FormAttachment(0);
    data.right = new FormAttachment(100);
    calendarControl.setLayoutData(data);
    return result;
}
Example 3
Project: org.eclipse.rap-master  File: PageUtil.java View source code
static DateTime createLabelDate(final Container container, final String labelContent, final Date date) {
    Composite client = container.client;
    FormToolkit toolkit = container.toolkit;
    Label label = toolkit.createLabel(client, labelContent);
    GridData gdLabel = new GridData();
    gdLabel.widthHint = 100;
    label.setLayoutData(gdLabel);
    int style = SWT.BORDER | SWT.DATE | SWT.DROP_DOWN;
    DateTime result = new DateTime(client, style);
    if (date != null) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        result.setDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
    }
    GridData gdResult = new GridData();
    gdResult.horizontalSpan = 2;
    result.setLayoutData(gdResult);
    return result;
}
Example 4
Project: rap-master  File: DateTimeLCA_Test.java View source code
// 315950: [DateTime] method getDay() return wrong day in particular circumstances
@Test
public void testDateTimeDate_Bug315950() {
    DateTime dateTime = new DateTime(shell, SWT.DATE | SWT.MEDIUM | SWT.DROP_DOWN);
    getRemoteObject(dateTime).setHandler(new DateTimeOperationHandler(dateTime));
    dateTime.setDay(15);
    dateTime.setMonth(5);
    dateTime.setYear(2010);
    Fixture.markInitialized(display);
    Fixture.fakeNotifyOperation(getId(dateTime), ClientMessageConst.EVENT_SELECTION, null);
    JsonObject properties = new JsonObject().add("year", 2010).add("month", 4).add("day", 31);
    Fixture.fakeSetOperation(getId(dateTime), properties);
    Fixture.readDataAndProcessAction(dateTime);
    assertEquals(31, dateTime.getDay());
    assertEquals(4, dateTime.getMonth());
    assertEquals(2010, dateTime.getYear());
}
Example 5
Project: Secure-Service-Specification-and-Deployment-master  File: CustomPropertyDatePickerField.java View source code
@Override
public Composite render(final Composite parent, final TabbedPropertySheetWidgetFactory factory, final FocusListener listener) {
    final Composite result = factory.createFlatFormComposite(parent);
    FormData data;
    int controlStyle = SWT.CALENDAR;
    final DatePickerProperty datePickerPropertyAnnotation = getField().getAnnotation(DatePickerProperty.class);
    if (datePickerPropertyAnnotation != null) {
        sdf = new SimpleDateFormat(datePickerPropertyAnnotation.dateTimePattern());
        controlStyle = datePickerPropertyAnnotation.swtStyle();
    } else {
        sdf = new SimpleDateFormat(DatePickerProperty.DEFAULT_DATE_TIME_PATTERN);
        controlStyle = DatePickerProperty.DEFAULT_DATE_TIME_CONTROL_STYLE;
    }
    calendarControl = new DateTime(result, controlStyle | SWT.BORDER_SOLID);
    calendarControl.setEnabled(true);
    if (getPropertyAnnotation().required()) {
        addFieldValidator(calendarControl, RequiredFieldValidator.class);
    }
    if (getPropertyAnnotation().fieldValidator() != null) {
        addFieldValidator(calendarControl, getPropertyAnnotation().fieldValidator());
    }
    calendarControl.addFocusListener(listener);
    data = new FormData();
    data.left = new FormAttachment(0);
    data.top = new FormAttachment(0);
    data.right = new FormAttachment(100);
    calendarControl.setLayoutData(data);
    return result;
}
Example 6
Project: Security-Service-Validation-and-Verification-master  File: CustomPropertyDatePickerField.java View source code
@Override
public Composite render(final Composite parent, final TabbedPropertySheetWidgetFactory factory, final FocusListener listener) {
    final Composite result = factory.createFlatFormComposite(parent);
    FormData data;
    int controlStyle = SWT.CALENDAR;
    final DatePickerProperty datePickerPropertyAnnotation = getField().getAnnotation(DatePickerProperty.class);
    if (datePickerPropertyAnnotation != null) {
        sdf = new SimpleDateFormat(datePickerPropertyAnnotation.dateTimePattern());
        controlStyle = datePickerPropertyAnnotation.swtStyle();
    } else {
        sdf = new SimpleDateFormat(DatePickerProperty.DEFAULT_DATE_TIME_PATTERN);
        controlStyle = DatePickerProperty.DEFAULT_DATE_TIME_CONTROL_STYLE;
    }
    calendarControl = new DateTime(result, controlStyle | SWT.BORDER_SOLID);
    calendarControl.setEnabled(true);
    if (getPropertyAnnotation().required()) {
        addFieldValidator(calendarControl, RequiredFieldValidator.class);
    }
    if (getPropertyAnnotation().fieldValidator() != null) {
        addFieldValidator(calendarControl, getPropertyAnnotation().fieldValidator());
    }
    calendarControl.addFocusListener(listener);
    data = new FormData();
    data.left = new FormAttachment(0);
    data.top = new FormAttachment(0);
    data.right = new FormAttachment(100);
    calendarControl.setLayoutData(data);
    return result;
}
Example 7
Project: stocks-master  File: DateTimePicker.java View source code
public void setSelection(LocalDate date) {
    if (control instanceof CDateTime) {
        Date d = Date.from(date.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
        ((CDateTime) control).setSelection(d);
    } else {
        // DateTime widget has zero-based months
        ((DateTime) control).setDate(date.getYear(), date.getMonthValue() - 1, date.getDayOfMonth());
    }
}
Example 8
Project: swt-javafx-master  File: Test_org_eclipse_swt_widgets_DateTime.java View source code
@Override
public void test_ConstructorLorg_eclipse_swt_widgets_CompositeI() {
    new DateTime(shell, SWT.NULL);
    new DateTime(shell, SWT.DATE);
    new DateTime(shell, SWT.TIME);
    new DateTime(shell, SWT.CALENDAR);
    new DateTime(shell, SWT.DATE | SWT.LONG);
    new DateTime(shell, SWT.TIME | SWT.LONG);
    new DateTime(shell, SWT.CALENDAR | SWT.LONG);
    new DateTime(shell, SWT.DATE | SWT.MEDIUM);
    new DateTime(shell, SWT.TIME | SWT.MEDIUM);
    new DateTime(shell, SWT.CALENDAR | SWT.MEDIUM);
    new DateTime(shell, SWT.DATE | SWT.SHORT);
    new DateTime(shell, SWT.TIME | SWT.SHORT);
    new DateTime(shell, SWT.CALENDAR | SWT.SHORT);
    try {
        new DateTime(null, 0);
        fail("No exception thrown for parent == null");
    } catch (IllegalArgumentException e) {
    }
}
Example 9
Project: cdo-master  File: OMPreferencePage.java View source code
protected void addListeners(Control control) {
    if (control instanceof Text) {
        Text c = (Text) control;
        c.addModifyListener(modifyListener);
    }
    if (control instanceof Combo) {
        Combo c = (Combo) control;
        c.addModifyListener(modifyListener);
        c.addSelectionListener(selectionListener);
    }
    if (control instanceof CCombo) {
        CCombo c = (CCombo) control;
        c.addModifyListener(modifyListener);
        c.addSelectionListener(selectionListener);
    }
    if (control instanceof List) {
        List c = (List) control;
        c.addSelectionListener(selectionListener);
    }
    if (control instanceof DateTime) {
        DateTime c = (DateTime) control;
        c.addSelectionListener(selectionListener);
    }
    if (control instanceof Table) {
        Table c = (Table) control;
        c.addSelectionListener(selectionListener);
    }
    if (control instanceof Tree) {
        Table c = (Table) control;
        c.addSelectionListener(selectionListener);
    }
    if (control instanceof Button) {
        Button c = (Button) control;
        c.addSelectionListener(selectionListener);
    }
    if (control instanceof Composite) {
        Composite c = (Composite) control;
        for (Control child : c.getChildren()) {
            addListeners(child);
        }
    }
}
Example 10
Project: eclipse.platform.ui-master  File: ResourceFilterGroup.java View source code
private void setupMultiOperatorAndField(boolean updateOperator) {
    boolean isUsingRegularExpression = false;
    String selectedKey = MultiMatcherLocalization.getMultiMatcherKey(multiKey.getText());
    if (updateOperator) {
        String[] operators = getLocalOperatorsForKey(selectedKey);
        multiOperator.setItems(operators);
        FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments());
        String local = MultiMatcherLocalization.getLocalMultiMatcherKey(argument.operator);
        int index = multiOperator.indexOf(local);
        if (index != -1)
            multiOperator.select(index);
        else
            multiOperator.select(0);
    }
    String selectedOperator = MultiMatcherLocalization.getMultiMatcherKey(multiOperator.getText());
    Class selectedKeyOperatorType = FileInfoAttributesMatcher.getTypeForKey(selectedKey, selectedOperator);
    if (intiantiatedKeyOperatorType != null) {
        if (arguments != null) {
            arguments.dispose();
            arguments = null;
        }
        if (attributeStringArgumentComposite != null) {
            attributeStringArgumentComposite.dispose();
            attributeStringArgumentComposite = null;
        }
        if (stringArgumentComposite != null) {
            stringArgumentComposite.dispose();
            stringArgumentComposite = null;
        }
        if (argumentsBoolean != null) {
            argumentsBoolean.dispose();
            argumentsBoolean = null;
        }
        if (argumentsDate != null) {
            argumentsDate.dispose();
            argumentsDate = null;
        }
        if (argumentsRegularExpresion != null) {
            argumentsRegularExpresion.dispose();
            argumentsRegularExpresion = null;
        }
        if (argumentsCaseSensitive != null) {
            argumentsCaseSensitive.dispose();
            argumentsCaseSensitive = null;
        }
        if (dummyLabel1 != null) {
            dummyLabel1.dispose();
            dummyLabel1 = null;
        }
        if (dummyLabel2 != null) {
            dummyLabel2.dispose();
            dummyLabel2 = null;
        }
        fContentAssistField = null;
        FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments());
        valueCache.put(intiantiatedKeyOperatorType.getName(), argument.pattern);
        argument.pattern = (String) valueCache.get(selectedKeyOperatorType.getName());
        if (argument.pattern == null)
            //$NON-NLS-1$
            argument.pattern = //$NON-NLS-1$
            "";
        filter.setArguments(FileInfoAttributesMatcher.encodeArguments(argument));
    }
    if (selectedKeyOperatorType.equals(String.class)) {
        arguments = new Text(multiArgumentComposite, SWT.SINGLE | SWT.BORDER);
        GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
        data.widthHint = 150;
        arguments.setLayoutData(data);
        arguments.setFont(multiArgumentComposite.getFont());
        arguments.addModifyListener( e -> validateInputText());
        dummyLabel1 = new Label(multiArgumentComposite, SWT.NONE);
        data = new GridData(SWT.LEFT, SWT.CENTER, true, true);
        //$NON-NLS-1$
        dummyLabel1.setText("");
        data.horizontalSpan = 1;
        dummyLabel1.setLayoutData(data);
        dummyLabel2 = new Label(multiArgumentComposite, SWT.NONE);
        data = new GridData(SWT.LEFT, SWT.CENTER, true, true);
        //$NON-NLS-1$
        dummyLabel2.setText("");
        data.horizontalSpan = 1;
        dummyLabel2.setLayoutData(data);
        stringArgumentComposite = new Composite(multiArgumentComposite, SWT.NONE);
        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginWidth = 0;
        layout.marginTop = dialog.getVerticalDLUsToPixel(IDialogConstants.VERTICAL_SPACING) / 2;
        layout.marginHeight = 0;
        layout.marginBottom = 0;
        stringArgumentComposite.setLayout(layout);
        data = new GridData(SWT.FILL, SWT.CENTER, true, true);
        data.horizontalSpan = 1;
        stringArgumentComposite.setLayoutData(data);
        stringArgumentComposite.setFont(multiArgumentComposite.getFont());
        argumentsCaseSensitive = new Button(stringArgumentComposite, SWT.CHECK);
        argumentsCaseSensitive.setText(NLS.bind(IDEWorkbenchMessages.ResourceFilterPage_caseSensitive, null));
        data = new GridData(SWT.LEFT, SWT.CENTER, false, false);
        argumentsCaseSensitive.setLayoutData(data);
        argumentsCaseSensitive.setFont(multiArgumentComposite.getFont());
        argumentsRegularExpresion = new Button(stringArgumentComposite, SWT.CHECK);
        argumentsRegularExpresion.setText(NLS.bind(IDEWorkbenchMessages.ResourceFilterPage_regularExpression, null));
        data = new GridData(SWT.LEFT, SWT.CENTER, false, false);
        data.minimumWidth = 100;
        argumentsRegularExpresion.setLayoutData(data);
        argumentsRegularExpresion.setFont(multiArgumentComposite.getFont());
        if (filter.hasStringArguments()) {
            FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments());
            arguments.setText(argument.pattern);
            isUsingRegularExpression = argument.regularExpression;
            argumentsCaseSensitive.setSelection(argument.caseSensitive);
            argumentsRegularExpresion.setSelection(argument.regularExpression);
        }
        arguments.addModifyListener( e -> storeMultiSelection());
        argumentsRegularExpresion.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                setupDescriptionText(null);
                storeMultiSelection();
                if (fContentAssistField != null)
                    fContentAssistField.setEnabled(argumentsRegularExpresion.getSelection());
            }
        });
        argumentsCaseSensitive.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                storeMultiSelection();
            }
        });
        TextContentAdapter contentAdapter = new TextContentAdapter();
        FindReplaceDocumentAdapterContentProposalProvider findProposer = new FindReplaceDocumentAdapterContentProposalProvider(true);
        fContentAssistField = new ContentAssistCommandAdapter(arguments, contentAdapter, findProposer, null, new char[] { '\\', '[', '(' }, true);
    }
    if (selectedKeyOperatorType.equals(Integer.class)) {
        GridData data;
        arguments = new Text(multiArgumentComposite, SWT.SINGLE | SWT.BORDER);
        data = new GridData(SWT.FILL, SWT.FILL, true, false);
        data.widthHint = 150;
        arguments.setLayoutData(data);
        arguments.setFont(multiArgumentComposite.getFont());
        arguments.addModifyListener( e -> validateInputText());
        if (filter.hasStringArguments()) {
            FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments());
            if (selectedKey.equals(FileInfoAttributesMatcher.KEY_LAST_MODIFIED) || selectedKey.equals(FileInfoAttributesMatcher.KEY_CREATED))
                arguments.setText(convertToEditableTimeInterval(argument.pattern));
            else
                arguments.setText(convertToEditableLength(argument.pattern));
        }
        arguments.addModifyListener( e -> storeMultiSelection());
    }
    if (selectedKeyOperatorType.equals(Date.class)) {
        GridData data;
        argumentsDate = new DateTime(multiArgumentComposite, SWT.DATE | SWT.MEDIUM | SWT.BORDER);
        data = new GridData(SWT.FILL, SWT.FILL, true, false);
        argumentsDate.setLayoutData(data);
        argumentsDate.setFont(multiArgumentComposite.getFont());
        argumentsDate.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                storeMultiSelection();
            }
        });
        if (filter.hasStringArguments()) {
            FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments());
            Date date;
            Calendar calendar = Calendar.getInstance();
            try {
                date = new Date(Long.parseLong(argument.pattern));
                calendar.setTime(date);
            } catch (NumberFormatException e1) {
                date = new Date();
                calendar.setTime(date);
                argument.pattern = Long.toString(calendar.getTimeInMillis());
            }
            argumentsDate.setDay(calendar.get(Calendar.DAY_OF_MONTH));
            argumentsDate.setMonth(calendar.get(Calendar.MONTH));
            argumentsDate.setYear(calendar.get(Calendar.YEAR));
        }
    }
    if (selectedKeyOperatorType.equals(Boolean.class)) {
        GridData data;
        argumentsBoolean = new Combo(multiArgumentComposite, SWT.READ_ONLY);
        data = new GridData(SWT.FILL, SWT.TOP, true, false);
        argumentsBoolean.setLayoutData(data);
        argumentsBoolean.setFont(multiArgumentComposite.getFont());
        argumentsBoolean.setItems(new String[] { MultiMatcherLocalization.getLocalMultiMatcherKey(Boolean.TRUE.toString()), MultiMatcherLocalization.getLocalMultiMatcherKey(Boolean.FALSE.toString()) });
        argumentsBoolean.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                storeMultiSelection();
            }
        });
        if (filter.hasStringArguments()) {
            FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments());
            if (argument.pattern.length() == 0)
                argumentsBoolean.select(0);
            else
                argumentsBoolean.select(Boolean.valueOf(argument.pattern).booleanValue() ? 0 : 1);
        }
    }
    intiantiatedKeyOperatorType = selectedKeyOperatorType;
    if (fContentAssistField != null)
        fContentAssistField.setEnabled(isUsingRegularExpression);
    shell.layout(true, true);
    if (initializationComplete) {
        Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        Point shellSize = shell.getSize();
        size.x = Math.max(size.x, shellSize.x);
        size.y = Math.max(size.y, shellSize.y);
        if ((size.x > shellSize.x) || (size.y > shellSize.y))
            shell.setSize(size);
    }
    shell.redraw();
    setupDescriptionText(null);
}
Example 11
Project: elexis-3-base-master  File: SerienTerminDialog.java View source code
/**
	 * Create contents of the dialog.
	 * 
	 * @param parent
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite area = (Composite) super.createDialogArea(parent);
    setTitleImage(ResourceManager.getPluginImage("ch.elexis.agenda", "icons/recurringDate.png"));
    if (noedit) {
        //$NON-NLS-1$
        setMessage(Messages.getString("SerienTerminDialog.this.message.show"));
    } else {
        //$NON-NLS-1$
        setMessage(Messages.getString("SerienTerminDialog.this.message.create"));
    }
    Group grpTermin = new Group(area, SWT.NONE);
    grpTermin.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    grpTermin.setLayout(new GridLayout(6, false));
    //$NON-NLS-1$
    grpTermin.setText(Messages.getString("SerienTerminDialog.grpTermin.text"));
    Label lblBeginn = new Label(grpTermin, SWT.NONE);
    //$NON-NLS-1$
    lblBeginn.setText(Messages.getString("SerienTerminDialog.lblBeginn.text"));
    dateTimeBegin = new DateTime(grpTermin, SWT.BORDER | SWT.TIME | SWT.SHORT);
    dateTimeBegin.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateSpinner();
        }
    });
    Label lblEnde = new Label(grpTermin, SWT.NONE);
    //$NON-NLS-1$
    lblEnde.setText(Messages.getString("SerienTerminDialog.lblEnde.text"));
    dateTimeEnd = new DateTime(grpTermin, SWT.BORDER | SWT.TIME | SWT.SHORT);
    dateTimeEnd.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateSpinner();
        }
    });
    Label lblDauer = new Label(grpTermin, SWT.NONE);
    //$NON-NLS-1$
    lblDauer.setText(Messages.getString("SerienTerminDialog.lblDauer.text"));
    durationSpinner = new Spinner(grpTermin, SWT.NONE);
    durationSpinner.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
    durationSpinner.setMinimum(5);
    durationSpinner.setMaximum(1440);
    durationSpinner.setIncrement(5);
    durationSpinner.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int value = durationSpinner.getSelection();
            Calendar cal = Calendar.getInstance();
            cal.clear();
            cal.set(Calendar.HOUR_OF_DAY, dateTimeBegin.getHours());
            cal.set(Calendar.MINUTE, dateTimeBegin.getMinutes());
            cal.add(Calendar.MINUTE, value);
            dateTimeEnd.setHours(cal.get(Calendar.HOUR_OF_DAY));
            dateTimeEnd.setMinutes(cal.get(Calendar.MINUTE));
        }
    });
    {
        Group grpSerienmuster = new Group(area, SWT.NONE);
        grpSerienmuster.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        grpSerienmuster.setLayout(new GridLayout(1, false));
        //$NON-NLS-1$
        grpSerienmuster.setText(Messages.getString("SerienTerminDialog.grpSerienmuster.text"));
        tabFolderSeriesPattern = new CTabFolder(grpSerienmuster, SWT.BORDER);
        tabFolderSeriesPattern.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        tabFolderSeriesPattern.setSelectionBackground(Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
        tabFolderSeriesPattern.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                serienTermin.setSeriesType((SeriesType) e.item.getData());
            }
        });
        CTabItem tbtmDaily = new CTabItem(tabFolderSeriesPattern, SWT.NONE);
        //$NON-NLS-1$
        tbtmDaily.setText(Messages.getString("SerienTerminDialog.tbtmDaily.text"));
        tbtmDaily.setData(SeriesType.DAILY);
        Label lblNoConfigurationNecessary = new Label(tabFolderSeriesPattern, SWT.NONE);
        tbtmDaily.setControl(lblNoConfigurationNecessary);
        lblNoConfigurationNecessary.setText(Messages.getString(//$NON-NLS-1$
        "SerienTerminDialog.lblNoConfigurationNecessary.text"));
        CTabItem tbtmWeekly = new CTabItem(tabFolderSeriesPattern, SWT.NONE);
        //$NON-NLS-1$
        tbtmWeekly.setText(Messages.getString("SerienTerminDialog.tbtmWeekly.text"));
        wsc = new WeeklySeriesComposite(tabFolderSeriesPattern, SWT.NONE);
        tbtmWeekly.setControl(wsc);
        tbtmWeekly.setData(SeriesType.WEEKLY);
        CTabItem tbtmMonthly = new CTabItem(tabFolderSeriesPattern, SWT.NONE);
        //$NON-NLS-1$
        tbtmMonthly.setText(Messages.getString("SerienTerminDialog.tbtmMonthly.text"));
        msc = new MonthlySeriesComposite(tabFolderSeriesPattern, SWT.NONE);
        tbtmMonthly.setControl(msc);
        new Label(msc, SWT.NONE);
        tbtmMonthly.setData(SeriesType.MONTHLY);
        CTabItem tbtmYearly = new CTabItem(tabFolderSeriesPattern, SWT.NONE);
        //$NON-NLS-1$
        tbtmYearly.setText(Messages.getString("SerienTerminDialog.tbtmYearly.text"));
        ysc = new YearlySeriesComposite(tabFolderSeriesPattern, SWT.NONE);
        tbtmYearly.setControl(ysc);
        tbtmYearly.setData(SeriesType.YEARLY);
    }
    Group grpSeriendauer = new Group(area, SWT.NONE);
    grpSeriendauer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    grpSeriendauer.setLayout(new GridLayout(3, false));
    //$NON-NLS-1$
    grpSeriendauer.setText(Messages.getString("SerienTerminDialog.grpSeriendauer.text"));
    Label beginOfSeries = new Label(grpSeriendauer, SWT.NONE);
    beginOfSeries.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
    //$NON-NLS-1$
    beginOfSeries.setText(Messages.getString("SerienTerminDialog.beginOfSeries.text"));
    dateTimeBeginOfSeries = new DateTime(grpSeriendauer, SWT.BORDER | SWT.DROP_DOWN | SWT.LONG);
    dateTimeBeginOfSeries.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
    dateTimeBeginOfSeries.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            TimeTool tt = new TimeTool(serienTermin.getSeriesStartDate());
            wsc.setWeekNumberLabel(tt.get(Calendar.WEEK_OF_YEAR), tt.get(Calendar.YEAR));
            super.widgetSelected(e);
        }
    });
    Composite composite = new Composite(grpSeriendauer, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    GridLayout composite_layout = new GridLayout(2, false);
    composite_layout.marginHeight = 0;
    composite_layout.marginWidth = 0;
    composite.setLayout(composite_layout);
    btnEndsAfter = new Button(composite, SWT.RADIO);
    //$NON-NLS-1$
    btnEndsAfter.setText(Messages.getString("SerienTerminDialog.btnEndsAfter.text"));
    btnEndsAfter.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            serienTermin.setEndingType(EndingType.AFTER_N_OCCURENCES);
        }
    });
    Composite composite_1 = new Composite(composite, SWT.NONE);
    composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
    GridLayout composite_1_layout = new GridLayout(2, false);
    composite_1_layout.marginHeight = 0;
    composite_1_layout.marginWidth = 0;
    composite_1.setLayout(composite_1_layout);
    txtEndsAfterNOccurences = new Text(composite_1, SWT.BORDER);
    txtEndsAfterNOccurences.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    Label lblNewLabel = new Label(composite_1, SWT.NONE);
    //$NON-NLS-1$
    lblNewLabel.setText(Messages.getString("SerienTerminDialog.lblNewLabel.text"));
    btnEndsOn = new Button(composite, SWT.RADIO);
    //$NON-NLS-1$
    btnEndsOn.setText(Messages.getString("SerienTerminDialog.btnEndsOn.text"));
    btnEndsOn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            serienTermin.setEndingType(EndingType.ON_SPECIFIC_DATE);
        }
    });
    dateEndsOn = new DateTime(composite, SWT.BORDER);
    groupData = new Group(area, SWT.NONE);
    //$NON-NLS-1$
    groupData.setText(Messages.getString("SerienTerminDialog.groupData.text"));
    groupData.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    groupData.setLayout(new GridLayout(4, false));
    txtReason = new Text(groupData, SWT.BORDER);
    //$NON-NLS-1$
    txtReason.setMessage(Messages.getString("SerienTerminDialog.txtReason.message"));
    txtReason.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));
    Link linkCustomText = new Link(groupData, SWT.NONE);
    //$NON-NLS-1$
    linkCustomText.setText(Messages.getString("SerienTerminDialog.linkCustomText.text"));
    linkCustomText.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            InputDialog inp = new InputDialog(getShell(), "Enter Text", //$NON-NLS-1$
            "Enter Text/Name for the appointment", //$NON-NLS-1$
            "", //$NON-NLS-1$
            null);
            if (inp.open() == Dialog.OK) {
                txtContact.setText(inp.getValue());
                serienTermin.setContact(null);
            }
        }
    });
    Link linkSelectContact = new Link(groupData, SWT.NONE);
    //$NON-NLS-1$
    linkSelectContact.setText(Messages.getString("SerienTerminDialog.linkSelectContact.text"));
    linkSelectContact.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            KontaktSelektor ksl = new KontaktSelektor(getShell(), Kontakt.class, "Datum zuordnen", "Please select the contact the date is assigned to", Kontakt.DEFAULT_SORT);
            if (ksl.open() == Dialog.OK) {
                serienTermin.setContact((Kontakt) ksl.getSelection());
                if (serienTermin.getContact() != null) {
                    txtContact.setText(serienTermin.getContact().getLabel());
                }
            }
        }
    });
    Label lblArea = new Label(groupData, SWT.NONE);
    lblArea.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
    //$NON-NLS-1$
    lblArea.setText(Messages.getString("SerienTerminDialog.lblArea.text"));
    comboArea = new Combo(groupData, SWT.NONE);
    comboArea.setItems(Activator.getDefault().getResources());
    comboArea.setText(Activator.getDefault().getActResource());
    comboArea.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Activator.getDefault().setActResource(comboArea.getText());
        }
    });
    txtContact = new Text(groupData, SWT.BORDER);
    //$NON-NLS-1$
    txtContact.setMessage(Messages.getString("SerienTerminDialog.txtContact.message"));
    txtContact.setEditable(false);
    txtContact.setTextLimit(80);
    txtContact.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));
    m_bindingContext = initDataBindings();
    initDialog();
    if (noedit) {
        disableAll(area);
    }
    return area;
}
Example 12
Project: fabeclipse-master  File: TimeToolWorkbenchWindowControl.java View source code
@Override
protected Control createControl(Composite parent) {
    //		final ToolItem item = new ToolItem((ToolBar) parent, SWT.DROP_DOWN);
    final Button item = new Button(parent, SWT.ARROW | SWT.FLAT);
    //		item.setText(df.format(new Date()));
    //		final DateTime item = new DateTime(parent, SWT.TIME);
    //		final DateTime item = new DateTime(parent, SWT.TIME);
    //		final CalendarCombo item = new CalendarCombo(parent, SWT.READ_ONLY | SWT.FLAT);
    //		item.setDate(new Date());
    Timer timeUpdater = new Timer();
    TimerTask task = new TimerTask() {

        private String shown = "";

        private String ttShown = "";

        @Override
        public void run() {
            // if widget is disposed, cancel the timer
            if (item.isDisposed()) {
                this.cancel();
                return;
            }
            Date date = new Date();
            final String dateToShow = df.format(date);
            if (!shown.equals(dateToShow)) {
                shown = dateToShow;
                item.getDisplay().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        if (!item.isDisposed())
                            //								item.setText(dateToShow);
                            ;
                    }
                });
            }
            final String ttDateToShow = ttdf.format(date);
            if (!ttShown.equals(ttDateToShow)) {
                ttShown = ttDateToShow;
                item.getDisplay().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        if (!item.isDisposed())
                            item.setToolTipText(ttDateToShow);
                    }
                });
            }
        }
    };
    timeUpdater.scheduleAtFixedRate(task, 1000, 1000);
    return item;
}
Example 13
Project: jactr-eclipse-master  File: TimeFieldEditor.java View source code
@Override
protected void doFillIntoGrid(Composite parent, int numColumns) {
    getLabelControl(parent);
    if (_timeControl == null)
        _timeControl = new DateTime(parent, SWT.TIME | SWT.SHORT);
    GridData gd = new GridData();
    gd.horizontalSpan = numColumns - 1;
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    _timeControl.setLayoutData(gd);
}
Example 14
Project: riena-master  File: SwtControlRidgetMapper.java View source code
/**
	 * Sets the default mapping of UI control-classes to a ridget-classes
	 */
private void initDefaultMappings() {
    addMapping(MenuItem.class, MenuItemRidget.class, new MenuItemCondition());
    addMapping(MenuItem.class, MenuRidget.class, new MenuCondition());
    addMapping(ToolItem.class, ToolItemRidget.class);
    addMapping(Text.class, NumericTextRidget.class, new TypedTextWidgetCondition(UIControlsFactory.TYPE_NUMERIC));
    addMapping(Text.class, DecimalTextRidget.class, new TypedTextWidgetCondition(UIControlsFactory.TYPE_DECIMAL));
    addMapping(Text.class, DateTextRidget.class, new TypedTextWidgetCondition(UIControlsFactory.TYPE_DATE));
    addMapping(DatePickerComposite.class, DateTextRidget.class);
    addMapping(Text.class, TextRidget.class);
    addMapping(Label.class, LabelRidget.class);
    addMapping(Table.class, TableRidget.class);
    addMapping(Browser.class, BrowserRidget.class);
    addMapping(Button.class, ToggleButtonRidget.class, SWT.CHECK);
    addMapping(Button.class, ToggleButtonRidget.class, SWT.TOGGLE);
    addMapping(Button.class, ToggleButtonRidget.class, SWT.RADIO);
    addMapping(ImageButton.class, ImageButtonRidget.class);
    addMapping(Button.class, ActionRidget.class);
    addMapping(ChoiceComposite.class, SingleChoiceRidget.class, new SingleChoiceCondition());
    addMapping(ChoiceComposite.class, MultipleChoiceRidget.class, new MultipleChoiceCondition());
    addMapping(Composite.class, CompositeRidget.class, new CompositeWithBindingIdCondition());
    addMapping(Group.class, CompositeRidget.class, new CompositeWithBindingIdCondition());
    addMapping(CCombo.class, CComboRidget.class);
    addMapping(CompletionCombo.class, CompletionComboRidget.class);
    addMapping(Combo.class, ComboRidget.class);
    addMapping(DateTime.class, DateTimeRidget.class);
    addMapping(org.eclipse.swt.widgets.List.class, ListRidget.class);
    addMapping(Link.class, LinkRidget.class);
    addMapping(Tree.class, TreeRidget.class, new TreeWithoutColumnsCondition());
    addMapping(Tree.class, TreeTableRidget.class, new TreeWithColumnsCondition());
    addMapping(MessageBox.class, MessageBoxRidget.class);
    addMapping(Statusline.class, StatuslineRidget.class);
    addMapping(StatuslineNumber.class, StatuslineNumberRidget.class);
    addMapping(EmbeddedTitleBar.class, EmbeddedTitleBarRidget.class);
    addMapping(ModuleTitleBar.class, ModuleTitleBarRidget.class);
    addMapping(MasterDetailsComposite.class, MasterDetailsRidget.class);
    addMapping(Scale.class, ScaleRidget.class);
    addMapping(Spinner.class, SpinnerRidget.class);
    addMapping(Slider.class, SliderRidget.class);
    addMapping(ProgressBar.class, ProgressBarRidget.class);
    addMapping(InfoFlyout.class, InfoFlyoutRidget.class);
    addMapping(StatusMeterWidget.class, StatusMeterRidget.class);
    addMapping(Shell.class, ShellRidget.class);
}
Example 15
Project: swtbot-original-master  File: DateTimeTab.java View source code
/**
	 * Creates the "Example" widgets.
	 */
void createExampleWidgets() {
    /* Compute the widget style */
    int style = getDefaultStyle();
    if (dateButton.getSelection())
        style |= SWT.DATE;
    if (timeButton.getSelection())
        style |= SWT.TIME;
    if (calendarButton.getSelection())
        style |= SWT.CALENDAR;
    if (shortButton.getSelection())
        style |= SWT.SHORT;
    if (mediumButton.getSelection())
        style |= SWT.MEDIUM;
    if (longButton.getSelection())
        style |= SWT.LONG;
    if (borderButton.getSelection())
        style |= SWT.BORDER;
    /* Create the example widgets */
    dateTime1 = new DateTime(dateTimeGroup, style);
}
Example 16
Project: tdq-studio-se-master  File: DQRespositoryView.java View source code
@Override
protected Composite createViewerToolTipContentArea(Event event, ViewerCell cell, Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new RowLayout(SWT.VERTICAL));
    Text text = new Text(composite, SWT.SINGLE);
    text.setText(getText(event));
    text.setSize(100, 60);
    DateTime calendar = new DateTime(composite, SWT.CALENDAR);
    calendar.setEnabled(false);
    calendar.setSize(100, 100);
    composite.pack();
    return composite;
}
Example 17
Project: yang-ide-master  File: RevisionDialog.java View source code
@Override
protected Control createDialogArea(Composite parent) {
    Composite content = (Composite) super.createDialogArea(parent);
    dateTime = new DateTime(content, SWT.CALENDAR);
    Calendar cal = Calendar.getInstance();
    cal.setTime(revision);
    dateTime.setYear(cal.get(Calendar.YEAR));
    dateTime.setMonth(cal.get(Calendar.MONTH));
    dateTime.setDay(cal.get(Calendar.DATE));
    dateTime.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Calendar cal = Calendar.getInstance();
            cal.set(dateTime.getYear(), dateTime.getMonth(), dateTime.getDay());
            revision = cal.getTime();
        }
    });
    return content;
}
Example 18
Project: eclipse.platform.swt-master  File: DateTime.java View source code
void createDropDownButton() {
    down = new Button(this, SWT.ARROW | SWT.DOWN);
    OS.gtk_widget_set_can_focus(down.handle, false);
    down.addListener(SWT.Selection,  event -> {
        popupCalendar.calendarDisplayed = !isDropped();
        setFocus();
        dropDownCalendar(!isDropped());
    });
    popupListener =  event -> {
        if (event.widget == popupShell) {
            popupShellEvent(event);
            return;
        }
        if (event.widget == popupCalendar) {
            popupCalendarEvent(event);
            return;
        }
        if (event.widget == DateTime.this) {
            onDispose(event);
            return;
        }
        if (event.widget == getShell()) {
            getDisplay().asyncExec(() -> {
                if (isDisposed())
                    return;
                handleFocus(SWT.FocusOut);
            });
        }
    };
    popupFilter =  event -> {
        Shell shell = ((Control) event.widget).getShell();
        if (shell == DateTime.this.getShell()) {
            handleFocus(SWT.FocusOut);
        }
    };
}
Example 19
Project: atdl4j-master  File: SWTClockWidget.java View source code
public Widget createWidget(Composite parent, int style) {
    if (parameter instanceof UTCTimestampT || parameter instanceof TZTimestampT) {
        if (getAtdl4jOptions() == null || getAtdl4jOptions().isShowDateInputOnTimestampClockControl()) {
            showMonthYear = true;
            showDay = true;
        } else {
            showMonthYear = false;
            showDay = false;
            useNowAsDate = true;
        }
        showTime = true;
    } else if (parameter instanceof UTCDateOnlyT || parameter instanceof LocalMktDateT) {
        showMonthYear = true;
        showDay = true;
        showTime = false;
    } else if (parameter instanceof MonthYearT) {
        showMonthYear = true;
        showDay = false;
        showTime = false;
    } else if (parameter == null || parameter instanceof UTCTimeOnlyT || parameter instanceof TZTimeOnlyT) {
        showMonthYear = false;
        showDay = false;
        showTime = true;
    }
    boolean hasLabelOrCheckbox = false;
    if ((getAtdl4jOptions() != null) && (getAtdl4jOptions().isShowEnabledCheckboxOnOptionalClockControl()) && (parameter != null) && (UseT.OPTIONAL.equals(parameter.getUse()))) {
        hasLabelOrCheckbox = true;
        enabledButton = new Button(parent, SWT.CHECK);
        if (control.getLabel() != null) {
            enabledButton.setText(control.getLabel());
        }
        enabledButton.setToolTipText("Check to enable and specify or uncheck to disable this optional parameter value");
        // TODO disabled by default ????
        enabledButton.setSelection(false);
        enabledButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                applyEnabledSetting();
            }
        });
    } else // "required" -- use standard label without preceding checkbox
    {
        // label
        hasLabelOrCheckbox = true;
        label = new Label(parent, SWT.NONE);
        if (control.getLabel() != null)
            label.setText(control.getLabel());
    }
    Composite c = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, true);
    gridLayout.horizontalSpacing = 2;
    gridLayout.verticalSpacing = 0;
    gridLayout.marginLeft = gridLayout.marginRight = 0;
    gridLayout.marginTop = gridLayout.marginBottom = 0;
    gridLayout.marginWidth = gridLayout.marginHeight = 0;
    c.setLayout(gridLayout);
    GridData controlGD = new GridData(SWT.FILL, SWT.FILL, false, false);
    controlGD.horizontalSpan = hasLabelOrCheckbox ? 1 : 2;
    c.setLayoutData(controlGD);
    GridData clockGD = new GridData(SWT.FILL, SWT.FILL, false, false);
    clockGD.horizontalSpan = (showMonthYear && showTime) ? 1 : 2;
    // date clock
    if (showMonthYear) {
        dateClock = new org.eclipse.swt.widgets.DateTime(c, style | SWT.BORDER | SWT.DATE | (showDay ? SWT.MEDIUM : SWT.SHORT));
        dateClock.setLayoutData(clockGD);
    }
    // time clock
    if (showTime) {
        timeClock = new org.eclipse.swt.widgets.DateTime(c, style | SWT.BORDER | SWT.TIME | SWT.MEDIUM);
        timeClock.setLayoutData(clockGD);
    }
    // tooltip
    String tooltip = getTooltip();
    if (tooltip != null) {
        if (showMonthYear)
            dateClock.setToolTipText(tooltip);
        if (showTime)
            timeClock.setToolTipText(tooltip);
        if (label != null)
            label.setToolTipText(tooltip);
        if (enabledButton != null && tooltip != null)
            enabledButton.setToolTipText(tooltip);
    }
    // init value, if applicable
    setAndRenderInitValue((XMLGregorianCalendar) ControlHelper.getInitValue(control, getAtdl4jOptions()), ((ClockT) control).getInitValueMode());
    if (enabledButton != null) {
        applyEnabledSetting();
    }
    return parent;
}
Example 20
Project: elexis-3-core-master  File: MedicationComposite.java View source code
private void medicationDetailComposite() {
    compositeMedicationDetail = new Composite(this, SWT.BORDER);
    GridLayout gl_compositeMedicationDetail = new GridLayout(6, false);
    gl_compositeMedicationDetail.marginBottom = 5;
    gl_compositeMedicationDetail.marginRight = 5;
    gl_compositeMedicationDetail.marginLeft = 5;
    gl_compositeMedicationDetail.marginTop = 5;
    gl_compositeMedicationDetail.marginWidth = 0;
    gl_compositeMedicationDetail.marginHeight = 0;
    compositeMedicationDetail.setLayout(gl_compositeMedicationDetail);
    compositeMedicationDetailLayoutData = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    compositeMedicationDetail.setLayoutData(compositeMedicationDetailLayoutData);
    {
        stackCompositeDosage = new Composite(compositeMedicationDetail, SWT.NONE);
        stackCompositeDosage.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        stackLayoutDosage = new StackLayout();
        stackCompositeDosage.setLayout(stackLayoutDosage);
        compositeDayTimeDosage = new Composite(stackCompositeDosage, SWT.NONE);
        compositeDayTimeDosage.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        GridLayout gl_compositeDayTimeDosage = new GridLayout(7, false);
        gl_compositeDayTimeDosage.marginWidth = 0;
        gl_compositeDayTimeDosage.marginHeight = 0;
        gl_compositeDayTimeDosage.verticalSpacing = 1;
        gl_compositeDayTimeDosage.horizontalSpacing = 0;
        compositeDayTimeDosage.setLayout(gl_compositeDayTimeDosage);
        txtMorning = new Text(compositeDayTimeDosage, SWT.BORDER);
        //varchar 255 divided by 4 minus 3 '-'
        txtMorning.setTextLimit(60);
        txtMorning.setMessage("morn");
        GridData gd_txtMorning = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
        gd_txtMorning.widthHint = 40;
        txtMorning.setLayoutData(gd_txtMorning);
        txtMorning.addModifyListener(new SignatureArrayModifyListener(0));
        Label lblStop = new Label(compositeDayTimeDosage, SWT.HORIZONTAL);
        lblStop.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblStop.setText("-");
        txtNoon = new Text(compositeDayTimeDosage, SWT.BORDER);
        txtNoon.setTextLimit(60);
        txtNoon.setMessage("noon");
        GridData gd_txtNoon = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
        gd_txtNoon.widthHint = 40;
        txtNoon.setLayoutData(gd_txtNoon);
        txtNoon.addModifyListener(new SignatureArrayModifyListener(1));
        Label lblStop2 = new Label(compositeDayTimeDosage, SWT.NONE);
        lblStop2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblStop2.setText("-");
        txtEvening = new Text(compositeDayTimeDosage, SWT.BORDER);
        txtEvening.setTextLimit(60);
        txtEvening.setMessage("eve");
        GridData gd_txtEvening = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
        gd_txtEvening.widthHint = 40;
        txtEvening.setLayoutData(gd_txtEvening);
        txtEvening.addModifyListener(new SignatureArrayModifyListener(2));
        txtEvening.addKeyListener(new KeyAdapter() {

            public void keyPressed(KeyEvent e) {
                switch(e.keyCode) {
                    case SWT.CR:
                        if (btnConfirm.isEnabled())
                            applyDetailChanges();
                        break;
                    default:
                        break;
                }
            }

            ;
        });
        Label lblStop3 = new Label(compositeDayTimeDosage, SWT.NONE);
        lblStop3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblStop3.setText("-");
        txtNight = new Text(compositeDayTimeDosage, SWT.BORDER);
        txtNight.setTextLimit(60);
        txtNight.setMessage("night");
        GridData gd_txtNight = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
        gd_txtNight.widthHint = 40;
        txtNight.setLayoutData(gd_txtNight);
        txtNight.addModifyListener(new SignatureArrayModifyListener(3));
        txtNight.addKeyListener(new KeyAdapter() {

            public void keyPressed(KeyEvent e) {
                switch(e.keyCode) {
                    case SWT.CR:
                        if (btnConfirm.isEnabled())
                            applyDetailChanges();
                        break;
                    default:
                        break;
                }
            }

            ;
        });
        compositeFreeTextDosage = new Composite(stackCompositeDosage, SWT.NONE);
        compositeFreeTextDosage.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        GridLayout gl_compositeFreeTextDosage = new GridLayout(1, false);
        gl_compositeFreeTextDosage.marginWidth = 0;
        gl_compositeFreeTextDosage.marginHeight = 0;
        gl_compositeFreeTextDosage.verticalSpacing = 1;
        gl_compositeFreeTextDosage.horizontalSpacing = 0;
        compositeFreeTextDosage.setLayout(gl_compositeFreeTextDosage);
        txtFreeText = new Text(compositeFreeTextDosage, SWT.BORDER);
        txtFreeText.setMessage(Messages.MedicationComposite_freetext);
        GridData gd_txtFreeText = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
        gd_txtFreeText.widthHint = 210;
        txtFreeText.setLayoutData(gd_txtFreeText);
        txtFreeText.setTextLimit(255);
        txtFreeText.addModifyListener(new SignatureArrayModifyListener(0));
        txtFreeText.addKeyListener(new KeyAdapter() {

            public void keyPressed(KeyEvent e) {
                switch(e.keyCode) {
                    case SWT.CR:
                        if (btnConfirm.isEnabled())
                            applyDetailChanges();
                        break;
                    default:
                        break;
                }
            }

            ;
        });
        stackLayoutDosage.topControl = compositeDayTimeDosage;
        stackCompositeDosage.layout();
    }
    Button btnDoseSwitch = new Button(compositeMedicationDetail, SWT.PUSH);
    btnDoseSwitch.setImage(Images.IMG_SYNC.getImage());
    btnDoseSwitch.setToolTipText(Messages.MedicationComposite_tooltipDosageType);
    btnDoseSwitch.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (stackLayoutDosage.topControl == compositeDayTimeDosage) {
                stackLayoutDosage.topControl = compositeFreeTextDosage;
            } else {
                stackLayoutDosage.topControl = compositeDayTimeDosage;
            }
            stackCompositeDosage.layout();
        }

        ;
    });
    timeStopped = new DateTime(compositeMedicationDetail, SWT.TIME);
    timeStopped.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            activateConfirmButton(true);
        }
    });
    dateStopped = new DateTime(compositeMedicationDetail, SWT.DATE);
    dateStopped.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            activateConfirmButton(true);
        }
    });
    DataBindingContext dbc = new DataBindingContext();
    IObservableValue dateTimeStopObservable = PojoProperties.value("endTime", Date.class).observeDetail(selectedMedication);
    IObservableValue timeObservable = WidgetProperties.selection().observe(timeStopped);
    IObservableValue dateObservable = WidgetProperties.selection().observe(dateStopped);
    dbc.bindValue(new DateAndTimeObservableValue(dateObservable, timeObservable), dateTimeStopObservable);
    btnStopMedication = new Button(compositeMedicationDetail, SWT.FLAT | SWT.TOGGLE);
    btnStopMedication.setImage(Images.IMG_STOP.getImage());
    btnStopMedication.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
    btnStopMedication.setToolTipText(Messages.MedicationComposite_btnStop);
    btnStopMedication.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (btnStopMedication.getSelection()) {
                stackLayout.topControl = compositeStopMedicationTextDetails;
                // change color
                compositeMedicationDetail.setBackground(stopBGColor);
                compositeStopMedicationTextDetails.setBackground(stopBGColor);
                dateStopped.setEnabled(true);
                timeStopped.setEnabled(true);
                // highlight confirm button
                activateConfirmButton(true);
            } else {
                // change color
                compositeMedicationDetail.setBackground(defaultBGColor);
                compositeStopMedicationTextDetails.setBackground(defaultBGColor);
                stackLayout.topControl = compositeMedicationTextDetails;
                dateStopped.setEnabled(false);
                timeStopped.setEnabled(false);
                //set confirm button defaults
                activateConfirmButton(false);
            }
            stackedMedicationDetailComposite.layout();
        }
    });
    btnConfirm = new Button(compositeMedicationDetail, SWT.FLAT);
    btnConfirm.setText(Messages.MedicationComposite_btnConfirm);
    GridData gdBtnConfirm = new GridData();
    gdBtnConfirm.horizontalIndent = 5;
    gdBtnConfirm.horizontalAlignment = SWT.RIGHT;
    btnConfirm.setLayoutData(gdBtnConfirm);
    btnConfirm.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            applyDetailChanges();
        }
    });
    btnConfirm.setEnabled(false);
    stackedMedicationDetailComposite = new Composite(compositeMedicationDetail, SWT.NONE);
    stackedMedicationDetailComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 5, 1));
    stackLayout = new StackLayout();
    stackedMedicationDetailComposite.setLayout(stackLayout);
    // --- medication detail
    compositeMedicationTextDetails = new Composite(stackedMedicationDetailComposite, SWT.NONE);
    GridLayout gl_compositeMedicationTextDetails = new GridLayout(1, false);
    gl_compositeMedicationTextDetails.marginWidth = 0;
    gl_compositeMedicationTextDetails.horizontalSpacing = 0;
    gl_compositeMedicationTextDetails.marginHeight = 0;
    compositeMedicationTextDetails.setLayout(gl_compositeMedicationTextDetails);
    compositeMedicationTextDetails.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 5, 1));
    txtIntakeOrder = new Text(compositeMedicationTextDetails, SWT.BORDER);
    txtIntakeOrder.setMessage(Messages.MedicationComposite_txtIntakeOrder_message);
    txtIntakeOrder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    IObservableValue txtIntakeOrderObservable = WidgetProperties.text(SWT.Modify).observeDelayed(100, txtIntakeOrder);
    IObservableValue intakeOrderObservable = PojoProperties.value("remark", String.class).observeDetail(selectedMedication);
    dbc.bindValue(txtIntakeOrderObservable, intakeOrderObservable, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE));
    txtIntakeOrderObservable.addChangeListener(new IChangeListener() {

        @Override
        public void handleChange(ChangeEvent event) {
            activateConfirmButton(true);
        }
    });
    txtDisposalComment = new Text(compositeMedicationTextDetails, SWT.BORDER);
    txtDisposalComment.setMessage(Messages.MedicationComposite_txtComment_message);
    txtDisposalComment.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    IObservableValue txtCommentObservable = WidgetProperties.text(SWT.Modify).observeDelayed(100, txtDisposalComment);
    IObservableValue commentObservable = PojoProperties.value("disposalComment", String.class).observeDetail(selectedMedication);
    dbc.bindValue(txtCommentObservable, commentObservable, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE));
    txtCommentObservable.addChangeListener(new IChangeListener() {

        @Override
        public void handleChange(ChangeEvent event) {
            activateConfirmButton(true);
        }
    });
    stackLayout.topControl = compositeMedicationTextDetails;
    // --- stop medication detail
    compositeStopMedicationTextDetails = new Composite(stackedMedicationDetailComposite, SWT.NONE);
    GridLayout gl_compositeStopMedicationTextDetails = new GridLayout(1, false);
    gl_compositeStopMedicationTextDetails.marginWidth = 0;
    gl_compositeStopMedicationTextDetails.horizontalSpacing = 0;
    gl_compositeStopMedicationTextDetails.marginHeight = 0;
    compositeStopMedicationTextDetails.setLayout(gl_compositeStopMedicationTextDetails);
    compositeStopMedicationTextDetails.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 5, 1));
    txtStopComment = new Text(compositeStopMedicationTextDetails, SWT.BORDER);
    txtStopComment.setMessage(Messages.MedicationComposite_stopReason);
    txtStopComment.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    IObservableValue txtStopCommentObservableUi = WidgetProperties.text(SWT.Modify).observeDelayed(100, txtStopComment);
    IObservableValue txtStopCommentObservable = PojoProperties.value("stopReason", String.class).observeDetail(selectedMedication);
    dbc.bindValue(txtStopCommentObservableUi, txtStopCommentObservable, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE));
    txtStopCommentObservableUi.addChangeListener(new IChangeListener() {

        @Override
        public void handleChange(ChangeEvent event) {
            activateConfirmButton(true);
        }
    });
}
Example 21
Project: ITK-Stock-master  File: IntervalDataCandleComposite.java View source code
private void initWindow(final Composite panel) {
    Label labelTitle = new Label(panel, SWT.NONE);
    labelTitle.setText("Ticker name");
    labelTitle.setLayoutData(new GridData(0));
    ticker = new Text(panel, SWT.BORDER);
    ticker.setLayoutData(new GridData(1));
    Label labelFrom = new Label(panel, SWT.NONE);
    labelFrom.setText("From:");
    labelFrom.setLayoutData(new GridData(2));
    fromdate = new DateTime(panel, SWT.BORDER);
    fromdate.setLayoutData(new GridData(3));
    Label labelTo = new Label(panel, SWT.NONE);
    labelTo.setText("To:");
    labelTo.setLayoutData(new GridData(4));
    todate = new DateTime(panel, SWT.BORDER);
    todate.setLayoutData(new GridData(5));
    button = new Button(panel, SWT.NONE);
    button.setText("OK");
    button.setLayoutData(new GridData(6));
    button.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            addCandlestickChart(ticker.getText().toUpperCase(), new StockDate(fromdate.getYear(), fromdate.getMonth() + 1, fromdate.getDay()), new StockDate(todate.getYear(), todate.getMonth() + 1, todate.getDay()));
            panel.setVisible(false);
        }
    });
    Label label = new Label(panel, SWT.NONE);
    label.setLayoutData(new GridData(7));
    Button modedays = new Button(panel, SWT.RADIO);
    modedays.setText("Daily");
    modedays.setLayoutData(new GridData(8));
    Button modehours = new Button(panel, SWT.RADIO);
    modehours.setText("Hourly");
    modehours.setLayoutData(new GridData(9));
    modehours.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            MODE = 11;
        }
    });
    modedays.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            MODE = 10;
        }
    });
    //presets
    fromdate.setYear(2006);
    fromdate.setMonth(5);
    fromdate.setDay(6);
    ticker.setText("mol");
    todate.setYear(2006);
    todate.setMonth(5);
    todate.setDay(7);
    //enter key listener
    ticker.addKeyListener(listener);
    todate.addKeyListener(listener);
    fromdate.addKeyListener(listener);
}
Example 22
Project: opal-master  File: PTDateEditor.java View source code
/**
	 * @see org.mihalis.opal.propertyTable.editor.PTEditor#render(org.mihalis.opal.propertyTable.PTWidget,
	 *      org.eclipse.swt.widgets.Item,
	 *      org.mihalis.opal.propertyTable.PTProperty)
	 */
@Override
public ControlEditor render(final PTWidget widget, final Item item, final PTProperty property) {
    ControlEditor editor;
    if (widget.getWidget() instanceof Table) {
        editor = new TableEditor((Table) widget.getWidget());
    } else {
        editor = new TreeEditor((Tree) widget.getWidget());
    }
    final DateTime dateEditor = new DateTime(widget.getWidget(), SWT.DATE | SWT.MEDIUM | SWT.DROP_DOWN);
    final Date date = (Date) property.getValue();
    final Calendar c = Calendar.getInstance();
    if (date != null) {
        c.setTime(date);
        dateEditor.setDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH));
    }
    dateEditor.addSelectionListener(new SelectionAdapter() {

        /**
			 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
			 */
        @Override
        public void widgetSelected(final SelectionEvent e) {
            c.setTime(new Date());
            c.clear();
            c.set(dateEditor.getYear(), dateEditor.getMonth(), dateEditor.getDay());
            property.setValue(c.getTime());
        }
    });
    dateEditor.addListener(SWT.FocusIn, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            widget.updateDescriptionPanel(property);
        }
    });
    editor.grabHorizontal = true;
    editor.horizontalAlignment = SWT.LEFT;
    if (widget.getWidget() instanceof Table) {
        ((TableEditor) editor).setEditor(dateEditor, (TableItem) item, 1);
    } else {
        ((TreeEditor) editor).setEditor(dateEditor, (TreeItem) item, 1);
    }
    dateEditor.setEnabled(property.isEnabled());
    return editor;
}
Example 23
Project: rap-osgi-tutorial-ece2011-master  File: DatePicker.java View source code
private DateTime createCalendar() {
    DateTime result = new DateTime(shell, SWT.CALENDAR | SWT.BORDER);
    result.addSelectionListener(new SelectionAdapter() {

        private static final long serialVersionUID = 1L;

        @Override
        public void widgetSelected(SelectionEvent e) {
            triggerSelectedDateHasChanged();
        }
    });
    return result;
}
Example 24
Project: rmf-master  File: FilterControlDate.java View source code
private void showControl(int controlId, boolean show) {
    if (control == null)
        control = new DateTime[2];
    if (show && control[controlId] == null) {
        control[controlId] = new DateTime(this, SWT.DATE | SWT.DROP_DOWN | SWT.BORDER);
        GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
        control[controlId].setLayoutData(layoutData);
    }
    if (!show && control[controlId] != null) {
        control[controlId].dispose();
        control[controlId] = null;
    }
}
Example 25
Project: RWT_CONFIG_ADMIN_EXAMPLE-master  File: DatePicker.java View source code
private DateTime createCalendar() {
    DateTime result = new DateTime(shell, SWT.CALENDAR | SWT.BORDER);
    result.addSelectionListener(new SelectionAdapter() {

        private static final long serialVersionUID = 1L;

        @Override
        public void widgetSelected(SelectionEvent e) {
            triggerSelectedDateHasChanged();
        }
    });
    return result;
}
Example 26
Project: sapphire-master  File: CalendarBrowseActionHandler.java View source code
@Override
protected Control createContentArea(final Composite parent) {
    this.calendar = new DateTime(parent, SWT.CALENDAR);
    final Date existing = (Date) property().content();
    if (existing != null) {
        final Calendar cal = Calendar.getInstance();
        cal.setTime(existing);
        this.calendar.setYear(cal.get(Calendar.YEAR));
        this.calendar.setMonth(cal.get(Calendar.MONTH));
        this.calendar.setDay(cal.get(Calendar.DATE));
    }
    this.calendar.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(final MouseEvent event) {
            registerSelectionAndClose();
        }
    });
    this.calendar.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(final KeyEvent event) {
            if (event.character == SWT.CR) {
                registerSelectionAndClose();
            }
        }
    });
    return calendar;
}
Example 27
Project: swtbot-master  File: SWTBotDateTimeTest.java View source code
@Test
public void sendsNotification() throws Exception {
    bot.checkBox("Listen").click();
    SWTBotDateTime dateTime = bot.dateTimeInGroup("DateTime");
    dateTime.setDate(new Date());
    // FIXME https://bugs.eclipse.org/bugs/show_bug.cgi?id=206715
    // FIXED > 071107 for all platforms.
    String expectedLinux = "Selection [13]: SelectionEvent{DateTime";
    String expectedWindows = "Selection [13]: SelectionEvent{DateTime {DateTime";
    String text = bot.textInGroup("Listeners").getText();
    assertThat(text, AnyOf.anyOf(containsString(expectedLinux), containsString(expectedWindows)));
    assertThat(text, containsString(" data=null item=null detail=0 x=0 y=0 width=0 height=0 stateMask=" + toStateMask(0, dateTime.widget) + " text=null doit=true}"));
}
Example 28
Project: bpmn2-modeler-master  File: DateTimeObjectEditor.java View source code
protected Control createDialogArea(Composite parent) {
    Composite composite = createMyComposite(parent);
    if ((style & (SWT.CALENDAR | SWT.DATE | SWT.TIME)) == 0)
        style = SWT.CALENDAR | SWT.TIME;
    if ((style & SWT.CALENDAR) != 0) {
        calendar = new DateTime(composite, SWT.CALENDAR);
        calendar.setDate(result.getYear(), result.getMonth(), result.getDay());
    } else if ((style & SWT.DATE) != 0) {
        date = new DateTime(composite, SWT.DATE);
        date.setDate(result.getYear(), result.getMonth(), result.getDay());
    }
    if ((style & SWT.TIME) != 0) {
        time = new DateTime(composite, SWT.TIME);
        time.setTime(result.getHours(), result.getMinutes(), result.getSeconds());
    }
    return composite;
}
Example 29
Project: eclipse4book-master  File: EditorPart.java View source code
@PostConstruct
public void createControls(Composite parent, ITodoService todoService) {
    // extract the id of the todo item
    String string = part.getPersistedState().get(Todo.FIELD_ID);
    Long idOfTodo = Long.valueOf(string);
    // retrieve the todo based on the persistedState
    todo = todoService.getTodo(idOfTodo);
    GridLayout gl_parent = new GridLayout(2, false);
    gl_parent.marginRight = 10;
    gl_parent.marginLeft = 10;
    gl_parent.horizontalSpacing = 10;
    gl_parent.marginWidth = 0;
    parent.setLayout(gl_parent);
    Label lblSummary = new Label(parent, SWT.NONE);
    lblSummary.setText("Summary");
    txtSummary = new Text(parent, SWT.BORDER);
    txtSummary.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Label lblDescription = new Label(parent, SWT.NONE);
    lblDescription.setText("Description");
    txtDescription = new Text(parent, SWT.BORDER | SWT.MULTI);
    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd.heightHint = 122;
    txtDescription.setLayoutData(gd);
    Label lblNewLabel = new Label(parent, SWT.NONE);
    lblNewLabel.setText("Due Date");
    dateTime = new DateTime(parent, SWT.BORDER);
    dateTime.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    new Label(parent, SWT.NONE);
    btnDone = new Button(parent, SWT.CHECK);
    btnDone.setText("Done");
    Button button = new Button(parent, SWT.PUSH);
    button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    button.setText("Save");
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ParameterizedCommand command = commandService.createCommand("org.eclipse.ui.file.saveAll", null);
            handlerService.executeHandler(command);
        }
    });
    updateUserInterface(todo);
}
Example 30
Project: olca-app-master  File: DataBinding.java View source code
public void onDate(final Supplier<?> supplier, final String property, final DateTime dateTime) {
    log.trace("Register data binding - date - {}", property);
    if (supplier == null || property == null || dateTime == null)
        return;
    initValue(supplier.get(), property, dateTime);
    dateTime.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            setDateValue(supplier.get(), property, dateTime);
            editorChange();
        }
    });
}
Example 31
Project: quantcomponents-master  File: NewHistoricalDataPage3.java View source code
@Override
public void createControl(Composite parent) {
    // root container
    Composite rootContainer = new Composite(parent, SWT.NULL);
    GridLayout rootLayout = new GridLayout();
    rootLayout.verticalSpacing = 15;
    rootLayout.numColumns = 1;
    rootContainer.setLayout(rootLayout);
    // Data parameters
    Composite dataSpecContainer = new Composite(rootContainer, SWT.NULL);
    GridLayout dataSpecContainerLayout = new GridLayout();
    dataSpecContainerLayout.numColumns = 4;
    dataSpecContainer.setLayout(dataSpecContainerLayout);
    Label periodLabel = new Label(dataSpecContainer, SWT.NULL);
    periodLabel.setText("Period Length");
    periodEdit = new PeriodCombo(dataSpecContainer, SWT.NULL);
    GridData periodLayoutData = new GridData(GridData.FILL_HORIZONTAL);
    periodLayoutData.horizontalSpan = 3;
    periodEdit.setLayoutData(periodLayoutData);
    Label dataTypeLabel = new Label(dataSpecContainer, SWT.NULL);
    dataTypeLabel.setText("Data Type");
    dataTypeEdit = new Combo(dataSpecContainer, SWT.READ_ONLY);
    GridData dataTypeLayoutData = new GridData();
    dataTypeLayoutData.horizontalSpan = 3;
    dataTypeEdit.setLayoutData(dataTypeLayoutData);
    String[] dataTypeValues = new String[marketDataManager.availableDataTypes().length];
    for (int i = 0; i < marketDataManager.availableDataTypes().length; i++) {
        dataTypeValues[i] = marketDataManager.availableDataTypes()[i].name();
    }
    dataTypeEdit.setItems(dataTypeValues);
    Label barSizeLabel = new Label(dataSpecContainer, SWT.NULL);
    barSizeLabel.setText("Bar Size");
    barSizeEdit = new Combo(dataSpecContainer, SWT.READ_ONLY);
    String[] barSizeValues = new String[marketDataManager.availableBarSizes().length];
    for (int i = 0; i < marketDataManager.availableBarSizes().length; i++) {
        barSizeValues[i] = marketDataManager.availableBarSizes()[i].name();
    }
    barSizeEdit.setItems(barSizeValues);
    afterHoursButton = new Button(dataSpecContainer, SWT.CHECK);
    afterHoursButton.setText("Include after-hours");
    afterHoursButton.setSelection(false);
    realtimeButton = new Button(dataSpecContainer, SWT.CHECK);
    realtimeButton.setText("Realtime update");
    realtimeButton.setSelection(false);
    realtimeButton.setEnabled(marketDataManager instanceof IRealTimeMarketDataManager);
    endDateLabel = new Label(dataSpecContainer, SWT.NULL);
    endDateLabel.setText("End Date");
    endDateEdit = new DateTime(dataSpecContainer, SWT.DROP_DOWN | SWT.DATE | SWT.LONG);
    GridData endDateLayoutData = new GridData();
    endDateLayoutData.horizontalSpan = 3;
    endDateEdit.setLayoutData(endDateLayoutData);
    endTimeLabel = new Label(dataSpecContainer, SWT.NULL);
    endTimeLabel.setText("End Time");
    endTimeEdit = new DateTime(dataSpecContainer, SWT.DROP_DOWN | SWT.TIME | SWT.MEDIUM);
    midnightButton = new Button(dataSpecContainer, SWT.PUSH);
    midnightButton.setText("midnight");
    GridData midnightLayoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    midnightButton.setLayoutData(midnightLayoutData);
    midnightButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            endTimeEdit.setTime(0, 0, 0);
        }
    });
    nowButton = new Button(dataSpecContainer, SWT.PUSH);
    nowButton.setText("now");
    GridData nowLayoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    nowButton.setLayoutData(nowLayoutData);
    nowButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            Calendar now = Calendar.getInstance(contractTimeZone);
            endDateEdit.setDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DATE));
            endTimeEdit.setTime(now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND));
        }
    });
    if (marketDataManager instanceof IRealTimeMarketDataManager) {
        realtimeButton.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean enableEndDateTime = !realtimeButton.getSelection();
                endDateLabel.setEnabled(enableEndDateTime);
                endDateEdit.setEnabled(enableEndDateTime);
                endTimeLabel.setEnabled(enableEndDateTime);
                endTimeEdit.setEnabled(enableEndDateTime);
                timeZoneLabel.setEnabled(enableEndDateTime);
                timeZoneEdit.setEnabled(enableEndDateTime);
                midnightButton.setEnabled(enableEndDateTime);
                nowButton.setEnabled(enableEndDateTime);
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
    }
    timeZoneLabel = new Label(dataSpecContainer, SWT.NULL);
    timeZoneLabel.setText("Time zone");
    timeZoneEdit = new Text(dataSpecContainer, SWT.NULL);
    GridData timeZoneEditLayoutData = new GridData(GridData.FILL_HORIZONTAL);
    timeZoneEdit.setLayoutData(timeZoneEditLayoutData);
    initialize();
    setControl(rootContainer);
}
Example 32
Project: scout-master  File: AlertDetailListView.java View source code
public void createPartControl(Composite parent) {
    parent.setLayout(new GridLayout(1, true));
    Group parentGroup = new Group(parent, SWT.NONE);
    parentGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    GridLayout layout = new GridLayout(10, false);
    parentGroup.setLayout(layout);
    Label label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("Date");
    dateText = new Text(parentGroup, SWT.READ_ONLY | SWT.BORDER);
    dateText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    dateText.setBackground(ColorUtil.getInstance().getColor("white"));
    dateText.setText(DateUtil.format(TimeUtil.getCurrentTime(serverId), "yyyy-MM-dd"));
    Button button = new Button(parentGroup, SWT.PUSH);
    button.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    button.setImage(Images.calendar);
    button.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            switch(event.type) {
                case SWT.Selection:
                    Display display = Display.getCurrent();
                    if (display == null) {
                        display = Display.getDefault();
                    }
                    CalendarDialog dialog = new CalendarDialog(display, AlertDetailListView.this);
                    dialog.show(dateText.getLocation().x, dateText.getLocation().y, DateUtil.yyyymmdd(yyyymmdd));
                    break;
            }
        }
    });
    long now = TimeUtil.getCurrentTime(serverId);
    label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("From");
    fromTime = new DateTime(parentGroup, SWT.TIME | SWT.SHORT);
    fromTime.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    fromTime.setHours(DateUtil.getHour(now) - 1);
    fromTime.setMinutes(DateUtil.getMin(now));
    label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("To");
    toTime = new DateTime(parentGroup, SWT.TIME | SWT.SHORT);
    toTime.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    toTime.setHours(DateUtil.getHour(now));
    toTime.setMinutes(DateUtil.getMin(now));
    label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("Count(Max:1000)");
    maxCountText = new Text(parentGroup, SWT.BORDER);
    maxCountText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    maxCountText.setText("500");
    maxCountText.setToolTipText("1~1000");
    maxCountText.addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
            String count = maxCountText.getText();
            if (StringUtil.isEmpty(count)) {
                return;
            }
            try {
                Integer.valueOf(count);
            } catch (Exception ex) {
                MessageDialog.openError(maxCountText.getShell(), "Invalid Count", "Count is allowed only digits");
                maxCountText.setText("");
            }
        }

        public void keyPressed(KeyEvent e) {
        }
    });
    button = new Button(parentGroup, SWT.PUSH);
    button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    button.setText("&Search");
    button.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            load();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("Level");
    GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gridData.horizontalSpan = 2;
    levelCombo = new Combo(parentGroup, SWT.READ_ONLY);
    levelCombo.setLayoutData(gridData);
    levelCombo.add("ALL");
    StringEnumer itr = AlertLevel.names();
    while (itr.hasMoreElements()) {
        levelCombo.add(itr.nextString());
    }
    levelCombo.select(0);
    label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("Object");
    objText = new Text(parentGroup, SWT.BORDER);
    objText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("Key");
    keyText = new Text(parentGroup, SWT.BORDER);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gridData.horizontalSpan = 3;
    keyText.setLayoutData(gridData);
    button = new Button(parentGroup, SWT.PUSH);
    button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    button.setText("&Clear");
    button.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            levelCombo.select(0);
            objText.setText("");
            keyText.setText("");
            viewer.getTable().removeAll();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    Composite tableComposite = new Composite(parent, SWT.NONE);
    tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    tableColumnLayout = new TableColumnLayout();
    tableComposite.setLayout(tableColumnLayout);
    viewer = new TableViewer(tableComposite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    createColumns();
    final Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setComparator(new ColumnLabelSorter(viewer));
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            StructuredSelection sel = (StructuredSelection) event.getSelection();
            Object o = sel.getFirstElement();
            if (o instanceof AlertData) {
                AlertData data = (AlertData) o;
                Display display = Display.getCurrent();
                if (display == null) {
                    display = Display.getDefault();
                }
                AlertNotifierDialog alertDialog = new AlertNotifierDialog(display, serverId);
                alertDialog.setObjName(data.object);
                alertDialog.setPack(data.toPack());
                alertDialog.show(getViewSite().getShell().getBounds());
            } else {
                System.out.println(o);
            }
        }
    });
    IToolBarManager man = getViewSite().getActionBars().getToolBarManager();
    man.add(new Action("Export CSV", ImageUtil.getImageDescriptor(Images.csv)) {

        public void run() {
            Server server = ServerManager.getInstance().getServer(serverId);
            FileDialog dialog = new FileDialog(getViewSite().getShell(), SWT.SAVE);
            dialog.setOverwrite(true);
            String filename = "[" + server.getName() + "]" + yyyymmdd + "_" + fromTime.getHours() + fromTime.getMinutes() + "_" + toTime.getHours() + toTime.getMinutes() + ".csv";
            dialog.setFileName(filename);
            dialog.setFilterExtensions(new String[] { "*.csv", "*.*" });
            dialog.setFilterNames(new String[] { "CSV File(*.csv)", "All Files" });
            String fileSelected = dialog.open();
            if (fileSelected != null) {
                CSVWriter cw = null;
                try {
                    cw = new CSVWriter(new FileWriter(fileSelected));
                    int colCnt = viewer.getTable().getColumnCount();
                    List<String> list = new ArrayList<String>();
                    for (int i = 0; i < colCnt; i++) {
                        TableColumn column = viewer.getTable().getColumn(i);
                        list.add(column.getText());
                    }
                    cw.writeNext(list.toArray(new String[list.size()]));
                    cw.flush();
                    TableItem[] items = viewer.getTable().getItems();
                    if (items != null && items.length > 0) {
                        for (TableItem item : items) {
                            list.clear();
                            for (int i = 0; i < colCnt; i++) {
                                list.add(item.getText(i));
                            }
                            cw.writeNext(list.toArray(new String[list.size()]));
                            cw.flush();
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                } finally {
                    try {
                        if (cw != null) {
                            cw.close();
                        }
                    } catch (Throwable th) {
                    }
                }
            }
        }
    });
}
Example 33
Project: scouter-master  File: AlertDetailListView.java View source code
public void createPartControl(Composite parent) {
    parent.setLayout(new GridLayout(1, true));
    Group parentGroup = new Group(parent, SWT.NONE);
    parentGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    GridLayout layout = new GridLayout(10, false);
    parentGroup.setLayout(layout);
    Label label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("Date");
    dateText = new Text(parentGroup, SWT.READ_ONLY | SWT.BORDER);
    dateText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    dateText.setBackground(ColorUtil.getInstance().getColor("white"));
    dateText.setText(DateUtil.format(TimeUtil.getCurrentTime(serverId), "yyyy-MM-dd"));
    Button button = new Button(parentGroup, SWT.PUSH);
    button.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    button.setImage(Images.calendar);
    button.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            switch(event.type) {
                case SWT.Selection:
                    Display display = Display.getCurrent();
                    if (display == null) {
                        display = Display.getDefault();
                    }
                    CalendarDialog dialog = new CalendarDialog(display, AlertDetailListView.this);
                    dialog.show(dateText.getLocation().x, dateText.getLocation().y, DateUtil.yyyymmdd(yyyymmdd));
                    break;
            }
        }
    });
    long now = TimeUtil.getCurrentTime(serverId);
    label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("From");
    fromTime = new DateTime(parentGroup, SWT.TIME | SWT.SHORT);
    fromTime.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    fromTime.setHours(DateUtil.getHour(now) - 1);
    fromTime.setMinutes(DateUtil.getMin(now));
    label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("To");
    toTime = new DateTime(parentGroup, SWT.TIME | SWT.SHORT);
    toTime.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    toTime.setHours(DateUtil.getHour(now));
    toTime.setMinutes(DateUtil.getMin(now));
    label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("Count(Max:1000)");
    maxCountText = new Text(parentGroup, SWT.BORDER);
    maxCountText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    maxCountText.setText("500");
    maxCountText.setToolTipText("1~1000");
    maxCountText.addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
            String count = maxCountText.getText();
            if (StringUtil.isEmpty(count)) {
                return;
            }
            try {
                Integer.valueOf(count);
            } catch (Exception ex) {
                MessageDialog.openError(maxCountText.getShell(), "Invalid Count", "Count is allowed only digits");
                maxCountText.setText("");
            }
        }

        public void keyPressed(KeyEvent e) {
        }
    });
    button = new Button(parentGroup, SWT.PUSH);
    button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    button.setText("&Search");
    button.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            load();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("Level");
    GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gridData.horizontalSpan = 2;
    levelCombo = new Combo(parentGroup, SWT.READ_ONLY);
    levelCombo.setLayoutData(gridData);
    levelCombo.add("ALL");
    StringEnumer itr = AlertLevel.names();
    while (itr.hasMoreElements()) {
        levelCombo.add(itr.nextString());
    }
    levelCombo.select(0);
    label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("Object");
    objText = new Text(parentGroup, SWT.BORDER);
    objText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    label = new Label(parentGroup, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    label.setText("Key");
    keyText = new Text(parentGroup, SWT.BORDER);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gridData.horizontalSpan = 3;
    keyText.setLayoutData(gridData);
    button = new Button(parentGroup, SWT.PUSH);
    button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    button.setText("&Clear");
    button.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            levelCombo.select(0);
            objText.setText("");
            keyText.setText("");
            viewer.getTable().removeAll();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    Composite tableComposite = new Composite(parent, SWT.NONE);
    tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    tableColumnLayout = new TableColumnLayout();
    tableComposite.setLayout(tableColumnLayout);
    viewer = new TableViewer(tableComposite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    createColumns();
    final Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setComparator(new ColumnLabelSorter(viewer));
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            StructuredSelection sel = (StructuredSelection) event.getSelection();
            Object o = sel.getFirstElement();
            if (o instanceof AlertData) {
                AlertData data = (AlertData) o;
                Display display = Display.getCurrent();
                if (display == null) {
                    display = Display.getDefault();
                }
                AlertNotifierDialog alertDialog = new AlertNotifierDialog(display, serverId);
                alertDialog.setObjName(data.object);
                alertDialog.setPack(data.toPack());
                alertDialog.show(getViewSite().getShell().getBounds());
            } else {
                System.out.println(o);
            }
        }
    });
    IToolBarManager man = getViewSite().getActionBars().getToolBarManager();
    man.add(new Action("Export CSV", ImageUtil.getImageDescriptor(Images.csv)) {

        public void run() {
            Server server = ServerManager.getInstance().getServer(serverId);
            FileDialog dialog = new FileDialog(getViewSite().getShell(), SWT.SAVE);
            dialog.setOverwrite(true);
            String filename = "[" + server.getName() + "]" + yyyymmdd + "_" + fromTime.getHours() + fromTime.getMinutes() + "_" + toTime.getHours() + toTime.getMinutes() + ".csv";
            dialog.setFileName(filename);
            dialog.setFilterExtensions(new String[] { "*.csv", "*.*" });
            dialog.setFilterNames(new String[] { "CSV File(*.csv)", "All Files" });
            String fileSelected = dialog.open();
            if (fileSelected != null) {
                CSVWriter cw = null;
                try {
                    cw = new CSVWriter(new FileWriter(fileSelected));
                    int colCnt = viewer.getTable().getColumnCount();
                    List<String> list = new ArrayList<String>();
                    for (int i = 0; i < colCnt; i++) {
                        TableColumn column = viewer.getTable().getColumn(i);
                        list.add(column.getText());
                    }
                    cw.writeNext(list.toArray(new String[list.size()]));
                    cw.flush();
                    TableItem[] items = viewer.getTable().getItems();
                    if (items != null && items.length > 0) {
                        for (TableItem item : items) {
                            list.clear();
                            for (int i = 0; i < colCnt; i++) {
                                list.add(item.getText(i));
                            }
                            cw.writeNext(list.toArray(new String[list.size()]));
                            cw.flush();
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                } finally {
                    try {
                        if (cw != null) {
                            cw.close();
                        }
                    } catch (Throwable th) {
                    }
                }
            }
        }
    });
}
Example 34
Project: sling-master  File: DateTimeEditor.java View source code
@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;
}
Example 35
Project: xwiki-eclipse-master  File: CommentEditor.java View source code
/**
     * {@inheritDoc}
     * 
     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
     */
@Override
public void createPartControl(Composite parent) {
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    scrolledForm = toolkit.createScrolledForm(parent);
    toolkit.decorateFormHeading(scrolledForm.getForm());
    TableWrapLayout layout = new TableWrapLayout();
    layout.numColumns = 2;
    scrolledForm.getBody().setLayout(layout);
    CommentEditorInput input = (CommentEditorInput) getEditorInput();
    final XWikiEclipseComment comment = input.getComment();
    String text = input.getCommandText();
    /* command button */
    if (comment.getId() != null) {
        /* it is editing the comment */
        commandButton = toolkit.createButton(scrolledForm.getBody(), "Edit", SWT.PUSH);
    } else {
        /* can be either New or Reply To */
        commandButton = toolkit.createButton(scrolledForm.getBody(), text, SWT.PUSH);
    }
    TableWrapData layoutData = new TableWrapData();
    layoutData.colspan = 2;
    commandButton.setLayoutData(layoutData);
    commandButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (comment.getId() != null) {
                /* it is updating the comment */
                UIUtils.showMessageDialog(Display.getDefault().getActiveShell(), SWT.ICON_ERROR, "Save is not implemented", "Update comment is not supported yet in REST API yet");
            } else {
                /* get all the data and populate Comment instance */
                final XWikiEclipseComment c = new XWikiEclipseComment(comment.getDataManager());
                c.setAuthor(author.getText());
                c.setHighlight(highlight.getText());
                c.setText(commentText.getText());
                c.setPageId(comment.getPageId());
                String replyToIdStr = replyTo.getText();
                c.setReplyTo(replyToIdStr.equals("") ? null : Integer.parseInt(replyToIdStr));
                Calendar d = Calendar.getInstance();
                d.set(date.getYear(), date.getMonth(), date.getDay(), time.getHours(), time.getMinutes(), time.getSeconds());
                c.setDate(d);
                /* store the comment via REST API */
                Job storeJob = new Job(String.format("Storing Comment %s", c.getAuthor())) {

                    @Override
                    protected IStatus run(final IProgressMonitor monitor) {
                        monitor.beginTask("Storing", 100);
                        if (monitor.isCanceled()) {
                            return Status.CANCEL_STATUS;
                        }
                        SafeRunner.run(new XWikiEclipseSafeRunnable() {

                            public void run() throws Exception {
                                comment.getDataManager().storeComment(c);
                                monitor.worked(50);
                            }
                        });
                        monitor.done();
                        return Status.OK_STATUS;
                    }
                };
                storeJob.setUser(true);
                storeJob.schedule();
                /* close the editor */
                site.getPage().closeEditor(CommentEditor.this, false);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // TODO Auto-generated method stub
        }
    });
    /* author prettyName: Author */
    Section authorSection = toolkit.createSection(scrolledForm.getBody(), Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED | Section.CLIENT_INDENT);
    authorSection.setText("Author");
    authorSection.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
    Composite compositeClient = toolkit.createComposite(authorSection, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(compositeClient);
    author = toolkit.createText(compositeClient, comment.getAuthor(), SWT.BORDER | SWT.SINGLE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(author);
    author.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            dirty = true;
            firePropertyChange(PROP_DIRTY);
        }
    });
    authorSection.setClient(compositeClient);
    /* highlight, Highlighted Text */
    Section highlightSection = toolkit.createSection(scrolledForm.getBody(), Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED | Section.CLIENT_INDENT);
    highlightSection.setText("Highlighted Text");
    highlightSection.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
    compositeClient = toolkit.createComposite(highlightSection, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(compositeClient);
    highlight = toolkit.createText(compositeClient, comment.getHighlight() == null ? "" : comment.getHighlight(), SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).hint(0, highlight.getLineHeight() * 3).applyTo(highlight);
    highlight.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            dirty = true;
            firePropertyChange(PROP_DIRTY);
        }
    });
    highlightSection.setClient(compositeClient);
    /* text, Comment */
    Section commentTextSection = toolkit.createSection(scrolledForm.getBody(), Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED | Section.CLIENT_INDENT);
    commentTextSection.setText("Comment");
    commentTextSection.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
    compositeClient = toolkit.createComposite(commentTextSection, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(compositeClient);
    commentText = toolkit.createText(compositeClient, comment.getText() == null ? "" : comment.getText(), SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).hint(0, commentText.getLineHeight() * 5).applyTo(commentText);
    commentText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            dirty = true;
            firePropertyChange(PROP_DIRTY);
        }
    });
    commentTextSection.setClient(compositeClient);
    /* reply to, Reply To */
    Section replyToSection = toolkit.createSection(scrolledForm.getBody(), Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED | Section.CLIENT_INDENT);
    replyToSection.setText("Reply To");
    replyToSection.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
    compositeClient = toolkit.createComposite(replyToSection, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(compositeClient);
    replyTo = toolkit.createText(compositeClient, comment.getReplyTo() == null ? "" : comment.getReplyTo().toString(), SWT.BORDER | SWT.SINGLE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(replyTo);
    replyTo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            dirty = true;
            firePropertyChange(PROP_DIRTY);
        }
    });
    replyToSection.setClient(compositeClient);
    /* date, Date and time */
    Section dateSection = toolkit.createSection(scrolledForm.getBody(), Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED | Section.CLIENT_INDENT);
    dateSection.setText("Date and Time");
    dateSection.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 2));
    compositeClient = toolkit.createComposite(dateSection, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(compositeClient);
    Label dateLabel = toolkit.createLabel(compositeClient, "Date");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(dateLabel);
    Label timeLabel = toolkit.createLabel(compositeClient, "Time");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(timeLabel);
    date = new DateTime(compositeClient, SWT.DROP_DOWN);
    GridDataFactory.fillDefaults().applyTo(date);
    toolkit.adapt(date);
    time = new DateTime(compositeClient, SWT.TIME);
    toolkit.adapt(time);
    time.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        // TODO Auto-generated method stub
        }

        public void widgetSelected(SelectionEvent e) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(Calendar.DAY_OF_MONTH, date.getDay());
            calendar.set(Calendar.MONTH, date.getMonth());
            calendar.set(Calendar.YEAR, date.getYear());
            calendar.set(Calendar.HOUR_OF_DAY, time.getHours());
            calendar.set(Calendar.MINUTE, time.getMinutes());
            calendar.set(Calendar.SECOND, time.getSeconds());
            dirty = true;
            firePropertyChange(PROP_DIRTY);
        }
    });
    date.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        // TODO Auto-generated method stub
        }

        public void widgetSelected(SelectionEvent e) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(Calendar.DAY_OF_MONTH, date.getDay());
            calendar.set(Calendar.MONTH, date.getMonth());
            calendar.set(Calendar.YEAR, date.getYear());
            calendar.set(Calendar.HOUR_OF_DAY, time.getHours());
            calendar.set(Calendar.MINUTE, time.getMinutes());
            calendar.set(Calendar.SECOND, time.getSeconds());
            dirty = true;
            firePropertyChange(PROP_DIRTY);
        }
    });
    dateSection.setClient(compositeClient);
}
Example 36
Project: aws-toolkit-eclipse-master  File: GeneratePresignedUrlAction.java View source code
@Override
protected Control createCustomArea(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
    composite.setLayoutData(layoutData);
    composite.setLayout(new GridLayout(1, false));
    new Label(composite, SWT.None).setText("Expiration date:");
    final DateTime calendarControl = new DateTime(composite, SWT.CALENDAR);
    calendarControl.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            calendar.set(Calendar.YEAR, calendarControl.getYear());
            calendar.set(Calendar.MONTH, calendarControl.getMonth());
            calendar.set(Calendar.DAY_OF_MONTH, calendarControl.getDay());
        }
    });
    Composite timeComposite = new Composite(composite, SWT.NONE);
    timeComposite.setLayout(new GridLayout(2, false));
    new Label(timeComposite, SWT.None).setText("Expiration time: ");
    final DateTime timeControl = new DateTime(timeComposite, SWT.TIME);
    timeControl.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            calendar.set(Calendar.HOUR, timeControl.getHours());
            calendar.set(Calendar.MINUTE, timeControl.getMinutes());
            calendar.set(Calendar.SECOND, timeControl.getSeconds());
        }
    });
    Composite contentTypeComp = new Composite(composite, SWT.None);
    contentTypeComp.setLayoutData(layoutData);
    contentTypeComp.setLayout(new GridLayout(1, false));
    new Label(contentTypeComp, SWT.None).setText("Content-type override (optional): ");
    final Text contentTypeText = new Text(contentTypeComp, SWT.BORDER);
    contentTypeText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            contentType = contentTypeText.getText();
        }
    });
    contentTypeText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    return composite;
}
Example 37
Project: eclipselaunchsc-master  File: AddTaskWindow.java View source code
protected Control createContents(Composite parent) {
    Shell shell = this.getShell();
    shell.setText("Launch Schedule");
    FormLayout layout = new FormLayout();
    shell.setLayout(layout);
    shell.setSize(500, 300);
    Label repeatLabel = new Label(shell, SWT.NULL);
    repeatLabel.setText("Repeat every: ");
    hour = new Button(shell, SWT.CHECK);
    hour.setText("Hour");
    day = new Button(shell, SWT.CHECK);
    day.setText("day");
    week = new Button(shell, SWT.CHECK);
    week.setText("Week");
    Label laucheLabel = new Label(shell, SWT.NULL);
    laucheLabel.setText("Runner to schedule: ");
    selectLaunche = new Combo(shell, SWT.NULL);
    ILaunchConfiguration[] iLaunchConfigurations;
    try {
        iLaunchConfigurations = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations();
        log.info("iLaunchConfigurations.length  " + iLaunchConfigurations.length);
        for (ILaunchConfiguration launchConfiguration : iLaunchConfigurations) {
            selectLaunche.add(launchConfiguration.getName());
        }
    } catch (CoreException e1) {
        e1.printStackTrace();
    }
    selectLaunche.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            Device device = Display.getCurrent();
            Color white = new Color(device, 255, 255, 255);
            selectLaunche.setBackground(white);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent arg0) {
        // TODO Auto-generated method stub
        }
    });
    Label dateLabel = new Label(shell, SWT.NULL);
    dateLabel.setText("Date for run:");
    calendar = new DateTime(shell, SWT.CALENDAR);
    calendar.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            System.out.println("calendar date changed: ");
        }
    });
    time = new DateTime(shell, SWT.TIME);
    time.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            System.out.println("time changed");
        }
    });
    Button add = new Button(shell, SWT.PUSH);
    add.setText(" Add task ");
    add.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            log.info("add");
            addTask();
            Preferences prefs = //Platform.getPreferencesService().getRootNode().node(Plugin.PLUGIN_PREFEERENCES_SCOPE).node(MY_PLUGIN_ID);
            InstanceScope.INSTANCE.getNode(// does all the above behind the scenes
            "");
            prefs.put("test", "test");
            try {
                // prefs are automatically flushed during a plugin's "super.stop()".
                prefs.flush();
                log.info("check pref" + prefs.get("test", "err"));
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
    Button ok = new Button(shell, SWT.PUSH);
    ok.setText("Ok");
    ok.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            log.info("Ok");
            close();
        }
    });
    Button cancel = new Button(shell, SWT.PUSH);
    cancel.setText("Cancel");
    cancel.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            log.info("Cancel");
            removeAddedTask();
            close();
        }
    });
    //row1
    FormData laucheForm = new FormData();
    laucheForm.left = new FormAttachment(0, 5);
    laucheLabel.setLayoutData(laucheForm);
    //row 1
    FormData data0 = new FormData();
    data0.left = new FormAttachment(laucheLabel, 5);
    selectLaunche.setLayoutData(data0);
    //row  1
    FormData data1 = new FormData();
    data1.left = new FormAttachment(0, 5);
    data1.top = new FormAttachment(laucheLabel, 10);
    dateLabel.setLayoutData(data1);
    //row 2
    FormData data2 = new FormData();
    data2.left = new FormAttachment(laucheLabel, 5);
    data2.top = new FormAttachment(laucheLabel, 10);
    calendar.setLayoutData(data2);
    FormData data3 = new FormData();
    data3.left = new FormAttachment(laucheLabel, 5);
    data3.top = new FormAttachment(calendar, 5);
    time.setLayoutData(data3);
    FormData re1 = new FormData();
    re1.left = new FormAttachment(time, 5);
    re1.top = new FormAttachment(calendar, 5);
    repeatLabel.setLayoutData(re1);
    FormData re2 = new FormData();
    re2.left = new FormAttachment(repeatLabel, 5);
    re2.top = new FormAttachment(calendar, 5);
    hour.setLayoutData(re2);
    FormData re3 = new FormData();
    re3.left = new FormAttachment(hour, 5);
    re3.top = new FormAttachment(calendar, 5);
    day.setLayoutData(re3);
    FormData re4 = new FormData();
    re4.left = new FormAttachment(day, 5);
    re4.top = new FormAttachment(calendar, 5);
    week.setLayoutData(re4);
    FormData dataAdd = new FormData();
    dataAdd.top = new FormAttachment(time, 5);
    dataAdd.left = new FormAttachment(laucheLabel, 5);
    add.setLayoutData(dataAdd);
    FormData dataOk = new FormData();
    dataOk.top = new FormAttachment(add, 10);
    dataOk.left = new FormAttachment(week, 5);
    ok.setLayoutData(dataOk);
    FormData dataCancel = new FormData();
    dataCancel.top = new FormAttachment(add, 10);
    dataCancel.left = new FormAttachment(ok, 5);
    cancel.setLayoutData(dataCancel);
    return null;
}
Example 38
Project: ecommons-uimisc-master  File: DateCellEditor.java View source code
@Override
public DateTime createEditorControl(final Composite parent) {
    final DateTime dateControl = new DateTime(parent, SWT.DATE | SWT.DROP_DOWN);
    //set style information configured in the associated cell style
    dateControl.setBackground(this.cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
    dateControl.setForeground(this.cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
    dateControl.setFont(this.cellStyle.getAttributeValue(CellStyleAttributes.FONT));
    //add a key listener that will commit or close the editor for special key strokes
    dateControl.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(final KeyEvent event) {
            if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
                final boolean commit = (event.stateMask == SWT.ALT) ? false : true;
                Direction move = null;
                if (DateCellEditor.this.moveSelectionOnEnter && DateCellEditor.this.editMode == EditMode.INLINE) {
                    if (event.stateMask == 0) {
                        move = Direction.DOWN;
                    } else if (event.stateMask == SWT.SHIFT) {
                        move = Direction.UP;
                    }
                }
                if (commit) {
                    commit(move);
                }
                if (DateCellEditor.this.editMode == EditMode.DIALOG) {
                    parent.forceFocus();
                }
            } else if (event.keyCode == SWT.ESC && event.stateMask == 0) {
                close();
            }
        }
    });
    return dateControl;
}
Example 39
Project: jubula.core-master  File: SWTAdapterFactory.java View source code
/**
     * {@inheritDoc}
     */
public Object getAdapter(Class targetedClass, Object objectToAdapt) {
    if (targetedClass.isAssignableFrom(IComponent.class)) {
        IComponent returnvalue = null;
        if (objectToAdapt instanceof Button) {
            returnvalue = new ButtonAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof Menu) {
            returnvalue = new MenuAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof MenuItem) {
            returnvalue = new MenuItemAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof Tree) {
            returnvalue = new TreeAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof Table) {
            returnvalue = new TableAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof List) {
            returnvalue = new ListAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof Text) {
            returnvalue = new TextComponentAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof StyledText) {
            returnvalue = new StyledTextAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof Combo) {
            returnvalue = new ComboAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof CCombo) {
            returnvalue = new CComboAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof Label) {
            returnvalue = new LabelAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof CLabel) {
            returnvalue = new CLabelAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof TabFolder) {
            returnvalue = new TabFolderAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof CTabFolder) {
            returnvalue = new CTabFolderAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof Link) {
            returnvalue = new ControlAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof Spinner) {
            returnvalue = new ControlAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof Slider) {
            returnvalue = new SliderAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof Scale) {
            returnvalue = new ControlAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof DateTime) {
            returnvalue = new ControlAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof ToolItem) {
            returnvalue = new ToolItemAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof ProgressBar) {
            returnvalue = new ControlAdapter(objectToAdapt);
        } else if (objectToAdapt instanceof Canvas) {
            returnvalue = new ControlAdapter(objectToAdapt);
        // FALLBACK! Leave at the end
        } else if (objectToAdapt instanceof Control) {
            returnvalue = new ControlAdapter(objectToAdapt);
        }
        return returnvalue;
    }
    return null;
}
Example 40
Project: marketcetera-master  File: OptionOrderTicketView.java View source code
@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    final DateTime calendar = new DateTime(composite, SWT.CALENDAR);
    calendar.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            getXSWTView().getOptionExpiryText().setText(String.format(DATE_FORMAT, calendar.getYear(), calendar.getMonth() + 1, calendar.getDay()));
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
            close();
        }
    });
    return composite;
}
Example 41
Project: mylyn.commons-master  File: DatePickerPanel.java View source code
private void initialize(boolean includeTime, int marginSize) {
    if (date == null) {
        date = Calendar.getInstance();
        date.set(Calendar.HOUR_OF_DAY, hourOfDay);
        date.set(Calendar.MINUTE, 0);
        date.set(Calendar.SECOND, 0);
        date.set(Calendar.MILLISECOND, 0);
    }
    GridLayout gridLayout = new GridLayout();
    if (includeTime) {
        gridLayout.numColumns = 2;
    } else {
        gridLayout.numColumns = 1;
    }
    if (marginSize != -1) {
        gridLayout.marginWidth = marginSize;
    }
    this.setLayout(gridLayout);
    calendar = new DateTime(this, SWT.CALENDAR);
    calendar.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            date.set(Calendar.YEAR, calendar.getYear());
            date.set(Calendar.MONTH, calendar.getMonth());
            date.set(Calendar.DAY_OF_MONTH, calendar.getDay());
            setSelection(new DateSelection(date, true));
            notifyListeners(new SelectionChangedEvent(DatePickerPanel.this, getSelection()));
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            date.set(Calendar.YEAR, calendar.getYear());
            date.set(Calendar.MONTH, calendar.getMonth());
            date.set(Calendar.DAY_OF_MONTH, calendar.getDay());
            setSelection(new DateSelection(date));
            notifyListeners(new SelectionChangedEvent(DatePickerPanel.this, getSelection()));
        }
    });
    if (includeTime) {
        createTimeList(this);
    }
    Hyperlink todayLink = new Hyperlink(this, SWT.NONE);
    todayLink.setText(Messages.DatePickerPanel_Today);
    todayLink.setUnderlined(true);
    todayLink.setForeground(CommonColors.HYPERLINK_WIDGET);
    GridDataFactory.fillDefaults().span(2, 1).grab(true, false).align(SWT.CENTER, SWT.TOP).applyTo(todayLink);
    todayLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            Calendar today = Calendar.getInstance();
            ISelection selection = getSelection();
            if (selection instanceof DateSelection && !selection.isEmpty()) {
                Calendar selectedDate = ((DateSelection) selection).getDate();
                if (selectedDate != null) {
                    today.set(Calendar.HOUR_OF_DAY, selectedDate.get(Calendar.HOUR_OF_DAY));
                    today.set(Calendar.MINUTE, selectedDate.get(Calendar.MINUTE));
                    today.set(Calendar.SECOND, selectedDate.get(Calendar.SECOND));
                    today.set(Calendar.MILLISECOND, selectedDate.get(Calendar.MILLISECOND));
                }
            }
            setDate(today, true);
        }
    });
}
Example 42
Project: nebula.widgets.nattable-master  File: DateCellEditor.java View source code
@Override
public DateTime createEditorControl(final Composite parent) {
    final DateTime dateControl = new DateTime(parent, SWT.DATE | SWT.DROP_DOWN);
    // set style information configured in the associated cell style
    dateControl.setBackground(this.cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
    dateControl.setForeground(this.cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
    dateControl.setFont(this.cellStyle.getAttributeValue(CellStyleAttributes.FONT));
    // add a key listener that will commit or close the editor for special
    // key strokes
    dateControl.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent event) {
            if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
                boolean commit = (event.stateMask == SWT.MOD3) ? false : true;
                MoveDirectionEnum move = MoveDirectionEnum.NONE;
                if (DateCellEditor.this.moveSelectionOnEnter && DateCellEditor.this.editMode == EditModeEnum.INLINE) {
                    if (event.stateMask == 0) {
                        move = MoveDirectionEnum.DOWN;
                    } else if (event.stateMask == SWT.MOD2) {
                        move = MoveDirectionEnum.UP;
                    }
                }
                if (commit)
                    commit(move);
                if (DateCellEditor.this.editMode == EditModeEnum.DIALOG) {
                    parent.forceFocus();
                }
            } else if (event.keyCode == SWT.ESC && event.stateMask == 0) {
                close();
            }
        }
    });
    return dateControl;
}
Example 43
Project: pomedoro-eclipse-plugin-master  File: RabbitView.java View source code
@Override
protected Control createControl(Composite parent) {
    final Calendar dateToBind = preferences.getStartDate();
    final DateTime fromDateTime = new DateTime(parent, SWT.DROP_DOWN | SWT.BORDER);
    fromDateTime.setToolTipText("Select the start date for the data to be displayed");
    updateDateTime(fromDateTime, dateToBind);
    fromDateTime.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            updateDate(dateToBind, fromDateTime);
        }
    });
    return fromDateTime;
}
Example 44
Project: Curators-Workbench-master  File: AccessControlFormPage.java View source code
/**
	 * @param parent
	 * @param toolkit
	 */
private void createEmbargoContent(Composite parent, FormToolkit toolkit) {
    TableWrapData gd = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.MIDDLE);
    Section s1 = toolkit.createSection(parent, Section.TITLE_BAR);
    //$NON-NLS-1$
    s1.setText("Embargo");
    s1.marginWidth = 10;
    s1.marginHeight = 5;
    s1.setLayoutData(gd);
    Label descriptionLabel = new Label(s1, SWT.WRAP);
    //$NON-NLS-1$
    descriptionLabel.setText("You may embargo this object and its contents until a specified date.");
    s1.setDescriptionControl(descriptionLabel);
    Composite client = toolkit.createComposite(s1);
    TableWrapLayout twl = new TableWrapLayout();
    twl.numColumns = 2;
    client.setLayout(twl);
    TableWrapData twd = new TableWrapData(TableWrapData.RIGHT, TableWrapData.MIDDLE, 1, 1);
    //$NON-NLS-1$
    embargoFlag = toolkit.createButton(client, "Yes, embargo until", SWT.CHECK);
    if (model != null)
        embargoFlag.setSelection(model.isSetEmbargoUntil());
    embargoFlag.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            untilDate.setEnabled(embargoFlag.getSelection());
            updateEmbargo();
        }
    });
    embargoFlag.setLayoutData(twd);
    untilDate = new DateTime(client, SWT.DATE | SWT.BORDER);
    if (model != null && model.isSetEmbargoUntil() && model.getEmbargoUntil() != null) {
        XMLGregorianCalendar cal = model.getEmbargoUntil();
        untilDate.setYear(cal.getYear());
        untilDate.setMonth(cal.getMonth() - 1);
        untilDate.setDay(cal.getDay());
    } else {
        // default 3 years from current day
        Calendar cal = GregorianCalendar.getInstance();
        cal.add(Calendar.YEAR, 3);
        untilDate.setYear(cal.get(Calendar.YEAR));
        untilDate.setMonth(cal.get(Calendar.MONTH));
        untilDate.setDay(cal.get(Calendar.DAY_OF_MONTH));
    }
    untilDate.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateEmbargo();
        }
    });
    s1.setClient(client);
}
Example 45
Project: depan-master  File: MigrationTaskEditor.java View source code
/**
   * Create the editor's GUI.
   *
   * @param parent Parent Composite.
   * @return the top level Control for the GUI.
   */
private Control createControl(Composite parent) {
    // controls
    Composite topLevel = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    topLevel.setLayout(layout);
    Label labelId = new Label(topLevel, SWT.NONE);
    id = new Text(topLevel, SWT.BORDER);
    Label labelName = new Label(topLevel, SWT.NONE);
    name = new Text(topLevel, SWT.BORDER);
    Label labelDescription = new Label(topLevel, SWT.NONE);
    description = new Text(topLevel, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    Label labelQuarter = new Label(topLevel, SWT.NONE);
    quarter = new Text(topLevel, SWT.BORDER);
    Label labelUpdatedBy = new Label(topLevel, SWT.NONE);
    updatedBy = new Text(topLevel, SWT.BORDER);
    Label labelUpdateDate = new Label(topLevel, SWT.NONE);
    updateDate = new DateTime(topLevel, SWT.CALENDAR);
    Label labelEngineers = new Label(topLevel, SWT.None);
    Control engineersEdit = createEngineersEditor(topLevel);
    // content
    labelId.setText("ID");
    labelName.setText("Name");
    labelDescription.setText("Description");
    labelQuarter.setText("Quarter");
    labelUpdatedBy.setText("Updated by");
    labelUpdateDate.setText("Updated date");
    labelEngineers.setText("Engineers");
    // layout
    labelUpdateDate.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    labelDescription.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    labelEngineers.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    id.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    name.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    quarter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    updatedBy.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    GridData descriptionLayout = new GridData(SWT.FILL, SWT.FILL, true, false);
    descriptionLayout.heightHint = 150;
    description.setLayoutData(descriptionLayout);
    engineersEdit.setLayoutData(descriptionLayout);
    fillContent();
    return topLevel;
}
Example 46
Project: directory-studio-master  File: GeneralizedTimeValueDialog.java View source code
/**
     * Creates the "Date" dialog area.
     *
     * @param parent
     *      the parent composite
     */
private void createDateDialogArea(Composite parent) {
    // Label
    Label dateLabel = BaseWidgetUtils.createLabel(parent, Messages.getString("GeneralizedTimeValueDialog.Date"), //$NON-NLS-1$
    1);
    dateLabel.setLayoutData(new GridData(SWT.NONE, SWT.TOP, false, false));
    Composite rightComposite = BaseWidgetUtils.createColumnContainer(parent, 1, 1);
    // Calendar
    dateCalendar = new DateTime(rightComposite, SWT.CALENDAR | SWT.BORDER);
    dateCalendar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
}
Example 47
Project: tabris-demos-master  File: InputControlsDemo.java View source code
private DateTime createDateField(Composite formComp) {
    Label label = new Label(formComp, SWT.NONE);
    label.setForeground(label.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    label.setText("Date:");
    int dateTimeStyle = SWT.READ_ONLY | SWT.BORDER;
    final DateTime dateTime = new DateTime(formComp, dateTimeStyle);
    GridData gridData = GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).create();
    dateTime.setLayoutData(gridData);
    return dateTime;
}
Example 48
Project: eu.geclipse.core-master  File: DateTimeText.java View source code
private void createHour(final Composite parent) {
    Label label = new Label(parent, SWT.NONE);
    //$NON-NLS-1$
    label.setText(Messages.getString("DateTimeText.labelHour"));
    GridData gridData = new GridData();
    gridData.horizontalAlignment = SWT.END;
    label.setLayoutData(gridData);
    this.timeControl = new DateTime(parent, SWT.TIME);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    this.timeControl.setLayoutData(gridData);
}
Example 49
Project: gmc-master  File: VolumeLogsPage.java View source code
private Date extractTimestamp(DateTime date, DateTime time) {
    Calendar calendar = Calendar.getInstance();
    calendar.setLenient(false);
    calendar.set(Calendar.DAY_OF_MONTH, date.getDay());
    // in Calendar class, month starts with zero i.e. Jan = 0
    calendar.set(Calendar.MONTH, date.getMonth());
    calendar.set(Calendar.YEAR, date.getYear());
    calendar.set(Calendar.HOUR_OF_DAY, time.getHours());
    calendar.set(Calendar.MINUTE, time.getMinutes());
    calendar.set(Calendar.SECOND, time.getSeconds());
    return calendar.getTime();
}
Example 50
Project: jucy-master  File: LogViewerEditor.java View source code
@Override
public void createPartControl(Composite parent) {
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    parent.setLayout(gridLayout);
    tableViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
    table = tableViewer.getTable();
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
    tva = new TableViewerAdministrator<DBLogger>(tableViewer, Collections.singletonList(new LogEntityNameCol()), GUIPI.logViewerTable, 0);
    tva.apply();
    final Composite comp = new Composite(parent, SWT.BORDER);
    final GridLayout gridLayout_0 = new GridLayout();
    gridLayout_0.numColumns = 1;
    comp.setLayout(gridLayout_0);
    comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
    styledText = new StyledText(comp, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
    styledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    final Composite belowText = new Composite(comp, SWT.BORDER);
    final GridLayout gridLayout_b = new GridLayout();
    gridLayout_b.numColumns = 3;
    belowText.setLayout(gridLayout_b);
    belowText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
    countLabel = new Label(belowText, SWT.NONE);
    countLabel.setLayoutData(new GridData(100, SWT.DEFAULT));
    Label distLabel = new Label(belowText, SWT.NONE);
    distLabel.setLayoutData(new GridData(100, SWT.DEFAULT));
    linkComp = new Composite(belowText, SWT.NONE);
    linkComp.setLayout(new RowLayout());
    /*final GridLayout gridLayout_l = new GridLayout();
		gridLayout_l.numColumns = 3;
		belowText.setLayout(gridLayout_l); */
    linkComp.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false));
    final Composite composite = new Composite(parent, SWT.NONE);
    final GridLayout gridLayout_1 = new GridLayout();
    gridLayout_1.numColumns = 2;
    composite.setLayout(gridLayout_1);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    final Button pruneButton = new Button(composite, SWT.NONE);
    pruneButton.setText(Lang.PruneAllOlderThan);
    calendar = new DateTime(composite, SWT.DATE | SWT.DROP_DOWN);
    pruneButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            final Calendar cal = Calendar.getInstance();
            cal.set(calendar.getYear(), calendar.getMonth(), calendar.getDay());
            final DCClient dcc = ApplicationWorkbenchWindowAdvisor.get();
            new Job(Lang.DeleteLog) {

                @Override
                protected IStatus run(IProgressMonitor monitor) {
                    dcc.getDatabase().pruneLogentrys(null, cal.getTime(), monitor);
                    new SUIJob(calendar) {

                        @Override
                        public void run() {
                            setCalendarToday();
                            update(true, false);
                        }
                    };
                    return Status.OK_STATUS;
                }
            }.schedule();
        }
    });
    Calendar cal = Calendar.getInstance();
    //prune all older than 6 Months as default..
    cal.add(Calendar.MONTH, -6);
    calendar.setDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
    final Button exportAll = new Button(composite, SWT.NONE);
    CommandButton.setCommandToButton(ExportAllLogs.COMMAND_ID, exportAll, getSite(), false);
    //		exportAll.setText("Export All Logs");
    //		exportAll.addSelectionListener (new SelectionAdapter () {
    //			public void widgetSelected (SelectionEvent e) {
    //				Export.exportAll();
    //			}
    //		});
    tableViewer.setContentProvider(new LogViewerContentProvider());
    tableViewer.setInput(ApplicationWorkbenchWindowAdvisor.get().getDatabase());
    tableViewer.addPostSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection iss = (IStructuredSelection) selection;
                DBLogger newl = (DBLogger) iss.getFirstElement();
                if (newl != null && (newl != dbLogger)) {
                    dbLogger = newl;
                    setCalendarToday();
                    update(false, false);
                }
            }
        }
    });
    tableViewer.getTable().getColumn(0).pack();
    //	makeActions();
    getSite().setSelectionProvider(tableViewer);
    createContextPopup(tableViewer);
    setControlsForFontAndColour(tableViewer.getTable(), styledText, calendar);
    logger.debug("Editor Created");
}
Example 51
Project: ModularityCheck-master  File: ConfigurationsDialog.java View source code
/**
	 * @wbp.parser.entryPoint
	 */
public void showDialog(Shell shell) {
    Display dialog = shell.getDisplay();
    dialogShell = new Shell(shell, SWT.CLOSE | SWT.TITLE | SWT.BORDER | SWT.OK | SWT.APPLICATION_MODAL);
    dialogShell.setText("Configure your repository");
    //		dialogShell.setSize(475, 291);
    dialogShell.setSize(505, 341);
    dialogShell.setLayout(new FillLayout(SWT.HORIZONTAL));
    Rectangle screenSize = dialog.getPrimaryMonitor().getBounds();
    dialogShell.setLocation((screenSize.width - dialogShell.getBounds().width) / 2, (screenSize.height - dialogShell.getBounds().height) / 2);
    scrolledComposite = new ScrolledComposite(dialogShell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setMinSize(new Point(330, 200));
    mainContainer = new Composite(scrolledComposite, SWT.NONE);
    mainContainer.setLayout(new GridLayout(1, false));
    grpRepositoryInformation = new Group(mainContainer, SWT.NONE);
    GridData gd_grpRepositoryInformation = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_grpRepositoryInformation.widthHint = 313;
    grpRepositoryInformation.setLayoutData(gd_grpRepositoryInformation);
    grpRepositoryInformation.setText("Repository Information");
    grpRepositoryInformation.setLayout(new GridLayout(2, false));
    lblType = new Label(grpRepositoryInformation, SWT.NONE);
    lblType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblType.setBounds(0, 0, 70, 17);
    lblType.setText("Type");
    cmbRepoType = new Combo(grpRepositoryInformation, SWT.READ_ONLY);
    cmbRepoType.setVisibleItemCount(4);
    cmbRepoType.setItems(new String[] { "Select the repository type", "Bugzilla", "JIRA", "Tigris" });
    cmbRepoType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    cmbRepoType.select(repoType);
    lblVersionManager = new Label(grpRepositoryInformation, SWT.NONE);
    lblVersionManager.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblVersionManager.setText("Version Manager");
    cmbRepoManager = new Combo(grpRepositoryInformation, SWT.READ_ONLY);
    cmbRepoManager.setVisibleItemCount(3);
    cmbRepoManager.setItems(new String[] { "Select your version  manager", "GIT", "SVN" });
    cmbRepoManager.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    cmbRepoManager.select(repoManager);
    lblUrl = new Label(grpRepositoryInformation, SWT.NONE);
    lblUrl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblUrl.setText("URL");
    txtRepoUrl = new Text(grpRepositoryInformation, SWT.BORDER);
    GridData gd_txtRepoUrl = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_txtRepoUrl.widthHint = 242;
    txtRepoUrl.setLayoutData(gd_txtRepoUrl);
    txtRepoUrl.setText(repoUrl);
    lblIssues = new Label(grpRepositoryInformation, SWT.NONE);
    lblIssues.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblIssues.setText("Issues (XML Format)");
    issuesContainer = new Composite(grpRepositoryInformation, SWT.NONE);
    GridData gd_issuesContainer = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_issuesContainer.widthHint = 328;
    issuesContainer.setLayoutData(gd_issuesContainer);
    GridLayout gl_issuesContainer = new GridLayout(2, false);
    gl_issuesContainer.marginWidth = 0;
    gl_issuesContainer.marginHeight = 0;
    issuesContainer.setLayout(gl_issuesContainer);
    txtRepoXml = new Text(issuesContainer, SWT.BORDER);
    GridData gd_txtRepoXml = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_txtRepoXml.widthHint = 308;
    txtRepoXml.setLayoutData(gd_txtRepoXml);
    txtRepoXml.setText(repoXml);
    btnXmlChoose = new Button(issuesContainer, SWT.NONE);
    btnXmlChoose.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dlg = new DirectoryDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
            dlg.setMessage("Select the directory where your XML files are placed");
            dlg.setText("Issues (XML Format)");
            String path = dlg.open();
            if (path == null)
                return;
            txtRepoXml.setText(path);
        }
    });
    GridData gd_btnXmlChoose = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_btnXmlChoose.widthHint = 32;
    btnXmlChoose.setLayoutData(gd_btnXmlChoose);
    btnXmlChoose.setText("...");
    grpEvaluationPeriod = new Group(mainContainer, SWT.NONE);
    GridData gd_grpEvaluationPeriod = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_grpEvaluationPeriod.widthHint = 330;
    grpEvaluationPeriod.setLayoutData(gd_grpEvaluationPeriod);
    grpEvaluationPeriod.setText("Evaluation Period");
    grpEvaluationPeriod.setLayout(new GridLayout(2, false));
    grpBegin = new Group(grpEvaluationPeriod, SWT.NONE);
    grpBegin.setText("Begin");
    grpBegin.setBounds(0, 0, 68, 68);
    grpBegin.setLayout(new GridLayout(1, false));
    Calendar instance = Calendar.getInstance();
    instance.setTime(repoBegin);
    dtBegin = new DateTime(grpBegin, SWT.BORDER);
    dtBegin.setBounds(0, 0, 131, 29);
    dtBegin.setYear(instance.get(Calendar.YEAR));
    dtBegin.setMonth(instance.get(Calendar.MONTH));
    dtBegin.setDay(instance.get(Calendar.DAY_OF_MONTH));
    grpEnd = new Group(grpEvaluationPeriod, SWT.NONE);
    grpEnd.setText("End");
    grpEnd.setLayout(new GridLayout(1, false));
    instance.setTime(repoEnd);
    dtEnd = new DateTime(grpEnd, SWT.BORDER);
    dtEnd.setBounds(0, 0, 131, 29);
    dtEnd.setYear(instance.get(Calendar.YEAR));
    dtEnd.setMonth(instance.get(Calendar.MONTH));
    dtEnd.setDay(instance.get(Calendar.DAY_OF_MONTH));
    btContainer = new Composite(mainContainer, SWT.NONE);
    btContainer.setLayout(new FormLayout());
    GridData gd_btContainer = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_btContainer.widthHint = 45;
    btContainer.setLayoutData(gd_btContainer);
    btnOk = new Button(btContainer, SWT.NONE);
    FormData fd_btnOk = new FormData();
    fd_btnOk.left = new FormAttachment(0, 251);
    fd_btnOk.bottom = new FormAttachment(100);
    fd_btnOk.top = new FormAttachment(100, -29);
    btnOk.setLayoutData(fd_btnOk);
    btnOk.setText("OK");
    btnOk.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            switch(validateConfigurations()) {
                case NO_ERROR:
                    savePreferences();
                    dialogShell.dispose();
                    break;
                case BEGIN_ERROR:
                    MessageDialog.open(SWT.ERROR, dialogShell, "Begin Date Error", "Set the correct date of begining.", SWT.OK);
                    dtBegin.setFocus();
                    break;
                case END_ERROR:
                    MessageDialog.open(SWT.ERROR, dialogShell, "End Date Error", "Set the correct date of ending.", SWT.OK);
                    dtEnd.setFocus();
                    break;
                case TYPE_ERROR:
                    MessageDialog.open(SWT.ERROR, dialogShell, "Type Error", "Select the repository type.", SWT.OK);
                    cmbRepoType.setFocus();
                    break;
                case URL_ERROR:
                    MessageDialog.open(SWT.ERROR, dialogShell, "URL Error", "Enter a valid " + cmbRepoType.getText() + " URL.", SWT.OK);
                    txtRepoUrl.setFocus();
                    txtRepoUrl.selectAll();
                    break;
                case XML_ERROR:
                    MessageDialog.open(SWT.ERROR, dialogShell, "Missing XML File Error", "Select an existing XML file.", SWT.OK);
                    btnXmlChoose.setFocus();
                    break;
                case MANAGER_ERROR:
                    MessageDialog.open(SWT.ERROR, dialogShell, "Version Manager Error", "Select the version manager type.", SWT.OK);
                    cmbRepoManager.setFocus();
                    break;
                default:
                    break;
            }
        }
    });
    btnCancel = new Button(btContainer, SWT.NONE);
    fd_btnOk.right = new FormAttachment(btnCancel, -6);
    btnCancel.setText("Cancel");
    FormData fd_btnCancel = new FormData();
    fd_btnCancel.top = new FormAttachment(btnOk, 0, SWT.TOP);
    fd_btnCancel.right = new FormAttachment(100);
    fd_btnCancel.bottom = new FormAttachment(100);
    fd_btnCancel.left = new FormAttachment(100, -99);
    btnCancel.setLayoutData(fd_btnCancel);
    btnCancel.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            dialogShell.dispose();
        }
    });
    scrolledComposite.setContent(mainContainer);
    dialogShell.open();
    while (!dialogShell.isDisposed()) {
        if (!dialog.readAndDispatch()) {
            dialog.sleep();
        }
    }
}
Example 52
Project: mylyn.docs-master  File: MainPage.java View source code
/**
	 * Create contents of the wizard.
	 *
	 * @param parent
	 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    container.setLayout(new GridLayout(1, true));
    Group grpRequiredDetails = new Group(container, SWT.NONE);
    grpRequiredDetails.setLayout(new GridLayout(4, false));
    GridData gd_grpRequiredDetails = new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1);
    gd_grpRequiredDetails.heightHint = 187;
    grpRequiredDetails.setLayoutData(gd_grpRequiredDetails);
    grpRequiredDetails.setText(Messages.MainPage_2);
    Label lblTitle = new Label(grpRequiredDetails, SWT.NONE);
    lblTitle.setText(Messages.MainPage_3);
    titleText = new Text(grpRequiredDetails, SWT.BORDER);
    titleText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    Label lblAuthor = new Label(grpRequiredDetails, SWT.NONE);
    lblAuthor.setText(Messages.MainPage_4);
    authorText = new Text(grpRequiredDetails, SWT.BORDER);
    authorText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblNewLabel_1 = new Label(grpRequiredDetails, SWT.NONE);
    lblNewLabel_1.setText(Messages.MainPage_5);
    dateTime = new DateTime(grpRequiredDetails, SWT.BORDER | SWT.LONG);
    Label lblIdentifier = new Label(grpRequiredDetails, SWT.NONE);
    lblIdentifier.setText(Messages.MainPage_6);
    identifierText = new Text(grpRequiredDetails, SWT.BORDER);
    identifierText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblScheme = new Label(grpRequiredDetails, SWT.NONE);
    lblScheme.setText(Messages.MainPage_7);
    schemeText = new Combo(grpRequiredDetails, SWT.BORDER);
    schemeText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    schemeText.add(Messages.MainPage_8);
    Label lblCopyright = new Label(grpRequiredDetails, SWT.NONE);
    lblCopyright.setText(Messages.MainPage_9);
    copyrightText = new Text(grpRequiredDetails, SWT.BORDER);
    copyrightText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblLanguage = new Label(grpRequiredDetails, SWT.NONE);
    lblLanguage.setText(Messages.MainPage_10);
    combo = new Combo(grpRequiredDetails, SWT.READ_ONLY);
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Set<String> locales = bean.getLocales().keySet();
    for (String name : locales) {
        combo.add(name);
    }
    Label lblDescription = new Label(grpRequiredDetails, SWT.NONE);
    lblDescription.setText(Messages.MainPage_11);
    subjectText = new Text(grpRequiredDetails, SWT.BORDER);
    subjectText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    Group grpCoverAndStyling = new Group(container, SWT.NONE);
    grpCoverAndStyling.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
    grpCoverAndStyling.setText(Messages.MainPage_12);
    grpCoverAndStyling.setLayout(new GridLayout(3, false));
    Label lblNewLabel = new Label(grpCoverAndStyling, SWT.NONE);
    lblNewLabel.setText(Messages.MainPage_13);
    coverText = new Text(grpCoverAndStyling, SWT.BORDER);
    coverText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    Button button = new Button(grpCoverAndStyling, SWT.NONE);
    //$NON-NLS-1$
    button.setText("...");
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // XXX: Replace with ResourceSelectionDialog?
            FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
            dialog.setFilterNames(new String[] { Messages.MainPage_15 });
            //$NON-NLS-1$
            dialog.setFilterExtensions(//$NON-NLS-1$
            new String[] { "*.png;*.gif;*.jpg;*.svg" });
            dialog.setFilterPath(bean.getMarkupFile().getAbsolutePath());
            String s = dialog.open();
            if (s != null) {
                coverText.setText(s);
            }
        }
    });
    Label lblStyleSheet = new Label(grpCoverAndStyling, SWT.NONE);
    lblStyleSheet.setBounds(0, 0, 59, 14);
    lblStyleSheet.setText(Messages.MainPage_16);
    styleSheetText = new Text(grpCoverAndStyling, SWT.BORDER);
    styleSheetText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Button button_1 = new Button(grpCoverAndStyling, SWT.NONE);
    //$NON-NLS-1$
    button_1.setText("...");
    button_1.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // XXX: Replace with ResourceSelectionDialog?
            FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
            dialog.setFilterNames(new String[] { Messages.MainPage_18 });
            //$NON-NLS-1$
            dialog.setFilterExtensions(//$NON-NLS-1$
            new String[] { "*.css" });
            dialog.setFilterPath(bean.getMarkupFile().getAbsolutePath());
            String s = dialog.open();
            if (s != null) {
                styleSheetText.setText(s);
            }
        }
    });
    m_bindingContext = initDataBindings();
    WizardPageSupport.create(this, m_bindingContext);
    setMessage(Messages.MainPage_0);
}
Example 53
Project: org.eclipse.mylyn.docs-master  File: MainPage.java View source code
/**
	 * Create contents of the wizard.
	 *
	 * @param parent
	 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    container.setLayout(new GridLayout(1, true));
    Group grpRequiredDetails = new Group(container, SWT.NONE);
    grpRequiredDetails.setLayout(new GridLayout(4, false));
    GridData gd_grpRequiredDetails = new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1);
    gd_grpRequiredDetails.heightHint = 187;
    grpRequiredDetails.setLayoutData(gd_grpRequiredDetails);
    grpRequiredDetails.setText(Messages.MainPage_2);
    Label lblTitle = new Label(grpRequiredDetails, SWT.NONE);
    lblTitle.setText(Messages.MainPage_3);
    titleText = new Text(grpRequiredDetails, SWT.BORDER);
    titleText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    Label lblAuthor = new Label(grpRequiredDetails, SWT.NONE);
    lblAuthor.setText(Messages.MainPage_4);
    authorText = new Text(grpRequiredDetails, SWT.BORDER);
    authorText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblNewLabel_1 = new Label(grpRequiredDetails, SWT.NONE);
    lblNewLabel_1.setText(Messages.MainPage_5);
    dateTime = new DateTime(grpRequiredDetails, SWT.BORDER | SWT.LONG);
    Label lblIdentifier = new Label(grpRequiredDetails, SWT.NONE);
    lblIdentifier.setText(Messages.MainPage_6);
    identifierText = new Text(grpRequiredDetails, SWT.BORDER);
    identifierText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblScheme = new Label(grpRequiredDetails, SWT.NONE);
    lblScheme.setText(Messages.MainPage_7);
    schemeText = new Combo(grpRequiredDetails, SWT.BORDER);
    schemeText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    schemeText.add(Messages.MainPage_8);
    Label lblCopyright = new Label(grpRequiredDetails, SWT.NONE);
    lblCopyright.setText(Messages.MainPage_9);
    copyrightText = new Text(grpRequiredDetails, SWT.BORDER);
    copyrightText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblLanguage = new Label(grpRequiredDetails, SWT.NONE);
    lblLanguage.setText(Messages.MainPage_10);
    combo = new Combo(grpRequiredDetails, SWT.READ_ONLY);
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Set<String> locales = bean.getLocales().keySet();
    for (String name : locales) {
        combo.add(name);
    }
    Label lblDescription = new Label(grpRequiredDetails, SWT.NONE);
    lblDescription.setText(Messages.MainPage_11);
    subjectText = new Text(grpRequiredDetails, SWT.BORDER);
    subjectText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    Group grpCoverAndStyling = new Group(container, SWT.NONE);
    grpCoverAndStyling.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
    grpCoverAndStyling.setText(Messages.MainPage_12);
    grpCoverAndStyling.setLayout(new GridLayout(3, false));
    Label lblNewLabel = new Label(grpCoverAndStyling, SWT.NONE);
    lblNewLabel.setText(Messages.MainPage_13);
    coverText = new Text(grpCoverAndStyling, SWT.BORDER);
    coverText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    Button button = new Button(grpCoverAndStyling, SWT.NONE);
    //$NON-NLS-1$
    button.setText("...");
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // XXX: Replace with ResourceSelectionDialog?
            FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
            dialog.setFilterNames(new String[] { Messages.MainPage_15 });
            //$NON-NLS-1$
            dialog.setFilterExtensions(//$NON-NLS-1$
            new String[] { "*.png;*.gif;*.jpg;*.svg" });
            dialog.setFilterPath(bean.getMarkupFile().getAbsolutePath());
            String s = dialog.open();
            if (s != null) {
                coverText.setText(s);
            }
        }
    });
    Label lblStyleSheet = new Label(grpCoverAndStyling, SWT.NONE);
    lblStyleSheet.setBounds(0, 0, 59, 14);
    lblStyleSheet.setText(Messages.MainPage_16);
    styleSheetText = new Text(grpCoverAndStyling, SWT.BORDER);
    styleSheetText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Button button_1 = new Button(grpCoverAndStyling, SWT.NONE);
    //$NON-NLS-1$
    button_1.setText("...");
    button_1.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // XXX: Replace with ResourceSelectionDialog?
            FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
            dialog.setFilterNames(new String[] { Messages.MainPage_18 });
            //$NON-NLS-1$
            dialog.setFilterExtensions(//$NON-NLS-1$
            new String[] { "*.css" });
            dialog.setFilterPath(bean.getMarkupFile().getAbsolutePath());
            String s = dialog.open();
            if (s != null) {
                styleSheetText.setText(s);
            }
        }
    });
    m_bindingContext = initDataBindings();
    WizardPageSupport.create(this, m_bindingContext);
    setMessage(Messages.MainPage_0);
}
Example 54
Project: blizzys-backup-master  File: SettingsDialog.java View source code
@Override
protected Control createDialogArea(Composite parent) {
    Settings settings = BackupApplication.getSettingsManager().getSettings();
    Composite composite = (Composite) super.createDialogArea(parent);
    ((GridLayout) composite.getLayout()).numColumns = 1;
    ((GridLayout) composite.getLayout()).verticalSpacing = 10;
    Group foldersComposite = new Group(composite, SWT.NONE);
    foldersComposite.setText(Messages.Title_FoldersToBackup);
    foldersComposite.setLayout(new GridLayout(2, false));
    foldersComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    foldersViewer = new ListViewer(foldersComposite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    foldersViewer.setContentProvider(new ArrayContentProvider());
    foldersViewer.setLabelProvider(new FoldersLabelProvider());
    foldersViewer.setSorter(new ViewerSorter() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            return ((ILocation) e1).getDisplayName().compareToIgnoreCase(((ILocation) e2).getDisplayName());
        }
    });
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = convertWidthInCharsToPixels(60);
    gd.heightHint = convertHeightInCharsToPixels(10);
    foldersViewer.getControl().setLayoutData(gd);
    foldersViewer.setInput(new HashSet<>(settings.getLocations()));
    Composite folderButtonsComposite = new Composite(foldersComposite, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    folderButtonsComposite.setLayout(layout);
    folderButtonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    for (final LocationProviderDescriptor descriptor : BackupPlugin.getDefault().getLocationProviders()) {
        Button button = new Button(folderButtonsComposite, SWT.PUSH);
        button.setText(NLS.bind(Messages.Button_AddX, descriptor.getName()));
        button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        button.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                addFolder(descriptor.getLocationProvider());
            }
        });
    }
    final Button removeFolderButton = new Button(folderButtonsComposite, SWT.PUSH);
    removeFolderButton.setText(Messages.Button_Remove);
    removeFolderButton.setEnabled(false);
    removeFolderButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Label label = new Label(foldersComposite, SWT.NONE);
    label.setText(Messages.DropFoldersHelp);
    gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    Group outputFolderComposite = new Group(composite, SWT.NONE);
    outputFolderComposite.setText(Messages.Title_OutputFolder);
    outputFolderComposite.setLayout(new GridLayout(3, false));
    outputFolderComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    label = new Label(outputFolderComposite, SWT.NONE);
    //$NON-NLS-1$
    label.setText(Messages.Label_BackupOutputFolder + ":");
    label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    outputFolderText = new Text(outputFolderComposite, SWT.BORDER | SWT.READ_ONLY);
    outputFolderText.setText(StringUtils.defaultString(settings.getOutputFolder()));
    outputFolderText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button browseOutputFolderButton = new Button(outputFolderComposite, SWT.PUSH);
    //$NON-NLS-1$
    browseOutputFolderButton.setText(Messages.Button_Browse + "...");
    browseOutputFolderButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    Group scheduleComposite = new Group(composite, SWT.NONE);
    scheduleComposite.setText(Messages.Title_WhenToBackup);
    scheduleComposite.setLayout(new GridLayout(2, false));
    scheduleComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    runHourlyRadio = new Button(scheduleComposite, SWT.RADIO);
    runHourlyRadio.setText(Messages.Label_RunHourly);
    gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    gd.horizontalSpan = 2;
    runHourlyRadio.setLayoutData(gd);
    final Button runDailyRadio = new Button(scheduleComposite, SWT.RADIO);
    //$NON-NLS-1$
    runDailyRadio.setText(Messages.Label_RunDaily + ":");
    runDailyRadio.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    dailyTime = new DateTime(scheduleComposite, SWT.TIME | SWT.SHORT);
    runHourlyRadio.setSelection(settings.isRunHourly());
    runDailyRadio.setSelection(!settings.isRunHourly());
    dailyTime.setHours(settings.getDailyHours());
    dailyTime.setMinutes(settings.getDailyMinutes());
    dailyTime.setEnabled(!settings.isRunHourly());
    Group fileComparisonComposite = new Group(composite, SWT.NONE);
    fileComparisonComposite.setText(Messages.Title_FileComparison);
    fileComparisonComposite.setLayout(new GridLayout(1, false));
    fileComparisonComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    fileCompareMetadataRadio = new Button(fileComparisonComposite, SWT.RADIO);
    fileCompareMetadataRadio.setText(Messages.CompareFilesMetadata);
    fileCompareMetadataRadio.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    fileCompareChecksumRadio = new Button(fileComparisonComposite, SWT.RADIO);
    fileCompareChecksumRadio.setText(Messages.CompareFilesChecksum);
    fileCompareChecksumRadio.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    fileCompareMetadataRadio.setSelection(!settings.isUseChecksums());
    fileCompareChecksumRadio.setSelection(settings.isUseChecksums());
    Group maxAgeComposite = new Group(composite, SWT.NONE);
    maxAgeComposite.setText(Messages.Title_MaximumBackupAge);
    maxAgeComposite.setLayout(new GridLayout(2, false));
    maxAgeComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    Button maxAgeUnlimitedRadio = new Button(maxAgeComposite, SWT.RADIO);
    maxAgeUnlimitedRadio.setText(Messages.Label_KeepAll);
    gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    gd.horizontalSpan = 2;
    maxAgeUnlimitedRadio.setLayoutData(gd);
    maxAgeDaysRadio = new Button(maxAgeComposite, SWT.RADIO);
    //$NON-NLS-1$
    maxAgeDaysRadio.setText(Messages.Label_DeleteAfterDays + ":");
    maxAgeDaysRadio.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    maxAgeDaysSpinner = new Spinner(maxAgeComposite, SWT.BORDER);
    maxAgeDaysSpinner.setMinimum(14);
    maxAgeDaysSpinner.setMaximum(365);
    maxAgeUnlimitedRadio.setSelection(settings.getMaxAgeDays() < 0);
    maxAgeDaysRadio.setSelection(settings.getMaxAgeDays() > 0);
    maxAgeDaysSpinner.setEnabled(settings.getMaxAgeDays() > 0);
    maxAgeDaysSpinner.setSelection(settings.getMaxAgeDays() > 0 ? settings.getMaxAgeDays() : 90);
    Group maxDiskFillRateComposite = new Group(composite, SWT.NONE);
    maxDiskFillRateComposite.setText(Messages.Title_MaximumDiskFillRate);
    maxDiskFillRateComposite.setLayout(new GridLayout(3, false));
    maxDiskFillRateComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    label = new Label(maxDiskFillRateComposite, SWT.NONE);
    //$NON-NLS-1$
    label.setText(Messages.Label_DiskFillRate + ":");
    label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    maxDiskFillRateSpinner = new Spinner(maxDiskFillRateComposite, SWT.BORDER);
    maxDiskFillRateSpinner.setMinimum(5);
    maxDiskFillRateSpinner.setMaximum(95);
    maxDiskFillRateSpinner.setSelection(settings.getMaxDiskFillRate());
    label = new Label(maxDiskFillRateComposite, SWT.NONE);
    //$NON-NLS-1$
    label.setText("%");
    label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    Group scheduleExplanationComposite = new Group(composite, SWT.NONE);
    scheduleExplanationComposite.setText(Messages.Title_ScheduleExplanation);
    scheduleExplanationComposite.setLayout(new GridLayout(1, false));
    scheduleExplanationComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    scheduleExplanationLabel = new Label(scheduleExplanationComposite, SWT.NONE);
    scheduleExplanationLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    updateExplanationLabel();
    foldersViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent e) {
            removeFolderButton.setEnabled(!e.getSelection().isEmpty());
        }
    });
    removeFolderButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            removeFolder();
        }
    });
    browseOutputFolderButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            browseOutputFolder();
        }
    });
    runDailyRadio.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            dailyTime.setEnabled(runDailyRadio.getSelection());
            updateExplanationLabel();
        }
    });
    dailyTime.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateExplanationLabel();
        }
    });
    fileCompareChecksumRadio.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            showWarnings(fileCompareChecksumRadio);
        }
    });
    maxAgeDaysRadio.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            maxAgeDaysSpinner.setEnabled(maxAgeDaysRadio.getSelection());
            updateExplanationLabel();
        }
    });
    maxAgeDaysSpinner.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            maxAgeDaysSpinner.setEnabled(maxAgeDaysRadio.getSelection());
            updateExplanationLabel();
        }
    });
    maxDiskFillRateSpinner.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateExplanationLabel();
        }
    });
    DropTarget dropTarget = new DropTarget(foldersViewer.getControl(), DND.DROP_LINK);
    dropTarget.setTransfer(new Transfer[] { FileTransfer.getInstance() });
    dropTarget.addDropListener(new DropTargetListener() {

        @Override
        public void dragEnter(DropTargetEvent event) {
            if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
                event.detail = DND.DROP_LINK;
                event.feedback = DND.FEEDBACK_SCROLL;
            } else {
                event.detail = DND.DROP_NONE;
            }
        }

        @Override
        public void dragLeave(DropTargetEvent event) {
        }

        @Override
        public void dragOver(DropTargetEvent event) {
            if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
                event.detail = DND.DROP_LINK;
                event.feedback = DND.FEEDBACK_SCROLL;
            } else {
                event.detail = DND.DROP_NONE;
            }
        }

        @Override
        public void dropAccept(DropTargetEvent event) {
            if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
                event.detail = DND.DROP_LINK;
                event.feedback = DND.FEEDBACK_SCROLL;
            } else {
                event.detail = DND.DROP_NONE;
            }
        }

        @Override
        public void drop(DropTargetEvent event) {
            if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
                if (event.data != null) {
                    for (String file : (String[]) event.data) {
                        if (new File(file).isDirectory()) {
                            addFolder(FileSystemLocationProvider.location(Utils.toCanonicalFile(new File(file))));
                        }
                    }
                } else {
                    event.detail = DND.DROP_NONE;
                }
            } else {
                event.detail = DND.DROP_NONE;
            }
        }

        @Override
        public void dragOperationChanged(DropTargetEvent event) {
            if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
                event.detail = DND.DROP_LINK;
                event.feedback = DND.FEEDBACK_SCROLL;
            } else {
                event.detail = DND.DROP_NONE;
            }
        }
    });
    return composite;
}
Example 55
Project: corona_src-master  File: AutoScheduleSettingDialog.java View source code
private void createScheduleArea(Composite parent) {
    /* 間隔�択 */
    Composite buttonGroup = new Composite(parent, SWT.NONE);
    buttonGroup.setLayout(new GridLayout(1, false));
    buttonGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    weeklyButton = new Button(buttonGroup, SWT.RADIO);
    weeklyButton.setText("週��(&W)");
    weeklyButton.addSelectionListener(validateListener);
    monthlyButton = new Button(buttonGroup, SWT.RADIO);
    monthlyButton.setText("月��(&M)");
    monthlyButton.addSelectionListener(validateListener);
    /* セパレータ */
    new Label(parent, SWT.SEPARATOR | SWT.VERTICAL).setLayoutData(new GridData(SWT.NONE, SWT.FILL, false, true));
    /* 時間設定 */
    Composite detailArea = new Composite(parent, SWT.NONE);
    detailArea.setLayout(new GridLayout(2, false));
    detailArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    new Label(detailArea, SWT.NONE).setText("実行時間(&T)");
    timeBox = new DateTime(detailArea, SWT.TIME | SWT.SHORT);
    pageBook = new PageBook(detailArea, SWT.NONE);
    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    layoutData.widthHint = 200;
    pageBook.setLayoutData(layoutData);
    final Control[] pages = new Control[2];
    pages[0] = createWeeklyArea(pageBook);
    pages[1] = createMonthlyArea(pageBook);
    /* ページ領域ã?Œå¤§ã??ã?„ã?»ã?†ã?®ã‚µã‚¤ã‚ºã?¾ã?§ãƒ€ã‚¤ã‚¢ãƒ­ã‚°ã‚’æ‹¡å¼µã?—ã?¦ã‚‚らã?†ã?Ÿã‚?ã?«ã€?両方ã?®ãƒšãƒ¼ã‚¸ã‚’表示ã?™ã‚‹ */
    pageBook.showPage(pages[1]);
    pageBook.showPage(pages[0]);
    weeklyButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (((Button) e.getSource()).getSelection()) {
                updatePage(0);
            }
        }
    });
    monthlyButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (((Button) e.getSource()).getSelection()) {
                updatePage(1);
            }
        }
    });
}
Example 56
Project: droolsjbpm-master  File: DSLSentenceWidget.java View source code
public void widgetSelected(SelectionEvent e) {
    final Shell dialog = new Shell(open.getShell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    dialog.setText("Set date:");
    dialog.setLayout(new GridLayout(1, false));
    final DateTime calendar = new DateTime(dialog, SWT.CALENDAR);
    Date date = new Date();
    try {
        String txt = field.getText();
        if (txt != null && txt.length() > 0) {
            date = formatter.parse(txt);
        }
    } catch (ParseException e1) {
        e1.printStackTrace();
    }
    calendar.setDate(date.getYear() + 1900, date.getMonth(), date.getDate());
    Point p2 = open.toDisplay(0, 0);
    int x = p2.x;
    int y = p2.y + 20;
    dialog.setLocation(x, y);
    Button ok = new Button(dialog, SWT.PUSH);
    ok.setText("OK");
    ok.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    ok.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            field.setText(formatter.format(new Date(calendar.getYear() - 1900, calendar.getMonth(), calendar.getDay())));
            updateSentence();
            modeller.setDirty(true);
            dialog.close();
        }
    });
    dialog.setDefaultButton(ok);
    dialog.pack();
    dialog.open();
}
Example 57
Project: scisoft-icat-master  File: ICATWizardPage.java View source code
/**
	 * @see IDialogPage#createControl(Composite)
	 */
@Override
public void createControl(Composite parent) {
    // Set up the composite to hold all the information
    sc = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    sc.setLayout(new FillLayout());
    final Composite composite = new Composite(sc, SWT.NULL);
    composite.setLocation(-708, 1);
    composite.setLayout(new GridLayout(2, false));
    // Specify the expansion Adapter
    expansionAdapter = new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            // advanced options expanded, resize
            composite.layout();
            sc.notifyListeners(SWT.Resize, null);
            // force shell resize
            Point size;
            if (e.getState())
                size = getShell().computeSize(550, 920);
            else
                size = getShell().computeSize(550, 400);
            getShell().setSize(size);
        }
    };
    Label lblNewLabel = new Label(composite, SWT.NONE);
    lblNewLabel.setText("&ICAT site ID");
    icatIDCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
    GridData gd_icatIDCombo = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_icatIDCombo.widthHint = 269;
    icatIDCombo.setLayoutData(gd_icatIDCombo);
    icatIDCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            logger.debug("selection changed: " + icatIDCombo.getText());
            // change remaining parameters
            int index = icatIDCombo.getSelectionIndex();
            icatSiteNameText.setText(getToken(index, preferenceStore.getString("ICAT_NAME_PREF"), DELIMITER));
            txtSftpServer.setText(getToken(index, preferenceStore.getString("ICAT_SFTPSERVER_PREF"), DELIMITER));
            txtDirectory.setText(getToken(index, preferenceStore.getString("ICAT_DOWNLOADDIR_PREF"), DELIMITER));
        }
    });
    /*
		 * populate wizard with current ICAT preferences
		 */
    icatIDCombo.removeAll();
    String[] tokens = preferenceStore.getDefaultString("ICAT_ID_PREF").split(DELIMITER);
    for (int count = 0; count < tokens.length; count++) {
        icatIDCombo.add(tokens[count]);
    }
    icatIDCombo.select(0);
    int index = icatIDCombo.getSelectionIndex();
    Label lblicatDatabase = new Label(composite, SWT.NONE);
    lblicatDatabase.setText("&ICAT site name:");
    icatSiteNameText = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
    GridData gd_icatSiteNameText = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_icatSiteNameText.widthHint = 260;
    icatSiteNameText.setLayoutData(gd_icatSiteNameText);
    icatSiteNameText.setEditable(false);
    icatSiteNameText.setText(getToken(index, preferenceStore.getString("ICAT_NAME_PREF"), DELIMITER));
    icatSiteNameText.setBounds(113, 53, 212, 27);
    Label fedidLbl = new Label(composite, SWT.NONE);
    fedidLbl.setText("&FedId:");
    txtFedid = new Text(composite, SWT.BORDER);
    GridData gd_txtFedid = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_txtFedid.widthHint = 260;
    txtFedid.setLayoutData(gd_txtFedid);
    txtFedid.setText(initFedid);
    txtFedid.addKeyListener(this);
    Label passwordLbl = new Label(composite, SWT.NONE);
    passwordLbl.setBounds(4, 139, 64, 13);
    passwordLbl.setText("&Password:");
    txtPassword = new Text(composite, SWT.BORDER | SWT.PASSWORD);
    GridData gd_txtPassword = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_txtPassword.widthHint = 260;
    txtPassword.setLayoutData(gd_txtPassword);
    txtPassword.addKeyListener(this);
    /**
		 * set-up the standard GUI elements
		 * */
    Label lblProjectName = new Label(composite, SWT.NULL);
    lblProjectName.setText("&Project name:");
    txtProject = new Text(composite, SWT.BORDER);
    GridData gd_txtProject = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_txtProject.widthHint = 260;
    txtProject.setLayoutData(gd_txtProject);
    txtProject.setBounds(113, 173, 212, 27);
    txtProject.setText(initProject);
    txtProject.addKeyListener(this);
    sc.setContent(composite);
    sc.setExpandVertical(true);
    sc.setExpandHorizontal(true);
    new Label(composite, SWT.NONE);
    new Label(composite, SWT.NONE);
    /**
		 * set-up advanced options GUI elements
		 */
    advancedOptionsExpander = new ExpandableComposite(composite, SWT.NONE);
    GridData gd_advancedOptionsExpander = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
    gd_advancedOptionsExpander.widthHint = 242;
    advancedOptionsExpander.setLayoutData(gd_advancedOptionsExpander);
    advancedOptionsExpander.setLayout(new GridLayout(2, false));
    advancedOptionsExpander.setText("Advanced Options");
    advancedOptionsExpander.setExpanded(false);
    Composite optionsComposite = new Composite(advancedOptionsExpander, SWT.NONE);
    optionsComposite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    optionsComposite.setLayout(new GridLayout(3, false));
    Label sftpServerLbl = new Label(optionsComposite, SWT.NONE);
    sftpServerLbl.setText("&SFTP server:");
    txtSftpServer = new Text(optionsComposite, SWT.BORDER);
    GridData gd_txtSftpServer = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_txtSftpServer.widthHint = 193;
    txtSftpServer.setLayoutData(gd_txtSftpServer);
    txtSftpServer.setEditable(true);
    txtSftpServer.setText(getToken(index, preferenceStore.getString("ICAT_SFTPSERVER_PREF"), DELIMITER));
    final Button btnSftpTest = new Button(optionsComposite, SWT.NONE);
    GridData gd_btnSftpTest = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_btnSftpTest.widthHint = 100;
    btnSftpTest.setLayoutData(gd_btnSftpTest);
    btnSftpTest.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            /*
				 * test server using ping
				 */
            if (NetworkUtils.isReachable(txtSftpServer.getText())) {
                Image okImage = (ResourceManager.getPluginImage(ICAT_PLUGIN_ID, "icons/ok.png"));
                ;
                btnSftpTest.setImage(okImage);
            } else {
                Image noImage = (ResourceManager.getPluginImage(ICAT_PLUGIN_ID, "icons/no.png"));
                ;
                btnSftpTest.setImage(noImage);
            }
        }
    });
    btnSftpTest.setText("Test");
    txtSftpServer.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            btnSftpTest.setImage(null);
        }
    });
    Label lbldownloadDirectory = new Label(optionsComposite, SWT.NULL);
    lbldownloadDirectory.setText("&Download directory:");
    txtDirectory = new Text(optionsComposite, SWT.BORDER);
    GridData gd_txtDirectory = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_txtDirectory.widthHint = 193;
    txtDirectory.setLayoutData(gd_txtDirectory);
    txtDirectory.setEditable(true);
    txtDirectory.setEnabled(true);
    txtDirectory.setText(getToken(index, preferenceStore.getString("ICAT_DOWNLOADDIR_PREF"), DELIMITER));
    Button BtnBrowseDirectory = new Button(optionsComposite, SWT.PUSH);
    GridData gd_BtnBrowseDirectory = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_BtnBrowseDirectory.widthHint = 100;
    BtnBrowseDirectory.setLayoutData(gd_BtnBrowseDirectory);
    BtnBrowseDirectory.setText("Browse...");
    BtnBrowseDirectory.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleDownloadDirBrowse();
        }
    });
    Label lbltruststorePath = new Label(optionsComposite, SWT.NONE);
    lbltruststorePath.setBounds(10, 131, 103, 19);
    lbltruststorePath.setText("&Truststore path:");
    txtTruststore = new Text(optionsComposite, SWT.BORDER);
    txtTruststore.setText(getToken(index, preferenceStore.getString("ICAT_TRUSTSTORE_PATH_PREF"), DELIMITER));
    GridData gd_txtTruststore = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_txtTruststore.widthHint = 193;
    txtTruststore.setLayoutData(gd_txtTruststore);
    txtTruststore.setEnabled(true);
    txtTruststore.setEditable(true);
    Button BtnBrowseTruststore = new Button(optionsComposite, SWT.PUSH);
    GridData gd_BtnBrowseTruststore = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_BtnBrowseTruststore.widthHint = 100;
    BtnBrowseTruststore.setLayoutData(gd_BtnBrowseTruststore);
    BtnBrowseTruststore.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleTruststoreBrowse();
        }
    });
    BtnBrowseTruststore.setText("Browse...");
    Label lbltruststorePassword = new Label(optionsComposite, SWT.NONE);
    lbltruststorePassword.setText("&Truststore password:");
    txtTruststorePassword = new Text(optionsComposite, SWT.BORDER | SWT.PASSWORD);
    txtTruststorePassword.setText(getToken(index, preferenceStore.getString("ICAT_TRUSTSTORE_PASS_PREF"), DELIMITER));
    GridData gd_txtTruststorePassword = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_txtTruststorePassword.widthHint = 193;
    txtTruststorePassword.setLayoutData(gd_txtTruststorePassword);
    txtTruststorePassword.setEnabled(true);
    txtTruststorePassword.addKeyListener(this);
    final Button btnShowPassword = new Button(optionsComposite, SWT.CHECK);
    btnShowPassword.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (btnShowPassword.getSelection()) {
                txtTruststorePassword.setEchoChar((char) 0);
            } else {
                txtTruststorePassword.setEchoChar('*');
            }
        }
    });
    btnShowPassword.setText("Show password");
    // set default FROM date to current date
    Calendar calA = Calendar.getInstance();
    Label lblFrom = new Label(optionsComposite, SWT.TOP);
    lblFrom.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
    lblFrom.setText("Visit StartDate from:");
    dateFrom = new DateTime(optionsComposite, SWT.NONE | SWT.CALENDAR | SWT.DROP_DOWN);
    dateFrom.setForeground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_FOREGROUND));
    dateFrom.setBackground(SWTResourceManager.getColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
    GridData gd_dateFrom = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
    gd_dateFrom.widthHint = 193;
    dateFrom.setLayoutData(gd_dateFrom);
    dateFrom.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // set from date
            setSqlFromDate(dateFrom);
        }
    });
    //calA.get(Calendar.YEAR));
    dateFrom.setYear(2006);
    dateFrom.setMonth(calA.get(Calendar.MONTH));
    dateFrom.setDay(calA.get(Calendar.DAY_OF_YEAR));
    setSqlFromDate(dateFrom);
    Label lblTo = new Label(optionsComposite, SWT.TOP);
    lblTo.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
    lblTo.setText("Visit StartDate to:");
    dateTo = new DateTime(optionsComposite, SWT.NONE | SWT.CALENDAR | SWT.DROP_DOWN);
    dateTo.setBackground(SWTResourceManager.getColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
    dateTo.setForeground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_FOREGROUND));
    GridData gd_dateTo = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
    gd_dateTo.widthHint = 193;
    dateTo.setLayoutData(gd_dateTo);
    dateTo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // set to date
            setSqlToDate(dateTo);
        }
    });
    // end with current date + 1 month
    dateTo.setYear(calA.get(Calendar.YEAR));
    dateTo.setMonth(calA.get(Calendar.MONTH) + 1);
    dateTo.setDay(calA.get(Calendar.DAY_OF_YEAR));
    setSqlToDate(dateTo);
    advancedOptionsExpander.setClient(optionsComposite);
    new Label(optionsComposite, SWT.NONE);
    new Label(optionsComposite, SWT.NONE);
    new Label(optionsComposite, SWT.NONE);
    advancedOptionsExpander.addExpansionListener(expansionAdapter);
    setControl(composite);
    dialogChanged();
    new Label(composite, SWT.NONE);
    new Label(composite, SWT.NONE);
}
Example 58
Project: ssSKB-master  File: VRView.java View source code
@Override
public void createPartControl(Composite parent) {
    this.display = Activator.getDisplay();
    this.shell = parent.getShell();
    this.popupShell = new Shell(display, SWT.ON_TOP);
    this.popupShell.setLayout(new FillLayout());
    this.cal = new DateTime(popupShell, SWT.CALENDAR);
    this.cal.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent event) {
            refreshDate();
            popupShell.setVisible(false);
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseUp(MouseEvent e) {
        }
    });
    this.cal.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
        }

        public void focusLost(FocusEvent e) {
            if (popupShell.isVisible()) {
                popupShell.setVisible(false);
            }
        }
    });
    this.popupShell.pack();
    this.userShell = new Shell(display, SWT.ON_TOP);
    this.userShell.setLayout(new FillLayout());
    this.treeViewer = new TreeViewer(this.userShell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
    Platform.getAdapterManager().registerAdapters(this.adapterFactory, SwitchUsersManager.class);
    Platform.getAdapterManager().registerAdapters(this.adapterFactory, SwitchUsersGroup.class);
    Platform.getAdapterManager().registerAdapters(this.adapterFactory, SwitchUser.class);
    Platform.getAdapterManager().registerAdapters(this.adapterFactory, SwitchUsersSession.class);
    this.session = Activator.getSwitchUsersSession();
    getSite().setSelectionProvider(this.treeViewer);
    this.treeViewer.setLabelProvider(new WorkbenchLabelProvider());
    this.treeViewer.setContentProvider(new BaseWorkbenchContentProvider());
    //this.treeViewer.setInput(this.session.getTreeRoot());
    this.treeViewer.setInput(this.session.getlocalUserManager());
    this.treeViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            ISelection selection = event.getSelection();
            if (selection instanceof IStructuredSelection) {
                Object obj = ((IStructuredSelection) selection).getFirstElement();
                //activeEditorFromModel(obj);
                if (obj instanceof SwitchUser) {
                    if (userId != null) {
                        userId.setText(((SwitchUser) obj).getUserId());
                        userShell.setVisible(false);
                    }
                }
            }
        //if(selection instanceof IStructuredSelection){
        }
    });
    this.treeViewer.getControl().addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
        }

        public void focusLost(FocusEvent e) {
            if (userShell.isVisible()) {
                userShell.setVisible(false);
            }
        }
    });
    this.userShell.pack();
    this.tipShell = new Shell(display, SWT.ON_TOP);
    this.tipShell.setLayout(new FillLayout());
    this.tipcomp = new Composite(tipShell, SWT.NONE);
    tipcomp.setLayout(new FillLayout());
    //Label LoadingImage = new  Label(tipcomp,SWT.NONE);
    //LoadingImage.setImage(NodeImage.LoadingImage);
    this.tipLabel = new Label(tipcomp, SWT.NONE);
    this.tipLabel.setText("ÕýÔÚ²éѯ£¬ÇëÉÔºò...");
    tipcomp.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
        // TODO Auto-generated method stub
        }

        @Override
        public void focusLost(FocusEvent e) {
            if (tipShell.isVisible()) {
                tipShell.setVisible(false);
            }
        }
    });
    this.tipShell.pack();
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(1, true));
    Composite querryBoard = new Composite(comp, SWT.NONE);
    querryBoard.setLayout(new RowLayout());
    this.startArea = new Composite(querryBoard, SWT.NONE);
    this.startArea.setLayout(new GridLayout(3, false));
    Label startLable = new Label(startArea, SWT.NONE);
    startLable.setText("¿ªÊ¼Ê±¿Ì£º");
    this.startDate = new DateTime(startArea, SWT.DATE);
    this.startTime = new DateTime(startArea, SWT.TIME);
    this.startDate.setToolTipText("Ë«»÷µ¯³öÈÕÀú");
    this.startDate.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent event) {
            selectDateObj = startDate;
            cal.setYear(startDate.getYear());
            cal.setMonth(startDate.getMonth());
            cal.setDay(startDate.getDay());
            Rectangle dateRect = display.map(startArea, null, startDate.getBounds());
            Rectangle calRect = popupShell.getBounds();
            popupShell.setBounds(dateRect.x, dateRect.y + dateRect.height, calRect.width, calRect.height);
            popupShell.setVisible(true);
            cal.setFocus();
        //cal.setVisible(true);
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseUp(MouseEvent e) {
        }
    });
    this.endArea = new Composite(querryBoard, SWT.NONE);
    this.endArea.setLayout(new GridLayout(3, false));
    Label endLable = new Label(endArea, SWT.NONE);
    endLable.setText("½áÊøÊ±¿Ì£º");
    this.endDate = new DateTime(endArea, SWT.DATE);
    this.endTime = new DateTime(endArea, SWT.TIME);
    this.endDate.setToolTipText("Ë«»÷µ¯³öÈÕÀú");
    this.endDate.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent event) {
            selectDateObj = endDate;
            cal.setYear(endDate.getYear());
            cal.setMonth(endDate.getMonth());
            cal.setDay(endDate.getDay());
            Rectangle dateRect = display.map(endArea, null, endDate.getBounds());
            Rectangle calRect = popupShell.getBounds();
            popupShell.setBounds(dateRect.x, dateRect.y + dateRect.height, calRect.width, calRect.height);
            popupShell.setVisible(true);
            cal.setFocus();
        //cal.setVisible(true);
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseUp(MouseEvent e) {
        }
    });
    this.userArea = new Composite(querryBoard, SWT.NONE);
    this.userArea.setLayout(new GridLayout(2, false));
    Label userLable = new Label(userArea, SWT.NONE);
    userLable.setText("Óû§£º");
    this.userId = new Text(userArea, SWT.SINGLE | SWT.BORDER);
    this.userId.setToolTipText("Ϊ¿Õ±íʾȫ²¿Óû§,Ë«»÷µ¯³öÓû§Áбí");
    this.userId.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent event) {
            treeViewer.refresh();
            Rectangle dateRect = display.map(userArea, null, userId.getBounds());
            Rectangle calRect = userShell.getBounds();
            userShell.setBounds(dateRect.x, dateRect.y + dateRect.height, calRect.width, calRect.height < 100 ? 100 : calRect.height);
            userShell.setVisible(true);
            treeViewer.getControl().setFocus();
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseUp(MouseEvent e) {
        }
    });
    Button qerry = new Button(querryBoard, SWT.NONE);
    qerry.setText("²éѯ¼Òô¼Ç¼");
    qerry.setImage(MenuImage.querry);
    qerry.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent event) {
            onQuerryClick();
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseUp(MouseEvent e) {
            onQuerryClick();
        }
    });
    exportXls = new Button(querryBoard, SWT.NONE);
    exportXls.setText("XLSµ¼³ö¼Òô¼Ç¼");
    exportXls.setImage(MenuImage.export);
    exportXls.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent event) {
            onSaveAsXLS();
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseUp(MouseEvent e) {
            onSaveAsXLS();
        }
    });
    exportXls.setEnabled(false);
    deldeled = new Button(querryBoard, SWT.NONE);
    deldeled.setText("Çå³ýÏÂÊö¼ÒôÒÑɾ¼Ç¼");
    deldeled.setImage(MenuImage.cut);
    deldeled.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent event) {
            onDeldeledClick();
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseUp(MouseEvent e) {
            onDeldeledClick();
        }
    });
    deldeled.setEnabled(false);
    try {
        browser = new Browser(comp, SWT.NONE);
    } catch (SWTError e) {
        return;
    }
    this.browser.setBounds(0, 0, 1, 1);
    this.browser.setJavascriptEnabled(true);
    this.browser.setVisible(true);
    this.browser.addLocationListener(new LocationListener() {

        public void changing(LocationEvent event) {
        }

        public void changed(LocationEvent event) {
            lastUrl = event.location;
        }
    });
    //this.browser.setLayoutData(new GridData(GridData.FILL_BOTH));
    /*this.browser.addProgressListener(new ProgressListener(){
			public void changed(ProgressEvent event){
				onProgress(event);
			}
			
			public void completed(ProgressEvent event){
				
			}
		});*/
    //ÏÂÔØ¡¢ÊÔÌýΪ context menu
    this.tv = new TableViewer(comp, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    this.tb = this.tv.getTable();
    this.tb.setLayoutData(new GridData(GridData.FILL_BOTH));
    this.tb.setHeaderVisible(true);
    this.tb.setLinesVisible(true);
    TableLayout layout = new TableLayout();
    this.tb.setLayout(layout);
    layout.addColumnData(new ColumnWeightData(30));
    new TableColumn(this.tb, SWT.NONE).setText("ºÅÂë");
    layout.addColumnData(new ColumnWeightData(30));
    new TableColumn(this.tb, SWT.NONE).setText("Ãû³Æ");
    layout.addColumnData(new ColumnWeightData(30));
    new TableColumn(this.tb, SWT.NONE).setText("Ö÷/±»");
    layout.addColumnData(new ColumnWeightData(60));
    new TableColumn(this.tb, SWT.NONE).setText("¿ªÊ¼Ê±¿Ì");
    layout.addColumnData(new ColumnWeightData(20));
    new TableColumn(this.tb, SWT.NONE).setText("¼ÒôÀàÐÍ");
    layout.addColumnData(new ColumnWeightData(30));
    new TableColumn(this.tb, SWT.NONE).setText("¼Òôʱ³¤(s)");
    layout.addColumnData(new ColumnWeightData(30));
    new TableColumn(this.tb, SWT.NONE).setText("±êʶ");
    this.tv.setLabelProvider(new recordingsLabelProvider());
    this.tv.setContentProvider(new recordingsContentProvider());
    this.tv.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            onRecordingDoubleClick(event);
        }
    });
    recordingActionGroup actiongroup = new recordingActionGroup(this);
    context_menu = actiongroup.fillContextMemu(new MenuManager());
    context_menu.addMenuListener(new MenuListener() {

        public void menuShown(MenuEvent e) {
            IStructuredSelection selection = (IStructuredSelection) tv.getSelection();
            Object o = selection.getFirstElement();
            if (o instanceof recording) {
                for (MenuItem item : context_menu.getItems()) {
                    item.setEnabled(true);
                }
            } else {
                for (MenuItem item : context_menu.getItems()) {
                    item.setEnabled(false);
                }
            }
        }

        public void menuHidden(MenuEvent e) {
        }
    });
}
Example 59
Project: TadpoleForDBTools-master  File: CreateJobDialog.java View source code
/**
	 * Create contents of the dialog.
	 * 
	 * @param parent
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite containerInput = (Composite) super.createDialogArea(parent);
    GridLayout gl_containerInput = (GridLayout) containerInput.getLayout();
    gl_containerInput.verticalSpacing = 1;
    gl_containerInput.horizontalSpacing = 1;
    gl_containerInput.marginHeight = 1;
    gl_containerInput.marginWidth = 1;
    Composite compositeHead = new Composite(containerInput, SWT.NONE);
    compositeHead.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    compositeHead.setLayout(new GridLayout(2, false));
    lblJobId = new Label(compositeHead, SWT.NONE);
    lblJobId.setText("Job ID");
    textJob = new Text(compositeHead, SWT.BORDER | SWT.READ_ONLY | SWT.RIGHT);
    GridData gd_textJob = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
    gd_textJob.widthHint = 100;
    textJob.setLayoutData(gd_textJob);
    textJob.setText(this.jobDao.getJob() + "");
    Label lblObjectType = new Label(compositeHead, SWT.NONE);
    lblObjectType.setText(Messages.get().CreateJobDialog_FirstStartDatetime);
    Composite composite = new Composite(compositeHead, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    btnSpecify = new Button(composite, SWT.RADIO);
    btnSpecify.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // 최초 실행�시를 �접 지정하�� 선�했으면...
            dateStartDate.setEnabled(true);
            dateStartTime.setEnabled(true);
            Calendar c = Calendar.getInstance();
            dateStartDate.setDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH));
            dateStartTime.setDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH));
            dateStartTime.setTime(c.get(Calendar.HOUR), c.get(Calendar.MINUTE), c.get(Calendar.SECOND));
            createScript();
        }
    });
    btnSpecify.setText(Messages.get().CreateJobDialog_specification);
    btnNext = new Button(composite, SWT.RADIO);
    btnNext.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            dateStartDate.setEnabled(false);
            dateStartTime.setEnabled(false);
            createScript();
        }
    });
    btnNext.setText(Messages.get().CreateJobDialog_NextIterationExecutionCycle);
    if (this.jobDao.getJob() > 0) {
        btnNext.setSelection(true);
    } else {
        btnSpecify.setSelection(true);
    }
    dateStartDate = new DateTime(composite, SWT.BORDER);
    dateStartDate.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            createScript();
        }
    });
    GridData gd_dateStartDate = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
    gd_dateStartDate.widthHint = 120;
    dateStartDate.setLayoutData(gd_dateStartDate);
    dateStartTime = new DateTime(composite, SWT.BORDER | SWT.TIME);
    dateStartTime.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            createScript();
        }
    });
    GridData gd_dateStartTime = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
    gd_dateStartTime.widthHint = 120;
    dateStartTime.setLayoutData(gd_dateStartTime);
    dateStartTime.setSize(104, 27);
    Label lblObjectName = new Label(compositeHead, SWT.NONE);
    lblObjectName.setText(Messages.get().CreateJobDialog_IterationExecutionCycle);
    Composite composite_3 = new Composite(compositeHead, SWT.NONE);
    composite_3.setLayout(new GridLayout(2, false));
    comboRepeat = new Combo(composite_3, SWT.READ_ONLY);
    comboRepeat.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            setRepeatString();
            createScript();
        }
    });
    //		"매� 저� �정�", 		"7�마다 �정�", 			"30�마다 �정�", 				"�요� 마다 �정�", 			"매� 오전 6시�",			  
    comboRepeat.setItems(new String[] { Messages.get().EveryNight, Messages.get().Every7Days, Messages.get().Every30Days, Messages.get().EverySunday, Messages.get().Every6Morning, // 		"3시간� 한번씩", 						"매달 1� �정�", 			"매달 1� 오전 6시 30분�"
    Messages.get().Every3Hours, Messages.get().EveryFristDayMonth, Messages.get().EveryFirstDayAm });
    GridData gd_comboRepeat = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_comboRepeat.widthHint = 250;
    comboRepeat.setLayoutData(gd_comboRepeat);
    comboRepeat.setVisibleItemCount(8);
    textRepeat = new Text(composite_3, SWT.BORDER);
    textRepeat.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent event) {
            createScript();
        }
    });
    GridData gd_textRepeat = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_textRepeat.minimumWidth = 200;
    gd_textRepeat.widthHint = 300;
    textRepeat.setLayoutData(gd_textRepeat);
    if (this.jobDao.getJob() <= 0) {
        comboRepeat.select(0);
        this.setRepeatString();
    } else {
        textRepeat.setText(this.jobDao.getInterval());
    }
    Label lblParsing = new Label(compositeHead, SWT.NONE);
    lblParsing.setText(Messages.get().CreateJobDialog_analysis);
    Composite composite_2 = new Composite(compositeHead, SWT.NONE);
    composite_2.setLayout(new GridLayout(2, false));
    btnParse = new Button(composite_2, SWT.RADIO);
    btnParse.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            createScript();
        }
    });
    GridData gd_btnParse = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_btnParse.widthHint = 120;
    btnParse.setLayoutData(gd_btnParse);
    btnParse.setText("Parse");
    btnNoParse = new Button(composite_2, SWT.RADIO);
    btnNoParse.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            createScript();
        }
    });
    GridData gd_btnNoParse = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_btnNoParse.widthHint = 120;
    btnNoParse.setLayoutData(gd_btnNoParse);
    btnNoParse.setText("No Parse");
    btnParse.setSelection(true);
    // 새로 �성할때만 선�가능하다. 수정중�때는 사용불가.
    composite_2.setEnabled(this.jobDao.getJob() <= 0);
    lblNewLabel = new Label(compositeHead, SWT.NONE);
    lblNewLabel.setText("실행작업");
    Composite composite_1 = new Composite(compositeHead, SWT.NONE);
    composite_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    composite_1.setLayout(new GridLayout(3, false));
    comboType = new Combo(composite_1, SWT.READ_ONLY);
    comboType.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (StringUtils.startsWithIgnoreCase(PublicTadpoleDefine.OBJECT_TYPE.PACKAGES.name(), comboType.getText()) || StringUtils.startsWithIgnoreCase(PublicTadpoleDefine.OBJECT_TYPE.PROCEDURES.name(), comboType.getText())) {
                initMainObject(comboType.getText());
            } else {
                //PL/SQL블럭 스�립트를 �성한다.
                textScript.setText("DBMS_OUTPUT.PUT_LINE('today is ' || to_char(sysdate)); ");
                createScript();
            }
        }
    });
    comboType.setItems(new String[] { "Procedure", "Package", "PL/SQL Block" });
    comboType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboType.select(0);
    comboObject = new Combo(composite_1, SWT.READ_ONLY);
    comboObject.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (StringUtils.startsWithIgnoreCase(PublicTadpoleDefine.OBJECT_TYPE.PACKAGES.name(), comboType.getText())) {
                // 패키지 �면 패키지 목�(함수, 프로시져)를 로딩한다.
                initPackgeBodys(comboObject.getText());
            } else if (StringUtils.startsWithIgnoreCase(PublicTadpoleDefine.OBJECT_TYPE.PROCEDURES.name(), comboType.getText())) {
                // 프로시져�때는 아규먼트 목�� 로딩한다.
                initParameters(comboObject.getSelectionIndex());
            }
            createScript();
        }
    });
    GridData gd_comboObject = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_comboObject.widthHint = 200;
    comboObject.setLayoutData(gd_comboObject);
    comboSubObject = new Combo(composite_1, SWT.READ_ONLY);
    comboSubObject.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            initParameters(comboSubObject.getSelectionIndex());
            createScript();
        }
    });
    comboSubObject.setEnabled(false);
    GridData gd_comboSubObject = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_comboSubObject.widthHint = 200;
    comboSubObject.setLayoutData(gd_comboSubObject);
    SashForm sashForm = new SashForm(containerInput, SWT.VERTICAL);
    sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    grpTables = new Group(sashForm, SWT.NONE);
    GridLayout gl_grpTables = new GridLayout(1, false);
    gl_grpTables.horizontalSpacing = 2;
    gl_grpTables.verticalSpacing = 2;
    gl_grpTables.marginHeight = 2;
    gl_grpTables.marginWidth = 2;
    grpTables.setLayout(gl_grpTables);
    grpTables.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    grpTables.setText(Messages.get().CreateJobDialog_executedScript);
    textScript = new Text(grpTables, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    textScript.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent event) {
            createScript();
        }
    });
    textScript.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            createScript();
        }
    });
    GridData gd_textScript = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    gd_textScript.heightHint = 100;
    gd_textScript.minimumHeight = 100;
    textScript.setLayoutData(gd_textScript);
    textScript.setText(this.jobDao.getWhat());
    label_1 = new Label(grpTables, SWT.NONE);
    label_1.setText(Messages.get().Preview);
    textPreview = new Text(grpTables, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    textPreview.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    initMainObject(this.comboType.getText());
    createScript();
    // google analytic
    AnalyticCaller.track(this.getClass().getName());
    return containerInput;
}
Example 60
Project: ui-bindings-master  File: UIAttributeFactoryTest.java View source code
@Parameters
public static Collection<Object[]> data() {
    return Arrays.asList(new Object[][] { { Button.class, SWT.PUSH, "", String.class, "text" }, { Button.class, SWT.PUSH, "text", String.class, "text" }, { Button.class, SWT.PUSH, "background", Color.class, "background" }, { Button.class, SWT.PUSH, "enabled", Boolean.TYPE, "enabled" }, { Button.class, SWT.PUSH, "cursor", Cursor.class, "cursor" }, { Button.class, SWT.PUSH, "font", Font.class, "font" }, { Button.class, SWT.PUSH, "foreground", Color.class, "foreground" }, { Button.class, SWT.PUSH, "foreground", Color.class, "foreground" }, { Button.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { Button.class, SWT.PUSH, "visible", Boolean.TYPE, "visible" }, { Button.class, SWT.CHECK, "", Boolean.TYPE, null }, { Button.class, SWT.CHECK, "selection", Boolean.TYPE, "selection" }, { Button.class, SWT.RADIO, "", Boolean.TYPE, null }, { Button.class, SWT.RADIO, "selection", Boolean.TYPE, "selection" }, { Button.class, SWT.TOGGLE, "", Boolean.TYPE, null }, { Button.class, SWT.TOGGLE, "selection", Boolean.TYPE, "selection" }, { CCombo.class, SWT.NONE, "", String.class, "text" }, { CCombo.class, SWT.NONE, "selection", Point.class, "selection" }, { CCombo.class, SWT.NONE, "text", String.class, "text" }, { CCombo.class, SWT.NONE, "background", Color.class, "background" }, { CCombo.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { CCombo.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { CCombo.class, SWT.NONE, "font", Font.class, "font" }, { CCombo.class, SWT.NONE, "foreground", Color.class, "foreground" }, { CCombo.class, SWT.NONE, "foreground", Color.class, "foreground" }, { CCombo.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { CCombo.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { CLabel.class, SWT.NONE, "", String.class, "text" }, { CLabel.class, SWT.NONE, "text", String.class, "text" }, { CLabel.class, SWT.NONE, "background", Color.class, "background" }, { CLabel.class, SWT.NONE, "image", Image.class, "image" }, { CLabel.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { CLabel.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { CLabel.class, SWT.NONE, "font", Font.class, "font" }, { CLabel.class, SWT.NONE, "foreground", Color.class, "foreground" }, { CLabel.class, SWT.NONE, "foreground", Color.class, "foreground" }, { CLabel.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { CLabel.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { Combo.class, SWT.NONE, "", String.class, "text" }, { Combo.class, SWT.NONE, "selection", Point.class, "selection" }, { Combo.class, SWT.NONE, "text", String.class, "text" }, { Combo.class, SWT.NONE, "background", Color.class, "background" }, { Combo.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { Combo.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { Combo.class, SWT.NONE, "font", Font.class, "font" }, { Combo.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Combo.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Combo.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { Combo.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { DateTime.class, SWT.NONE, "", Date.class, null }, /* composite value */
    { DateTime.class, SWT.NONE, "date", Date.class, null }, /* composite value */
    { DateTime.class, SWT.NONE, "background", Color.class, "background" }, { DateTime.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { DateTime.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { DateTime.class, SWT.NONE, "font", Font.class, "font" }, { DateTime.class, SWT.NONE, "foreground", Color.class, "foreground" }, { DateTime.class, SWT.NONE, "foreground", Color.class, "foreground" }, { DateTime.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { DateTime.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { Form.class, SWT.NONE, "", String.class, "text" }, { Form.class, SWT.NONE, "text", String.class, "text" }, { Form.class, SWT.NONE, "background", Color.class, "background" }, { Form.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { Form.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { Form.class, SWT.NONE, "font", Font.class, "font" }, { Form.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Form.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Form.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { Form.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { Hyperlink.class, SWT.NONE, "", String.class, "text" }, { Hyperlink.class, SWT.NONE, "text", String.class, "text" }, { Hyperlink.class, SWT.NONE, "background", Color.class, "background" }, { Hyperlink.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { Hyperlink.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { Hyperlink.class, SWT.NONE, "font", Font.class, "font" }, { Hyperlink.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Hyperlink.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Hyperlink.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { Hyperlink.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { Label.class, SWT.NONE, "", String.class, "text" }, { Label.class, SWT.NONE, "text", String.class, "text" }, { Label.class, SWT.NONE, "image", Image.class, "image" }, { Label.class, SWT.NONE, "background", Color.class, "background" }, { Label.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { Label.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { Label.class, SWT.NONE, "font", Font.class, "font" }, { Label.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Label.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Label.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { Label.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { Link.class, SWT.NONE, "", String.class, "text" }, { Link.class, SWT.NONE, "text", String.class, "text" }, { Link.class, SWT.NONE, "background", Color.class, "background" }, { Link.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { Link.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { Link.class, SWT.NONE, "font", Font.class, "font" }, { Link.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Link.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Link.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { Link.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, // Calculated property
    { List.class, SWT.NONE, "", String.class, null }, // Calculated property
    { List.class, SWT.NONE, "selection", String.class, null }, { List.class, SWT.NONE, "background", Color.class, "background" }, { List.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { List.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { List.class, SWT.NONE, "font", Font.class, "font" }, { List.class, SWT.NONE, "foreground", Color.class, "foreground" }, { List.class, SWT.NONE, "foreground", Color.class, "foreground" }, { List.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { List.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { Scale.class, SWT.NONE, "", Integer.TYPE, "selection" }, { Scale.class, SWT.NONE, "max", Integer.TYPE, "maximum" }, { Scale.class, SWT.NONE, "min", Integer.TYPE, "minimum" }, { Scale.class, SWT.NONE, "selection", Integer.TYPE, "selection" }, { Scale.class, SWT.NONE, "background", Color.class, "background" }, { Scale.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { Scale.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { Scale.class, SWT.NONE, "font", Font.class, "font" }, { Scale.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Scale.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { Scale.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { ScrolledForm.class, SWT.NONE, "", String.class, "text" }, { ScrolledForm.class, SWT.NONE, "text", String.class, "text" }, { ScrolledForm.class, SWT.NONE, "background", Color.class, "background" }, { ScrolledForm.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { ScrolledForm.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { ScrolledForm.class, SWT.NONE, "font", Font.class, "font" }, { ScrolledForm.class, SWT.NONE, "foreground", Color.class, "foreground" }, { ScrolledForm.class, SWT.NONE, "foreground", Color.class, "foreground" }, { ScrolledForm.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { ScrolledForm.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { Section.class, SWT.NONE, "text", String.class, "text" }, { Section.class, SWT.NONE, "background", Color.class, "background" }, { Section.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { Section.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { Section.class, SWT.NONE, "font", Font.class, "font" }, { Section.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Section.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Section.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { Section.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { Shell.class, SWT.NONE, "text", String.class, "text" }, { Shell.class, SWT.NONE, "background", Color.class, "background" }, { Shell.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { Shell.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { Shell.class, SWT.NONE, "font", Font.class, "font" }, { Shell.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Shell.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Shell.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { Slider.class, SWT.NONE, "", Integer.TYPE, "selection" }, { Slider.class, SWT.NONE, "max", Integer.TYPE, "maximum" }, { Slider.class, SWT.NONE, "min", Integer.TYPE, "minimum" }, { Slider.class, SWT.NONE, "selection", Integer.TYPE, "selection" }, { Slider.class, SWT.NONE, "background", Color.class, "background" }, { Slider.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { Slider.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { Slider.class, SWT.NONE, "font", Font.class, "font" }, { Slider.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Slider.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Slider.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { Slider.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { Spinner.class, SWT.NONE, "", Integer.TYPE, "selection" }, { Spinner.class, SWT.NONE, "max", Integer.TYPE, "maximum" }, { Spinner.class, SWT.NONE, "min", Integer.TYPE, "minimum" }, { Spinner.class, SWT.NONE, "selection", Integer.TYPE, "selection" }, { Spinner.class, SWT.NONE, "background", Color.class, "background" }, { Spinner.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { Spinner.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { Spinner.class, SWT.NONE, "font", Font.class, "font" }, { Spinner.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Spinner.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Spinner.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { Spinner.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { StyledText.class, SWT.NONE, "", String.class, "text" }, { StyledText.class, SWT.NONE, "text", String.class, "text" }, { StyledText.class, SWT.NONE, "background", Color.class, "background" }, { StyledText.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { StyledText.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { StyledText.class, SWT.NONE, "font", Font.class, "font" }, { StyledText.class, SWT.NONE, "foreground", Color.class, "foreground" }, { StyledText.class, SWT.NONE, "foreground", Color.class, "foreground" }, { StyledText.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { StyledText.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { TableColumn.class, SWT.NONE, "alignment", Integer.TYPE, "alignment" }, { TableColumn.class, SWT.NONE, "image", Image.class, "image" }, { TableColumn.class, SWT.NONE, "text", String.class, "text" }, { TableColumn.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { TableColumn.class, SWT.NONE, "width", Integer.TYPE, "width" }, { Text.class, SWT.NONE, "", String.class, "text" }, { Text.class, SWT.NONE, "editable", Boolean.TYPE, "editable" }, { Text.class, SWT.NONE, "text", String.class, "text" }, { Text.class, SWT.NONE, "background", Color.class, "background" }, { Text.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { Text.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { Text.class, SWT.NONE, "font", Font.class, "font" }, { Text.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Text.class, SWT.NONE, "foreground", Color.class, "foreground" }, { Text.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { Text.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { TreeColumn.class, SWT.NONE, "alignment", Integer.TYPE, "alignment" }, { TreeColumn.class, SWT.NONE, "image", Image.class, "image" }, { TreeColumn.class, SWT.NONE, "text", String.class, "text" }, { TreeColumn.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { TreeColumn.class, SWT.NONE, "width", Integer.TYPE, "width" }, { TabItem.class, SWT.NONE, "", String.class, "text" }, { TabItem.class, SWT.NONE, "image", Image.class, "image" }, { TabItem.class, SWT.NONE, "text", String.class, "text" }, { TabItem.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { ToolItem.class, SWT.NONE, "", String.class, "text" }, { ToolItem.class, SWT.NONE, "image", Image.class, "image" }, { ToolItem.class, SWT.NONE, "text", String.class, "text" }, { ToolItem.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { ToolItem.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { RadioGroup.class, SWT.NONE, "", String.class, null }, { RadioGroup.class, SWT.NONE, "text", String.class, null }, { RadioGroup.class, SWT.NONE, "background", Color.class, "background" }, { RadioGroup.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { RadioGroup.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { RadioGroup.class, SWT.NONE, "font", Font.class, "font" }, { RadioGroup.class, SWT.NONE, "foreground", Color.class, "foreground" }, { RadioGroup.class, SWT.NONE, "foreground", Color.class, "foreground" }, { RadioGroup.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { RadioGroup.class, SWT.NONE, "visible", Boolean.TYPE, "visible" }, { FileNameControl.class, SWT.NONE, "", String.class, null }, { FileNameControl.class, SWT.NONE, "text", String.class, null }, { FileNameControl.class, SWT.NONE, "background", Color.class, "background" }, { FileNameControl.class, SWT.NONE, "enabled", Boolean.TYPE, "enabled" }, { FileNameControl.class, SWT.NONE, "cursor", Cursor.class, "cursor" }, { FileNameControl.class, SWT.NONE, "font", Font.class, "font" }, { FileNameControl.class, SWT.NONE, "foreground", Color.class, "foreground" }, { FileNameControl.class, SWT.NONE, "foreground", Color.class, "foreground" }, { FileNameControl.class, SWT.NONE, "tooltip", String.class, "toolTipText" }, { FileNameControl.class, SWT.NONE, "visible", Boolean.TYPE, "visible" } });
}
Example 61
Project: uml-auto-assessment-master  File: PreviewQueryClausePanel.java View source code
private Composite createTimestampDetailPanel(Composite parent) {
    GridData gd;
    Composite composite = new Composite(parent, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    composite.setLayoutData(gd);
    GridLayout layout = createGridLayout(2, false);
    composite.setLayout(layout);
    dateOperandField = new DateTime(composite, SWT.DATE | SWT.MEDIUM);
    gd = new GridData(SWT.FILL, SWT.CENTER, false, false);
    dateOperandField.setLayoutData(gd);
    timeOperandField = new DateTime(composite, SWT.TIME | SWT.SHORT);
    gd = new GridData(SWT.FILL, SWT.CENTER, false, false);
    timeOperandField.setLayoutData(gd);
    return composite;
}
Example 62
Project: gmf-tooling-master  File: AbstractCustomSectionParent.java View source code
private DateTime createDate(Composite parent, String label, Control leftControl, Control topControl, boolean defaultIsTop, boolean defaultIsLeft, boolean lowermost, boolean rightmost) {
    DateTime date = new DateTime(parent, SWT.DATE);
    date.setBackground(parent.getBackground());
    date.setForeground(parent.getForeground());
    getWidgetFactory().adapt(date);
    Control leftWidget = leftControl;
    if (label != null && label.length() != 0) {
        leftWidget = createLabelWidget(parent, label, leftControl, topControl);
    }
    FormData data = createFormData(leftWidget, topControl, null, null, defaultIsLeft, defaultIsTop, lowermost, rightmost);
    date.setLayoutData(data);
    return date;
}
Example 63
Project: Klerk-master  File: SingleDocumentEditor.java View source code
@Override
public void createPartControl(Composite parent) {
    form = toolkit.createScrolledForm(parent);
    form.setText(Messages.SingleDocumentEditor_INVOICE + document.getTitle());
    TableWrapLayout twlayout = new TableWrapLayout();
    twlayout.numColumns = 2;
    form.getBody().setLayout(twlayout);
    // general section
    Section sectionGeneral = toolkit.createSection(form.getBody(), Section.DESCRIPTION | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
    sectionGeneral.setText(Messages.SingleDocumentEditor_Main);
    sectionGeneral.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(true);
        }
    });
    toolkit.createCompositeSeparator(sectionGeneral);
    createSectionToolbar(sectionGeneral, toolkit);
    sectionGeneral.setDescription(Messages.SingleDocumentEditor_Invoice_main_properties);
    Composite sectionGeneralClient = toolkit.createComposite(sectionGeneral);
    TableWrapLayout twLayoutSectionGeneral = new TableWrapLayout();
    twLayoutSectionGeneral.numColumns = 4;
    sectionGeneralClient.setLayout(twLayoutSectionGeneral);
    // invoice title
    Label titleLbl = toolkit.createLabel(sectionGeneralClient, Messages.SingleDocumentEditor_Title);
    final Text titleTxt = toolkit.createText(sectionGeneralClient, this.document.getTitle(), SWT.BORDER);
    //$NON-NLS-1$
    bindValidator(titleTxt, document, "title", new FieldNotEmptyValidator("This field cannot be empty!"));
    titleTxt.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            docTitle = titleTxt.getText();
            document.setTitle(docTitle);
            enableSave(true);
        }
    });
    TableWrapData twd_titleTxt = new TableWrapData(TableWrapData.FILL_GRAB);
    twd_titleTxt.colspan = 3;
    titleTxt.setLayoutData(twd_titleTxt);
    // invoice created date
    Label createdDateLbl = toolkit.createLabel(sectionGeneralClient, Messages.SingleDocumentEditor_Created_Date);
    final DateTime createDate = new DateTime(sectionGeneralClient, SWT.DATE | SWT.BORDER);
    createDate.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            document.setCreatedDate(new Date(createDate.getYear(), createDate.getMonth(), createDate.getDay()));
            enableSave(true);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    // invoice seller
    Label sellerLbl = toolkit.createLabel(sectionGeneralClient, Messages.SingleDocumentEditor_Seller);
    TableWrapData twd_sellerLbl = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
    twd_sellerLbl.indent = 55;
    sellerLbl.setLayoutData(twd_sellerLbl);
    //$NON-NLS-1$
    sellerTxt = toolkit.createText(sectionGeneralClient, "", SWT.BORDER);
    //$NON-NLS-1$
    bindValidator(sellerTxt, document.getSeller(), "fullName", new FieldNotEmptyValidator("This field cannot be empty!"));
    new AutocompleteTextInput(sellerTxt, getCompanyNames(CompaniesModelProvider.INSTANCE.getCompanies()));
    TableWrapData twd_sellerTxt = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
    twd_sellerTxt.indent = 5;
    twd_sellerTxt.align = TableWrapData.FILL;
    sellerTxt.setLayoutData(twd_sellerTxt);
    sellerTxt.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            docSeller = getCurrentContractor(sellerTxt.getText());
            document.setSeller(docSeller);
            enableSave(true);
        }
    });
    // invoice transaction date
    Label transactionDateLbl = toolkit.createLabel(sectionGeneralClient, Messages.SingleDocumentEditor_Transaction_Date);
    final DateTime transactionDate = new DateTime(sectionGeneralClient, SWT.DATE | SWT.BORDER);
    transactionDate.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            document.setTransactionDate(new Date(transactionDate.getYear(), transactionDate.getMonth(), transactionDate.getDay()));
            enableSave(true);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    // invoice buyer
    Label buyerLbl = toolkit.createLabel(sectionGeneralClient, Messages.SingleDocumentEditor_Buyer);
    TableWrapData twd_buyerLbl = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
    twd_buyerLbl.indent = 55;
    buyerLbl.setLayoutData(twd_buyerLbl);
    //$NON-NLS-1$
    buyerTxt = toolkit.createText(sectionGeneralClient, "", SWT.BORDER);
    //$NON-NLS-1$
    bindValidator(buyerTxt, document.getBuyer(), "fullName", new FieldNotEmptyValidator("This field cannot be empty!"));
    new AutocompleteTextInput(buyerTxt, getCompanyNames(CompaniesModelProvider.INSTANCE.getCompanies()));
    TableWrapData twd_buyerTxt = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
    twd_buyerTxt.indent = 5;
    twd_buyerTxt.align = TableWrapData.FILL;
    buyerTxt.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            docBuyer = getCurrentContractor(buyerTxt.getText());
            document.setBuyer(docBuyer);
            enableSave(true);
        }
    });
    buyerTxt.setLayoutData(twd_buyerTxt);
    // invoice due date
    Label dueDateLbl = toolkit.createLabel(sectionGeneralClient, Messages.SingleDocumentEditor_due_date);
    final DateTime dueDate = new DateTime(sectionGeneralClient, SWT.DATE | SWT.BORDER);
    dueDate.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            document.setDueDate(new Date(dueDate.getYear(), dueDate.getMonth(), dueDate.getDay()));
            enableSave(true);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    //invoice created by
    Label createdByLbl = toolkit.createLabel(sectionGeneralClient, Messages.SingleDocumentEditor_created_by);
    TableWrapData twd_createdByLbl = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
    twd_createdByLbl.indent = 55;
    createdByLbl.setLayoutData(twd_createdByLbl);
    //$NON-NLS-1$
    final Text createdByTxt = toolkit.createText(sectionGeneralClient, "", SWT.BORDER);
    new AutocompleteTextInput(createdByTxt, getPeopleNames(PeopleModelProvider.INSTANCE.getPeople()));
    createdByTxt.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            docCreatedBy = findSelectedCreator(createdByTxt.getText());
            document.setCreator(docCreatedBy);
            enableSave(true);
        }

        private Person findSelectedCreator(String selected) {
            for (Person p : PeopleModelProvider.INSTANCE.getPeople()) {
                String fullName = p.getFirstName() + " " + p.getLastName();
                if (fullName.equals(selected)) {
                    return p;
                }
            }
            return null;
        }
    });
    //$NON-NLS-1$
    bindValidator(createdByTxt, document.getCreator(), "fullName", new FieldNotEmptyValidator("This field cannot be empty!"));
    TableWrapData twd_createdByTxt = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
    twd_createdByTxt.indent = 5;
    twd_createdByTxt.align = TableWrapData.FILL;
    createdByTxt.setLayoutData(twd_createdByTxt);
    sectionGeneral.setClient(sectionGeneralClient);
    TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
    data.colspan = 2;
    data.grabVertical = true;
    data.valign = TableWrapData.FILL;
    sectionGeneral.setLayoutData(data);
    // invoice items section
    Section sectionItems = toolkit.createSection(form.getBody(), Section.DESCRIPTION | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
    sectionItems.setText(Messages.SingleDocumentEditor_Invoice_Items);
    sectionItems.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(true);
        }
    });
    toolkit.createCompositeSeparator(sectionItems);
    createItemsSectionToolbar(sectionItems, toolkit);
    Composite sectionItemsClient = toolkit.createComposite(sectionItems);
    TableWrapLayout twLayoutSectionItems = new TableWrapLayout();
    twLayoutSectionItems.numColumns = 2;
    sectionItemsClient.setLayout(twLayoutSectionItems);
    createTableViewer(sectionItemsClient);
    sectionItems.setClient(sectionItemsClient);
    data = new TableWrapData(TableWrapData.FILL_GRAB);
    data.colspan = 2;
    data.grabVertical = true;
    data.valign = TableWrapData.FILL;
    sectionItems.setLayoutData(data);
    // section summary
    Section sectionSummary = toolkit.createSection(form.getBody(), Section.DESCRIPTION | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
    sectionSummary.setText(Messages.SingleDocumentEditor_Invoice_Summary);
    sectionSummary.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(true);
        }
    });
    toolkit.createCompositeSeparator(sectionSummary);
    sectionSummary.setDescription(Messages.SingleDocumentEditor_Summary);
    Composite sectionSummaryClient = toolkit.createComposite(sectionSummary);
    TableWrapLayout twLayoutSectionSummary = new TableWrapLayout();
    twLayoutSectionSummary.numColumns = 4;
    sectionSummaryClient.setLayout(twLayoutSectionSummary);
    //		Composite filler = toolkit.createComposite(sectionSummaryClient);
    //		filler.setForeground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION));
    Label lblToPay = new Label(sectionSummaryClient, SWT.NONE);
    lblToPay.setFont(SWTResourceManager.getFont("Ubuntu", 22, SWT.NORMAL));
    //		lblToPay.setBounds(10, 10, 137, 33);
    //		toolkit.adapt(lblToPay, true, true);
    lblToPay.setText(Messages.SingleDocumentEditor_lblToPay_text);
    data_1 = new TableWrapData(TableWrapData.FILL_GRAB);
    data_1.grabVertical = true;
    data_1.valign = TableWrapData.FILL;
    data_1.colspan = 1;
    lblToPay.setLayoutData(data_1);
    toPayTxt = new Label(sectionSummaryClient, SWT.NONE);
    toPayTxt.setFont(SWTResourceManager.getFont("Ubuntu", 22, SWT.NORMAL));
    //		toPayTxt.setBounds(153, 10, 365, 34);
    //		toolkit.adapt(toPayTxt, true, true);
    toPayTxt.setText(getToPayText());
    data_1 = new TableWrapData(TableWrapData.FILL_GRAB);
    data_1.grabVertical = true;
    data_1.valign = TableWrapData.FILL;
    data_1.colspan = 1;
    toPayTxt.setLayoutData(data_1);
    createSummaryTableViewer(sectionSummaryClient);
    sectionSummary.setClient(sectionSummaryClient);
    data = new TableWrapData(TableWrapData.FILL_GRAB);
    data.colspan = 2;
    sectionSummary.setLayoutData(data);
    // section notes
    Section sectionNotes = toolkit.createSection(form.getBody(), Section.DESCRIPTION | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
    sectionNotes.setText(Messages.SingleDocumentEditor_Notes);
    sectionNotes.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(true);
        }
    });
    toolkit.createCompositeSeparator(sectionNotes);
    Composite sectionNotesClient = toolkit.createComposite(sectionNotes);
    TableWrapLayout twLayoutsectionNotes = new TableWrapLayout();
    twLayoutsectionNotes.numColumns = 2;
    sectionNotesClient.setLayout(twLayoutsectionNotes);
    final Text notesTxt = toolkit.createText(sectionNotesClient, this.document.getNotes(), SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    TableWrapData twd_notesTxt = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
    twd_notesTxt.grabVertical = true;
    twd_notesTxt.grabHorizontal = true;
    twd_notesTxt.heightHint = 180;
    twd_notesTxt.colspan = 1;
    notesTxt.setLayoutData(twd_notesTxt);
    notesTxt.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            document.setNotes(notesTxt.getText());
            enableSave(true);
        }
    });
    sectionNotes.setClient(sectionNotesClient);
    data = new TableWrapData(TableWrapData.FILL_GRAB);
    data.colspan = 2;
    sectionNotes.setLayoutData(data);
    setDocumentSpecificFieldState();
    m_bindingContext = initDataBindings();
    this.started = true;
}
Example 64
Project: RSSOwl-master  File: SearchConditionItem.java View source code
@SuppressWarnings("unchecked")
private void updateInputField(Composite inputField, final ISearchField field, final Object input) {
    /* Dispose any old Children first */
    Control[] children = inputField.getChildren();
    for (Control child : children) {
        child.dispose();
    }
    /* Specially treat News-State */
    if (field.getId() == INews.STATE) {
        final StateConditionControl stateConditionControl = new StateConditionControl(inputField, SWT.NONE);
        stateConditionControl.addListener(SWT.Modify, new Listener() {

            public void handleEvent(Event event) {
                fInputValue = stateConditionControl.getSelection();
                if (fInputValue == null && input != null || (fInputValue != null && !fInputValue.equals(input)))
                    fModified = true;
            }
        });
        /* Pre-Select input if given */
        Object presetInput = (input == null) ? fInputValue : input;
        if (presetInput != null && presetInput instanceof EnumSet)
            stateConditionControl.select((EnumSet<State>) presetInput);
        /* Update Input Value */
        fInputValue = stateConditionControl.getSelection();
    } else /* Specially treat News-Location */
    if (field.getId() == INews.LOCATION) {
        final LocationControl locationConditionControl = new LocationControl(inputField, SWT.NONE);
        locationConditionControl.addListener(SWT.Modify, new Listener() {

            public void handleEvent(Event event) {
                fInputValue = locationConditionControl.getSelection();
                if (fInputValue == null && input != null || (fInputValue != null && !fInputValue.equals(input)))
                    fModified = true;
            }
        });
        /* Pre-Select input if given */
        Object presetInput = (input == null) ? fInputValue : input;
        if (presetInput != null && presetInput instanceof Long[][])
            locationConditionControl.select((Long[][]) presetInput);
        /* Update Input Value */
        fInputValue = locationConditionControl.getSelection();
    } else /* Specially treat Age */
    if (field.getId() == INews.AGE_IN_DAYS || field.getId() == INews.AGE_IN_MINUTES) {
        Composite container = new Composite(inputField, SWT.NONE);
        container.setLayout(LayoutUtils.createGridLayout(2, 0, 0));
        final Spinner spinner = new Spinner(container, SWT.BORDER);
        spinner.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
        spinner.setMinimum(1);
        spinner.setMaximum(1000000);
        final Combo combo = new Combo(container, SWT.BORDER | SWT.READ_ONLY);
        combo.add(Messages.SearchConditionItem_DAYS);
        combo.add(Messages.SearchConditionItem_HOURS);
        combo.add(Messages.SearchConditionItem_MINUTES);
        Listener listener = new Listener() {

            public void handleEvent(Event event) {
                fInputValue = getAgeValue(spinner, combo);
                if (!fInputValue.equals(input))
                    fModified = true;
            }
        };
        spinner.addListener(SWT.Modify, listener);
        combo.addListener(SWT.Modify, listener);
        /* Pre-Select input if given */
        Object presetInput = (input == null) ? fInputValue : input;
        if (presetInput != null && presetInput instanceof Integer) {
            Integer inputValue = (Integer) presetInput;
            /* Day */
            if (inputValue >= 0) {
                spinner.setSelection(inputValue);
                combo.select(0);
            } else /* Hour */
            if (inputValue % 60 == 0) {
                spinner.setSelection(Math.abs(inputValue) / 60);
                combo.select(1);
            } else /* Minute */
            {
                spinner.setSelection(Math.abs(inputValue));
                combo.select(2);
            }
        } else /* Otherwise use Default */
        {
            spinner.setSelection(1);
            combo.select(0);
        }
        /* Update Input Value */
        fInputValue = getAgeValue(spinner, combo);
    } else /* Create new Input Field based on search-value-type */
    {
        switch(field.getSearchValueType().getId()) {
            /* Type: Boolean */
            case ISearchValueType.BOOLEAN:
                {
                    final Combo combo = new Combo(inputField, SWT.BORDER | SWT.READ_ONLY);
                    combo.add(Messages.SearchConditionItem_TRUE);
                    combo.add(Messages.SearchConditionItem_FALSE);
                    combo.addListener(SWT.Modify, new Listener() {

                        public void handleEvent(Event event) {
                            fInputValue = Boolean.valueOf(combo.getItem(combo.getSelectionIndex()));
                            if (!fInputValue.equals(input))
                                fModified = true;
                        }
                    });
                    /* Pre-Select input if given */
                    Object presetInput = (input == null) ? fInputValue : input;
                    if (presetInput != null && presetInput instanceof Boolean)
                        combo.select(((Boolean) presetInput) ? 0 : 1);
                    else
                        combo.select(0);
                    /* Update Input Value */
                    fInputValue = Boolean.valueOf(combo.getItem(combo.getSelectionIndex()));
                    break;
                }
            /* Type: Date / Time */
            case ISearchValueType.DATE:
            case ISearchValueType.TIME:
            case ISearchValueType.DATETIME:
                {
                    final Calendar cal = Calendar.getInstance();
                    final DateTime datetime = new DateTime(inputField, SWT.DATE | SWT.BORDER);
                    datetime.addListener(SWT.Selection, new Listener() {

                        public void handleEvent(Event event) {
                            cal.set(Calendar.DATE, datetime.getDay());
                            cal.set(Calendar.MONTH, datetime.getMonth());
                            cal.set(Calendar.YEAR, datetime.getYear());
                            fInputValue = cal.getTime();
                            if (!fInputValue.equals(input))
                                fModified = true;
                        }
                    });
                    /* Pre-Select input if given */
                    Object presetInput = (input == null) ? fInputValue : input;
                    if (presetInput != null && presetInput instanceof Date)
                        cal.setTime((Date) presetInput);
                    datetime.setDay(cal.get(Calendar.DATE));
                    datetime.setMonth(cal.get(Calendar.MONTH));
                    datetime.setYear(cal.get(Calendar.YEAR));
                    /* Update Input Value */
                    fInputValue = cal.getTime();
                    break;
                }
            /* Type: Enumeration */
            case ISearchValueType.ENUM:
                {
                    final Text text = new Text(inputField, SWT.BORDER);
                    text.addListener(SWT.Modify, new Listener() {

                        public void handleEvent(Event event) {
                            fInputValue = text.getText();
                            if (!fInputValue.equals(input))
                                fModified = true;
                        }
                    });
                    /* Provide Auto-Complete Field */
                    OwlUI.hookAutoComplete(text, field.getSearchValueType().getEnumValues(), true, true);
                    /* Pre-Select input if given */
                    String inputValue = (input != null ? input.toString() : null);
                    if (inputValue != null)
                        text.setText(inputValue);
                    /* Update Input Value */
                    fInputValue = text.getText();
                    break;
                }
            /* Type: Number */
            case ISearchValueType.NUMBER:
            case ISearchValueType.INTEGER:
                {
                    final Spinner spinner = new Spinner(inputField, SWT.BORDER);
                    spinner.setMinimum(0);
                    spinner.setMaximum(1000);
                    spinner.addListener(SWT.Modify, new Listener() {

                        public void handleEvent(Event event) {
                            fInputValue = spinner.getSelection();
                            if (!fInputValue.equals(input))
                                fModified = true;
                        }
                    });
                    /* Pre-Select input if given */
                    Object presetInput = (input == null) ? fInputValue : input;
                    if (presetInput != null && presetInput instanceof Integer)
                        spinner.setSelection((Integer) presetInput);
                    /* Update Input Value */
                    fInputValue = spinner.getSelection();
                    break;
                }
            /* Type: String */
            case ISearchValueType.STRING:
            case ISearchValueType.LINK:
                {
                    final Text text = new Text(inputField, SWT.BORDER);
                    OwlUI.makeAccessible(text, NLS.bind(Messages.SearchConditionItem_SEARCH_VALUE_FIELD, field.getName()));
                    /* Show UI Hint for extra information is available */
                    final ControlDecoration controlDeco = new ControlDecoration(text, SWT.LEFT | SWT.TOP);
                    controlDeco.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage());
                    controlDeco.setShowOnlyOnFocus(true);
                    /* Listen to Changes of Input */
                    text.addListener(SWT.Modify, new Listener() {

                        private boolean isShowingWarning = false;

                        public void handleEvent(Event event) {
                            String textValue = text.getText();
                            fInputValue = textValue;
                            if (!fInputValue.equals(input))
                                fModified = true;
                            if (isShowingWarning)
                                controlDeco.hideHover();
                            /* Determine any Search Warning to show depending on field and text value */
                            SearchWarning warning = SearchWarning.NO_WARNING;
                            if (field.getId() == INews.CATEGORIES || field.getId() == INews.SOURCE || field.getId() == INews.FEED || field.getId() == INews.LINK) {
                                if (StringUtils.isPhraseSearch(textValue))
                                    warning = SearchWarning.PHRASE_SEARCH_UNSUPPORTED;
                            } else {
                                if (StringUtils.isPhraseSearchWithWildcardToken(textValue))
                                    warning = SearchWarning.PHRASE_AND_WILDCARD_SEARCH_COMBINED;
                                else if (StringUtils.isSpecialCharacterSearchWithWildcardToken(textValue))
                                    warning = SearchWarning.WILDCARD_AND_SPECIAL_CHAR_SEARCH;
                            }
                            /* Indicate a warning to the user if phrase search and wildcards combined or wrongly used */
                            if (warning != SearchWarning.NO_WARNING && !isShowingWarning) {
                                updateFieldDecoration(text, controlDeco, warning, field);
                                isShowingWarning = true;
                            } else /* Clear any error if shown previously */
                            if (warning == SearchWarning.NO_WARNING && isShowingWarning) {
                                updateFieldDecoration(text, controlDeco, warning, field);
                                isShowingWarning = false;
                            }
                        }
                    });
                    /* Provide auto-complete for Categories, Authors and Feeds */
                    if (field.getId() == INews.CATEGORIES || field.getId() == INews.AUTHOR || field.getId() == INews.FEED) {
                        controlDeco.setDescriptionText(Messages.SearchConditionItem_CONTENT_ASSIST_INFO);
                        final Pair<SimpleContentProposalProvider, ContentProposalAdapter> pair = OwlUI.hookAutoComplete(text, null, false, true);
                        /* Load proposals in the Background */
                        JobRunner.runInBackgroundThread(100, new Runnable() {

                            public void run() {
                                if (!text.isDisposed()) {
                                    Set<String> values = new TreeSet<String>(new Comparator<String>() {

                                        public int compare(String o1, String o2) {
                                            return o1.compareToIgnoreCase(o2);
                                        }
                                    });
                                    if (field.getId() == INews.CATEGORIES)
                                        values.addAll(fDaoService.getCategoryDAO().loadAllNames());
                                    else if (field.getId() == INews.AUTHOR)
                                        values.addAll(fDaoService.getPersonDAO().loadAllNames());
                                    else if (field.getId() == INews.FEED)
                                        values.addAll(CoreUtils.getFeedLinks());
                                    /* Apply Proposals */
                                    if (!text.isDisposed())
                                        OwlUI.applyAutoCompleteProposals(values, pair.getFirst(), pair.getSecond(), true);
                                }
                            }
                        });
                    } else /* Show UI Hint that Wildcards can be used */
                    {
                        controlDeco.setDescriptionText(Messages.SearchConditionItem_SEARCH_HELP);
                    }
                    /* Pre-Select input if given */
                    Object presetInput = (input == null && fInputValue instanceof String) ? fInputValue : input;
                    if (presetInput != null)
                        text.setText(presetInput.toString());
                    /* Update Input Value */
                    fInputValue = text.getText();
                    break;
                }
        }
    }
    /* Update Layout */
    inputField.getParent().layout();
    inputField.getParent().update();
    inputField.layout();
    inputField.update();
}
Example 65
Project: TACIT-master  File: SenateCrawlerView.java View source code
private void createSenateInputParameters(Composite client) {
    Section inputParamsSection = toolkit.createSection(client, Section.TITLE_BAR | Section.EXPANDED | Section.DESCRIPTION);
    GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(inputParamsSection);
    GridLayoutFactory.fillDefaults().numColumns(3).applyTo(inputParamsSection);
    inputParamsSection.setText("Input Parameters");
    ScrolledComposite sc = new ScrolledComposite(inputParamsSection, SWT.H_SCROLL | SWT.V_SCROLL);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(sc);
    Composite sectionClient = toolkit.createComposite(inputParamsSection);
    sc.setContent(sectionClient);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(sc);
    GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(sectionClient);
    inputParamsSection.setClient(sectionClient);
    String[] loading = { "Loading..." };
    Label congressLabel = toolkit.createLabel(sectionClient, "Congress:", SWT.NONE);
    GridDataFactory.fillDefaults().grab(false, false).span(1, 0).applyTo(congressLabel);
    cmbCongress = new Combo(sectionClient, SWT.FLAT | SWT.READ_ONLY);
    GridDataFactory.fillDefaults().grab(true, false).span(2, 0).applyTo(cmbCongress);
    toolkit.adapt(cmbCongress);
    cmbCongress.setItems(loading);
    cmbCongress.select(0);
    Label dummy1 = new Label(sectionClient, SWT.NONE);
    dummy1.setText("Senator:");
    GridDataFactory.fillDefaults().grab(false, false).span(1, 0).applyTo(dummy1);
    senatorTable = new Table(sectionClient, SWT.BORDER | SWT.MULTI);
    GridDataFactory.fillDefaults().grab(true, true).span(1, 3).hint(90, 50).applyTo(senatorTable);
    Composite buttonComp = new Composite(sectionClient, SWT.NONE);
    GridLayout btnLayout = new GridLayout();
    btnLayout.marginWidth = btnLayout.marginHeight = 0;
    btnLayout.makeColumnsEqualWidth = false;
    buttonComp.setLayout(btnLayout);
    buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    //$NON-NLS-1$
    addSenatorBtn = new Button(buttonComp, SWT.PUSH);
    addSenatorBtn.setText("Add...");
    GridDataFactory.fillDefaults().grab(false, false).span(1, 1).applyTo(addSenatorBtn);
    addSenatorBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleAdd(addSenatorBtn.getShell());
        }
    });
    addSenatorBtn.setEnabled(false);
    removeSenatorButton = new Button(buttonComp, SWT.PUSH);
    removeSenatorButton.setText("Remove...");
    GridDataFactory.fillDefaults().grab(false, false).span(1, 1).applyTo(removeSenatorButton);
    removeSenatorButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            for (TableItem item : senatorTable.getSelection()) {
                selectedSenators.remove(item.getText());
                item.dispose();
            }
            if (selectedSenators.size() == 0) {
                removeSenatorButton.setEnabled(false);
            }
        }
    });
    removeSenatorButton.setEnabled(false);
    TacitFormComposite.createEmptyRow(toolkit, sectionClient);
    Group limitGroup = new Group(client, SWT.SHADOW_IN);
    limitGroup.setText("Limit Records");
    //limitGroup.setBackground(client.getBackground());
    limitGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout limitLayout = new GridLayout();
    limitLayout.numColumns = 1;
    limitGroup.setLayout(limitLayout);
    final Composite limitRecordsClient = new Composite(limitGroup, SWT.None);
    GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(limitRecordsClient);
    GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(limitRecordsClient);
    limitRecords = new Button(limitRecordsClient, SWT.CHECK);
    limitRecords.setText("Limit Records per Senator");
    GridDataFactory.fillDefaults().grab(false, false).span(3, 0).applyTo(limitRecords);
    limitRecords.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (!limitRecords.getSelection()) {
                form.getMessageManager().removeMessage("limitText");
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // TODO Auto-generated method stub			
        }
    });
    final Label sortLabel = new Label(limitRecordsClient, SWT.NONE);
    sortLabel.setText("Sort Records by Date:");
    GridDataFactory.fillDefaults().grab(false, false).span(1, 0).applyTo(sortLabel);
    sortLabel.setEnabled(false);
    sortByDateYes = new Button(limitRecordsClient, SWT.RADIO);
    sortByDateYes.setText("Yes");
    sortByDateYes.setEnabled(false);
    sortByDateYes.setSelection(true);
    sortByDateNo = new Button(limitRecordsClient, SWT.RADIO);
    sortByDateNo.setText("No");
    sortByDateNo.setEnabled(false);
    final Label limitLabel = new Label(limitRecordsClient, SWT.NONE);
    limitLabel.setText("No.of.Records per Senator:");
    GridDataFactory.fillDefaults().grab(false, false).span(1, 0).applyTo(limitLabel);
    limitLabel.setEnabled(false);
    limitText = new Text(limitRecordsClient, SWT.BORDER);
    limitText.setText("1");
    GridDataFactory.fillDefaults().grab(true, false).span(2, 0).applyTo(limitText);
    limitText.setEnabled(false);
    limitText.addKeyListener(new KeyListener() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (!(e.character >= '0' && e.character <= '9')) {
                form.getMessageManager().addMessage("limitText", "Provide valid no.of.records per senator", null, IMessageProvider.ERROR);
                limitText.setText("");
            } else {
                form.getMessageManager().removeMessage("limitText");
            }
        }

        @Override
        public void keyPressed(KeyEvent e) {
        // TODO Auto-generated method stub			
        }
    });
    TacitFormComposite.createEmptyRow(toolkit, client);
    Group dateGroup = new Group(client, SWT.SHADOW_IN);
    dateGroup.setText("Date");
    dateGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    dateGroup.setLayout(layout);
    dateRange = new Button(dateGroup, SWT.CHECK);
    dateRange.setText("Specify Date Range");
    //TacitFormComposite.createEmptyRow(toolkit, group);
    final Composite dateRangeClient = new Composite(dateGroup, SWT.None);
    GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(dateRangeClient);
    GridLayoutFactory.fillDefaults().numColumns(4).equalWidth(false).applyTo(dateRangeClient);
    dateRangeClient.setEnabled(false);
    dateRangeClient.pack();
    final Label fromLabel = new Label(dateRangeClient, SWT.NONE);
    fromLabel.setText("From:");
    GridDataFactory.fillDefaults().grab(false, false).span(1, 0).applyTo(fromLabel);
    fromDate = new DateTime(dateRangeClient, SWT.DATE | SWT.DROP_DOWN | SWT.BORDER);
    GridDataFactory.fillDefaults().grab(false, false).span(1, 0).applyTo(fromDate);
    fromLabel.setEnabled(false);
    fromDate.setEnabled(false);
    fromDate.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            int day = fromDate.getDay();
            int month = fromDate.getMonth() + 1;
            int year = fromDate.getYear();
            Date newDate = null;
            try {
                newDate = format.parse(day + "/" + month + "/" + year);
            } catch (ParseException e) {
                e.printStackTrace();
            }
            if (newDate.before(minDate) || newDate.after(maxDate)) {
                Calendar cal = Calendar.getInstance();
                cal.setTime(minDate);
                fromDate.setMonth(cal.get(Calendar.MONTH));
                fromDate.setDay(cal.get(Calendar.DAY_OF_MONTH));
                fromDate.setYear(cal.get(Calendar.YEAR));
            }
        }
    });
    final Label toLabel = new Label(dateRangeClient, SWT.NONE);
    toLabel.setText("To:");
    GridDataFactory.fillDefaults().grab(false, false).span(1, 0).applyTo(toLabel);
    toDate = new DateTime(dateRangeClient, SWT.DATE | SWT.DROP_DOWN | SWT.BORDER);
    GridDataFactory.fillDefaults().grab(false, false).span(1, 0).applyTo(toDate);
    toLabel.setEnabled(false);
    toDate.setEnabled(false);
    toDate.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            int day = toDate.getDay();
            int month = toDate.getMonth() + 1;
            int year = toDate.getYear();
            Date newDate = null;
            try {
                newDate = format.parse(day + "/" + month + "/" + year);
            } catch (ParseException e) {
                e.printStackTrace();
            }
            if (newDate.after(maxDate) || newDate.before(minDate)) {
                Calendar cal = Calendar.getInstance();
                cal.setTime(maxDate);
                toDate.setMonth(cal.get(Calendar.MONTH));
                toDate.setDay(cal.get(Calendar.DAY_OF_MONTH));
                toDate.setYear(cal.get(Calendar.YEAR));
            }
        }
    });
    Job loadFieldValuesJob = new Job("Loading form field values") {

        HashMap<String, String> congressDetails = null;

        final ArrayList<String> tempCongress = new ArrayList<String>();

        final ArrayList<String> tempCongressYears = new ArrayList<String>();

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                congressDetails = AvailableRecords.getAllCongresses();
            } catch (IOException e) {
                e.printStackTrace();
            }
            Display.getDefault().syncExec(new Runnable() {

                @Override
                public void run() {
                    cmbCongress.removeAll();
                    for (String key : congressDetails.keySet()) {
                        tempCongress.add(key);
                        String value = congressDetails.get(key);
                        tempCongressYears.add(value);
                        cmbCongress.add(key + " (" + value + ")");
                        if (key.equalsIgnoreCase("All")) {
                            String[] tempYears = value.split("-");
                            Calendar cal = Calendar.getInstance();
                            cal.set(Integer.parseInt(tempYears[0]), 0, 1);
                            minDate = cal.getTime();
                            fromDate.setMonth(cal.get(Calendar.MONTH));
                            fromDate.setDay(cal.get(Calendar.DAY_OF_MONTH));
                            fromDate.setYear(cal.get(Calendar.YEAR));
                            cal.set(Integer.parseInt(tempYears[1]), 11, 31);
                            toDate.setMonth(cal.get(Calendar.MONTH));
                            toDate.setDay(cal.get(Calendar.DAY_OF_MONTH));
                            toDate.setYear(cal.get(Calendar.YEAR));
                            maxDate = cal.getTime();
                        }
                    }
                    //cmbCongress.setItems(congresses);
                    cmbCongress.select(0);
                }
            });
            congresses = tempCongress.toArray(new String[0]);
            congressYears = tempCongressYears.toArray(new String[0]);
            try {
                allSenators = AvailableRecords.getAllSenators(congresses);
                totalSenators = allSenators.length + 5;
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        addSenatorBtn.setEnabled(true);
                    }
                });
            } catch (IOException e2) {
                e2.printStackTrace();
            }
            return Status.OK_STATUS;
        }
    };
    //loadFieldValuesJob.setUser(true);
    loadFieldValuesJob.schedule();
    cmbCongress.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // set dates
            String tempYears[] = congressYears[cmbCongress.getSelectionIndex()].split("-");
            Calendar cal = Calendar.getInstance();
            cal.set(Integer.parseInt(tempYears[0]), 0, 1);
            minDate = cal.getTime();
            fromDate.setMonth(cal.get(Calendar.MONTH));
            fromDate.setDay(cal.get(Calendar.DAY_OF_MONTH));
            fromDate.setYear(cal.get(Calendar.YEAR));
            cal.set(Integer.parseInt(tempYears[1]), 11, 31);
            toDate.setMonth(cal.get(Calendar.MONTH));
            toDate.setDay(cal.get(Calendar.DAY_OF_MONTH));
            toDate.setYear(cal.get(Calendar.YEAR));
            maxDate = cal.getTime();
            //cmbSenator.select(0);
            //Empty the senatorTable
            senatorTable.removeAll();
            selectedSenators = new ArrayList<String>();
        }
    });
    dateRange.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (dateRange.getSelection()) {
                dateRangeClient.setEnabled(true);
                fromLabel.setEnabled(true);
                fromDate.setEnabled(true);
                toLabel.setEnabled(true);
                toDate.setEnabled(true);
            } else {
                dateRangeClient.setEnabled(false);
                fromLabel.setEnabled(false);
                fromDate.setEnabled(false);
                toLabel.setEnabled(false);
                toDate.setEnabled(false);
            }
        }
    });
    limitRecords.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (limitRecords.getSelection()) {
                sortByDateYes.setEnabled(true);
                sortByDateNo.setEnabled(true);
                sortLabel.setEnabled(true);
                limitLabel.setEnabled(true);
                limitText.setEnabled(true);
            } else {
                sortByDateYes.setEnabled(false);
                sortByDateNo.setEnabled(false);
                sortLabel.setEnabled(false);
                limitLabel.setEnabled(false);
                limitText.setEnabled(false);
            }
        }
    });
}
Example 66
Project: modellipse-master  File: XWTLoader.java View source code
private synchronized void initialize() {
    cores = new Stack<Core>();
    Core core = new Core(new ResourceLoaderFactory(), this);
    cores.push(core);
    core.registerService(ValueConvertorRegister.class, new ValueConvertorRegister());
    core.registerMetaclassManager(IConstants.XWT_NAMESPACE, new MetaclassManager(null, null, this));
    core.registerMetaclass(new BindingMetaclass(this), IConstants.XWT_NAMESPACE);
    core.registerMetaclass(new BindingMetaclass(MultiBinding.class, this), IConstants.XWT_NAMESPACE);
    core.registerMetaclass(new TableEditorMetaclass(core.getMetaclass(ControlEditor.class, IConstants.XWT_NAMESPACE), this), IConstants.XWT_NAMESPACE);
    registerConvertor(ObjectToString.FROM_OBJECT);
    registerConvertor(DateToString.instance);
    registerConvertor(EnumToString.instance);
    registerConvertor(StringToInteger.instance);
    // It is not supported by eclipse 3.4.1
    registerConvertor(StringToNumberConverter.class, "toBigDecimal");
    registerConvertor(StringToNumberConverter.class, "toByte", false);
    registerConvertor(StringToNumberConverter.toLong(false));
    // It is not supported by eclipse 3.4.1
    registerConvertor(StringToNumberConverter.class, "toShort", false);
    registerConvertor(StringToNumberConverter.toFloat(false));
    registerConvertor(StringToNumberConverter.toDouble(false));
    registerConvertor(NumberToStringConverter.fromInteger(false));
    // It is not supported by eclipse 3.4.1
    registerConvertor(NumberToStringConverter.class, "fromBigDecimal");
    registerConvertor(NumberToStringConverter.class, "fromByte", false);
    registerConvertor(NumberToStringConverter.fromLong(false));
    // It is not supported by eclipse 3.4.1
    registerConvertor(NumberToStringConverter.class, "fromShort", false);
    registerConvertor(NumberToStringConverter.fromFloat(false));
    registerConvertor(NumberToStringConverter.fromDouble(false));
    registerConvertor(StringToBoolean.instance);
    registerConvertor(ObjectToBoolean.instance);
    registerConvertor(SelectionToBoolean.instance);
    registerConvertor(CollectionToBoolean.instance);
    registerConvertor(CollectionToInteger.instance);
    registerConvertor(StringToIntArray.instance);
    registerConvertor(StringToDoubleArray.instance);
    registerConvertor(BindingToObject.instance);
    registerConvertor(StringToColor.instance);
    registerConvertor(StringToFont.instance);
    registerConvertor(StringToImage.instance);
    registerConvertor(StringToPoint.instance);
    registerConvertor(StringToRectangle.instance);
    registerConvertor(StringToURL.instance);
    registerConvertor(StringToType.instance);
    registerConvertor(StringToFormAttachment.instance);
    registerConvertor(StringToIValidationRule.instance);
    registerConvertor(StringToIValueConverter.instance);
    registerConvertor(ListToIObservableCollection.instance);
    registerConvertor(SetToIObservableCollection.instance);
    registerConvertor(ObjectToISelection.instance);
    registerConvertor(ListToSet.instance);
    //		registerConvertor(StringToKeyTime.instance);
    //		registerConvertor(StringToKeySpline.instance);
    registerConvertor(IStatusToString.instance);
    registerConvertor(IStatusToBoolean.instance);
    ValueConvertorRegister convertorRegister = (ValueConvertorRegister) core.getService(ValueConvertorRegister.class);
    convertorRegister.register(String.class, float.class, StringToNumberConverter.toFloat(true));
    convertorRegister.register(String.class, int.class, StringToInteger.instance);
    // It is not supported by eclipse 3.4.1
    // convertorRegister.register(String.class, short.class,
    // StringToNumberConverter.toShort(true));
    registerConvertor(convertorRegister, String.class, short.class, StringToNumberConverter.class, "toShort", true);
    convertorRegister.register(String.class, long.class, StringToNumberConverter.toLong(true));
    // It is not supported by eclipse 3.4.1
    // convertorRegister.register(String.class, byte.class,
    // StringToNumberConverter.toByte(true));
    registerConvertor(convertorRegister, String.class, byte.class, StringToNumberConverter.class, "toByte", true);
    convertorRegister.register(String.class, boolean.class, StringToBoolean.instance);
    convertorRegister.register(String.class, double.class, StringToNumberConverter.toDouble(true));
    convertorRegister.register(float.class, String.class, NumberToStringConverter.fromFloat(true));
    convertorRegister.register(int.class, String.class, NumberToStringConverter.fromInteger(true));
    // It is not supported by eclipse 3.4.1
    // convertorRegister.register(short.class, String.class,
    // NumberToStringConverter.fromShort(true));
    registerConvertor(convertorRegister, short.class, String.class, NumberToStringConverter.class, "fromShort", true);
    convertorRegister.register(long.class, String.class, NumberToStringConverter.fromLong(true));
    // It is not supported by eclipse 3.4.1
    // convertorRegister.register(byte.class, String.class,
    // NumberToStringConverter.fromByte(true));
    registerConvertor(convertorRegister, byte.class, String.class, NumberToStringConverter.class, "fromByte", true);
    convertorRegister.register(double.class, String.class, NumberToStringConverter.fromDouble(true));
    Class<?> type = org.eclipse.swt.widgets.Widget.class;
    IMetaclass metaclass = registerMetaclass(type);
    IProperty drawingProperty = new AbstractProperty(IUserDataConstants.XWT_DRAWING_KEY, Drawing.class) {

        public void setValue(Object target, Object value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchFieldException {
            if (!ObjectUtil.isAssignableFrom(IBinding.class, getType())) {
                if (value != null) {
                    value = ObjectUtil.resolveValue(value, getType(), value);
                }
            }
        }

        public Object getValue(Object target) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchFieldException {
            return null;
        }
    };
    metaclass.addProperty(drawingProperty);
    IProperty dataContextProperty = new DataProperty(IConstants.XAML_DATA_CONTEXT, IUserDataConstants.XWT_DATACONTEXT_KEY);
    metaclass.addProperty(dataContextProperty);
    ILoadingType loadingType = new DefaultLoadingType(IValueLoading.PostChildren, new IProperty[] { dataContextProperty });
    metaclass.addProperty(new DataProperty(IConstants.XAML_BINDING_CONTEXT, IUserDataConstants.XWT_BINDING_CONTEXT_KEY));
    metaclass.addProperty(new TriggersProperty(loadingType));
    metaclass.addProperty(new StyleProperty());
    registerEventGroup(type, new RadioEventGroup(IEventConstants.KEY_GROUP));
    registerEventGroup(type, new RadioEventGroup(IEventConstants.MOUSE_GROUP));
    registerEventGroup(type, new RadioEventGroup(IEventConstants.MOUSE_MOVING_GROUP));
    registerEventGroup(type, new RadioEventGroup(IEventConstants.FOCUS_GROUP));
    registerEventGroup(type, new RadioEventGroup(IEventConstants.EXPAND_GROUP));
    registerEventGroup(type, new RadioEventGroup(IEventConstants.WINDOW_GROUP));
    registerEventGroup(type, new RadioEventGroup(IEventConstants.ACTIVATION_GROUP));
    registerEventGroup(type, new RadioEventGroup(IEventConstants.HARD_KEY));
    type = org.eclipse.swt.browser.Browser.class;
    IMetaclass browserMetaclass = registerMetaclass(type);
    browserMetaclass.addProperty(new DynamicProperty(type, String.class, PropertiesConstants.PROPERTY_URL, loadingType));
    browserMetaclass.addProperty(new DynamicProperty(type, String.class, PropertiesConstants.PROPERTY_TEXT, loadingType));
    IMetaclass buttonMetaclass = registerMetaclass(Button.class);
    buttonMetaclass.addProperty(new DataProperty(IConstants.XAML_COMMAND, IUserDataConstants.XWT_COMMAND_KEY, ICommand.class));
    registerMetaclass(org.eclipse.swt.widgets.Canvas.class);
    registerMetaclass(org.eclipse.swt.widgets.Caret.class);
    metaclass = registerMetaclass(org.eclipse.swt.widgets.Combo.class);
    if (metaclass != null) {
        IProperty property = metaclass.findProperty("text");
        IProperty inputProperty = new DelegateProperty(property, loadingType);
        metaclass.addProperty(inputProperty);
    }
    registerMetaclass(org.eclipse.swt.widgets.Composite.class);
    registerMetaclass(org.eclipse.swt.widgets.CoolBar.class);
    registerMetaclass(org.eclipse.swt.widgets.CoolItem.class);
    registerMetaclass(org.eclipse.swt.widgets.DateTime.class);
    registerMetaclass(org.eclipse.swt.widgets.Decorations.class);
    registerMetaclass(org.eclipse.swt.widgets.ExpandBar.class);
    IMetaclass expandItemMetaclass = registerMetaclass(ExpandItem.class);
    expandItemMetaclass.findProperty("control").addSetPostAction(new ExpandItemHeightAction());
    registerMetaclass(Group.class);
    registerMetaclass(IME.class);
    registerMetaclass(Label.class);
    registerMetaclass(Link.class);
    registerMetaclass(Listener.class);
    registerMetaclass(List.class);
    registerMetaclass(Menu.class);
    IMetaclass menuItemMetaclass = registerMetaclass(MenuItem.class);
    menuItemMetaclass.addProperty(new DataProperty(IConstants.XAML_COMMAND, IUserDataConstants.XWT_COMMAND_KEY, ICommand.class));
    registerMetaclass(org.eclipse.swt.widgets.MessageBox.class);
    registerMetaclass(org.eclipse.swt.widgets.ProgressBar.class);
    registerMetaclass(org.eclipse.swt.widgets.Sash.class);
    registerMetaclass(org.eclipse.swt.widgets.Scale.class);
    registerMetaclass(org.eclipse.swt.widgets.ScrollBar.class);
    registerMetaclass(org.eclipse.swt.widgets.Shell.class);
    registerMetaclass(org.eclipse.swt.widgets.Slider.class);
    registerMetaclass(org.eclipse.swt.widgets.Spinner.class);
    registerMetaclass(org.eclipse.swt.widgets.TabFolder.class);
    registerMetaclass(org.eclipse.swt.widgets.TabItem.class);
    registerMetaclass(org.eclipse.swt.widgets.Table.class);
    type = org.eclipse.swt.widgets.TableItem.class;
    metaclass = registerMetaclass(type);
    metaclass.addProperty(new TableItemProperty());
    metaclass.addProperty(new TableItemEditorProperty());
    metaclass.addProperty(new DynamicBeanProperty(TableItem.class, String[].class, PropertiesConstants.PROPERTY_TEXTS, PropertiesConstants.PROPERTY_TEXT));
    registerMetaclass(TableItemProperty.Cell.class);
    registerMetaclass(ControlEditor.class);
    registerMetaclass(TableEditor.class);
    IMetaclass TableEditorMetaclass = core.getMetaclass(TableEditor.class, IConstants.XWT_NAMESPACE);
    TableEditorMetaclass.addProperty(new TableEditorDynamicProperty(loadingType));
    type = org.eclipse.swt.widgets.TableColumn.class;
    metaclass = registerMetaclass(type);
    metaclass.addProperty(new TableColumnEditorProperty());
    registerMetaclass(org.eclipse.swt.widgets.Text.class);
    registerMetaclass(org.eclipse.swt.widgets.ToolBar.class);
    registerMetaclass(org.eclipse.swt.widgets.ToolItem.class);
    registerMetaclass(org.eclipse.swt.widgets.ToolTip.class);
    registerMetaclass(org.eclipse.swt.widgets.Tracker.class);
    registerMetaclass(org.eclipse.swt.widgets.Tray.class);
    registerMetaclass(org.eclipse.swt.widgets.Tree.class);
    registerMetaclass(org.eclipse.swt.widgets.TreeColumn.class);
    type = org.eclipse.swt.widgets.TreeItem.class;
    registerMetaclass(type);
    metaclass = registerMetaclass(type);
    metaclass.addProperty(new DynamicBeanProperty(TreeItem.class, String[].class, PropertiesConstants.PROPERTY_TEXTS, PropertiesConstants.PROPERTY_TEXT));
    if (metaclass != null) {
        IProperty property = metaclass.findProperty("expanded");
        IProperty expandedProperty = new DelegateProperty(property, loadingType);
        metaclass.addProperty(expandedProperty);
    }
    // registerMetaclass(org.eclipse.swt.layout.FillData.class);
    registerMetaclass(org.eclipse.swt.layout.FillLayout.class);
    registerMetaclass(org.eclipse.swt.layout.FormAttachment.class);
    registerMetaclass(org.eclipse.swt.layout.FormData.class);
    registerMetaclass(org.eclipse.swt.layout.FormLayout.class);
    registerMetaclass(org.eclipse.swt.layout.GridData.class);
    registerMetaclass(org.eclipse.swt.layout.GridLayout.class);
    registerMetaclass(org.eclipse.swt.layout.RowData.class);
    registerMetaclass(org.eclipse.swt.layout.RowLayout.class);
    registerMetaclass(org.eclipse.swt.custom.StackLayout.class);
    registerMetaclass(org.eclipse.swt.custom.CLabel.class);
    metaclass = registerMetaclass(org.eclipse.swt.custom.CCombo.class);
    if (metaclass != null) {
        IProperty property = metaclass.findProperty("text");
        IProperty inputProperty = new DelegateProperty(property, loadingType);
        metaclass.addProperty(inputProperty);
    }
    registerMetaclass(org.eclipse.swt.custom.CTabFolder.class);
    registerMetaclass(org.eclipse.swt.custom.CTabItem.class);
    metaclass = registerMetaclass(org.eclipse.swt.custom.SashForm.class);
    if (metaclass != null) {
        IProperty property = metaclass.findProperty("weights");
        IProperty inputProperty = new DelegateProperty(property, loadingType);
        metaclass.addProperty(inputProperty);
    }
    registerMetaclass(org.eclipse.swt.custom.StyledText.class);
    registerMetaclass(org.eclipse.swt.custom.ScrolledComposite.class);
    registerMetaclass(org.eclipse.swt.custom.TableTree.class);
    registerMetaclass(org.eclipse.swt.custom.ViewForm.class);
    registerMetaclass(org.eclipse.swt.custom.CBanner.class);
    registerMetaclass(org.eclipse.swt.custom.TableCursor.class);
    type = org.eclipse.jface.viewers.Viewer.class;
    metaclass = core.getMetaclass(type, IConstants.XWT_NAMESPACE);
    if (metaclass != null) {
        IProperty property = metaclass.findProperty("Input");
        IProperty inputProperty = new InputBeanProperty(property, loadingType);
        metaclass.addProperty(inputProperty);
        metaclass.addProperty(new DataProperty(IConstants.XAML_DATA_CONTEXT, IUserDataConstants.XWT_DATACONTEXT_KEY));
        metaclass.removeProperty("selection");
        metaclass.addProperty(new DataProperty(PropertiesConstants.PROPERTY_BINDING_PATH, IUserDataConstants.XWT_PROPERTY_DATA_KEY, String.class));
        metaclass.addProperty(new DataProperty(PropertiesConstants.PROPERTY_ITEM_TEXT, IUserDataConstants.XWT_PROPERTY_ITEM_TEXT_KEY, IBinding.class));
        metaclass.addProperty(new DataProperty(PropertiesConstants.PROPERTY_ITEM_IMAGE, IUserDataConstants.XWT_PROPERTY_ITEM_IMAGE_KEY, IBinding.class));
        ILoadingType inputLoadingType = new DefaultLoadingType(IValueLoading.PostChildren, new IProperty[] { inputProperty });
        metaclass.addProperty(new SingleSelectionBeanProperty(PropertiesConstants.PROPERTY_SINGLE_SELECTION, inputLoadingType));
        metaclass.addProperty(new MultiSelectionBeanProperty(PropertiesConstants.PROPERTY_MULTI_SELECTION, inputLoadingType));
    }
    type = org.eclipse.jface.viewers.AbstractListViewer.class;
    metaclass = core.getMetaclass(type, IConstants.XWT_NAMESPACE);
    if (metaclass != null) {
        metaclass.addInitializer(new JFaceInitializer());
    }
    type = org.eclipse.jface.viewers.ColumnViewer.class;
    metaclass = core.getMetaclass(type, IConstants.XWT_NAMESPACE);
    if (metaclass != null) {
        metaclass.addProperty(new DynamicBeanProperty(type, String[].class, PropertiesConstants.PROPERTY_COLUMN_PROPERTIES));
        metaclass.addProperty(new ColumnViewerColumnsProperty());
        metaclass.addInitializer(new JFaceInitializer());
    }
    for (Class<?> cls : JFacesHelper.getSupportedElements()) {
        registerMetaclass(cls);
    }
    type = org.eclipse.jface.viewers.TableViewer.class;
    metaclass = core.getMetaclass(type, IConstants.XWT_NAMESPACE);
    IProperty property = metaclass.findProperty("table");
    if (property instanceof AbstractProperty) {
        AbstractProperty abstractProperty = (AbstractProperty) property;
        abstractProperty.setValueAsParent(true);
    }
    core.registerMetaclass(new ComboBoxCellEditorMetaclass(core.getMetaclass(ComboBoxCellEditor.class.getSuperclass(), IConstants.XWT_NAMESPACE), this), IConstants.XWT_NAMESPACE);
    type = org.eclipse.jface.viewers.TableViewerColumn.class;
    core.registerMetaclass(new TableViewerColumnMetaClass(core.getMetaclass(type.getSuperclass(), IConstants.XWT_NAMESPACE), this), IConstants.XWT_NAMESPACE);
    metaclass = core.getMetaclass(type, IConstants.XWT_NAMESPACE);
    //
    // PROPERTY_DATA_KEY
    //
    metaclass.addProperty(new TableViewerColumnWidthProperty());
    metaclass.addProperty(new TableViewerColumnTextProperty());
    metaclass.addProperty(new TableViewerColumnImageProperty());
    metaclass.addProperty(new TableViewerColumnDynamicProperty(PropertiesConstants.PROPERTY_BINDING_PATH, IUserDataConstants.XWT_PROPERTY_DATA_KEY, String.class));
    metaclass.addProperty(new TableViewerColumnDynamicProperty(PropertiesConstants.PROPERTY_ITEM_TEXT, IUserDataConstants.XWT_PROPERTY_ITEM_TEXT_KEY, IBinding.class));
    metaclass.addProperty(new TableViewerColumnDynamicProperty(PropertiesConstants.PROPERTY_ITEM_IMAGE, IUserDataConstants.XWT_PROPERTY_ITEM_IMAGE_KEY, IBinding.class));
    registerMetaclass(DefaultCellModifier.class);
    registerMetaclass(ViewerFilter.class);
    // DataBinding stuff
    registerMetaclass(BindingContext.class);
    registerMetaclass(ObjectDataProvider.class);
    registerMetaclass(Style.class);
    registerMetaclass(Setter.class);
    registerMetaclass(Trigger.class);
    registerMetaclass(MultiTrigger.class);
    registerMetaclass(EventTrigger.class);
    registerMetaclass(DataTrigger.class);
    registerMetaclass(MultiDataTrigger.class);
    registerMetaclass(Condition.class);
    //		registerConvertor(StringToDuration.instance);
    //		registerConvertor(StringToTimeSpan.instance);
    //		registerConvertor(StringToRepeatBehavior.instance);
    registerMetaclass(CollectionViewSource.class);
    registerMetaclass(ObservableListContentProvider.class);
    registerMetaclass(ObservableSetContentProvider.class);
    registerMetaclass(ObservableTreeContentProvider.class);
    registerFileResolveType(Image.class);
    registerFileResolveType(URL.class);
}
Example 67
Project: pentaho-kettle-master  File: JobEntryGetPOPDialog.java View source code
public void widgetSelected(SelectionEvent e) {
    final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM);
    dialog.setText(BaseMessages.getString(PKG, "JobGetPOP.SelectDate"));
    dialog.setImage(GUIResource.getInstance().getImageSpoon());
    dialog.setLayout(new GridLayout(3, false));
    final DateTime calendar = new DateTime(dialog, SWT.CALENDAR);
    final DateTime time = new DateTime(dialog, SWT.TIME | SWT.TIME);
    new Label(dialog, SWT.NONE);
    new Label(dialog, SWT.NONE);
    Button ok = new Button(dialog, SWT.PUSH);
    ok.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    ok.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    ok.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            Calendar cal = Calendar.getInstance();
            cal.set(Calendar.YEAR, calendar.getYear());
            cal.set(Calendar.MONTH, calendar.getMonth());
            cal.set(Calendar.DAY_OF_MONTH, calendar.getDay());
            cal.set(Calendar.HOUR_OF_DAY, time.getHours());
            cal.set(Calendar.MINUTE, time.getMinutes());
            cal.set(Calendar.SECOND, time.getSeconds());
            wReadFrom.setText(new SimpleDateFormat(JobEntryGetPOP.DATE_PATTERN).format(cal.getTime()));
            dialog.close();
        }
    });
    dialog.setDefaultButton(ok);
    dialog.pack();
    dialog.open();
}
Example 68
Project: org.eclipse.ui.ide.format.extension.patch-master  File: ResourceFilterGroup.java View source code
private void setupMultiOperatorAndField(boolean updateOperator) {
    boolean isUsingRegularExpression = false;
    String selectedKey = MultiMatcherLocalization.getMultiMatcherKey(multiKey.getText());
    if (updateOperator) {
        String[] operators = getLocalOperatorsForKey(selectedKey);
        multiOperator.setItems(operators);
        FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments());
        String local = MultiMatcherLocalization.getLocalMultiMatcherKey(argument.operator);
        int index = multiOperator.indexOf(local);
        if (index != -1)
            multiOperator.select(index);
        else
            multiOperator.select(0);
    }
    String selectedOperator = MultiMatcherLocalization.getMultiMatcherKey(multiOperator.getText());
    Class selectedKeyOperatorType = FileInfoAttributesMatcher.getTypeForKey(selectedKey, selectedOperator);
    if (intiantiatedKeyOperatorType != null) {
        if (intiantiatedKeyOperatorType.equals(selectedKeyOperatorType))
            return;
        if (arguments != null) {
            arguments.dispose();
            arguments = null;
        }
        if (attributeStringArgumentComposite != null) {
            attributeStringArgumentComposite.dispose();
            attributeStringArgumentComposite = null;
        }
        if (stringArgumentComposite != null) {
            stringArgumentComposite.dispose();
            stringArgumentComposite = null;
        }
        if (argumentsBoolean != null) {
            argumentsBoolean.dispose();
            argumentsBoolean = null;
        }
        if (argumentsDate != null) {
            argumentsDate.dispose();
            argumentsDate = null;
        }
        if (argumentsRegularExpresion != null) {
            argumentsRegularExpresion.dispose();
            argumentsRegularExpresion = null;
        }
        if (argumentsCaseSensitive != null) {
            argumentsCaseSensitive.dispose();
            argumentsCaseSensitive = null;
        }
        if (dummyLabel1 != null) {
            dummyLabel1.dispose();
            dummyLabel1 = null;
        }
        if (dummyLabel2 != null) {
            dummyLabel2.dispose();
            dummyLabel2 = null;
        }
        fContentAssistField = null;
        FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments());
        valueCache.put(intiantiatedKeyOperatorType.getName(), argument.pattern);
        argument.pattern = (String) valueCache.get(selectedKeyOperatorType.getName());
        if (argument.pattern == null)
            argument.pattern = new String();
        filter.setArguments(FileInfoAttributesMatcher.encodeArguments(argument));
    }
    if (selectedKeyOperatorType.equals(String.class)) {
        arguments = new Text(multiArgumentComposite, SWT.SINGLE | SWT.BORDER);
        GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
        data.widthHint = 150;
        arguments.setLayoutData(data);
        arguments.setFont(multiArgumentComposite.getFont());
        arguments.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                validateInputText();
            }
        });
        dummyLabel1 = new Label(multiArgumentComposite, SWT.NONE);
        data = new GridData(SWT.LEFT, SWT.CENTER, true, true);
        dummyLabel1.setText(new String());
        data.horizontalSpan = 1;
        dummyLabel1.setLayoutData(data);
        dummyLabel2 = new Label(multiArgumentComposite, SWT.NONE);
        data = new GridData(SWT.LEFT, SWT.CENTER, true, true);
        dummyLabel2.setText(new String());
        data.horizontalSpan = 1;
        dummyLabel2.setLayoutData(data);
        stringArgumentComposite = new Composite(multiArgumentComposite, SWT.NONE);
        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginWidth = 0;
        layout.marginTop = dialog.getVerticalDLUsToPixel(IDialogConstants.VERTICAL_SPACING) / 2;
        layout.marginHeight = 0;
        layout.marginBottom = 0;
        stringArgumentComposite.setLayout(layout);
        data = new GridData(SWT.FILL, SWT.CENTER, true, true);
        data.horizontalSpan = 1;
        stringArgumentComposite.setLayoutData(data);
        stringArgumentComposite.setFont(multiArgumentComposite.getFont());
        argumentsCaseSensitive = new Button(stringArgumentComposite, SWT.CHECK);
        argumentsCaseSensitive.setText(NLS.bind(IDEWorkbenchMessages.ResourceFilterPage_caseSensitive, null));
        data = new GridData(SWT.LEFT, SWT.CENTER, false, false);
        argumentsCaseSensitive.setLayoutData(data);
        argumentsCaseSensitive.setFont(multiArgumentComposite.getFont());
        argumentsRegularExpresion = new Button(stringArgumentComposite, SWT.CHECK);
        argumentsRegularExpresion.setText(NLS.bind(IDEWorkbenchMessages.ResourceFilterPage_regularExpression, null));
        data = new GridData(SWT.LEFT, SWT.CENTER, false, false);
        data.minimumWidth = 100;
        argumentsRegularExpresion.setLayoutData(data);
        argumentsRegularExpresion.setFont(multiArgumentComposite.getFont());
        if (filter.hasStringArguments()) {
            FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments());
            arguments.setText(argument.pattern);
            isUsingRegularExpression = argument.regularExpression;
            argumentsCaseSensitive.setSelection(argument.caseSensitive);
            argumentsRegularExpresion.setSelection(argument.regularExpression);
        }
        arguments.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                storeMultiSelection();
            }
        });
        argumentsRegularExpresion.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                setupDescriptionText(null);
                storeMultiSelection();
                if (fContentAssistField != null)
                    fContentAssistField.setEnabled(argumentsRegularExpresion.getSelection());
            }
        });
        argumentsCaseSensitive.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                storeMultiSelection();
            }
        });
        TextContentAdapter contentAdapter = new TextContentAdapter();
        FindReplaceDocumentAdapterContentProposalProvider findProposer = new FindReplaceDocumentAdapterContentProposalProvider(true);
        fContentAssistField = new ContentAssistCommandAdapter(arguments, contentAdapter, findProposer, null, new char[] { '\\', '[', '(' }, true);
    }
    if (selectedKeyOperatorType.equals(Integer.class)) {
        GridData data;
        arguments = new Text(multiArgumentComposite, SWT.SINGLE | SWT.BORDER);
        data = new GridData(SWT.FILL, SWT.FILL, true, false);
        data.widthHint = 150;
        arguments.setLayoutData(data);
        arguments.setFont(multiArgumentComposite.getFont());
        arguments.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                validateInputText();
            }
        });
        if (filter.hasStringArguments()) {
            FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments());
            if (selectedKey.equals(FileInfoAttributesMatcher.KEY_LAST_MODIFIED) || selectedKey.equals(FileInfoAttributesMatcher.KEY_CREATED))
                arguments.setText(convertToEditableTimeInterval(argument.pattern));
            else
                arguments.setText(convertToEditableLength(argument.pattern));
        }
        arguments.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                storeMultiSelection();
            }
        });
    }
    if (selectedKeyOperatorType.equals(Date.class)) {
        GridData data;
        argumentsDate = new DateTime(multiArgumentComposite, SWT.DATE | SWT.MEDIUM | SWT.BORDER);
        data = new GridData(SWT.FILL, SWT.FILL, true, false);
        argumentsDate.setLayoutData(data);
        argumentsDate.setFont(multiArgumentComposite.getFont());
        argumentsDate.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                storeMultiSelection();
            }
        });
        if (filter.hasStringArguments()) {
            FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments());
            Date date;
            Calendar calendar = Calendar.getInstance();
            try {
                date = new Date(Long.parseLong(argument.pattern));
                calendar.setTime(date);
            } catch (NumberFormatException e1) {
                date = new Date();
                calendar.setTime(date);
                argument.pattern = Long.toString(calendar.getTimeInMillis());
            }
            argumentsDate.setDay(calendar.get(Calendar.DAY_OF_MONTH));
            argumentsDate.setMonth(calendar.get(Calendar.MONTH));
            argumentsDate.setYear(calendar.get(Calendar.YEAR));
        }
    }
    if (selectedKeyOperatorType.equals(Boolean.class)) {
        GridData data;
        argumentsBoolean = new Combo(multiArgumentComposite, SWT.READ_ONLY);
        data = new GridData(SWT.FILL, SWT.TOP, true, false);
        argumentsBoolean.setLayoutData(data);
        argumentsBoolean.setFont(multiArgumentComposite.getFont());
        argumentsBoolean.setItems(new String[] { MultiMatcherLocalization.getLocalMultiMatcherKey(Boolean.TRUE.toString()), MultiMatcherLocalization.getLocalMultiMatcherKey(Boolean.FALSE.toString()) });
        argumentsBoolean.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                storeMultiSelection();
            }
        });
        if (filter.hasStringArguments()) {
            FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments());
            if (argument.pattern.length() == 0)
                argumentsBoolean.select(0);
            else
                argumentsBoolean.select(Boolean.valueOf(argument.pattern).booleanValue() ? 0 : 1);
        }
    }
    intiantiatedKeyOperatorType = selectedKeyOperatorType;
    if (fContentAssistField != null)
        fContentAssistField.setEnabled(isUsingRegularExpression);
    shell.layout(true, true);
    if (initializationComplete) {
        Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        Point shellSize = shell.getSize();
        size.x = Math.max(size.x, shellSize.x);
        size.y = Math.max(size.y, shellSize.y);
        if ((size.x > shellSize.x) || (size.y > shellSize.y))
            shell.setSize(size);
    }
    shell.redraw();
    setupDescriptionText(null);
}
Example 69
Project: pentaho-metadata-editor-master  File: DatePropertyEditorWidget.java View source code
protected void createContents(final Composite parent) {
    DateTime calendar = new DateTime(parent, SWT.CALENDAR);
    DateTime time = new DateTime(parent, SWT.TIME);
}
Example 70
Project: PerformanceHat-master  File: PropertyPageDateField.java View source code
public void createDateField(final Composite parent) {
    final GridData grid = new GridData();
    dateField = new DateTime(parent, SWT.DATE | SWT.DROP_DOWN | SWT.BORDER);
    dateField.setLayoutData(grid);
}
Example 71
Project: awe-core-master  File: DateTimeWidget.java View source code
private DateTime addDateTime(final Composite parent, final int style) {
    DateTime result = new DateTime(parent, style);
    result.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
    result.setVisible(true);
    return result;
}
Example 72
Project: jo-widgets-master  File: CalendarImpl.java View source code
@Override
public DateTime getUiReference() {
    return (DateTime) super.getUiReference();
}
Example 73
Project: jbosstools-integration-tests-master  File: WidgetResolver.java View source code
/**
	 * Finds out whether specified widget is resolvable or not.
	 * 
	 * @param w widget to resolve
	 * @return true if widget is resolvable, false otherwise.
	 */
public boolean isResolvable(Widget w) {
    // DateTime is not supported because of eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=206868
    if (w instanceof DateTime)
        return false;
    return Arrays.asList(supported).contains(w.getClass());
}