Search in sources :

Example 21 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class XpathSelectDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    parent.getShell().setText(this.title);
    Composite composite = (Composite) super.createDialogArea(parent);
    GridLayout layout = (GridLayout) composite.getLayout();
    layout.makeColumnsEqualWidth = false;
    layout.numColumns = 2;
    Label datamoelsLabel = new Label(composite, SWT.NONE);
    GridData dg = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1);
    datamoelsLabel.setLayoutData(dg);
    datamoelsLabel.setText(Messages.XpathSelectDialog_DataModels);
    dg = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    dg.widthHint = 400;
    dataModelCombo = new Combo(composite, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
    dataModelCombo.setLayoutData(dg);
    // Modified by hbhong,to fix bug 21784|the following can cause potential error,so comment it
    // if (this.parent == null) {
    // this.parent = (TreeParent) ServerView.show().getRoot().getChildren()[0];
    // }
    // The ending| bug:21784
    final TreeParent tree = this.parent == null ? null : this.parent.findServerFolder(TreeObject.DATA_MODEL);
    // filter the datamodel according to conceptName
    if (tree != null) {
        avaiList = getAvailableDataModel();
    } else {
        avaiList = MDMRepositoryViewExtensionService.findAllDataModelNames();
    }
    if (keepOneDatamodel && dataModelName != null) {
        avaiList.clear();
        avaiList.add(dataModelName);
    }
    dataModelCombo.setItems(avaiList.toArray(new String[avaiList.size()]));
    dataModelCombo.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
        }

        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            changeDomTree(tree, filterText.getText());
        }
    });
    schemaLabel = new Label(composite, SWT.NONE);
    schemaLabel.setText(Messages.XpathSelectDialog_Xpath);
    schemaLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    ((GridData) schemaLabel.getLayoutData()).widthHint = 10;
    xpathText = new Text(composite, SWT.BORDER);
    xpathText.setEditable(false);
    xpathText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    // add the filter for the xpath,see bug 0016511: Entity filtering in select multiple xpath dialog:
    Label filterLabel = new Label(composite, SWT.NONE);
    filterLabel.setText(Messages.XpathSelectDialog_Filter);
    filterLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
    filterText = new Text(composite, SWT.BORDER);
    filterText.setEditable(true);
    filterText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    if (conceptName != null) {
        filterText.setText(conceptName);
        if (keepFilterContent) {
            filterText.setEditable(false);
        }
    } else {
        // $NON-NLS-1$
        filterText.setText("");
    }
    filterText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String filter = ((Text) e.widget).getText();
            changeDomTree(tree, filter);
        }
    });
    if (isMulti) {
        domViewer = new TreeViewer(composite, SWT.H_SCROLL | SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
    } else {
        domViewer = new TreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    }
    int index = avaiList.indexOf(dataModelName);
    if (index < 0) {
        dataModelCombo.select(0);
    } else {
        dataModelCombo.select(index);
    }
    dataModelCombo.setEnabled(!lock);
    changeDomTree(tree, filterText.getText());
    domViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    ((GridData) domViewer.getControl().getLayoutData()).heightHint = 400;
    ((GridData) domViewer.getControl().getLayoutData()).widthHint = 400;
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) TreeParent(com.amalto.workbench.models.TreeParent) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 22 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class AddBrowseItemsWizard method createNewTreeObject.

