Search in sources :

Example 1 with CalendarSelectWidget

use of com.amalto.workbench.widgets.CalendarSelectWidget in project tmdm-studio-se by Talend.

the class RoutingEngineV2BrowserMainPage method createFormContent.

@Override
protected void createFormContent(IManagedForm managedForm) {
    try {
        // sets the title
        managedForm.getForm().setText(this.getTitle());
        // get the toolkit
        FormToolkit toolkit = managedForm.getToolkit();
        // get the body
        Composite composite = managedForm.getForm().getBody();
        composite.setLayout(new GridLayout(1, false));
        // Create a Router status holder
        Composite statusComposite = toolkit.createComposite(composite, SWT.NONE);
        statusComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        statusComposite.setLayout(new GridLayout(5, false));
        // status
        Label descriptionLabel = toolkit.createLabel(statusComposite, Messages.RoutingEngineV2BrowserMainPage_EventManagerStatus, SWT.NULL);
        descriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        // $NON-NLS-1$
        statusLabel = toolkit.createLabel(statusComposite, "                                           ", SWT.NULL);
        statusLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        startButton = toolkit.createButton(statusComposite, BLANK, SWT.PUSH);
        startButton.setImage(ImageCache.getCreatedImage(EImage.RUN_EXC.getPath()));
        startButton.setToolTipText(Messages.RoutingEngineV2BrowserMainPage_Start);
        startButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        startButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                startSubscriptionEngine();
                updateButtons();
            }
        });
        stopButton = toolkit.createButton(statusComposite, BLANK, SWT.PUSH);
        stopButton.setImage(ImageCache.getCreatedImage(EImage.STOP.getPath()));
        stopButton.setToolTipText(Messages.RoutingEngineV2BrowserMainPage_Stop);
        stopButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        stopButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                stopSubscriptionEngine();
                updateButtons();
            }
        });
        suspendButton = toolkit.createButton(statusComposite, BLANK, SWT.PUSH);
        suspendButton.setImage(ImageCache.getCreatedImage(EImage.SUSPEND.getPath()));
        suspendButton.setToolTipText(Messages.RoutingEngineV2BrowserMainPage_Suspend);
        suspendButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        suspendButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                suspendSubscriptionEngine();
                updateButtons();
            }
        });
        Composite separator = toolkit.createCompositeSeparator(composite);
        separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        ((GridData) separator.getLayoutData()).heightHint = 2;
        // first Line of routing Orders
        Composite firstLineComposite = toolkit.createComposite(composite);
        firstLineComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
        firstLineComposite.setLayout(new GridLayout(9, false));
        // Routing Orders Label
        Label routingOrdersLabel = toolkit.createLabel(firstLineComposite, Messages.RoutingEngineV2BrowserMainPage_RoutingOrders, SWT.NULL);
        routingOrdersLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 9, 1));
        // from
        Label fromLabel = toolkit.createLabel(firstLineComposite, Messages.RoutingEngineV2BrowserMainPage_From, SWT.NULL);
        fromLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        CalendarSelectWidget fromCalendar = new CalendarSelectWidget(toolkit, firstLineComposite, true);
        fromText = fromCalendar.getText();
        // to
        Label toLabel = toolkit.createLabel(firstLineComposite, Messages.RoutingEngineV2BrowserMainPage_To, SWT.NULL);
        toLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        CalendarSelectWidget toCalendar = new CalendarSelectWidget(toolkit, firstLineComposite, false);
        toText = toCalendar.getText();
        Label statusLab = toolkit.createLabel(firstLineComposite, Messages.RoutingEngineV2BrowserMainPage_Status, SWT.NULL);
        statusLab.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        statusCombo = new Combo(firstLineComposite, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.MULTI);
        statusCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        statusCombo.addKeyListener(new KeyAdapter() {

            @Override
            public void keyReleased(KeyEvent e) {
                if ((e.stateMask == 0) && (e.character == SWT.CR)) {
                    doSearch();
                }
            }
        });
        // $NON-NLS-1$
        statusCombo.add("FAILED");
        // $NON-NLS-1$
        statusCombo.add("COMPLETED");
        statusCombo.select(0);
        // to
        Button bSearch = toolkit.createButton(firstLineComposite, BLANK, SWT.CENTER);
        bSearch.setImage(ImageCache.getCreatedImage(EImage.BROWSE.getPath()));
        bSearch.setToolTipText(Messages.RoutingEngineV2BrowserMainPage_Search);
        bSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        bSearch.addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event event) {
                pageToolBar.reset();
                doSearch();
            }
        });
        // Second Line of routing Orders
        Composite searchLineComposite = toolkit.createComposite(composite);
        searchLineComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
        searchLineComposite.setLayout(new GridLayout(4, false));
        // document type
        Label documentTypeLabel = toolkit.createLabel(searchLineComposite, Messages.RoutingEngineV2BrowserMainPage_DocumentType, SWT.NULL);
        documentTypeLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        // DocumentType
        documentTypeText = toolkit.createText(searchLineComposite, BLANK, SWT.BORDER);
        documentTypeText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
        ((GridData) documentTypeText.getLayoutData()).widthHint = 120;
        documentTypeText.addKeyListener(new KeyAdapter() {

            @Override
            public void keyReleased(KeyEvent e) {
                if ((e.stateMask == 0) && (e.character == SWT.CR)) {
                    doSearch();
                }
            }
        });
        // ID
        Label idLabel = toolkit.createLabel(searchLineComposite, Messages.RoutingEngineV2BrowserMainPage_ItemIDs, SWT.NULL);
        idLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        // ID
        idText = toolkit.createText(searchLineComposite, BLANK, SWT.BORDER);
        idText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
        idText.addKeyListener(new KeyAdapter() {

            @Override
            public void keyReleased(KeyEvent e) {
                if ((e.stateMask == 0) && (e.character == SWT.CR)) {
                    doSearch();
                }
            }
        });
        // service
        Label serviceLabel = toolkit.createLabel(searchLineComposite, Messages.RoutingEngineV2BrowserMainPage_Service, SWT.NULL);
        serviceLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        // service
        serviceCombo = new Combo(searchLineComposite, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.MULTI);
        serviceCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        serviceCombo.addKeyListener(new KeyAdapter() {

            @Override
            public void keyReleased(KeyEvent e) {
                if ((e.stateMask == 0) && (e.character == SWT.CR)) {
                    doSearch();
                }
            }
        });
        serviceCombo.add(BLANK);
        // WSServicesListItem[] servicesList = Util.getPort(getXObject()).getServicesList(new
        // WSGetServicesList("en")).getItem();
        // $NON-NLS-1$
        List<WSServicesListItem> servicesList = getMDMService().getServicesList(new WSGetServicesList("en")).getItem();
        if ((servicesList != null) && (servicesList.size() > 0)) {
            String[] services = new String[servicesList.size()];
            for (int i = 0; i < servicesList.size(); i++) {
                // $NON-NLS-1$
                services[i] = servicesList.get(i).getJndiName().replaceFirst("amalto/local/service/", BLANK);
            }
            Arrays.sort(services);
            for (String service : services) {
                serviceCombo.add(service);
            }
        }
        serviceCombo.select(0);
        // any Field
        Label anyFieldLabel = toolkit.createLabel(searchLineComposite, Messages.RoutingEngineV2BrowserMainPage_AnyField, SWT.NULL);
        anyFieldLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        // anyField
        anyFieldText = toolkit.createText(searchLineComposite, BLANK, SWT.BORDER);
        anyFieldText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
        anyFieldText.addKeyListener(new KeyAdapter() {

            @Override
            public void keyReleased(KeyEvent e) {
                if ((e.stateMask == 0) && (e.character == SWT.CR)) {
                    doSearch();
                }
            }
        });
        // pageToolBar
        pageToolBar = new PageingToolBar(composite);
        pageToolBar.getComposite().setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 9, 1));
        pageToolBar.getComposite().setVisible(false);
        pageToolBar.setPageingListener(this);
        final Table table = createTable(composite);
        resultsViewer = new TableViewer(table);
        resultsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        // ((GridData) resultsViewer.getControl().getLayoutData()).heightHint = 500;
        resultsViewer.setContentProvider(new ArrayContentProvider());
        resultsViewer.setLabelProvider(new ClusterTableLabelProvider());
        resultsViewer.addDoubleClickListener(new IDoubleClickListener() {

            public void doubleClick(DoubleClickEvent event) {
                resultsViewer.setSelection(event.getSelection());
                try {
                    new EditItemAction(RoutingEngineV2BrowserMainPage.this.getSite().getShell(), resultsViewer).run();
                } catch (Exception e) {
                    MessageDialog.openError(RoutingEngineV2BrowserMainPage.this.getSite().getShell(), Messages._Error, Messages.bind(Messages.RoutingEngineV2BrowserMainPage_ErrorMsg, e.getClass().getName(), e.getLocalizedMessage()));
                }
            }
        });
        hookContextMenu();
        // nothing will show on the form if not called
        managedForm.reflow(true);
        // adapt body add mouse/focus listener for child
        WidgetFactory factory = WidgetFactory.getWidgetFactory();
        factory.adapt(managedForm.getForm().getBody());
        updateButtons();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) IXObjectModelListener(com.amalto.workbench.models.IXObjectModelListener) IMenuListener(org.eclipse.jface.action.IMenuListener) SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) IPagingListener(com.amalto.workbench.widgets.IPagingListener) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) PageingToolBar(com.amalto.workbench.widgets.PageingToolBar) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) WSGetServicesList(com.amalto.workbench.webservices.WSGetServicesList) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) EditItemAction(com.amalto.workbench.editors.actions.EditItemAction) XtentisException(com.amalto.workbench.utils.XtentisException) ParseException(java.text.ParseException) WSServicesListItem(com.amalto.workbench.webservices.WSServicesListItem) WidgetFactory(com.amalto.workbench.widgets.WidgetFactory) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) KeyEvent(org.eclipse.swt.events.KeyEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) CalendarSelectWidget(com.amalto.workbench.widgets.CalendarSelectWidget)

