Search in sources :

Example 1 with XpathSelectDialog

use of com.amalto.workbench.dialogs.XpathSelectDialog in project tmdm-studio-se by Talend.

the class RenameProcessDialog method widgetSelected.

public void widgetSelected(SelectionEvent e) {
    XpathSelectDialog dlg = new XpathSelectDialog(getShell(), null, Messages.ViewInputDialog_SelectOneEntity, site, false, null);
    dlg.setBlockOnOpen(true);
    dlg.open();
    if (dlg.getReturnCode() == Window.OK) {
        if (uiType == typeAll) {
            entityText1.setText(dlg.getEntityName());
        } else if (uiType == typeEntity) {
            entityText2.setText(dlg.getEntityName());
        }
        dlg.close();
    }
}
Also used : XpathSelectDialog(com.amalto.workbench.dialogs.XpathSelectDialog)

Example 2 with XpathSelectDialog

use of com.amalto.workbench.dialogs.XpathSelectDialog 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 3 with XpathSelectDialog

use of com.amalto.workbench.dialogs.XpathSelectDialog in project tmdm-studio-se by Talend.

the class ViewMainPage method addListener.

private void addListener() {
    combox_policy.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean toSelectXPath = combox_policy.getText().equals(selectXPath);
            if (toSelectXPath) {
                String modelName = getDatamodelName();
                String entityName = concept;
                XpathSelectDialog dlg = getXPathSelectionDialog(Messages.ViewMainPage_titleSelectField, modelName, new SortFieldSelectionFilter());
                dlg.setConceptName(entityName);
                String xpath = null;
                if (dlg.open() == IDialogConstants.OK_ID) {
                    xpath = dlg.getXpath();
                }
                if (xpath != null) {
                    combox_policy.setItems(new String[] { SORT_FIELD[0], SORT_FIELD[1], xpath, selectXPath });
                    combox_policy.setText(xpath);
                    combox_sortdirection.setVisible(true);
                    combox_sortdirection.select(0);
                    markDirtyWithoutCommit();
                } else {
                    lastSortField = lastSortField == null ? SORT_FIELD[0] : lastSortField;
                    combox_policy.setText(lastSortField);
                }
            } else if (combox_policy.getSelectionIndex() != 0 && combox_policy.getSelectionIndex() != 1) {
                combox_sortdirection.setVisible(true);
                combox_sortdirection.select(0);
                lastSortField = combox_policy.getText();
                markDirtyWithoutCommit();
            } else {
                lastSortField = combox_policy.getText();
                combox_sortdirection.setVisible(false);
                markDirtyWithoutCommit();
            }
        }
    });
    combox_policy.addMouseTrackListener(new MouseTrackAdapter() {

        @Override
        public void mouseHover(MouseEvent e) {
            combox_policy.setToolTipText(combox_policy.getText());
        }
    });
    combox_sortdirection.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            markDirtyWithoutCommit();
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) SortFieldSelectionFilter(com.amalto.workbench.dialogs.filter.SortFieldSelectionFilter) XpathSelectDialog(com.amalto.workbench.dialogs.XpathSelectDialog) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MouseTrackAdapter(org.eclipse.swt.events.MouseTrackAdapter)

Example 4 with XpathSelectDialog

use of com.amalto.workbench.dialogs.XpathSelectDialog in project tmdm-studio-se by Talend.

the class XpathWidget method widgetSelected.

public void widgetSelected(SelectionEvent e) {
    if (accommodation != null) {
        if (dlg == null) {
            dlg = new XpathSelectDialog(accommodation.getSite().getShell(), treeParent, dlgTitle, accommodation.getSite(), isMulti, dataModelName);
            dlg.setConceptName(conceptName);
        }
    } else {
        if (dlg == null) {
            dlg = new XpathSelectDialog(parent.getShell(), treeParent, dlgTitle, site, false, dataModelName);
            dlg.setConceptName(conceptName);
        }
    }
    dlg.setLock(lock);
    dlg.setBlockOnOpen(true);
    disableFocusListener();
    dlg.open();
    enableFocusListener();
    if (dlg.getReturnCode() == Window.OK) {
        descriptionText.setText(dlg.getXpath());
        dataModelName = dlg.getDataModelName();
        dlg.close();
        setOutFocus();
    } else {
        lostFocus();
    }
}
Also used : XpathSelectDialog(com.amalto.workbench.dialogs.XpathSelectDialog)

Example 5 with XpathSelectDialog