private TreeObject createNewTreeObject(XSDElementDeclaration decl, String browseItem) {
    WSView view = new WSView();
    view.setIsTransformerActive(new WSBoolean(false));
    // $NON-NLS-1$
    view.setTransformerPK("");
    view.setName(browseItem);
    EList<XSDIdentityConstraintDefinition> idtylist = decl.getIdentityConstraintDefinitions();
    List<String> keys = new ArrayList<String>();
    for (XSDIdentityConstraintDefinition idty : idtylist) {
        EList<XSDXPathDefinition> xpathList = idty.getFields();
        for (XSDXPathDefinition path : xpathList) {
            String key = decl.getName();
            // remove
            // $NON-NLS-1$//$NON-NLS-2$
            key = key.replaceFirst("#.*", "");
            // $NON-NLS-1$
            key += "/" + path.getValue();
            keys.add(key);
        }
    }
    view.getSearchableBusinessElements().addAll(keys);
    view.getViewableBusinessElements().addAll(keys);
    StringBuffer desc = new StringBuffer();
    LinkedHashMap<String, String> labels = new LinkedHashMap<String, String>();
    if (decl.getAnnotation() != null) {
        labels = new XSDAnnotationsStructure(decl.getAnnotation()).getLabels();
    }
    if (labels.size() == 0) {
        // $NON-NLS-1$
        labels.put("EN", decl.getName());
    }
    for (String lan : labels.keySet()) {
        // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
        desc.append("[" + lan.toUpperCase() + ":" + labels.get(lan) + "]");
    }
    view.setDescription(desc.toString());
    WSPutView wrap = new WSPutView();
    wrap.setWsView(view);
    WSViewPK viewPk = new WSViewPK();
    viewPk.setPk(browseItem);
    WSDeleteView delView = new WSDeleteView();
    delView.setWsViewPK(viewPk);
    WSGetView getView = new WSGetView();
    getView.setWsViewPK(viewPk);
    service.putView(wrap);
    // add node in the root
    TreeParent root = page.getXObject().getServerRoot();
    TreeObject obj = new // no storage to save
    TreeObject(// no storage to save
    browseItem, // no storage to save
    root, // no storage to save
    TreeObject.VIEW, // no storage to save
    viewPk, // no storage to save
    null);
    return obj;
}
Also used : XSDAnnotationsStructure(com.amalto.workbench.utils.XSDAnnotationsStructure) TreeParent(com.amalto.workbench.models.TreeParent) ArrayList(java.util.ArrayList) WSDeleteView(com.amalto.workbench.webservices.WSDeleteView) WSView(com.amalto.workbench.webservices.WSView) LinkedHashMap(java.util.LinkedHashMap) WSPutView(com.amalto.workbench.webservices.WSPutView) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) TreeObject(com.amalto.workbench.models.TreeObject) WSBoolean(com.amalto.workbench.webservices.WSBoolean) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) WSGetView(com.amalto.workbench.webservices.WSGetView) WSViewPK(com.amalto.workbench.webservices.WSViewPK)

Example 23 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class AddBrowseItemsWizard method newBrowseItemView.

protected void newBrowseItemView(String browseItem) {
    for (XSDElementDeclaration decl : declList) {
        String fullName = BROWSE_ITEMS + decl.getName();
        if (fullName.equals(browseItem)) {
            TreeParent serverRoot = page.getXObject().getServerRoot();
            TreeParent serverFolder = serverRoot.findServerFolder(TreeObject.VIEW);
            TreeObject obj = serverFolder.findObject(TreeObject.VIEW, browseItem);
            if (obj != null) {
                IEditorInput xobjectEditorinput = new XObjectEditorInput(obj, obj.getDisplayName());
                final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                IEditorPart currentEditor = activePage.findEditor(xobjectEditorinput);
                if (currentEditor != null) {
                    // editor is opened
                    if (MessageDialog.openConfirm(this.getShell(), Messages.Warning, Messages.AddBrowseItemsWizard_DuplicatedView)) {
                        refreshEditorContent(obj);
                    } else {
                        break;
                    }
                }
            }
            obj = createNewTreeObject(decl, browseItem);
            TreeParent folder = obj.findServerFolder(obj.getType());
            folder.addChild(obj);
        }
    }
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) TreeObject(com.amalto.workbench.models.TreeObject) XObjectEditorInput(com.amalto.workbench.providers.XObjectEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) IEditorInput(org.eclipse.ui.IEditorInput)

Example 24 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class RoutingRuleMainPage method createCharacteristicsContent.

