Search in sources :

Example 46 with AbstractMultiPageTalendEditor

use of org.talend.designer.core.ui.AbstractMultiPageTalendEditor in project tdi-studio-se by Talend.

the class NoteEditPart method performRequest.

@Override
public void performRequest(Request request) {
    Note note = (Note) getModel();
    if (note.isReadOnly()) {
        return;
    }
    if (request.getType() == RequestConstants.REQ_OPEN) {
        IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        if (part instanceof AbstractMultiPageTalendEditor) {
            CommandStack commandStack = (CommandStack) part.getAdapter(CommandStack.class);
            Command command = new ChangeNoteOpacityCommand(note, !note.isOpaque());
            commandStack.execute(command);
        }
    }
    if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
        if (directEditManager == null) {
            NoteFigure noteFigure = (NoteFigure) getFigure();
            directEditManager = new NoteDirectEditManager(this, TextCellEditor.class, new NoteCellEditorLocator(noteFigure));
        }
        directEditManager.show();
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) ChangeNoteOpacityCommand(org.talend.designer.core.ui.editor.cmd.ChangeNoteOpacityCommand) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ChangeNoteOpacityCommand(org.talend.designer.core.ui.editor.cmd.ChangeNoteOpacityCommand) Command(org.eclipse.gef.commands.Command) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor)

Example 47 with AbstractMultiPageTalendEditor

use of org.talend.designer.core.ui.AbstractMultiPageTalendEditor in project tdi-studio-se by Talend.

the class JavaCodeProblemsChecker method retrieveDetailedProblems.

/**
     * DOC amaumont Comment method "retrieveDetailedProblems".
     * 
     * @return
     */
