Search in sources :

Example 1 with BrowserEditorInput

use of com.archimatetool.editor.browser.BrowserEditorInput in project archi by archimatetool.

the class HTMLReportExporter method preview.

public void preview() throws Exception {
    PREVIEW_FOLDER.mkdirs();
    Exception[] exception = new Exception[1];
    // Since this can take a while, show the busy dialog
    IRunnableWithProgress runnable = monitor -> {
        try {
            // $NON-NLS-1$//$NON-NLS-2$
            File file = createReport(PREVIEW_FOLDER, "preview-" + fModel.getId() + ".html", monitor);
            // Open it in internal Browser
            // $NON-NLS-1$ //$NON-NLS-2$
            IBrowserEditorInput input = new BrowserEditorInput("file:///" + file.getPath(), Messages.HTMLReportExporter_0 + " " + fModel.getName());
            IBrowserEditor editor = (IBrowserEditor) EditorManager.openEditor(input, IBrowserEditor.ID);
            if (editor != null && editor.getBrowser() != null) {
                editor.getBrowser().refresh();
            }
        } catch (Exception ex) {
            // Catch OOM and SWT exceptions
            exception[0] = ex;
        }
    };
    try {
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
        dialog.run(false, true, runnable);
    } catch (Exception ex) {
        exception[0] = ex;
    }
    if (exception[0] instanceof CancelledException) {
        MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.HTMLReportExporter_2, exception[0].getMessage());
    } else if (exception[0] != null) {
        throw exception[0];
    }
}
Also used : ImageLoader(org.eclipse.swt.graphics.ImageLoader) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ModelReferencedImage(com.archimatetool.editor.diagram.util.ModelReferencedImage) URL(java.net.URL) IArchimateModel(com.archimatetool.model.IArchimateModel) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) Map(java.util.Map) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IArchimateConcept(com.archimatetool.model.IArchimateConcept) Bundle(org.osgi.framework.Bundle) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) IDiagramModel(com.archimatetool.model.IDiagramModel) NLS(org.eclipse.osgi.util.NLS) PlatformUI(org.eclipse.ui.PlatformUI) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) EObject(org.eclipse.emf.ecore.EObject) Display(org.eclipse.swt.widgets.Display) BrowserEditorInput(com.archimatetool.editor.browser.BrowserEditorInput) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) List(java.util.List) ST(org.stringtemplate.v4.ST) Rectangle(org.eclipse.draw2d.geometry.Rectangle) StringUtils(com.archimatetool.editor.utils.StringUtils) ArchiReportsPlugin(com.archimatetool.reports.ArchiReportsPlugin) SWT(org.eclipse.swt.SWT) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) IIdentifier(com.archimatetool.model.IIdentifier) STGroupFile(org.stringtemplate.v4.STGroupFile) IFolder(com.archimatetool.model.IFolder) FileUtils(com.archimatetool.editor.utils.FileUtils) ArchiPlugin(com.archimatetool.editor.ArchiPlugin) IBrowserEditor(com.archimatetool.editor.browser.IBrowserEditor) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) EditorManager(com.archimatetool.editor.ui.services.EditorManager) Image(org.eclipse.swt.graphics.Image) HashMap(java.util.HashMap) IBrowserEditorInput(com.archimatetool.editor.browser.IBrowserEditorInput) ImageData(org.eclipse.swt.graphics.ImageData) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) OutputStreamWriter(java.io.OutputStreamWriter) Hashtable(java.util.Hashtable) ImageFactory(com.archimatetool.editor.ui.ImageFactory) Iterator(java.util.Iterator) DiagramUtils(com.archimatetool.editor.diagram.util.DiagramUtils) FolderType(com.archimatetool.model.FolderType) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) StringRenderer(org.stringtemplate.v4.StringRenderer) File(java.io.File) FileLocator(org.eclipse.core.runtime.FileLocator) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Platform(org.eclipse.core.runtime.Platform) BrowserEditorInput(com.archimatetool.editor.browser.BrowserEditorInput) IBrowserEditorInput(com.archimatetool.editor.browser.IBrowserEditorInput) IBrowserEditor(com.archimatetool.editor.browser.IBrowserEditor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IBrowserEditorInput(com.archimatetool.editor.browser.IBrowserEditorInput) STGroupFile(org.stringtemplate.v4.STGroupFile) File(java.io.File) IOException(java.io.IOException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

ArchiPlugin (com.archimatetool.editor.ArchiPlugin)1 BrowserEditorInput (com.archimatetool.editor.browser.BrowserEditorInput)1 IBrowserEditor (com.archimatetool.editor.browser.IBrowserEditor)1 IBrowserEditorInput (com.archimatetool.editor.browser.IBrowserEditorInput)1 DiagramUtils (com.archimatetool.editor.diagram.util.DiagramUtils)1 ModelReferencedImage (com.archimatetool.editor.diagram.util.ModelReferencedImage)1 ImageFactory (com.archimatetool.editor.ui.ImageFactory)1 EditorManager (com.archimatetool.editor.ui.services.EditorManager)1 FileUtils (com.archimatetool.editor.utils.FileUtils)1 StringUtils (com.archimatetool.editor.utils.StringUtils)1 FolderType (com.archimatetool.model.FolderType)1 IArchimateConcept (com.archimatetool.model.IArchimateConcept)1 IArchimateModel (com.archimatetool.model.IArchimateModel)1 IDiagramModel (com.archimatetool.model.IDiagramModel)1 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)1 IDiagramModelContainer (com.archimatetool.model.IDiagramModelContainer)1 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)1 IDiagramModelReference (com.archimatetool.model.IDiagramModelReference)1 IFolder (com.archimatetool.model.IFolder)1 IIdentifier (com.archimatetool.model.IIdentifier)1