Search in sources :

Example 1 with JobSettingsView

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

the class BusinessAssignmentComposite method createSelectionListener.

private void createSelectionListener() {
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            BusinessAssignment businessAssignment = getBusinessAssignment(event.getSelection());
            if (businessAssignment != null) {
                final IRepositoryView repositoryView = getRepositoryView();
                if (repositoryView != null) {
                    IProjectRepositoryNode rootRepositoryNode = repositoryView.getRoot();
                    TalendItem item = businessAssignment.getTalendItem();
                    //
                    if (item instanceof Routine && rootRepositoryNode instanceof ProjectRepositoryNode) {
                        RepositoryNodeUtilities.expandParentNode(getRepositoryView(), ((ProjectRepositoryNode) rootRepositoryNode).getRootRepositoryNode(ERepositoryObjectType.CODE));
                    }
                    selectChild(item, (IRepositoryNode) rootRepositoryNode);
                }
            }
        }

        private void selectChild(TalendItem item, IRepositoryNode rootRepositoryNode) {
            try {
                RepositoryNode curNode = null;
                JobSettingsView viewer = (JobSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(JobSettingsView.ID);
                IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(item.getId());
                if (lastVersion != null) {
                    curNode = RepositoryNodeUtilities.getRepositoryNode(lastVersion);
                    select(viewer, curNode);
                } else if (item instanceof TableMetadata) {
                    MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(item.getId());
                    if (table != null) {
                        //$NON-NLS-1$
                        String id = item.getId().split(" - ")[0];
                        RepositoryNode node = RepositoryNodeUtilities.getMetadataTableFromConnection(item.getId());
                        IRepositoryView view = getRepositoryView();
                        if (view != null) {
                            RepositoryNodeUtilities.expandParentNode(view, node);
                            select(viewer, node);
                        }
                    }
                } else if (item instanceof Query) {
                    org.talend.core.model.metadata.builder.connection.Query query = MetadataToolHelper.getQueryFromRepository(item.getId());
                    if (query != null) {
                        //$NON-NLS-1$
                        String id = item.getId().split(" - ")[0];
                        IRepositoryView view = getRepositoryView();
                        RepositoryNode node = RepositoryNodeUtilities.getQueryFromConnection(item.getId());
                        RepositoryNodeUtilities.expandParentNode(view, node);
                        select(viewer, node);
                    }
                } else if (item instanceof SAPFunction) {
                    SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(item.getId());
                    if (function != null) {
                        IRepositoryView view = getRepositoryView();
                        RepositoryNode node = RepositoryNodeUtilities.getSAPFunctionFromConnection(item.getId());
                        RepositoryNodeUtilities.expandParentNode(view, node);
                        select(viewer, node);
                    }
                } else {
                    for (IRepositoryNode node : rootRepositoryNode.getChildren()) {
                        RepositoryNode rNode = (RepositoryNode) node;
                        if (item instanceof SQLPattern && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.SQLPATTERNS) {
                            if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
                                SQLPatternItem sqlItem = (SQLPatternItem) rNode.getObject().getProperty().getItem();
                                if (sqlItem.isSystem() && item.getLabel().equals(rNode.getObject().getLabel())) {
                                    select(viewer, rNode);
                                }
                            } else {
                                selectChild(item, rNode);
                            }
                        } else if (item instanceof Routine && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.ROUTINES) {
                            if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
                                RoutineItem sqlItem = (RoutineItem) rNode.getObject().getProperty().getItem();
                                if (sqlItem.isBuiltIn() && item.getLabel().equals(rNode.getObject().getLabel())) {
                                    select(viewer, rNode);
                                }
                            } else {
                                selectChild(item, rNode);
                            }
                        }
                    }
                }
            } catch (PersistenceException e) {
                // TODO Auto-generated catch block
                // e.printStackTrace();
                ExceptionHandler.process(e);
            }
        }

        private void select(JobSettingsView viewer, RepositoryNode repositoryNode) {
            if (viewer == null) {
                return;
            }
            if (repositoryNode == null) {
                return;
            }
            CorePlugin.getDefault().getRepositoryService().removeRepositoryTreeViewListener(viewer);
            final IRepositoryView repositoryView = getRepositoryView();
            if (repositoryView != null) {
                repositoryView.getViewer().setSelection(new StructuredSelection(repositoryNode));
            }
            CorePlugin.getDefault().getRepositoryService().addRepositoryTreeViewListener(viewer);
        }
    });
}
Also used : JobSettingsView(org.talend.designer.core.ui.views.jobsettings.JobSettingsView) BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) Query(org.talend.designer.business.model.business.Query) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) TalendItem(org.talend.designer.business.model.business.TalendItem) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) TableMetadata(org.talend.designer.business.model.business.TableMetadata) SAPFunction(org.talend.designer.business.model.business.SAPFunction) SQLPattern(org.talend.designer.business.model.business.SQLPattern) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) RoutineItem(org.talend.core.model.properties.RoutineItem) Routine(org.talend.designer.business.model.business.Routine) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 2 with JobSettingsView

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