private List<DetailedProblem> retrieveDetailedProblems(final IAloneProcessNodeConfigurer nodeConfigurer) {
    final ArrayList<DetailedProblem> iproblems = new ArrayList<DetailedProblem>();
    final IWorkbench workbench = PlatformUI.getWorkbench();
    Display display = workbench.getDisplay();
    if (display != null) {
        display.syncExec(new Runnable() {

            public void run() {
                IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
                IEditorPart editorPart = page.getActiveEditor();
                if (editorPart instanceof AbstractMultiPageTalendEditor) {
                    AbstractMultiPageTalendEditor multiPageTalendEditor = ((AbstractMultiPageTalendEditor) editorPart);
                    AbstractTalendEditor talendEditor = multiPageTalendEditor.getTalendEditor();
                    TalendJavaEditor codeEditor = (TalendJavaEditor) multiPageTalendEditor.getCodeEditor();
                    org.eclipse.jdt.core.ICompilationUnit compilationUnit = (org.eclipse.jdt.core.ICompilationUnit) codeEditor.getUnit();
                    IProcess process = talendEditor.getProcess();
                    if (AbstractProcessProvider.isExtensionProcessForJoblet(process)) {
                        // joblet
                        return;
                    }
                    String selectedNodeName = multiPageTalendEditor.getSelectedNodeName();
                    if (selectedNodeName == null) {
                        return;
                    }
                    String uniqueNodeName = null;
                    boolean found = false;
                    List<? extends INode> generatingNodes = process.getGeneratingNodes();
                    int generatingNodesListSize = generatingNodes.size();
                    for (int i = 0; i < generatingNodesListSize; i++) {
                        INode node = generatingNodes.get(i);
                        /* startsWith method used in case of virtual component such as 'tMap_1_TMAP_OUT' */
                        if (node.getUniqueName().equals(selectedNodeName) || node.getUniqueName().startsWith(selectedNodeName + "_")) {
                            //$NON-NLS-1$
                            uniqueNodeName = node.getUniqueName();
                            found = true;
                            break;
                        }
                    }
                    if (!found) {
                        // in case the component doesn't exist
                        return;
                    }
                    final String code = retrieveCode(process, uniqueNodeName, nodeConfigurer);
                    // System.out.println(code);
                    // create requestor for accumulating discovered problems
                    MyProblemRequestor problemRequestor = new MyProblemRequestor(code, iproblems, selectedNodeName);
                    // use working copy to hold source with error
                    org.eclipse.jdt.core.ICompilationUnit workingCopy = null;
                    try {
                        JavaProcessorUtilities.computeLibrariesPath(process.getNeededModules(false), process);
                        try {
                            WorkingCopyOwner workingCopyOwner = new WorkingCopyOwner() {
                            };
                            workingCopy = ((org.eclipse.jdt.core.ICompilationUnit) compilationUnit).getWorkingCopy(workingCopyOwner, problemRequestor, null);
                            problemRequestor.setReportProblems(true);
                            ((IOpenable) workingCopy).getBuffer().setContents(code);
                            ((org.eclipse.jdt.core.ICompilationUnit) workingCopy).reconcile(ICompilationUnit.NO_AST, true, null, null);
                            problemRequestor.setReportProblems(false);
                        } finally {
                            if (workingCopy != null) {
                                workingCopy.discardWorkingCopy();
                            }
                        }
                    } catch (JavaModelException e) {
                        ExceptionHandler.process(e);
                    } catch (CoreException e) {
                        ExceptionHandler.process(e);
                    }
                }
            }
        });
    }
    return iproblems;
}
Also used : INode(org.talend.core.model.process.INode) IOpenable(org.eclipse.jdt.core.IOpenable) JavaModelException(org.eclipse.jdt.core.JavaModelException) TalendJavaEditor(org.talend.designer.core.ui.editor.TalendJavaEditor) ArrayList(java.util.ArrayList) DetailedProblem(org.talend.designer.core.ui.editor.DetailedProblem) WorkingCopyOwner(org.eclipse.jdt.core.WorkingCopyOwner) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) ArrayList(java.util.ArrayList) List(java.util.List) IProcess(org.talend.core.model.process.IProcess) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IEditorPart(org.eclipse.ui.IEditorPart) IWorkbench(org.eclipse.ui.IWorkbench) CoreException(org.eclipse.core.runtime.CoreException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Display(org.eclipse.swt.widgets.Display)

Example 48 with AbstractMultiPageTalendEditor

use of org.talend.designer.core.ui.AbstractMultiPageTalendEditor in project tdi-studio-se by Talend.

the class ComponentChooseDialog method handleDrop.

// private void checkRequiredModules() {
// Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
// if (newObject instanceof Node) {
// IComponent component = ((Node) newObject).getComponent();
// Shell shell = Display.getCurrent().getActiveShell();
// ModulesInstallerUtil.installModules(new Shell(shell), component);
// }
// }
/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.dnd.TemplateTransferDropTargetListener#handleDrop()
     */
@Override
protected void handleDrop() {
    updateTargetRequest();
    updateTargetEditPart();
    // checkRequiredModules();
    if (fromPalette && getTargetRequest() instanceof CreateRequest) {
        if (selectedConnectionPart != null) {
            CreateRequest req = ((CreateRequest) getTargetRequest());
            Object o = req.getNewObject();
            Point location = req.getLocation();
            if (o instanceof Node) {
                createComponentOnLink((Node) o, location);
            }
            // checkRequiredModules();
            return;
        } else if (getTargetEditPart() instanceof ProcessPart) {
            // for palette dnd, feature 6457
            Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
            if (newObject != null) {
                Command command = getCommand();
                if (command != null) {
                    execCommandStack(command);
                }
            }
            // checkRequiredModules();
            return;
        } else if (getTargetEditPart() instanceof SubjobContainerPart) {
            // TDI-24985:for palette dnd.
            Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
            if (newObject != null) {
                Command command = getCommand();
                if (command != null) {
                    execCommandStack(command);
                }
            }
            return;
        } else if (getTargetEditPart() instanceof JobletContainerPart) {
            JobletContainerPart jobletPart = (JobletContainerPart) getTargetEditPart();
            if (isLock(jobletPart)) {
                Shell shell = Display.getCurrent().getActiveShell();
                ChooseJobletDialog dialog = new ChooseJobletDialog(new Shell(shell), getDropLocation());
                if (dialog.open() == dialog.OK) {
                    EditPart part = getTargetEditPart();
                    if (dialog.addToJoblet()) {
                        AbstractMultiPageTalendEditor openEditor = getJobletPart((JobletContainerPart) part);
                        part = openEditor.getDesignerEditor().getProcessPart();
                        // editor = openEditor.getTalendEditor();
                        setTargetEditPart(part);
                        Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
                        if (newObject != null) {
                            Command command = getCommand();
                            if (command != null) {
                                CommandStack commandStack = (CommandStack) openEditor.getAdapter(CommandStack.class);
                                if (commandStack != null) {
                                    commandStack.execute(command);
                                } else {
                                    command.execute();
                                }
                            }
                        }
                        // checkRequiredModules();
                        return;
                    } else {
                        part = getParentPart(part);
                        setTargetEditPart(part);
                        Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
                        if (newObject != null) {
                            Command command = getCommand();
                            if (command != null) {
                                execCommandStack(command);
                            }
                        }
                        // checkRequiredModules();
                        return;
                    }
                }
            }
        }
    }
    List<Object> sources = getSelectSource();
    if (containsContextSource(sources)) {
        createContext(sources);
    } else {
        if (!(getTargetEditPart() instanceof NodeContainerPart)) {
            try {
                createNewComponent(getCurrentEvent());
            } catch (OperationCanceledException e) {
                return;
            }
        } else {
            if (containsSQLPatternSource(sources)) {
                createSQLPattern(sources);
            } else {
                Object obj = getSelection().getFirstElement();
                createSchema(obj, getTargetEditPart());
                createQuery(obj, getTargetEditPart());
                createProperty(obj, getTargetEditPart());
                createChildJob(obj, getTargetEditPart());
                createValidationRule(obj, getTargetEditPart());
                if (obj instanceof IRepositoryNode) {
                    propaHadoopCfgChanges((IRepositoryNode) obj);
                }
                for (IExtendedNodeHandler hander : ExtendedNodeManager.getExtendedNodeHandler()) {
                    boolean updated = hander.updateComponent(obj, getTargetEditPart(), editor.getCommandStack());
                    if (updated) {
                        break;
                    }
                }
            }
        }
    }
    // in case after drag/drop the editor is dirty but can not get focus
    if (editor.isDirty()) {
        editor.setFocus();
    }
    this.eraseTargetFeedback();
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) IRepositoryNode(org.talend.repository.model.IRepositoryNode) CreateRequest(org.eclipse.gef.requests.CreateRequest) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart) EditPart(org.eclipse.gef.EditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) PaletteEditPart(org.eclipse.gef.ui.palette.editparts.PaletteEditPart) JobletContainerPart(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart) Point(org.eclipse.draw2d.geometry.Point) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ChooseJobletDialog(org.talend.designer.core.ui.dialog.mergeorder.ChooseJobletDialog) IExtendedNodeHandler(org.talend.designer.core.IExtendedNodeHandler) Shell(org.eclipse.swt.widgets.Shell) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) RepositoryChangeMetadataForSAPCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPCommand) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) RepositoryChangeQueryCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeQueryCommand) ConnectionReconnectCommand(org.talend.designer.core.ui.editor.cmd.ConnectionReconnectCommand) RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) RepositoryChangeMetadataForEBCDICCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForEBCDICCommand) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject)

