Search in sources :

Example 1 with TabFolderEditors

use of org.talend.designer.xmlmap.ui.tabs.TabFolderEditors in project tdi-studio-se by Talend.

the class RenameTreeNodeAction method run.

@Override
public void run() {
    if (selectedNode != null) {
        // validataor
        IInputValidator validataor = new IInputValidator() {

            public String isValid(String newText) {
                String xpath = XmlMapUtil.getXPath(((TreeNode) selectedNode.eContainer()).getXpath(), newText, selectedNode.getNodeType());
                EList<TreeNode> children = ((TreeNode) selectedNode.eContainer()).getChildren();
                boolean exist = false;
                for (TreeNode child : children) {
                    if (child.getNodeType().equals(selectedNode.getNodeType())) {
                        if (child.getXpath() != null && child.getXpath().equals(xpath) && !child.equals(selectedNode)) {
                            exist = true;
                            break;
                        }
                    }
                }
                if (exist) {
                    if (selectedNode.getNodeType().equals(NodeType.ATTRIBUT)) {
                        return "Atribute '" + newText + "' already exist !";
                    } else if (selectedNode.getNodeType().equals(NodeType.ELEMENT)) {
                        return "Element '" + newText + "' already exist !";
                    }
                }
                return null;
            }
        };
        String name = selectedNode.getName();
        if (selectedNode.isSubstitution()) {
            name = name.substring(0, name.lastIndexOf(XSDPopulationUtil2.SUBS));
        }
        InputDialog dialog = new InputDialog(null, "Rename Tree Node", "", name, validataor);
        if (dialog.open() == Window.OK) {
            if (selectedNode.isSubstitution()) {
                selectedNode.setName(dialog.getValue() + XSDPopulationUtil2.SUBS);
            } else {
                selectedNode.setName(dialog.getValue());
            }
            // refresh
            if (selectedNode.isSubstitution()) {
                TreeNode realParent = XmlMapUtil.getRealParentNode(selectedNode);
                if (realParent != null) {
                    selectedNode.setXpath(XmlMapUtil.getXPath(realParent.getXpath(), selectedNode.getName(), selectedNode.getNodeType()));
                }
            } else {
                XmlMapData externalEmfData = (XmlMapData) mapperManager.getExternalData();
                XmlMapUtil.updateXPathAndExpression(externalEmfData, mapperManager.getMapperComponent().getExpressionManager(), selectedNode, dialog.getValue(), XmlMapUtil.getXPathLength(selectedNode.getXpath()), true);
            }
            TabFolderEditors tabFolderEditors = mapperManager.getMapperUI().getTabFolderEditors();
            if (tabFolderEditors != null) {
                if (selectedNode instanceof OutputTreeNode) {
                    tabFolderEditors.getOutputTreeSchemaEditor().refresh();
                } else if (selectedNode instanceof TreeNode) {
                    tabFolderEditors.getInputTreeSchemaEditor().refresh();
                }
            }
        }
    }
}
Also used : TabFolderEditors(org.talend.designer.xmlmap.ui.tabs.TabFolderEditors) InputDialog(org.eclipse.jface.dialogs.InputDialog) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 2 with TabFolderEditors

use of org.talend.designer.xmlmap.ui.tabs.TabFolderEditors in project tdi-studio-se by Talend.

the class MapperUI method createWindow.