the class ShowJobSettingsViewAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
public void run() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
    try {
        page.showView(getViewId());
        JobSettingsView view = (JobSettingsView) page.findView(getViewId());
        IDiagramModelService service = CorePlugin.getDefault().getDiagramModelService();
        ISelection selection = service.getBusinessEditorSelection(page.getActiveEditor());
        if (selection instanceof IStructuredSelection) {
            Object firstElement = ((IStructuredSelection) selection).getFirstElement();
            if (firstElement != null) {
                BusinessType type = service.getBusinessModelType(firstElement);
                if (type == BusinessType.CONNECTION || type == BusinessType.NOTE || type == BusinessType.SHAP) {
                    view.refresh(false, firstElement);
                } else if (type == BusinessType.PROCESS || service.isInstanceOfCompartmentEditPart(firstElement)) {
                    view.refresh(false, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor());
                }
            }
        }
    } catch (PartInitException e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) JobSettingsView(org.talend.designer.core.ui.views.jobsettings.JobSettingsView) IDiagramModelService(org.talend.designer.business.diagram.custom.IDiagramModelService) ISelection(org.eclipse.jface.viewers.ISelection) BusinessType(org.talend.core.model.business.BusinessType) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException)

Example 3 with JobSettingsView

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

the class AbstractMultiPageTalendEditor method refreshJobSettingsView.

/**
     * Added by Marvin Wang on July 30, 2012 for refreshing the tab of Job view.
     */
protected void refreshJobSettingsView() {
    IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IJobSettingsView.ID);
    if (viewPart != null && viewPart instanceof JobSettingsView) {
        JobSettingsView jobView = (JobSettingsView) viewPart;
        TalendPropertyTabDescriptor currentSelectedTab = jobView.getCurrentSelectedTab();
        if (currentSelectedTab != null) {
            IDynamicProperty dc = currentSelectedTab.getPropertyComposite();
            if (dc != null) {
                dc.refresh();
            }
        }
    }
}
Also used : IJobSettingsView(org.talend.repository.ui.views.IJobSettingsView) JobSettingsView(org.talend.designer.core.ui.views.jobsettings.JobSettingsView) IViewPart(org.eclipse.ui.IViewPart) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) TalendPropertyTabDescriptor(org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor)

Example 4 with JobSettingsView

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

the class AbstractElementPropertySectionController method fixedCursorPosition.

/**
     * qzhang Comment method "fixedCursorPosition".
     *
     * @param param
     * @param labelText
     * @param value
     * @param valueChanged
     */
protected void fixedCursorPosition(IElementParameter param, Control labelText, Object value, boolean valueChanged) {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IWorkbenchPart workbenchPart = page.getActivePart();
    if ((workbenchPart instanceof PropertySheet) || (workbenchPart instanceof JobSettingsView) || (workbenchPart instanceof ComponentSettingsView)) {
        Object control = editionControlHelper.undoRedoHelper.typedTextCommandExecutor.getActiveControl();
        if (param.getName().equals(control) && valueChanged && !param.isRepositoryValueUsed()) {
            String previousText = editionControlHelper.undoRedoHelper.typedTextCommandExecutor.getPreviousText2();
            String currentText = String.valueOf(value);
            labelText.setFocus();
            ControlUtils.setCursorPosition(labelText, getcursorPosition(previousText, currentText));
        }
    }
}
Also used : JobSettingsView(org.talend.designer.core.ui.views.jobsettings.JobSettingsView) PropertySheet(org.eclipse.ui.views.properties.PropertySheet) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ComponentSettingsView(org.talend.designer.core.ui.views.properties.ComponentSettingsView)