Example 49 with AbstractMultiPageTalendEditor

use of org.talend.designer.core.ui.AbstractMultiPageTalendEditor in project tdi-studio-se by Talend.

the class DynamicTabbedPropertySection method setInput.

// private ISelection lastSelection;
/*
     * @Override (non-Java)
     * 
     * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection# setInput(org.eclipse.ui.IWorkbenchPart,
     * org.eclipse.jface.viewers.ISelection)
     */
@Override
public void setInput(final IWorkbenchPart workbenchPart, final ISelection selection) {
    if (!(selection instanceof IStructuredSelection)) {
        return;
    }
    curRowSize = 0;
    Object input = ((IStructuredSelection) selection).getFirstElement();
    if (input instanceof NodeContainerPart) {
        NodeContainerPart nContainer = (NodeContainerPart) input;
        elem = (Element) nContainer.getParent().getModel();
    } else if (input instanceof NodeTreeEditPart) {
        NodeTreeEditPart nTreePart = (NodeTreeEditPart) input;
        elem = (Element) nTreePart.getModel();
    } else if (!(input instanceof NodeReturnsTreeEditPart)) {
        EditPart editPart = (EditPart) input;
        elem = (Element) editPart.getModel();
    }
    if (elem instanceof NodeLabel) {
        elem = ((NodeLabel) elem).getNode();
    }
    if (elem instanceof ConnectionLabel) {
        elem = ((ConnectionLabel) elem).getConnection();
    }
    if (workbenchPart instanceof AbstractMultiPageTalendEditor) {
        part = (AbstractMultiPageTalendEditor) workbenchPart;
    } else {
        if (elem instanceof INode) {
            part = (AbstractMultiPageTalendEditor) ((IProcess2) ((INode) elem).getProcess()).getEditor();
        } else if (elem instanceof IConnection) {
            IConnection conn;
            conn = (IConnection) elem;
            part = (AbstractMultiPageTalendEditor) ((IProcess2) conn.getSource().getProcess()).getEditor();
        } else {
            part = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        }
    }
    super.setInput(part, selection);
    commandStackEventListener = null;
    if ((currentComponent == null) || (!currentComponent.equals(elem.getElementName()))) {
        forceRedraw = true;
        elem.setPropertyValue(updataComponentParamName, Boolean.TRUE);
    }
    currentComponent = elem.getElementName();
}
Also used : INode(org.talend.core.model.process.INode) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) Element(org.talend.core.model.process.Element) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) EditPart(org.eclipse.gef.EditPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) NodeReturnsTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeReturnsTreeEditPart) IConnection(org.talend.core.model.process.IConnection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) NodeLabel(org.talend.designer.core.ui.editor.nodes.NodeLabel) IProcess2(org.talend.core.model.process.IProcess2) NodeReturnsTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeReturnsTreeEditPart) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 50 with AbstractMultiPageTalendEditor

