Search in sources :

Example 51 with IWorkbenchPage

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

the class CreateDiagramAction method setRepositoryNode.

private void setRepositoryNode(Properties params) {
    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (null == workbenchWindow) {
        return;
    }
    IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
    if (null == workbenchPage) {
        return;
    }
    IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
    if (!IBrandingConfiguration.PERSPECTIVE_DI_ID.equals(currentPerspective.getId())) {
        // show di perspective
        try {
            workbenchWindow.getWorkbench().showPerspective(IBrandingConfiguration.PERSPECTIVE_DI_ID, workbenchWindow);
            workbenchPage = workbenchWindow.getActivePage();
        } catch (WorkbenchException e) {
            ExceptionHandler.process(e);
            return;
        }
    }
    // bug 16594
    IRepositoryView view = RepositoryManagerHelper.getRepositoryView();
    if (view != null) {
        Object type = params.get("type");
        if (ERepositoryObjectType.BUSINESS_PROCESS != null && ERepositoryObjectType.BUSINESS_PROCESS.name().equals(type)) {
            RepositoryNode processNode = ((ProjectRepositoryNode) view.getRoot()).getRootRepositoryNode(ERepositoryObjectType.BUSINESS_PROCESS);
            final StructuredViewer viewer = view.getViewer();
            if (viewer instanceof TreeViewer) {
                ((TreeViewer) viewer).expandToLevel(processNode, 1);
            }
            this.repositoryNode = processNode;
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) WorkbenchException(org.eclipse.ui.WorkbenchException) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 52 with IWorkbenchPage

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

the class DeleteAssignmentAction method doRun.

@Override
protected void doRun() {
    IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (activeEditor instanceof BusinessDiagramEditor) {
        BusinessDiagramEditor editor = (BusinessDiagramEditor) activeEditor;
        ISelection selection2 = editor.getSelection();
        EObject element = null;
        Object firstElement = ((IStructuredSelection) selection2).getFirstElement();
        if (firstElement instanceof BusinessItemShapeEditPart) {
            BusinessItemShapeEditPart editpart = (BusinessItemShapeEditPart) firstElement;
            element = ((Node) editpart.getModel()).getElement();
        } else if (firstElement instanceof BaseBusinessItemRelationShipEditPart) {
            BaseBusinessItemRelationShipEditPart editpart = (BaseBusinessItemRelationShipEditPart) firstElement;
            element = ((EdgeImpl) editpart.getModel()).getElement();
        }
        if (element instanceof BusinessItem) {
            BusinessItem businessItem = (BusinessItem) element;
            DeleteAssignmentCommand command = new DeleteAssignmentCommand(businessItem, selection);
            try {
                command.execute(null, null);
            } catch (ExecutionException e) {
                ExceptionHandler.process(e);
            }
            IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            for (IEditorReference editors : page.getEditorReferences()) {
                CorePlugin.getDefault().getDiagramModelService().refreshBusinessModel(editors);
            }
        }
    }
}
Also used : BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) EdgeImpl(org.eclipse.gmf.runtime.notation.impl.EdgeImpl) IEditorPart(org.eclipse.ui.IEditorPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DeleteAssignmentCommand(org.talend.designer.business.diagram.custom.commands.DeleteAssignmentCommand) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) IEditorReference(org.eclipse.ui.IEditorReference) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) EObject(org.eclipse.emf.ecore.EObject) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) EObject(org.eclipse.emf.ecore.EObject) ExecutionException(org.eclipse.core.commands.ExecutionException) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Example 53 with IWorkbenchPage

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

the class DownloadComponenentsAction method selectPaletteEntry.

