| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| */ |
| package org.eclipse.osbp.utils.vaadin.saiku; |
| |
| import java.io.BufferedReader; |
| import java.io.FileInputStream; |
| import java.io.IOException; |
| import java.io.InputStream; |
| import java.io.InputStreamReader; |
| import java.io.StringBufferInputStream; |
| import java.net.URL; |
| import java.util.stream.Collectors; |
| |
| import javax.annotation.PostConstruct; |
| import javax.inject.Inject; |
| import javax.inject.Named; |
| |
| import org.eclipse.e4.core.contexts.IEclipseContext; |
| import org.eclipse.e4.core.di.annotations.Optional; |
| import org.eclipse.e4.ui.model.application.MApplication; |
| import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
| import org.eclipse.e4.ui.model.application.ui.impl.UIElementImpl; |
| import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl; |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.impl.AdapterImpl; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.osbp.bpm.api.IBPMEngine; |
| import org.eclipse.osbp.bpm.api.IBlipBPMFunctionProvider; |
| import org.osgi.framework.Bundle; |
| import org.osgi.framework.BundleContext; |
| import org.osgi.framework.FrameworkUtil; |
| import org.slf4j.Logger; |
| |
| import com.vaadin.annotations.JavaScript; |
| import com.vaadin.server.Page; |
| import com.vaadin.server.Page.BrowserWindowResizeEvent; |
| import com.vaadin.server.Page.BrowserWindowResizeListener; |
| import com.vaadin.shared.ui.label.ContentMode; |
| import com.vaadin.ui.AbstractComponent; |
| import com.vaadin.ui.HorizontalLayout; |
| import com.vaadin.ui.Label; |
| import com.vaadin.ui.UI; |
| import com.vaadin.ui.VerticalLayout; |
| |
| @JavaScript({ |
| //<!-- jQuery 1.7.2 , jQuery UI 1.8.14--> |
| "theme://plugin/saiku.osgi/resources/js/jquery/jquery.min.js" |
| }) |
| |
| |
| @SuppressWarnings("all") |
| public class SaikuView { |
| private static Logger log = org.slf4j.LoggerFactory |
| .getLogger(SaikuView.class); |
| |
| private HorizontalLayout lowerArea; |
| |
| private VerticalLayout workArea; |
| |
| private SaikuRenderer saikuRenderer; |
| |
| private AbstractComponent label = null; |
| |
| private String processId; |
| |
| private VerticalLayout parent; |
| |
| private IEclipseContext eclipseContext; |
| |
| @Inject |
| public SaikuView(final VerticalLayout parent, final IEclipseContext context, |
| final MApplication app) { |
| this.parent = parent; |
| this.eclipseContext = context; |
| } |
| |
| @PostConstruct |
| public void createView(final VerticalLayout parent) { |
| parent.setPrimaryStyleName("osbp"); |
| saikuRenderer = new SaikuRenderer(eclipseContext); |
| |
| VerticalLayout inner = new VerticalLayout(); |
| inner.setMargin(false); |
| inner.setSizeFull(); |
| inner.setPrimaryStyleName("osbp"); |
| inner.addComponent(saikuRenderer); |
| parent.addComponent(inner); |
| |
| |
| |
| // if (label != null) { |
| // parent.removeComponent(label); |
| // } |
| // label = new Label(getSaikuIndexHTMLCode(), ContentMode.HTML); |
| // label.setSizeFull(); |
| // parent.addComponent(label); |
| // parent.setMargin(true); |
| |
| } |
| |
| private String getSaikuIndexHTMLCode() { |
| BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); |
| |
| |
| Bundle bundle = context.getBundle(); |
| URL url = bundle.getEntry("/resources/index.html"); |
| String path = url.getPath(); |
| try { |
| InputStream inputStream = url.openStream(); |
| String result = new BufferedReader(new InputStreamReader(inputStream)).lines() |
| .parallel().collect(Collectors.joining("\n")); |
| return result; |
| } catch (IOException e) { |
| // TODO Auto-generated catch block |
| e.printStackTrace(); |
| } |
| return ""; |
| } |
| |
| } |