Search in sources :

Example 11 with ISetSelectionTarget

use of org.eclipse.ui.part.ISetSelectionTarget in project InformationSystem by ObeoNetwork.

the class EcorebindingModelWizard method performFinish.

/**
 * Do the work after everything is specified.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean performFinish() {
    try {
        // Remember the file.
        // 
        final IFile modelFile = getModelFile();
        // Do the work within an operation.
        // 
        WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {

            @Override
            protected void execute(IProgressMonitor progressMonitor) {
                try {
                    // Create a resource set
                    // 
                    ResourceSet resourceSet = new ResourceSetImpl();
                    // Get the URI of the model file.
                    // 
                    URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
                    // Create a resource for this file.
                    // 
                    Resource resource = resourceSet.createResource(fileURI);
                    // Add the initial model object to the contents.
                    // 
                    EObject rootObject = createInitialModel();
                    if (rootObject != null) {
                        resource.getContents().add(rootObject);
                    }
                    // Save the contents of the resource to the file system.
                    // 
                    Map<Object, Object> options = new HashMap<Object, Object>();
                    options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
                    resource.save(options);
                } catch (Exception exception) {
                    EcorebindingEditorPlugin.INSTANCE.log(exception);
                } finally {
                    progressMonitor.done();
                }
            }
        };
        getContainer().run(false, false, operation);
        // Select the new file resource in the current view.
        // 
        IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
        IWorkbenchPage page = workbenchWindow.getActivePage();
        final IWorkbenchPart activePart = page.getActivePart();
        if (activePart instanceof ISetSelectionTarget) {
            final ISelection targetSelection = new StructuredSelection(modelFile);
            getShell().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    ((ISetSelectionTarget) activePart).selectReveal(targetSelection);
                }
            });
        }
        // 
        try {
            page.openEditor(new FileEditorInput(modelFile), workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
        } catch (PartInitException exception) {
            MessageDialog.openError(workbenchWindow.getShell(), EcorebindingEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
            return false;
        }
        return true;
    } catch (Exception exception) {
        EcorebindingEditorPlugin.INSTANCE.log(exception);
        return false;
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) HashMap(java.util.HashMap) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) Resource(org.eclipse.emf.ecore.resource.Resource) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) IResource(org.eclipse.core.resources.IResource) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI) PartInitException(org.eclipse.ui.PartInitException) MissingResourceException(java.util.MissingResourceException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) EObject(org.eclipse.emf.ecore.EObject) FileEditorInput(org.eclipse.ui.part.FileEditorInput) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ISetSelectionTarget(org.eclipse.ui.part.ISetSelectionTarget) EObject(org.eclipse.emf.ecore.EObject) PartInitException(org.eclipse.ui.PartInitException)

Example 12 with ISetSelectionTarget

use of org.eclipse.ui.part.ISetSelectionTarget in project InformationSystem by ObeoNetwork.

the class TypesLibraryModelWizard method performFinish.

/**
 * Do the work after everything is specified.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean performFinish() {
    try {
        // Remember the file.
        // 
        final IFile modelFile = getModelFile();
        // Do the work within an operation.
        // 
        WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {

            @Override
            protected void execute(IProgressMonitor progressMonitor) {
                try {
                    // Create a resource set
                    // 
                    ResourceSet resourceSet = new ResourceSetImpl();
                    // Get the URI of the model file.
                    // 
                    URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
                    // Create a resource for this file.
                    // 
                    Resource resource = resourceSet.createResource(fileURI);
                    // Add the initial model object to the contents.
                    // 
                    EObject rootObject = createInitialModel();
                    if (rootObject != null) {
                        resource.getContents().add(rootObject);
                    }
                    // Save the contents of the resource to the file system.
                    // 
                    Map<Object, Object> options = new HashMap<Object, Object>();
                    options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
                    resource.save(options);
                } catch (Exception exception) {
                    TypesLibraryEditorPlugin.INSTANCE.log(exception);
                } finally {
                    progressMonitor.done();
                }
            }
        };
        getContainer().run(false, false, operation);
        // Select the new file resource in the current view.
        // 
        IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
        IWorkbenchPage page = workbenchWindow.getActivePage();
        final IWorkbenchPart activePart = page.getActivePart();
        if (activePart instanceof ISetSelectionTarget) {
            final ISelection targetSelection = new StructuredSelection(modelFile);
            getShell().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    ((ISetSelectionTarget) activePart).selectReveal(targetSelection);
                }
            });
        }
        // 
        try {
            page.openEditor(new FileEditorInput(modelFile), workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
        } catch (PartInitException exception) {
            MessageDialog.openError(workbenchWindow.getShell(), TypesLibraryEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
            return false;
        }
        return true;
    } catch (Exception exception) {
        TypesLibraryEditorPlugin.INSTANCE.log(exception);
        return false;
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) HashMap(java.util.HashMap) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) Resource(org.eclipse.emf.ecore.resource.Resource) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) IResource(org.eclipse.core.resources.IResource) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI) PartInitException(org.eclipse.ui.PartInitException) MissingResourceException(java.util.MissingResourceException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) EObject(org.eclipse.emf.ecore.EObject) FileEditorInput(org.eclipse.ui.part.FileEditorInput) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ISetSelectionTarget(org.eclipse.ui.part.ISetSelectionTarget) EObject(org.eclipse.emf.ecore.EObject) PartInitException(org.eclipse.ui.PartInitException)

Example 13 with ISetSelectionTarget

use of org.eclipse.ui.part.ISetSelectionTarget in project InformationSystem by ObeoNetwork.

the class ClassDiagramConfigurationModelWizard method performFinish.

/**
 * Do the work after everything is specified.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean performFinish() {
    try {
        // Remember the file.
        // 
        final IFile modelFile = getModelFile();
        // Do the work within an operation.
        // 
        WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {

            @Override
            protected void execute(IProgressMonitor progressMonitor) {
                try {
                    // Create a resource set
                    // 
                    ResourceSet resourceSet = new ResourceSetImpl();
                    // Get the URI of the model file.
                    // 
                    URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
                    // Create a resource for this file.
                    // 
                    Resource resource = resourceSet.createResource(fileURI);
                    // Add the initial model object to the contents.
                    // 
                    EObject rootObject = createInitialModel();
                    if (rootObject != null) {
                        resource.getContents().add(rootObject);
                    }
                    // Save the contents of the resource to the file system.
                    // 
                    Map<Object, Object> options = new HashMap<Object, Object>();
                    options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
                    resource.save(options);
                } catch (Exception exception) {
                    ClassDiagramConfigurationEditorPlugin.INSTANCE.log(exception);
                } finally {
                    progressMonitor.done();
                }
            }
        };
        getContainer().run(false, false, operation);
        // Select the new file resource in the current view.
        // 
        IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
        IWorkbenchPage page = workbenchWindow.getActivePage();
        final IWorkbenchPart activePart = page.getActivePart();
        if (activePart instanceof ISetSelectionTarget) {
            final ISelection targetSelection = new StructuredSelection(modelFile);
            getShell().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    ((ISetSelectionTarget) activePart).selectReveal(targetSelection);
                }
            });
        }
        // 
        try {
            page.openEditor(new FileEditorInput(modelFile), workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
        } catch (PartInitException exception) {
            MessageDialog.openError(workbenchWindow.getShell(), ClassDiagramConfigurationEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
            return false;
        }
        return true;
    } catch (Exception exception) {
        ClassDiagramConfigurationEditorPlugin.INSTANCE.log(exception);
        return false;
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) HashMap(java.util.HashMap) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) Resource(org.eclipse.emf.ecore.resource.Resource) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) IResource(org.eclipse.core.resources.IResource) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI) PartInitException(org.eclipse.ui.PartInitException) MissingResourceException(java.util.MissingResourceException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) EObject(org.eclipse.emf.ecore.EObject) FileEditorInput(org.eclipse.ui.part.FileEditorInput) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ISetSelectionTarget(org.eclipse.ui.part.ISetSelectionTarget) EObject(org.eclipse.emf.ecore.EObject) PartInitException(org.eclipse.ui.PartInitException)

Example 14 with ISetSelectionTarget

use of org.eclipse.ui.part.ISetSelectionTarget in project InformationSystem by ObeoNetwork.

the class FlowModelWizard method performFinish.

/**
 * Do the work after everything is specified.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean performFinish() {
    try {
        // Remember the file.
        // 
        final IFile modelFile = getModelFile();
        // Do the work within an operation.
        // 
        WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {

            @Override
            protected void execute(IProgressMonitor progressMonitor) {
                try {
                    // Create a resource set
                    // 
                    ResourceSet resourceSet = new ResourceSetImpl();
                    // Get the URI of the model file.
                    // 
                    URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
                    // Create a resource for this file.
                    // 
                    Resource resource = resourceSet.createResource(fileURI);
                    // Add the initial model object to the contents.
                    // 
                    EObject rootObject = createInitialModel();
                    if (rootObject != null) {
                        resource.getContents().add(rootObject);
                    }
                    // Save the contents of the resource to the file system.
                    // 
                    Map<Object, Object> options = new HashMap<Object, Object>();
                    options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
                    resource.save(options);
                } catch (Exception exception) {
                    CinematicEditorPlugin.INSTANCE.log(exception);
                } finally {
                    progressMonitor.done();
                }
            }
        };
        getContainer().run(false, false, operation);
        // Select the new file resource in the current view.
        // 
        IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
        IWorkbenchPage page = workbenchWindow.getActivePage();
        final IWorkbenchPart activePart = page.getActivePart();
        if (activePart instanceof ISetSelectionTarget) {
            final ISelection targetSelection = new StructuredSelection(modelFile);
            getShell().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    ((ISetSelectionTarget) activePart).selectReveal(targetSelection);
                }
            });
        }
        // 
        try {
            page.openEditor(new FileEditorInput(modelFile), workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
        } catch (PartInitException exception) {
            MessageDialog.openError(workbenchWindow.getShell(), CinematicEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
            return false;
        }
        return true;
    } catch (Exception exception) {
        CinematicEditorPlugin.INSTANCE.log(exception);
        return false;
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) HashMap(java.util.HashMap) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) Resource(org.eclipse.emf.ecore.resource.Resource) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) IResource(org.eclipse.core.resources.IResource) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI) PartInitException(org.eclipse.ui.PartInitException) MissingResourceException(java.util.MissingResourceException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) EObject(org.eclipse.emf.ecore.EObject) FileEditorInput(org.eclipse.ui.part.FileEditorInput) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ISetSelectionTarget(org.eclipse.ui.part.ISetSelectionTarget) EObject(org.eclipse.emf.ecore.EObject) PartInitException(org.eclipse.ui.PartInitException)

Example 15 with ISetSelectionTarget

use of org.eclipse.ui.part.ISetSelectionTarget in project InformationSystem by ObeoNetwork.

the class EntityModelWizard method performFinish.

/**
 * Do the work after everything is specified.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@Override
public boolean performFinish() {
    try {
        // Remember the file.
        // 
        final IFile modelFile = getModelFile();
        // Do the work within an operation.
        // 
        WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {

            @Override
            protected void execute(IProgressMonitor progressMonitor) {
                try {
                    // Create a resource set
                    // 
                    ResourceSet resourceSet = new ResourceSetImpl();
                    // Get the URI of the model file.
                    // 
                    URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
                    // Create a resource for this file.
                    // 
                    Resource resource = resourceSet.createResource(fileURI);
                    // Add the initial model object to the contents.
                    // 
                    EObject rootObject = createInitialModel();
                    if (rootObject != null) {
                        resource.getContents().add(rootObject);
                    }
                    // Save the contents of the resource to the file system.
                    // 
                    Map<Object, Object> options = new HashMap<Object, Object>();
                    options.put(XMLResource.OPTION_ENCODING, "UTF-8");
                    resource.save(options);
                } catch (Exception exception) {
                    EntityEditorPlugin.INSTANCE.log(exception);
                } finally {
                    progressMonitor.done();
                }
            }
        };
        getContainer().run(false, false, operation);
        // Select the new file resource in the current view.
        // 
        IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
        IWorkbenchPage page = workbenchWindow.getActivePage();
        final IWorkbenchPart activePart = page.getActivePart();
        if (activePart instanceof ISetSelectionTarget) {
            final ISelection targetSelection = new StructuredSelection(modelFile);
            getShell().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    ((ISetSelectionTarget) activePart).selectReveal(targetSelection);
                }
            });
        }
        // 
        try {
            page.openEditor(new FileEditorInput(modelFile), workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
        } catch (PartInitException exception) {
            MessageDialog.openError(workbenchWindow.getShell(), EntityEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
            return false;
        }
        return true;
    } catch (Exception exception) {
        EntityEditorPlugin.INSTANCE.log(exception);
        return false;
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) HashMap(java.util.HashMap) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) Resource(org.eclipse.emf.ecore.resource.Resource) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) IResource(org.eclipse.core.resources.IResource) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI) PartInitException(org.eclipse.ui.PartInitException) MissingResourceException(java.util.MissingResourceException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) EObject(org.eclipse.emf.ecore.EObject) FileEditorInput(org.eclipse.ui.part.FileEditorInput) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ISetSelectionTarget(org.eclipse.ui.part.ISetSelectionTarget) EObject(org.eclipse.emf.ecore.EObject) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

ISetSelectionTarget (org.eclipse.ui.part.ISetSelectionTarget)38 ISelection (org.eclipse.jface.viewers.ISelection)37 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)37 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)36 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)35 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)33 IResource (org.eclipse.core.resources.IResource)32 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)31 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)31 WorkspaceModifyOperation (org.eclipse.ui.actions.WorkspaceModifyOperation)31 PartInitException (org.eclipse.ui.PartInitException)30 HashMap (java.util.HashMap)29 MissingResourceException (java.util.MissingResourceException)29 IFile (org.eclipse.core.resources.IFile)29 URI (org.eclipse.emf.common.util.URI)29 Resource (org.eclipse.emf.ecore.resource.Resource)29 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)29 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)29 XMLResource (org.eclipse.emf.ecore.xmi.XMLResource)29 EObject (org.eclipse.emf.ecore.EObject)28