Search in sources :

Example 36 with MessageBox

use of org.eclipse.swt.widgets.MessageBox in project tdi-studio-se by Talend.

the class AddArrayIndexDialog method okPressed.

protected void okPressed() {
    String com = text.getText();
    index = Integer.valueOf(indexText);
    if (text.getEnabled() == true && ("".equals(text.getText()) || text.getText() == null)) {
        MessageBox box = new MessageBox(parentShell, SWT.ICON_ERROR | SWT.OK);
        //$NON-NLS-1$
        box.setText(Messages.getString("AddArrayIndexDialog.Error"));
        //$NON-NLS-1$
        box.setMessage(Messages.getString("AddArrayIndexDialog.Input_Index"));
        box.open();
        return;
    }
    if (arraySize != -1 && (index < 0 || index > arraySize)) {
        MessageBox box = new MessageBox(parentShell, SWT.ICON_ERROR | SWT.OK | SWT.CANCEL);
        //$NON-NLS-1$
        box.setText(Messages.getString("AddArrayIndexDialog.Error"));
        //$NON-NLS-1$
        box.setMessage(Messages.getString("AddArrayIndexDialog.check_size"));
        box.open();
        //$NON-NLS-1$
        text.setText("");
        return;
    }
    super.okPressed();
}
Also used : MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 37 with MessageBox

use of org.eclipse.swt.widgets.MessageBox in project tdi-studio-se by Talend.

the class AddListDialog method okPressed.

@Override
protected void okPressed() {
    boolean falg = false;
    IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
    paramList = selection.toList();
    if (selection.size() == 1) {
        ParameterInfo selPara = getSelectedParaInfo();
        ParameterInfo usePara = null;
        paraUtil = new ParameterInfoUtil();
        int currentindex = -1;
        // if select multi simple type items.
        if (paramList != null && !paramList.isEmpty()) {
        }
        // if selected have branch.
        if (selPara == null) {
            return;
        }
        if (!selPara.getParameterInfos().isEmpty()) {
            MessageBox box = new MessageBox(parentShell, SWT.ICON_ERROR | SWT.OK);
            //$NON-NLS-1$
            box.setText(Messages.getString("AddListDialog.Error"));
            //$NON-NLS-1$
            box.setMessage("Please Select " + selPara.getName() + " branch Item.");
            box.open();
            return;
        }
    } else if (selection.size() > 1) {
        paraUtil = new ParameterInfoUtil();
        List<ParameterInfo> list = selection.toList();
        for (ParameterInfo info : list) {
            if (!info.getParameterInfos().isEmpty()) {
                MessageBox box = new MessageBox(parentShell, SWT.ICON_ERROR | SWT.OK);
                //$NON-NLS-1$
                box.setText(Messages.getString("AddListDialog.Error"));
                //$NON-NLS-1$
                box.setMessage("Please Select " + info.getName() + " branch Item.");
                box.open();
                return;
            }
        }
    }
    // if select a array item.
    // if (selPara.getArraySize() == -1) {
    // AddArrayIndexDialog dlg = new AddArrayIndexDialog(parentShell, selPara);
    // int openCode = dlg.open();
    // if (openCode == AddArrayIndexDialog.OK) {
    // String indexValue = dlg.getIndexText();
    // currentindex = Integer.valueOf(indexValue);
    // } else {
    // return;
    // }
    // paraUtil.setCurrentindex(currentindex);
    // // super.okPressed();
    // }
    // if select item's parent is array.
    // if (arraySize == 0 && selPara.getParent() != null && !getAllArrayFromParents(selPara, null).isEmpty()) {
    // List<ParameterInfo> paraList = paraUtil.getAllParameterInfo(selPara);
    // goout: for (ParameterInfo para : paraList) {
    // if (para.getArraySize() != 0) {
    // falg = true;
    // usePara = para;
    // arraySize = para.getArraySize();
    // break goout;
    // }
    // }
    // }
    // if (falg) {
    // String title = "";
    // if (usePara != null && usePara.getName() != null) {
    // title = usePara.getName() + " index is :";
    // }
    // if (getAllArrayFromParents(selPara, null).size() == 1 && "input".equals(inOrOut) && false) {
    //                InputDialog dlg = new InputDialog(parentShell, title, title, "", new InputIndexValidator()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    // int openCode = dlg.open();
    // if (openCode == InputDialog.OK) {
    // String indexValue = dlg.getValue();
    // currentindex = Integer.valueOf(indexValue);
    // } else if (openCode == InputDialog.CANCEL) {
    // // super.cancelPressed();
    // return;
    // }
    // if (arraySize != -1 && currentindex > arraySize) {
    // currentindex = -1;
    // MessageBox box = new MessageBox(parentShell, SWT.ICON_ERROR | SWT.OK | SWT.CANCEL);
    //                    box.setText(Messages.getString("AddListDialog.Error")); //$NON-NLS-1$
    //                    box.setMessage(Messages.getString("AddListDialog.CHECKSIZE")); //$NON-NLS-1$
    // box.open();
    // return;
    // }
    // paraUtil.setCurrentindex(currentindex);
    // super.okPressed();
    // } else if (getAllArrayFromParents(selPara, null).size() >= 1) {
    //
    // AddArrayIndexForParentsDialog multiDialog = new AddArrayIndexForParentsDialog(parentShell, selPara);
    // int openCode = multiDialog.open();
    // if (openCode == AddArrayIndexForParentsDialog.OK) {
    // List indexList = null;
    // if (multiDialog.getArrayIndexList() != null) {
    // indexList = multiDialog.getArrayIndexList();
    // }
    // paraUtil.setCurrenIndexList(indexList);
    // super.okPressed();
    // } else {
    // return;
    // }
    // }
    //
    // }
    // paraUtil.setCurrentindex(currentindex);
    super.okPressed();
}
Also used : ParameterInfoUtil(org.talend.designer.webservice.ui.ParameterInfoUtil) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

MessageBox (org.eclipse.swt.widgets.MessageBox)37 ArrayList (java.util.ArrayList)8 Shell (org.eclipse.swt.widgets.Shell)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 IOException (java.io.IOException)4 List (java.util.List)4 IElementParameter (org.talend.core.model.process.IElementParameter)4 Node (org.talend.designer.core.ui.editor.nodes.Node)4 File (java.io.File)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Label (org.eclipse.swt.widgets.Label)3 Text (org.eclipse.swt.widgets.Text)3 IConnection (org.talend.core.model.process.IConnection)3 Message (ca.uhn.hl7v2.model.Message)2 IllegalOperationException (cl.utfsm.acs.acg.core.IllegalOperationException)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2