Example 5 with JobSettingsView

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

the class BusinessDiagramEditor method selectionChanged.

@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    super.selectionChanged(part, selection);
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    JobSettingsView view = (JobSettingsView) page.findView(JobSettingsView.ID);
    getDiagramEditorInput().getItem().getProperty().eAdapters().remove(dirtyListener);
    if (view == null) {
        return;
    }
    if (!(selection instanceof IStructuredSelection)) {
        return;
    }
    Object firstElement = ((IStructuredSelection) selection).getFirstElement();
    if (!(selection instanceof IStructuredSelection)) {
        return;
    } else if (firstElement instanceof RepositoryNode) {
        return;
    }
    // for Find Assignment
    if (((IStructuredSelection) selection).size() > 0) {
        DiagramEditPart diagramEditPart = getDiagramEditPart();
        if (diagramEditPart instanceof BusinessProcessEditPart) {
            BusinessProcessEditPart processPart = (BusinessProcessEditPart) diagramEditPart;
            for (Object object : processPart.getChildren()) {
                if (object instanceof BusinessItemShapeEditPart) {
                    BusinessItemShapeEditPart shapEditPart = (BusinessItemShapeEditPart) object;
                    IFigure figure = shapEditPart.getFigure();
                    for (Object child : figure.getChildren()) {
                        if (child instanceof BusinessItemShapeFigure) {
                            BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) child;
                            Border border = shapFigure.getBorder();
                            if (border != null) {
                                shapFigure.setDrawFrame(false);
                                shapFigure.revalidate();
                                shapFigure.repaint();
                            }
                        }
                    }
                }
            }
        }
    }
    // to refresh the jobsettings view
    if (((IStructuredSelection) selection).size() > 1) {
        view.cleanDisplay();
    } else {
        if (firstElement instanceof BusinessItemShapeEditPart || firstElement instanceof BaseBusinessItemRelationShipEditPart || firstElement instanceof NoteEditPart || firstElement instanceof NoteAttachmentEditPart) {
            view.refresh(false, firstElement);
        } else if (firstElement instanceof BusinessProcessEditPart || firstElement instanceof CompartmentEditPart) {
            view.refresh(true, this);
        }
    }
    getDiagramEditorInput().getItem().getProperty().eAdapters().add(dirtyListener);
}
Also used : JobSettingsView(org.talend.designer.core.ui.views.jobsettings.JobSettingsView) CompartmentEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart) NoteEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.NoteEditPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) BusinessProcessEditPart(org.talend.designer.business.model.business.diagram.edit.parts.BusinessProcessEditPart) DiagramEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart) NoteAttachmentEditPart(org.eclipse.gmf.runtime.diagram.ui.internal.editparts.NoteAttachmentEditPart) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Border(org.eclipse.draw2d.Border) BusinessItemShapeFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

JobSettingsView (org.talend.designer.core.ui.views.jobsettings.JobSettingsView)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 RepositoryNode (org.talend.repository.model.RepositoryNode)2 Border (org.eclipse.draw2d.Border)1 IFigure (org.eclipse.draw2d.IFigure)1 CompartmentEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart)1 DiagramEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart)1 NoteEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.NoteEditPart)1 NoteAttachmentEditPart (org.eclipse.gmf.runtime.diagram.ui.internal.editparts.NoteAttachmentEditPart)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 IViewPart (org.eclipse.ui.IViewPart)1 IWorkbench (org.eclipse.ui.IWorkbench)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 PartInitException (org.eclipse.ui.PartInitException)1 PropertySheet (org.eclipse.ui.views.properties.PropertySheet)1