Search in sources :

Example 1 with ExtensibleContentEditor

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

the class TransformerMainPage method createCharacteristicsContent.

@Override
protected void createCharacteristicsContent(final FormToolkit toolkit, Composite topComposite) {
    try {
        initTransformer();
        descriptionComposite = toolkit.createComposite(topComposite, SWT.NONE);
        descriptionComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        descriptionComposite.setLayout(new GridLayout(3, false));
        // edit by ymli; fix the bug:0012024 Make Process descriptions multilingual.
        // description
        /*
             * Label descriptionLabel = toolkit.createLabel(descriptionComposite, "Description", SWT.NULL);
             * descriptionLabel.setLayoutData( new GridData(SWT.FILL,SWT.CENTER,false,true,1,1) ); descriptionText =
             * toolkit.createText(descriptionComposite, "",SWT.BORDER|SWT.MULTI); descriptionText.setLayoutData( new
             * GridData(SWT.FILL,SWT.FILL,true,true,1,1) ); ((GridData)descriptionText.getLayoutData()).minimumHeight =
             * 30; descriptionText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if
             * (refreshing) return; //commit as we go TransformerMainPage.this.comitting= true;
             * //((WSTransformerV2)getXObject().getWsObject()) transformer.setDescription(descriptionText.getText());
             * TransformerMainPage.this.comitting= false; //markDirtyWithoutCommit(); markDirtyWithoutCommit(); } });
             */
        desAntionComposite = new DescAnnotationComposite(Messages.TransformerMainPage_Description, // $NON-NLS-1$
        " ...", // $NON-NLS-1$
        toolkit, // $NON-NLS-1$
        descriptionComposite, this, false);
        desAntionComposite.getTextWidget().addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                if (refreshing) {
                    return;
                }
                TransformerMainPage.this.comitting = true;
                transformer.setDescription(desAntionComposite.getText());
                TransformerMainPage.this.comitting = false;
                markDirtyWithoutCommit();
            }
        });
        // 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());
        sequenceGroup = this.getNewSectionComposite(Messages.TransformerMainPage_StepsSequence);
        sequenceGroup.setLayout(new GridLayout(1, false));
        Composite sequenceComposite = toolkit.createComposite(sequenceGroup, SWT.NONE);
        sequenceComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        sequenceComposite.setLayout(new GridLayout(6, false));
        Label l3 = toolkit.createLabel(sequenceComposite, Messages.TransformerMainPage_StepDesc, SWT.NULL);
        l3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        // $NON-NLS-1$
        stepText = toolkit.createText(sequenceComposite, "", SWT.BORDER | SWT.SINGLE);
        stepText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
        stepText.addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent e) {
            }

            public void keyReleased(KeyEvent e) {
                if (e.keyCode == 13) {
                    // enter
                    performAdd();
                    int index = stepsList.getItemCount() - 1;
                    performSelect(index);
                }
            }
        });
        // $NON-NLS-1$
        Button addStepButton = toolkit.createButton(sequenceComposite, "", SWT.PUSH);
        addStepButton.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, false, true, 1, 1));
        addStepButton.setToolTipText(Messages.TransformerMainPage_Add);
        addStepButton.setImage(ImageCache.getCreatedImage(EImage.ADD_OBJ.getPath()));
        addStepButton.addSelectionListener(new SelectionListener() {

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

            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                // commit as we go
                performAdd();
            }
        });
        stepsList = new List(sequenceComposite, SWT.V_SCROLL | SWT.BORDER);
        stepsList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
        ((GridData) stepsList.getLayoutData()).heightHint = 40;
        /*
             * DragSource stepsSource = new DragSource(stepsList,DND.DROP_MOVE); stepsSource.setTransfer(new
             * Transfer[]{TextTransfer.getInstance()}); stepsSource.addDragListener(new DCDragSourceListener());
             */
        stepsList.addSelectionListener(new SelectionListener() {

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

            public void widgetSelected(SelectionEvent e) {
                performSelect(stepsList.getSelectionIndex());
            }
        });
        wrap.Wrap(this, stepsList);
        stepsList.addFocusListener(new FocusListener() {

            public void focusGained(FocusEvent e) {
                if (stepsList.getSelectionIndex() >= 0) {
                    refreshStep(stepsList.getSelectionIndex());
                    section.setVisible(true);
                }
            }

            public void focusLost(FocusEvent e) {
            }
        });
        Composite stepUpDownComposite = toolkit.createComposite(sequenceComposite, SWT.NONE);
        stepUpDownComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
        stepUpDownComposite.setLayout(new GridLayout(1, false));
        // $NON-NLS-1$
        Button stepUpButton = toolkit.createButton(stepUpDownComposite, "", SWT.PUSH | SWT.CENTER);
        stepUpButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
        stepUpButton.setImage(ImageCache.getCreatedImage(EImage.PREV_NAV.getPath()));
        stepUpButton.setToolTipText(Messages.TransformerMainPage_MoveUpTheItem);
        stepUpButton.addSelectionListener(new SelectionListener() {

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

            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                int index = TransformerMainPage.this.stepsList.getSelectionIndex();
                if (index > 0) {
                    // commit as we go
                    TransformerMainPage.this.comitting = true;
                    String val = TransformerMainPage.this.stepsList.getItem(index);
                    TransformerMainPage.this.stepsList.remove(index);
                    TransformerMainPage.this.stepsList.add(val, index - 1);
                    TransformerMainPage.this.stepsList.select(index - 1);
                    // (WSTransformerV2)getXObject().getWsObject();
                    WSTransformerV2 wsTransformer = transformer;
                    java.util.List<WSTransformerProcessStep> list = wsTransformer.getProcessSteps();
                    WSTransformerProcessStep spec = list.get(index);
                    list.remove(index);
                    list.add(index - 1, spec);
                    performSelect(index - 1);
                    TransformerMainPage.this.comitting = false;
                    TransformerMainPage.this.stepsList.forceFocus();
                    markDirtyWithoutCommit();
                }
            }
        });
        // $NON-NLS-1$
        Button stepDownButton = toolkit.createButton(stepUpDownComposite, "", SWT.PUSH | SWT.CENTER);
        stepDownButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
        stepDownButton.setImage(ImageCache.getCreatedImage(EImage.NEXT_NAV.getPath()));
        stepDownButton.setToolTipText(Messages.TransformerMainPage_MoveDownTheItem);
        stepDownButton.addSelectionListener(new SelectionListener() {

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

            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                int index = TransformerMainPage.this.stepsList.getSelectionIndex();
                if ((index >= 0) && (index < TransformerMainPage.this.stepsList.getItemCount() - 1)) {
                    // commit as we go
                    TransformerMainPage.this.comitting = true;
                    String val = TransformerMainPage.this.stepsList.getItem(index);
                    TransformerMainPage.this.stepsList.remove(index);
                    TransformerMainPage.this.stepsList.add(val, index + 1);
                    TransformerMainPage.this.stepsList.select(index + 1);
                    // (WSTransformerV2)getXObject().getWsObject();
                    WSTransformerV2 wsTransformer = transformer;
                    java.util.List<WSTransformerProcessStep> list = wsTransformer.getProcessSteps();
                    WSTransformerProcessStep spec = list.get(index);
                    list.remove(index);
                    list.add(index + 1, spec);
                    TransformerMainPage.this.comitting = false;
                    TransformerMainPage.this.stepsList.forceFocus();
                    markDirtyWithoutCommit();
                }
            }
        });
        // $NON-NLS-1$
        Button deleteStepButton = toolkit.createButton(stepUpDownComposite, "", SWT.PUSH | SWT.CENTER);
        deleteStepButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
        deleteStepButton.setImage(ImageCache.getCreatedImage(EImage.DELETE_OBJ.getPath()));
        deleteStepButton.setToolTipText(Messages.TransformerMainPage_DelTheItem);
        deleteStepButton.addSelectionListener(new SelectionListener() {

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

            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                int index = TransformerMainPage.this.stepsList.getSelectionIndex();
                if ((index >= 0) && (index < TransformerMainPage.this.stepsList.getItemCount())) {
                    removeStep(index);
                }
            }
        });
        // Plugin Specifications
        // Sequence
        section = this.getNewSection(Messages.TransformerMainPage_StepSpecification);
        section.setVisible(false);
        sequenceGroup.setLayout(new GridLayout(4, false));
        disabledButton = toolkit.createButton((Composite) section.getClient(), Messages.TransformerMainPage_Disabled, SWT.CHECK);
        disabledButton.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true, 4, 1));
        specsComposite = toolkit.createComposite((Composite) section.getClient(), SWT.NULL);
        specsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        specsComposite.setLayout(new GridLayout(4, false));
        disabledButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                WidgetUtils.enable(specsComposite, !disabledButton.getSelection());
                markDirtyWithoutCommit();
                if (stepsList.getSelectionIndex() >= 0) {
                    transformer.getProcessSteps().get(stepsList.getSelectionIndex()).setDisabled(disabledButton.getSelection());
                }
            }
        });
        // $NON-NLS-1$
        stepLabel = toolkit.createLabel(specsComposite, "", SWT.NULL);
        stepLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
        FontData fd = stepLabel.getFont().getFontData()[0];
        fd.setStyle(SWT.BOLD);
        stepLabel.setFont(new Font(Display.getDefault(), fd));
        stepWidget = new TransformerStepWidget(toolkit, specsComposite);
        stepWidget.create();
        btnAutoIndent = new Button(specsComposite, SWT.CHECK);
        btnAutoIndent.setText(Messages.TransformerMainPage_AutoIndent);
        btnAutoIndent.setImage(ImageCache.getCreatedImage(EImage.INTENT.getPath()));
        btnAutoIndent.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
        // refreshAutoIndentTooltip();
        btnAutoIndent.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                refreshAutoIndentTooltip();
            }
        });
        btnOpenXsltEditor = new Button(specsComposite, SWT.PUSH);
        btnOpenXsltEditor.setText(Messages.TransformerMainPage_open);
        btnOpenXsltEditor.setToolTipText(Messages.TransformerMainPage_opentext);
        btnOpenXsltEditor.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
        btnOpenXsltEditor.addSelectionListener(new SelectionAdapter() {

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

            public void openInXSLTEditor() {
                refreshEnableState(false);
                try {
                    // $NON-NLS-1$
                    IPreferenceStore preference = new ScopedPreferenceStore(new InstanceScope(), "org.eclipse.wst.xsl.ui");
                    // $NON-NLS-1$
                    String charSet = preference.getString("outputCodeset");
                    String xslcontent = parameterEditor.getContent().getContent();
                    IFile file = FileProvider.createdTempFile(xslcontent, getXSLTFileName(), charSet);
                    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                    xsltEditorInput = new XSLTFileEditorInput(file, new MainPageRefresher(), true);
                    page.openEditor(xsltEditorInput, XSLTEditor.ID);
                } catch (PartInitException e) {
                    log.error(e.getMessage(), e);
                }
            }
        });
        Group parametersGroup = new Group(specsComposite, SWT.SHADOW_NONE);
        parametersGroup.setText(Messages.TransformerMainPage_Parameters);
        parametersGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
        ((GridData) parametersGroup.getLayoutData()).minimumHeight = 300;
        parametersGroup.setLayout(new GridLayout(1, true));
        parameterEditor = new ExtensibleContentEditor(parametersGroup, SWT.NONE, EXCONTENTEDITOR_ID);
        parameterEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
        parameterEditorListener = new ProcessPluginParameterEditorListener();
        refreshParameterEditor();
        refreshData();
        addToolBarItem();
        this.oldBackground = parameterEditor.getBackground();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : ExtensibleContentEditor(com.amalto.workbench.widgets.xmleditor.ExtensibleContentEditor) XSLTFileEditorInput(com.amalto.workbench.editors.xslteditor.XSLTFileEditorInput) Group(org.eclipse.swt.widgets.Group) IFile(org.eclipse.core.resources.IFile) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) FocusEvent(org.eclipse.swt.events.FocusEvent) Font(org.eclipse.swt.graphics.Font) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ArrayList(java.util.ArrayList) WSGetTransformerPluginV2SList(com.amalto.workbench.webservices.WSGetTransformerPluginV2SList) List(org.eclipse.swt.widgets.List) WSTransformerPluginV2SList(com.amalto.workbench.webservices.WSTransformerPluginV2SList) PartInitException(org.eclipse.ui.PartInitException) Composite(org.eclipse.swt.widgets.Composite) DescAnnotationComposite(com.amalto.workbench.widgets.DescAnnotationComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FontData(org.eclipse.swt.graphics.FontData) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) XtentisException(com.amalto.workbench.utils.XtentisException) DescAnnotationComposite(com.amalto.workbench.widgets.DescAnnotationComposite) WSTransformerV2(com.amalto.workbench.webservices.WSTransformerV2) GridData(org.eclipse.swt.layout.GridData) WSTransformerProcessStep(com.amalto.workbench.webservices.WSTransformerProcessStep) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) KeyListener(org.eclipse.swt.events.KeyListener) DropTarget(org.eclipse.swt.dnd.DropTarget) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) FocusListener(org.eclipse.swt.events.FocusListener) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 2 with ExtensibleContentEditor

use of com.amalto.workbench.widgets.xmleditor.ExtensibleContentEditor 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)

Aggregations

XtentisException (com.amalto.workbench.utils.XtentisException)2 ExtensibleContentEditor (com.amalto.workbench.widgets.xmleditor.ExtensibleContentEditor)2 DropTarget (org.eclipse.swt.dnd.DropTarget)2 FocusEvent (org.eclipse.swt.events.FocusEvent)2 FocusListener (org.eclipse.swt.events.FocusListener)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)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 Label (org.eclipse.swt.widgets.Label)2 PluginDetailsDialog (com.amalto.workbench.dialogs.PluginDetailsDialog)1 XpathSelectDialog (com.amalto.workbench.dialogs.XpathSelectDialog)1 XSLTFileEditorInput (com.amalto.workbench.editors.xslteditor.XSLTFileEditorInput)1 TreeParent (com.amalto.workbench.models.TreeParent)1 WSGetTransformerPluginV2SList (com.amalto.workbench.webservices.WSGetTransformerPluginV2SList)1 WSServiceGetDocument (com.amalto.workbench.webservices.WSServiceGetDocument)1 WSString (com.amalto.workbench.webservices.WSString)1