@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite charComposite) {
    try {
        // description
        Label descriptionLabel = toolkit.createLabel(charComposite, Messages.descriptionLabel, SWT.NULL);
        descriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
        // $NON-NLS-1$
        descriptionText = toolkit.createText(charComposite, "", SWT.BORDER);
        descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        descriptionText.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                if (refreshing) {
                    return;
                }
                markDirtyWithoutCommit();
            }
        });
        // Util.createCompDropTarget(descriptionText);
        // objectType
        Label objectTypeLabel = toolkit.createLabel(charComposite, Messages.entityLabel, SWT.NULL);
        objectTypeLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true, 1, 1));
        Composite typeComposite = toolkit.createComposite(charComposite);
        typeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        GridLayout layout = new GridLayout(2, false);
        layout.marginLeft = 0;
        layout.marginWidth = 0;
        typeComposite.setLayout(layout);
        // $NON-NLS-1$
        objectTypeText = toolkit.createText(typeComposite, "", SWT.BORDER);
        objectTypeText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, SWT.CENTER, false, false, 1, 1));
        ((GridData) objectTypeText.getLayoutData()).widthHint = 300;
        // objectTypeText.setLocation(descriptionText.getLocation().x,descriptionText.getLocation().y+10);
        objectTypeText.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                if (refreshing) {
                    return;
                }
                markDirtyWithoutCommit();
            }
        });
        // $NON-NLS-1$
        xpathButton = toolkit.createButton(typeComposite, "", SWT.PUSH);
        xpathButton.setImage(ImageCache.getCreatedImage(EImage.DOTS_BUTTON.getPath()));
        xpathButton.setToolTipText(Messages.entitySelectLabel);
        xpathButton.addSelectionListener(new SelectionListener() {

            public void widgetDefaultSelected(SelectionEvent e) {
            }

            public void widgetSelected(SelectionEvent e) {
                XpathSelectDialog xpathDialog;
                xpathDialog = getNewXpathDlg();
                xpathDialog.setBlockOnOpen(true);
                xpathDialog.open();
                if (xpathDialog.getReturnCode() == Window.OK) {
                    String xpath = xpathDialog.getXpath();
                    // $NON-NLS-1$
                    int index = xpathDialog.getXpath().indexOf("/");
                    if (index > 0) {
                        xpath = xpathDialog.getXpath().substring(0, index);
                    }
                    objectTypeText.setText(xpath);
                }
            }
        });
        // xpathWidget1 = new XpathWidget("...",treeParent, toolkit,
        // charComposite,(AMainPageV2)RoutingRuleMainPage.this,false,false,dataModelName);
        Composite paramComposite = toolkit.createComposite(charComposite);
        GridLayout pcLayout = new GridLayout(4, false);
        pcLayout.marginLeft = 0;
        pcLayout.horizontalSpacing = 0;
        paramComposite.setLayout(pcLayout);
        GridData pcLayoutData = new GridData(SWT.FILL, SWT.FILL, true, false);
        pcLayoutData.horizontalSpan = 2;
        pcLayoutData.horizontalIndent = 0;
        paramComposite.setLayoutData(pcLayoutData);
        // issynchronous Button
        isSynchronousButton = toolkit.createButton(paramComposite, Messages.executesynLabel, SWT.CHECK);
        GridData synBtnLayoutData = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1);
        synBtnLayoutData.horizontalIndent = 0;
        isSynchronousButton.setLayoutData(synBtnLayoutData);
        isSynchronousButton.addMouseListener(new MouseListener() {

            public void mouseUp(MouseEvent e) {
                orderLabel.setEnabled(isSynchronousButton.getSelection());
                orderText.setEnabled(isSynchronousButton.getSelection());
                if (isSynchronousButton.getSelection()) {
                    // $NON-NLS-1$
                    orderText.setText("0");
                } else {
                    // $NON-NLS-1$
                    orderText.setText("");
                }
                // mark for need to save
                markDirtyWithoutCommit();
            }

            public void mouseDoubleClick(MouseEvent e) {
            }

            public void mouseDown(MouseEvent e) {
            }
        });
        orderLabel = toolkit.createLabel(paramComposite, Messages.RoutingRuleMainPage_executeOrder);
        GridData olLayoutData = new GridData();
        olLayoutData.horizontalIndent = 10;
        orderLabel.setLayoutData(olLayoutData);
        orderLabel.setEnabled(false);
        // $NON-NLS-1$
        orderText = toolkit.createText(paramComposite, "", SWT.BORDER | SWT.SINGLE);
        GridData otLayoutData = new GridData(SWT.FILL, SWT.CENTER, false, false);
        otLayoutData.widthHint = 50;
        otLayoutData.horizontalIndent = 10;
        orderText.setLayoutData(otLayoutData);
        orderText.setEnabled(false);
        orderText.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                markDirtyWithoutCommit();
            }
        });
        deactiveButton = toolkit.createButton(paramComposite, Messages.deactivateLabel, SWT.CHECK);
        GridData dbLayoutData = new GridData(SWT.BEGINNING, SWT.FILL, false, true, 1, 1);
        dbLayoutData.horizontalIndent = 25;
        deactiveButton.setLayoutData(dbLayoutData);
        deactiveButton.addMouseListener(new MouseListener() {

            public void mouseUp(MouseEvent e) {
                // mark for need to save
                markDirtyWithoutCommit();
            }

            public void mouseDoubleClick(MouseEvent e) {
            }

            public void mouseDown(MouseEvent e) {
            }
        });
        // Routing Expressions
        Composite serviceGroup = this.getNewSectionComposite(Messages.serviceLabel);
        serviceGroup.setLayout(new GridLayout(2, false));
        // Service Name
        Label serviceNameLabel = toolkit.createLabel(serviceGroup, Messages.serviceJndiLabel, SWT.NULL);
        serviceNameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        Composite subPanel = toolkit.createComposite(serviceGroup);
        subPanel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
        subPanel.setLayout(new GridLayout(2, false));
        serviceNameCombo = new Combo(subPanel, SWT.DROP_DOWN | SWT.SINGLE | SWT.READ_ONLY);
        serviceNameCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
        ((GridData) serviceNameCombo.getLayoutData()).widthHint = 300;
        serviceNameCombo.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                if (refreshing) {
                    return;
                }
                String serviceName = serviceNameCombo.getText();
                // $NON-NLS-1$
                String helpPara = "";
                if (!"".equals(serviceName) && !serviceName.equals(null)) {
                    // $NON-NLS-1$
                    if (EInputTemplate.getXtentisObjexts().get(serviceName) != null) {
                        helpPara = EInputTemplate.getXtentisObjexts().get(serviceName).getContent();
                    } else {
                        // $NON-NLS-1$
                        helpPara = "";
                    }
                }
                // serviceParametersText.setText(XmlUtil.formatXmlSource(helpPara));
                refreshParameterEditor(serviceName);
                serviceParametersEditor.setContent(XmlUtil.formatXmlSource(helpPara));
                markDirtyWithoutCommit();
                initParamterProposal(serviceNameCombo.getText());
            }
        });
        initServiceNameCombo();
        // default parameters button
        // $NON-NLS-1$
        defultParameterBtn = toolkit.createButton(subPanel, "", SWT.PUSH);
        defultParameterBtn.setImage(ImageCache.getCreatedImage(EImage.HELP_CONTENTS.getPath()));
        defultParameterBtn.setToolTipText(Messages.helpLabel);
        defultParameterBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
        defultParameterBtn.addSelectionListener(new SelectionListener() {

            public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
            }

            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                if (serviceNameCombo.getText().trim().length() == 0) {
                    return;
                }
                // $NON-NLS-1$
                String doc = "";
                // $NON-NLS-1$
                String desc = "";
                // WSRoutingRule wsObject = (WSRoutingRule) (getXObject().getWSObject());
                try {
                    WSServiceGetDocument document = getServiceDocument(serviceNameCombo.getText().trim());
                    doc = document.getDocument();
                    desc = document.getDescription();
                } catch (Exception e1) {
                    // $NON-NLS-1$
                    doc = "N/A";
                } finally {
                    showUpDialog(desc, doc);
                }
            }

            private void showUpDialog(String desc, String doc) {
                final PluginDetailsDialog dialog = new PluginDetailsDialog(getSite().getShell(), desc, doc, null, Messages.documentionLabel);
                dialog.addListener(new Listener() {

                    public void handleEvent(Event event) {
                        dialog.close();
                    }
                });
                dialog.create();
                dialog.getShell().setText(serviceNameCombo.getText() + Messages.serviceDetailLabel);
                dialog.setBlockOnOpen(true);
                dialog.open();
            }
        });
        // Service Parameters
        Label serviceParametersLabel = toolkit.createLabel(serviceGroup, Messages.serviceParamLabel, SWT.NULL);
        serviceParametersLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 2, 1));
        serviceParametersEditor = new ExtensibleContentEditor(serviceGroup, SWT.MULTI | SWT.WRAP, EXCONTENTEDITOR_ID);
        GridData gdServiceParameter = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
        // gdServiceParameter.widthHint = 200;
        gdServiceParameter.heightHint = 200;
        serviceParametersEditor.setLayoutData(gdServiceParameter);
        parameterEditorListener = new ParameterEditorListener();
        // serviceParametersText = toolkit.createText(serviceGroup, "",SWT.BORDER|SWT.MULTI|SWT.V_SCROLL|SWT.WRAP);
        // serviceParametersText.setLayoutData(
        // new GridData(SWT.FILL,SWT.FILL,true,false,2,1)
        // );
        // ((GridData) serviceParametersText.getLayoutData()).widthHint = 200;
        // ((GridData) serviceParametersText.getLayoutData()).heightHint = 120;
        // serviceParametersText.addModifyListener(new ModifyListener() {
        // 
        // public void modifyText(ModifyEvent e) {
        // if (refreshing)
        // return;
        // markDirtyWithoutCommit();
        // }
        // });
        // // add by ymli.fix the bug:0011830. We can reuse the same ctrl+space in trigger configs.
        // serviceParametersText.addKeyListener(new KeyListener() {
        // 
        // public void keyReleased(KeyEvent event) {
        // 
        // // System.out.println("SWT.CTRL:"+SWT.CTRL);
        // int start = serviceParametersText.getSelection().x;
        // int end = serviceParametersText.getSelection().y;
        // if (event.stateMask == SWT.CTRL && event.keyCode == 17) {
        // // if(event.keyCode == SWT.F2){
        // ResourceSelectDialog dialog = new ResourceSelectDialog(getSite().getShell(), treeParent.getParent(),
        // "Select a resource node", ServerView.show().getSite());
        // dialog.setBlockOnOpen(true);
        // dialog.open();
        // if (dialog.getReturnCode() == Window.OK) {
        // String xpath = dialog.getXpath();
        // String textHead = serviceParametersText.getText(0, start - 1);
        // String textEnd = serviceParametersText.getText(end, serviceParametersText.getText().length());
        // serviceParametersText.setText(textHead + xpath + textEnd);
        // serviceParametersText.setSelection(start, start + xpath.length());
        // markDirtyWithoutCommit();
        // }
        // }
        // }
        // 
        // public void keyPressed(KeyEvent e) {
        // }
        // });
        // Routing Expressions
        Composite routingExpressionsGroup = this.getNewSectionComposite(Messages.triggerExpressionLabel);
        routingExpressionsGroup.setLayout(new GridLayout(1, true));
        conditionsColumns[0].setColumnWidth(250);
        conditionsColumns[1].setColumnWidth(150);
        conditionsColumns[2].setColumnWidth(250);
        conditionsColumns[3].setColumnWidth(120);
        conditionViewer = getNewTisTableViewer(toolkit, routingExpressionsGroup);
        TreeParent treeParent = (TreeParent) getAdapter(TreeParent.class);
        conditionViewer.setTreeParent(treeParent);
        // $NON-NLS-1$
        conditionViewer.setDatamodelName("UpdateReport");
        conditionViewer.setXpath(true);
        conditionViewer.setMainPage(this);
        conditionViewer.setAddMulti(true);
        conditionViewer.create();
        conditionViewer.setHeight(110);
        // and or not condition
        ConditionWidget conditionWidget = new ConditionWidget(routingExpressionsGroup, toolkit, this);
        conditionText = conditionWidget.getConditionText();
        conditionText.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                if (!refreshing) {
                    markDirtyWithoutCommit();
                }
            }
        });
        wrap.Wrap(this, conditionViewer);
        // make the Page window a DropTarget - we need to dispose it
        windowTarget = new DropTarget(this.getPartControl(), DND.DROP_MOVE);
        windowTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
        windowTarget.addDropListener(new DCDropTargetListener());
        refreshData();
        conditionText.addFocusListener(new FocusListener() {

            public void focusLost(FocusEvent e) {
            // adapter.resetPosition();
            }

            public void focusGained(FocusEvent e) {
                initConditionProposal();
            }
        });
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : ExtensibleContentEditor(com.amalto.workbench.widgets.xmleditor.ExtensibleContentEditor) ExtensibleContentEditorPageListener(com.amalto.workbench.widgets.xmleditor.ExtensibleContentEditorPageListener) MouseListener(org.eclipse.swt.events.MouseListener) SelectionListener(org.eclipse.swt.events.SelectionListener) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) XpathSelectDialog(com.amalto.workbench.dialogs.XpathSelectDialog) TreeParent(com.amalto.workbench.models.TreeParent) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) WSString(com.amalto.workbench.webservices.WSString) FocusEvent(org.eclipse.swt.events.FocusEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) MouseListener(org.eclipse.swt.events.MouseListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) WSServiceGetDocument(com.amalto.workbench.webservices.WSServiceGetDocument) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) PluginDetailsDialog(com.amalto.workbench.dialogs.PluginDetailsDialog) XtentisException(com.amalto.workbench.utils.XtentisException) ConditionWidget(com.amalto.workbench.widgets.ConditionWidget) GridData(org.eclipse.swt.layout.GridData) FocusEvent(org.eclipse.swt.events.FocusEvent) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) TextEvent(java.awt.event.TextEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DropTarget(org.eclipse.swt.dnd.DropTarget) FocusListener(org.eclipse.swt.events.FocusListener) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 25 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class StoredProcedureMainPage method createCharacteristicsContent.

@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite charComposite) {
    try {
        WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
        // description
        Label descriptionLabel = toolkit.createLabel(charComposite, Messages.StoredProcedureMainPage_4, SWT.NULL);
        descriptionLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));
        // $NON-NLS-1$
        descriptionText = toolkit.createText(charComposite, "", SWT.BORDER);
        descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        // $NON-NLS-1$
        descriptionText.setText(wsStoredProcedure.getDescription() == null ? "" : wsStoredProcedure.getDescription());
        descriptionText.addModifyListener(this);
        // Procedure
        Group storedProcedureGroup = new Group(charComposite, SWT.SHADOW_NONE);
        storedProcedureGroup.setText(Messages.StoredProcedureMainPage_5);
        storedProcedureGroup.setLayout(new GridLayout(1, true));
        storedProcedureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
        ((GridData) storedProcedureGroup.getLayoutData()).minimumHeight = 100;
        procedureViewer = new SourceViewer(storedProcedureGroup, new VerticalRuler(10), SWT.V_SCROLL);
        procedureViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        procedureViewer.addTextListener(this);
        WidgetUtils.initRedoUndo(procedureViewer);
        refreshCacheBtn = toolkit.createButton(charComposite, Messages.StoredProcedureMainPage_6, SWT.CHECK);
        refreshCacheBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
        refreshCacheBtn.addSelectionListener(new SelectionListener() {

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

            public void widgetDefaultSelected(SelectionEvent e) {
                markDirty();
            }
        });
        /**
         **********************************************************
         * Execute Stored Procedure
         ***********************************************************
         */
        createCompDropTarget();
        Composite resultsGroup = this.getNewSectionComposite(Messages.StoredProcedureMainPage_7);
        resultsGroup.setLayout(new GridLayout(4, false));
        // data cluster
        Hyperlink dataClusterLink = toolkit.createHyperlink(resultsGroup, Messages.StoredProcedureMainPage_8, SWT.NULL);
        dataClusterLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        dataClusterLink.addHyperlinkListener(new IHyperlinkListener() {

            public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) {
            }

            public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) {
            }

            public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) {
                if (!isLocalInput()) {
                    TreeParent serverRoot = StoredProcedureMainPage.this.getXObject().getServerRoot();
                    TreeObject iaObject = new TreeObject(StoredProcedureMainPage.this.dataClusterCombo.getText(), serverRoot, TreeObject.DATA_CLUSTER, new WSDataClusterPK(StoredProcedureMainPage.this.dataClusterCombo.getText()), null);
                    (new EditXObjectAction(iaObject, StoredProcedureMainPage.this.getSite().getPage())).run();
                }
            }
        });
        dataClusterCombo = new Combo(resultsGroup, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
        dataClusterCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.NONE, false, false, 1, 1));
        Button executeButton = new Button(resultsGroup, SWT.PUSH);
        executeButton.setText(Messages.StoredProcedureMainPage_9);
        executeButton.addMouseListener(new MouseListener() {

            public void mouseUp(MouseEvent e) {
                executeProcedure();
            }

            public void mouseDoubleClick(MouseEvent e) {
            }

            public void mouseDown(MouseEvent e) {
            }
        });
        resultsLabel = toolkit.createLabel(resultsGroup, // $NON-NLS-1$
        "                                                                                                           ", SWT.NULL);
        resultsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
        resultsViewer = new TableViewer(resultsGroup);
        resultsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
        ((GridData) resultsViewer.getControl().getLayoutData()).heightHint = 300;
        resultsViewer.setContentProvider(new ArrayContentProvider());
        resultsViewer.setLabelProvider(new XMLTableLabelProvider());
        resultsViewer.addDoubleClickListener(new IDoubleClickListener() {

            public void doubleClick(DoubleClickEvent event) {
                resultsViewer.setSelection(event.getSelection());
                new ResultsViewAction(StoredProcedureMainPage.this.getSite().getShell(), resultsViewer).run();
            }
        });
        hookContextMenu();
        refreshData();
        dataClusterCombo.select(0);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) SourceViewer(org.eclipse.jface.text.source.SourceViewer) TreeParent(com.amalto.workbench.models.TreeParent) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) MouseListener(org.eclipse.swt.events.MouseListener) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IHyperlinkListener(org.eclipse.ui.forms.events.IHyperlinkListener) WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure) VerticalRuler(org.eclipse.jface.text.source.VerticalRuler) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) EditXObjectAction(com.amalto.workbench.actions.EditXObjectAction) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TreeObject(com.amalto.workbench.models.TreeObject) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink)

Aggregations

TreeParent (com.amalto.workbench.models.TreeParent)38 TreeObject (com.amalto.workbench.models.TreeObject)21 Document (org.dom4j.Document)7 Element (org.dom4j.Element)7 GridData (org.eclipse.swt.layout.GridData)7 UserInfo (com.amalto.workbench.utils.UserInfo)6 ArrayList (java.util.ArrayList)6 GridLayout (org.eclipse.swt.layout.GridLayout)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 Composite (org.eclipse.swt.widgets.Composite)5 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)4 HashMap (java.util.HashMap)4 SelectionListener (org.eclipse.swt.events.SelectionListener)4 Combo (org.eclipse.swt.widgets.Combo)4 Label (org.eclipse.swt.widgets.Label)4 XtentisException (com.amalto.workbench.utils.XtentisException)3 WSDataModel (com.amalto.workbench.webservices.WSDataModel)3 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)3 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)3 ModifyEvent (org.eclipse.swt.events.ModifyEvent)3