use of org.talend.designer.core.ui.AbstractMultiPageTalendEditor in project tdi-studio-se by Talend.

the class ImplicitContextLoadHelper method loadPropertyTypeFromPreference.

/**
     * DOC hcw Comment method "reloadPropertyType".
     * 
     * @param element
     * @param extraComposite
     * @param languagePrefix
     * @param elementParameter
     */
private static void loadPropertyTypeFromPreference(Element element, ExtraComposite extraComposite, String languagePrefix, IElementParameter elementParameter) {
    String propertyType = (String) getPreferenceValue(languagePrefix, EParameterName.PROPERTY_TYPE, String.class);
    String id = (String) getPreferenceValue(languagePrefix, EParameterName.REPOSITORY_PROPERTY_TYPE, String.class);
    Connection repositoryConnection = null;
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    Item item = null;
    try {
        IRepositoryViewObject repobj = factory.getLastVersion(id);
        if (repobj != null) {
            Property tmpproperty = repobj.getProperty();
            if (tmpproperty != null) {
                item = tmpproperty.getItem();
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    if (item != null && item instanceof ConnectionItem) {
        repositoryConnection = ((ConnectionItem) item).getConnection();
    } else {
        repositoryConnection = null;
    }
    ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(element, repositoryConnection, getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
    propertyType);
    ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(element, repositoryConnection, getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
    id);
    AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) element).getEditor();
    if (part instanceof AbstractMultiPageTalendEditor) {
        Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
        if (adapter != null) {
            CommandStack commandStack = ((CommandStack) adapter);
            commandStack.execute(cmd1);
            commandStack.execute(cmd2);
        }
    }
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) CommandStack(org.eclipse.gef.commands.CommandStack) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ConnectionItem(org.talend.core.model.properties.ConnectionItem) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) RepositoryToComponentProperty(org.talend.core.model.metadata.designerproperties.RepositoryToComponentProperty) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Aggregations

AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)53 IEditorPart (org.eclipse.ui.IEditorPart)26 INode (org.talend.core.model.process.INode)16 Node (org.talend.designer.core.ui.editor.nodes.Node)15 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)14 CommandStack (org.eclipse.gef.commands.CommandStack)13 AbstractTalendEditor (org.talend.designer.core.ui.editor.AbstractTalendEditor)12 GraphicalViewer (org.eclipse.gef.GraphicalViewer)10 IExternalNode (org.talend.core.model.process.IExternalNode)10 IProcess (org.talend.core.model.process.IProcess)10 ArrayList (java.util.ArrayList)9 List (java.util.List)8 EditPart (org.eclipse.gef.EditPart)8 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 IEditorReference (org.eclipse.ui.IEditorReference)7 PersistenceException (org.talend.commons.exception.PersistenceException)7 IProcess2 (org.talend.core.model.process.IProcess2)7 Property (org.talend.core.model.properties.Property)7 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 Process (org.talend.designer.core.ui.editor.process.Process)7