private void selectPaletteEntry(String componentName) {
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow != null) {
        IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
        if (activePage != null) {
            IEditorReference[] editorReferences = activePage.getEditorReferences();
            if (editorReferences != null) {
                for (IEditorReference er : editorReferences) {
                    IEditorPart part = er.getEditor(false);
                    if (part instanceof AbstractMultiPageTalendEditor) {
                        AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) part;
                        AbstractTalendEditor talendEditor = editor.getTalendEditor();
                        try {
                            ComponentPaletteUtilities.setSkipUpdatePalette(true);
                            talendEditor.selectPaletteEntry(componentName);
                        } catch (Exception e) {
                            ExceptionHandler.process(e);
                        }
                        return;
                    }
                }
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart)

Example 54 with IWorkbenchPage

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

the class ClipboardActionHandler method getCommand.

@Override
public ICommand getCommand(IGlobalActionContext cntxt) {
    IWorkbenchPart part = cntxt.getActivePart();
    if (!(part instanceof IDiagramWorkbenchPart)) {
        return null;
    }
    IDiagramWorkbenchPart workbenchPart = (IDiagramWorkbenchPart) part;
    DiagramEditPart diagramEditPart = workbenchPart.getDiagramEditPart();
    ICommand command = null;
    String actionId = cntxt.getActionId();
    if (actionId.equals(GlobalActionId.COPY)) {
        command = getCopyCommand(cntxt, workbenchPart, false);
        transfer(cntxt.getSelection());
        isCut = false;
        older = workbenchPart;
        orginalCopyFrom = workbenchPart;
        clonedSourceProcessItemsList = new ArrayList<BusinessItem>(((BusinessProcess) ((Diagram) diagramEditPart.getModel()).getElement()).getBusinessItems());
    } else if (actionId.equals(GlobalActionId.CUT) && cntxt.getSelection() != null) {
        saveCut(cntxt.getSelection());
        command = getCutCommand(cntxt, workbenchPart);
        transfer(cntxt.getSelection());
        isCut = true;
        older = workbenchPart;
        clonedSourceProcessItemsList = new ArrayList<BusinessItem>(((BusinessProcess) ((Diagram) diagramEditPart.getModel()).getElement()).getBusinessItems());
    } else if (actionId.equals(GlobalActionId.SAVE)) {
        if (workbenchPart instanceof IEditorPart) {
            IEditorPart editorPart = (IEditorPart) workbenchPart;
            if (editorPart.isDirty()) {
                IWorkbenchPage page = editorPart.getSite().getPage();
                page.saveEditor(editorPart, false);
            }
        }
    }
    if (actionId.equals(GlobalActionId.PASTE)) {
        // diagramPart.getDiagramGraphicalViewer().setSelection(new
        // StructuredSelection(diagramPart.getDiagramEditPart()));
        PasteViewRequest pasteReq = createPasteViewRequest();
        CommandStack cs = workbenchPart.getDiagramEditDomain().getDiagramCommandStack();
        IStructuredSelection selection = (IStructuredSelection) cntxt.getSelection();
        if (!(selection.getFirstElement() instanceof BusinessProcessEditPart)) {
            selection = new StructuredSelection(workbenchPart.getDiagramEditPart());
        }
        Object[] objects = selection.toArray();
        Collection returnValues = null;
        if (objects.length == 1) {
            Command paste = ((EditPart) objects[0]).getCommand(pasteReq);
            if (paste != null) {
                cs.execute(paste);
                workbenchPart.getDiagramEditPart().getFigure().invalidate();
                workbenchPart.getDiagramEditPart().getFigure().validate();
                returnValues = DiagramCommandStack.getReturnValues(paste);
            // selectAddedObject(diagramPart.getDiagramGraphicalViewer(), returnValues);
            }
        }
        Object elements = TemplateTransfer.getInstance().getObject();
        if (elements instanceof List) {
            List<BusinessItem> list = (List<BusinessItem>) elements;
            boolean inEditors = false;
            if (older != workbenchPart) {
                inEditors = true;
            } else if (!this.isCut && orginalCopyFrom != workbenchPart) {
                // bug 16065 fixed, by xtan. to resolve the copy(A)/parse(B)/parse(B)/parse(B)... problem.
                inEditors = true;
            }
            // always keep the last one as the current selection.
            older = workbenchPart;
            GmfPastCommand pastBusiness = new GmfPastCommand((BusinessProcess) ((Diagram) diagramEditPart.getModel()).getElement(), list, diagramEditPart, this.cutItemIds, this.isCut | inEditors);
            pastBusiness.setClonedSourceProcessItemsList(clonedSourceProcessItemsList);
            try {
                pastBusiness.execute(null, null);
            } catch (ExecutionException e) {
                ExceptionHandler.process(e);
            }
        }
        if (returnValues != null) {
            selectAddedObject(workbenchPart.getDiagramGraphicalViewer(), returnValues);
        }
        return null;
    }
    return command;
}
Also used : PasteViewRequest(org.eclipse.gmf.runtime.diagram.ui.requests.PasteViewRequest) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) BusinessProcessEditPart(org.talend.designer.business.model.business.diagram.edit.parts.BusinessProcessEditPart) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ICommand(org.eclipse.gmf.runtime.common.core.command.ICommand) ArrayList(java.util.ArrayList) List(java.util.List) ExecutionException(org.eclipse.core.commands.ExecutionException) GmfPastCommand(org.talend.designer.business.diagram.custom.commands.GmfPastCommand) DiagramCommandStack(org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack) CommandStack(org.eclipse.gef.commands.CommandStack) IDiagramWorkbenchPart(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) DiagramEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart) BusinessProcessEditPart(org.talend.designer.business.model.business.diagram.edit.parts.BusinessProcessEditPart) EditPart(org.eclipse.gef.EditPart) IEditorPart(org.eclipse.ui.IEditorPart) Diagram(org.eclipse.gmf.runtime.notation.Diagram) DiagramEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart) ICommand(org.eclipse.gmf.runtime.common.core.command.ICommand) GmfPastCommand(org.talend.designer.business.diagram.custom.commands.GmfPastCommand) Command(org.eclipse.gef.commands.Command) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Collection(java.util.Collection) EObject(org.eclipse.emf.ecore.EObject) BusinessItem(org.talend.designer.business.model.business.BusinessItem) BusinessProcess(org.talend.designer.business.model.business.BusinessProcess)