Example 2 with CalendarSelectWidget

use of com.amalto.workbench.widgets.CalendarSelectWidget in project tmdm-studio-se by Talend.

the class DataClusterComposite method createFirstPart.

protected void createFirstPart(Composite composite) {
    FormToolkit toolkit = WidgetFactory.getWidgetFactory();
    // We do not implement IFormPart: we do not care about lifecycle management
    Composite compFirstLine = toolkit.createComposite(composite, SWT.NONE);
    compFirstLine.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    compFirstLine.setLayout(new GridLayout(10, false));
    // from
    Label fromLabel = toolkit.createLabel(compFirstLine, Messages.DataClusterBrowserMainPage_1, SWT.NULL);
    fromLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    CalendarSelectWidget fromCalendar = new CalendarSelectWidget(toolkit, compFirstLine, true);
    fromText = fromCalendar.getText();
    fromText.addKeyListener(keylistener);
    // to
    Label toLabel = toolkit.createLabel(compFirstLine, Messages.DataClusterBrowserMainPage_2, SWT.NULL);
    toLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    CalendarSelectWidget toCalendar = new CalendarSelectWidget(toolkit, compFirstLine, false);
    toText = toCalendar.getText();
    toText.addKeyListener(keylistener);
    Label conceptLabel = toolkit.createLabel(compFirstLine, Messages.DataClusterBrowserMainPage_3, SWT.NULL);
    conceptLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    conceptCombo = new Combo(compFirstLine, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.MULTI);
    conceptCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    // ((GridData) conceptCombo.getLayoutData()).widthHint = 180;
    conceptCombo.addKeyListener(keylistener);
    // refresh
    // search
    // $NON-NLS-1$
    Button refreshBun = toolkit.createButton(compFirstLine, "", SWT.CENTER);
    refreshBun.setImage(ImageCache.getCreatedImage(EImage.REFRESH.getPath()));
    refreshBun.setToolTipText(Messages.XObjectBrowser_Refresh);
    refreshBun.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
    refreshBun.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            refreshData();
        }
    });
    // search
    // $NON-NLS-1$
    Button bSearch = toolkit.createButton(compFirstLine, "", SWT.CENTER);
    bSearch.setImage(ImageCache.getCreatedImage(EImage.BROWSE.getPath()));
    bSearch.setToolTipText(Messages.DataClusterBrowserMainPage_4);
    bSearch.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
    bSearch.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            pageToolBar.reset();
            doSearch();
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) IPagingListener(com.amalto.workbench.widgets.IPagingListener) KeyListener(org.eclipse.swt.events.KeyListener) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) KeyEvent(org.eclipse.swt.events.KeyEvent) Event(org.eclipse.swt.widgets.Event) Combo(org.eclipse.swt.widgets.Combo) CalendarSelectWidget(com.amalto.workbench.widgets.CalendarSelectWidget)

Aggregations

CalendarSelectWidget (com.amalto.workbench.widgets.CalendarSelectWidget)2 IPagingListener (com.amalto.workbench.widgets.IPagingListener)2 ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)2 KeyEvent (org.eclipse.swt.events.KeyEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Button (org.eclipse.swt.widgets.Button)2 Combo (org.eclipse.swt.widgets.Combo)2 Composite (org.eclipse.swt.widgets.Composite)2 Event (org.eclipse.swt.widgets.Event)2 Label (org.eclipse.swt.widgets.Label)2 Listener (org.eclipse.swt.widgets.Listener)2 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)2 EditItemAction (com.amalto.workbench.editors.actions.EditItemAction)1 IXObjectModelListener (com.amalto.workbench.models.IXObjectModelListener)1 XtentisException (com.amalto.workbench.utils.XtentisException)1 WSGetServicesList (com.amalto.workbench.webservices.WSGetServicesList)1 WSServicesListItem (com.amalto.workbench.webservices.WSServicesListItem)1 PageingToolBar (com.amalto.workbench.widgets.PageingToolBar)1