Search in sources :

Example 1 with AbstractUIPlugin

use of org.eclipse.ui.plugin.AbstractUIPlugin in project tdi-studio-se by Talend.

the class SetSubstitutionAction method run.

@Override
public void run() {
    TreeNode treeNode = null;
    boolean needWarning = false;
    if (input) {
        treeNode = XmlmapFactory.eINSTANCE.createTreeNode();
        if (!selectedNode.getOutgoingConnections().isEmpty()) {
            needWarning = true;
        }
    } else {
        treeNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
        EList<Connection> incomingConnections = selectedNode.getIncomingConnections();
        if (!incomingConnections.isEmpty()) {
            needWarning = true;
        }
    }
    boolean canContinue = true;
    // Shell shell = this.part.getSite().getShell();
    if (needWarning) {
        canContinue = MessageDialog.openConfirm(null, "Warning", "Do you want to disconnect the existing linker and then add a choice for the selected element ?");
    }
    if (canContinue) {
        AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
        IDialogSettings workbenchSettings = plugin.getDialogSettings();
        //$NON-NLS-1$
        IDialogSettings section = workbenchSettings.getSection("SetSubstitutionAction.SubsMessageDialog");
        if (section == null) {
            //$NON-NLS-1$
            section = workbenchSettings.addNewSection("SetSubstitutionAction.SubsMessageDialog");
        }
        boolean popupMessageDialog = !section.getBoolean(HIDE_MESSAGE);
        if (popupMessageDialog) {
            String message = "This element will be copied as part of the substitution group automatically." + "\n" + "If this element must be abstract and must be extended only, you can delete it.";
            SubsMessageDialog dialog = new SubsMessageDialog(null, message);
            int open = dialog.open();
            if (open == Window.OK) {
                boolean hideDialogNextTime = dialog.getResult();
                if (hideDialogNextTime) {
                    section.put(HIDE_MESSAGE, true);
                }
            }
            if (open == Window.CANCEL) {
                return;
            }
        }
        XmlMapUtil.detachNodeConnections(selectedNode, mapperManager.getExternalData(), false);
        treeNode.setName(selectedNode.getName() + XSDPopulationUtil2.SUBS);
        treeNode.setNodeType(NodeType.ELEMENT);
        treeNode.setXpath(selectedNode.getXpath() + XmlMapUtil.XPATH_SEPARATOR + treeNode.getName());
        treeNode.setSubstitution(true);
        TreeNode parentNode = (TreeNode) selectedNode.eContainer();
        int index = parentNode.getChildren().indexOf(selectedNode);
        parentNode.getChildren().remove(selectedNode);
        treeNode.getChildren().add(selectedNode);
        parentNode.getChildren().add(index, treeNode);
        if (!input) {
            OutputTreeNode output = (OutputTreeNode) selectedNode;
            if (!XmlMapUtil.isExpressionEditable(output) && output.isAggregate()) {
                output.setAggregate(false);
            }
        }
        Object object = graphicViewer.getEditPartRegistry().get(treeNode);
        if (object instanceof TreeNodeEditPart) {
            graphicViewer.select((TreeNodeEditPart) object);
        }
    }
}
Also used : AbstractUIPlugin(org.eclipse.ui.plugin.AbstractUIPlugin) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) Connection(org.talend.designer.xmlmap.model.emf.xmlmap.Connection) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart)

Example 2 with AbstractUIPlugin

use of org.eclipse.ui.plugin.AbstractUIPlugin in project tdi-studio-se by Talend.

the class ExportItemWizard method addPages.

@Override
public void addPages() {
    super.addPages();
    mainPage = new ExportItemWizardPage(getWindowTitle(), selection, baseViewId);
    addPage(mainPage);
    AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
    IDialogSettings workbenchSettings = plugin.getDialogSettings();
    //$NON-NLS-1$
    IDialogSettings section = workbenchSettings.getSection("ExportItemWizard");
    if (section == null) {
        //$NON-NLS-1$
        section = workbenchSettings.addNewSection("ExportItemWizard");
    }
    setDialogSettings(section);
}
Also used : AbstractUIPlugin(org.eclipse.ui.plugin.AbstractUIPlugin) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings)

Aggregations

IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 AbstractUIPlugin (org.eclipse.ui.plugin.AbstractUIPlugin)2 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)1 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)1 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)1 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)1