Example 55 with IWorkbenchPage

use of org.eclipse.ui.IWorkbenchPage in project KaiZen-OpenAPI-Editor by RepreZen.

the class NewFileWizard method performFinish.

@Override
public boolean performFinish() {
    final IFile file = page.createNewFile();
    if (file == null || !file.exists()) {
        return false;
    }
    getShell().getDisplay().asyncExec(new Runnable() {

        public void run() {
            IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            try {
                IDE.openEditor(page, file, editorId);
            } catch (PartInitException e) {
            }
        }
    });
    return true;
}
Also used : IFile(org.eclipse.core.resources.IFile) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)294 IEditorPart (org.eclipse.ui.IEditorPart)126 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)102 PartInitException (org.eclipse.ui.PartInitException)96 IFile (org.eclipse.core.resources.IFile)63 IViewPart (org.eclipse.ui.IViewPart)58 IEditorReference (org.eclipse.ui.IEditorReference)40 IWorkbench (org.eclipse.ui.IWorkbench)32 CoreException (org.eclipse.core.runtime.CoreException)31 ArrayList (java.util.ArrayList)30 IViewReference (org.eclipse.ui.IViewReference)29 IEditorInput (org.eclipse.ui.IEditorInput)28 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)27 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)22 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)18 Path (org.eclipse.core.runtime.Path)18 FileEditorInput (org.eclipse.ui.part.FileEditorInput)17 IOException (java.io.IOException)16 IProject (org.eclipse.core.resources.IProject)16 ISelection (org.eclipse.jface.viewers.ISelection)16