use of com.amalto.workbench.dialogs.XpathSelectDialog in project tmdm-studio-se by Talend.

the class SchematronExpressBuilder method create.

private void create() {
    com = new Composite(parent, SWT.NONE);
    com.setLayout(getLayout(3));
    // expression
    Group expressG = new Group(com, SWT.NONE);
    expressG.setText(Messages.SchematronExpressBuilder_Expression);
    expressG.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 2));
    expressG.setLayout(getLayout(1));
    // top button group
    Composite topCom = new Composite(expressG, 0);
    Button clearBtn = new Button(topCom, SWT.PUSH);
    topCom.setLayout(getLayout(4));
    clearBtn.setText(Messages.SchematronExpressBuilder_Clear);
    clearBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1));
    clearBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // $NON-NLS-1$
            sourceViewer.setDocument(new Document(""));
        }
    });
    org.eclipse.jface.text.Document doc = new org.eclipse.jface.text.Document(value);
    sourceViewer = new SourceViewer(expressG, new VerticalRuler(5), SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 6);
    gd.heightHint = 150;
    sourceViewer.getControl().setLayoutData(gd);
    WidgetUtils.initRedoUndo(sourceViewer);
    sourceViewer.setDocument(doc);
    // bottom button group
    Composite bottomCom = new Composite(expressG, 0);
    GridLayout ly = getLayout(4);
    bottomCom.setLayout(ly);
    Composite com1 = new Composite(bottomCom, 0);
    com1.setLayout(getLayout(4));
    // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    String[] strs1 = { "+", "-", "*", "div" };
    for (String str : strs1) {
        final Button btn = new Button(com1, SWT.PUSH);
        btn.setText(str);
        btn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                // getTextWidget().setText(getText() + btn.getText());
                insertText(btn.getText());
            }
        });
    }
    Composite com2 = new Composite(bottomCom, 0);
    com2.setLayout(getLayout(4));
    // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    String[] strs2 = { "=", "!=", ">", "<" };
    for (String str : strs2) {
        final Button btn = new Button(com2, SWT.PUSH);
        btn.setText(str);
        btn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                // getTextWidget().setText(getText() + btn.getText());
                insertText(btn.getText());
            }
        });
    }
    Composite com3 = new Composite(bottomCom, 0);
    com3.setLayout(getLayout(4));
    // $NON-NLS-1$//$NON-NLS-2$
    String[] strs3 = { "and", "or" };
    for (int i = 0; i < strs3.length; i++) {
        final Button btn = new Button(com3, SWT.PUSH);
        btn.setText(strs3[i]);
        btn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                // getTextWidget().setText(getText() + btn.getText());
                insertText(btn.getText());
            }
        });
    }
    Composite com4 = new Composite(bottomCom, 0);
    com4.setLayout(getLayout(3));
    // $NON-NLS-1$//$NON-NLS-2$
    String[] strs4 = { ")", "(" };
    for (int i = 0; i < strs4.length; i++) {
        final Button btn = new Button(com4, SWT.PUSH);
        btn.setText(strs4[i]);
        btn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                // getTextWidget().setText(getText() + btn.getText());
                insertText(btn.getText());
            }
        });
    }
    Button xpathButton = new Button(com4, SWT.PUSH);
    // $NON-NLS-1$
    xpathButton.setText("xpath");
    xpathButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            XpathSelectDialog dlg = getXPathSelectDialog();
            dlg.setConceptName(conceptName);
            // dlg.setContext(context);
            dlg.setBlockOnOpen(true);
            dlg.open();
            if (dlg.getReturnCode() == Window.OK) {
                if (getTextWidget().getSelectionText().length() > 0) {
                    // getTextWidget().setText(getText().replace(getTextWidget().getSelectionText(),
                    // dlg.getXpath()));
                    getTextWidget().replaceTextRange(getTextWidget().getSelectionRanges()[0], getTextWidget().getSelectionRanges()[1], dlg.getXpath());
                } else {
                    // getTextWidget().setText(getText()+dlg.getXpath());
                    insertText(dlg.getXpath());
                }
            }
        }
    });
    // //test
    // Group testG=new Group(com,SWT.NONE);
    // testG.setText("Test");
    // GridData gd2=new GridData(SWT.FILL,SWT.FILL,true,true,1,2);
    // gd2.widthHint=190;
    // testG.setLayoutData(gd2);
    // testG.setLayout(getLayout(2));
    // Button btnStartTest=new Button(testG,SWT.PUSH);
    // btnStartTest.setText("Start Test");
    // btnStartTest.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false,1,1));
    // 
    // Button btnCleartTest=new Button(testG,SWT.PUSH);
    // btnCleartTest.setText("Clear");
    // btnCleartTest.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false,1,1));
    // 
    // testResult=new StyledText(testG,SWT.V_SCROLL|SWT.BORDER);
    // testResult.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,2,3));
    // btnCleartTest.addSelectionListener(new SelectionAdapter(){
    // @Override
    // public void widgetSelected(SelectionEvent e) {
    // testResult.setText("");
    // }
    // });
    // categories
    Group categoryG = new Group(com, SWT.NONE);
    categoryG.setText(Messages.SchematronExpressBuilder_Categories);
    GridData gd1 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd1.heightHint = 200;
    gd1.widthHint = 140;
    categoryG.setLayoutData(gd1);
    categoryG.setLayout(getLayout(1));
    categoryList = new List(categoryG, SWT.BORDER | SWT.V_SCROLL);
    categoryList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    for (XPathFunc c : categories) {
        categoryList.add(c.getCategory());
    }
    categoryList.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            funcList.removeAll();
            String c = categoryList.getSelection()[0];
            for (XPathFunc func : categories) {
                if (func.getCategory().equals(c)) {
                    curfc = func;
                    for (KeyValue kv : func.getFuncs()) {
                        funcList.add(kv.key);
                    }
                    break;
                }
            }
            if (funcList.getItems().length > 0) {
                funcList.select(0);
                helpTxt.setText(curfc.getFuncs().get(0).value);
            }
        }
    });
    // funcations
    Group functionG = new Group(com, SWT.NONE);
    functionG.setText(Messages.SchematronExpressBuilder_Functions);
    functionG.setLayout(getLayout(1));
    GridData gd3 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd3.widthHint = 220;
    functionG.setLayoutData(gd3);
    funcList = new List(functionG, SWT.BORDER | SWT.V_SCROLL);
    funcList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    funcList.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            getTextWidget().setText(getText() + funcList.getItem(funcList.getSelectionIndex()));
        }

        public void widgetSelected(SelectionEvent e) {
            String c = funcList.getSelection()[0];
            for (KeyValue kv : curfc.getFuncs()) {
                if (kv.key.equals(c)) {
                    helpTxt.setText(kv.value);
                    break;
                }
            }
        }
    });
    // help
    Group helpG = new Group(com, SWT.NONE);
    helpG.setText(Messages.SchematronExpressBuilder_Help);
    helpG.setLayout(getLayout(1));
    helpG.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    helpTxt = new StyledText(helpG, SWT.BORDER | SWT.WRAP);
    GridData gd4 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd4.widthHint = 210;
    helpTxt.setLayoutData(gd4);
}
Also used : Group(org.eclipse.swt.widgets.Group) SourceViewer(org.eclipse.jface.text.source.SourceViewer) KeyValue(com.amalto.workbench.models.KeyValue) XpathSelectDialog(com.amalto.workbench.dialogs.XpathSelectDialog) Document(org.eclipse.jface.text.Document) Document(org.eclipse.jface.text.Document) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(org.eclipse.swt.widgets.List) VerticalRuler(org.eclipse.jface.text.source.VerticalRuler) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) XPathFunc(com.amalto.workbench.models.XPathFunc) Point(org.eclipse.swt.graphics.Point) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

XpathSelectDialog (com.amalto.workbench.dialogs.XpathSelectDialog)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 MouseEvent (org.eclipse.swt.events.MouseEvent)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 PluginDetailsDialog (com.amalto.workbench.dialogs.PluginDetailsDialog)1 SortFieldSelectionFilter (com.amalto.workbench.dialogs.filter.SortFieldSelectionFilter)1 KeyValue (com.amalto.workbench.models.KeyValue)1 TreeParent (com.amalto.workbench.models.TreeParent)1 XPathFunc (com.amalto.workbench.models.XPathFunc)1 XtentisException (com.amalto.workbench.utils.XtentisException)1 WSServiceGetDocument (com.amalto.workbench.webservices.WSServiceGetDocument)1 WSString (com.amalto.workbench.webservices.WSString)1 ConditionWidget (com.amalto.workbench.widgets.ConditionWidget)1 ExtensibleContentEditor (com.amalto.workbench.widgets.xmleditor.ExtensibleContentEditor)1 ExtensibleContentEditorPageListener (com.amalto.workbench.widgets.xmleditor.ExtensibleContentEditorPageListener)1 TextEvent (java.awt.event.TextEvent)1