public Shell createWindow(final Display display) {
    Shell activeShell = display.getActiveShell();
    int style = SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.APPLICATION_MODAL | SWT.RESIZE;
    if (activeShell == null) {
        mapperShell = new Shell(mapperShell, style);
    } else {
        mapperShell = new Shell(activeShell, style);
    }
    mapperShell.addShellListener(new ShellListener() {

        @Override
        public void shellActivated(ShellEvent e) {
        }

        @Override
        public void shellClosed(ShellEvent e) {
            if (editor != null && editor.isDirty() && !closeWithoutPrompt) {
                boolean closeWindow = MessageDialog.openConfirm(mapperShell, "Close without save", Messages.getString("MapperUI.CloseWindow.Message"));
                if (!closeWindow) {
                    e.doit = false;
                } else {
                    prepareClosing(SWT.CANCEL);
                }
            }
        }

        @Override
        public void shellDeactivated(ShellEvent e) {
        }

        @Override
        public void shellDeiconified(ShellEvent e) {
        }

        @Override
        public void shellIconified(ShellEvent e) {
        }
    });
    mapperShell.setMaximized(true);
    mapperShell.setImage(CoreImageProvider.getComponentIcon(mapperComponent.getComponent(), ICON_SIZE.ICON_32));
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    String productName = brandingService.getFullProductName();
    mapperShell.setText(productName + " - " + mapperComponent.getComponent().getName() + " - " + //$NON-NLS-1$
    mapperComponent.getUniqueName());
    GridLayout parentLayout = new GridLayout(1, true);
    mapperShell.setLayout(parentLayout);
    // Composite composite = new Composite(mapperShell, SWT.NONE);
    // composite.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
    mainSashForm = new SashForm(mapperShell, SWT.SMOOTH | SWT.VERTICAL);
    GridData mainSashFormGridData = new GridData(GridData.FILL_BOTH);
    mainSashForm.setLayoutData(mainSashFormGridData);
    datasViewSashForm = new SashForm(mainSashForm, SWT.SMOOTH | SWT.HORIZONTAL | SWT.BORDER);
    editor = new XmlMapEditor(mapperManager);
    editor.createPartControl(datasViewSashForm);
    if (copyOfMapData.getVarTables().isEmpty()) {
        VarTable varTable1 = XmlmapFactory.eINSTANCE.createVarTable();
        varTable1.setName("Var");
        varTable1.setMinimized(true);
        copyOfMapData.getVarTables().add(varTable1);
    }
    editor.setContent(copyOfMapData);
    tabFolderEditors = new TabFolderEditors(mainSashForm, mapperManager, SWT.BORDER);
    // selectFirstInOutTree();
    mainSashForm.setWeights(new int[] { 70, 30 });
    footerComposite = new FooterComposite(mapperShell, this);
    footerComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    mapperShell.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            ColorProviderMapper.releaseColors();
            FontProviderMapper.releaseFonts();
            ImageProviderMapper.releaseImages();
        }
    });
    editor.makeDefaultSelection();
    mapperShell.open();
    return mapperShell;
}
Also used : TabFolderEditors(org.talend.designer.xmlmap.ui.tabs.TabFolderEditors) DisposeListener(org.eclipse.swt.events.DisposeListener) FooterComposite(org.talend.designer.xmlmap.ui.footer.FooterComposite) ShellEvent(org.eclipse.swt.events.ShellEvent) IBrandingService(org.talend.core.ui.branding.IBrandingService) DisposeEvent(org.eclipse.swt.events.DisposeEvent) XmlMapEditor(org.talend.designer.xmlmap.editor.XmlMapEditor) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) SashForm(org.eclipse.swt.custom.SashForm) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) ShellListener(org.eclipse.swt.events.ShellListener) GridData(org.eclipse.swt.layout.GridData)

Aggregations

TabFolderEditors (org.talend.designer.xmlmap.ui.tabs.TabFolderEditors)2 IInputValidator (org.eclipse.jface.dialogs.IInputValidator)1 InputDialog (org.eclipse.jface.dialogs.InputDialog)1 SashForm (org.eclipse.swt.custom.SashForm)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 ShellEvent (org.eclipse.swt.events.ShellEvent)1 ShellListener (org.eclipse.swt.events.ShellListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Shell (org.eclipse.swt.widgets.Shell)1 IBrandingService (org.talend.core.ui.branding.IBrandingService)1 XmlMapEditor (org.talend.designer.xmlmap.editor.XmlMapEditor)1 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)1 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)1 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)1 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)1 FooterComposite (org.talend.designer.xmlmap.ui.footer.FooterComposite)1