Si eclipse integration start

This commit is contained in:
BoykoAlex
2019-09-03 20:24:10 -04:00
parent 60c8209eaf
commit 384f028ef4
17 changed files with 337 additions and 46 deletions

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.springframework.tooling.eclipse.si.view</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

View File

@@ -0,0 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Spring Integration View
Bundle-SymbolicName: org.springframework.tooling.eclipse.si.view;singleton:=true
Bundle-Version: 4.4.0.qualifier
Automatic-Module-Name: org.springframework.tooling.eclipse.si.view
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime

View File

@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.views">
<view
category="org.springframework.ide.eclipse.ui.views"
class="org.springframework.tooling.eclipse.si.view.LiveGraphView"
id="org.springframework.tooling.eclipse.si.view.LiveGraphView"
name="Integration Graph View">
</view>
</extension>
</plugin>

View File

@@ -0,0 +1,25 @@
package org.springframework.tooling.eclipse.si.view;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
public class LiveGraphView extends ViewPart {
private Browser browser;
@Override
public void createPartControl(Composite parent) {
browser = new Browser(parent, SWT.NONE);
browser.setUrl("http://localhost:8877");
}
@Override
public void setFocus() {
if (!browser.isFocusControl()) {
browser.setFocus();
}
}
}

View File

@@ -96,6 +96,7 @@ import org.springframework.tooling.ls.eclipse.commons.preferences.PreferenceCons
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonObject;
@SuppressWarnings("restriction")
public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4LanguageClient {
@@ -540,4 +541,8 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La
});
}
@Override
public void sprottyMessage(JsonObject message) {
}
}

View File

@@ -19,6 +19,7 @@ mkdir -p $static_dir
echo "cp ${client_dir}/bundle* $static_dir"
cp ${client_dir}/bundle* $static_dir
cp ${client_dir}/index.html $static_dir
cp ${client_dir}/eclipse.html $static_dir
cp -R ${client_dir}/css $static_dir/css
cp -R ${client_dir}/lib $static_dir/lib
cp -R ${client_dir}/src $static_dir/src

View File

@@ -0,0 +1,4 @@
svg {
width: 100%;
height: 100vh;
}

View File

@@ -38,7 +38,7 @@
svg {
margin-top: 15px;
width: 100%;
height: 500px;
height: 600px;
border-style: solid;
border-width: 1px;
border-color: #bbb;

View File

@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Spring Integration Graph</title>
<link rel="stylesheet" href="css/page.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dom4/3.0.0/dom4.js">
<link rel="stylesheet" href="css/eclipse-page.css">
</head>
<body id="sprotty-app" client-id="spring-boot">
<div id="spring-boot" class="sprotty" />
</div>
<script src="bundle.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js"></script>
</body>
</html>

View File

@@ -51,7 +51,7 @@ import {
HtmlRoot,
PreRenderedView,
PreRenderedElement,
labelEditModule, edgeEditModule, RectangularPort
labelEditModule, edgeEditModule, RectangularPort, LayoutRegistry, VBoxLayouter, HBoxLayouter
} from "sprotty";
import {
IntegrationNodeView,
@@ -65,6 +65,7 @@ import {
import fadeModule from "sprotty/lib/features/fade/di.config";
import buttonModule from "sprotty/lib/features/button/di.config";
import expandModule from "sprotty/lib/features/expand/di.config";
import {MyHBoxLayouter, MyVBoxLayouter} from "./layout";
export enum TransportMedium {
None,
@@ -113,5 +114,13 @@ export default (transport: TransportMedium, clientId: string) => {
viewportModule, fadeModule, hoverModule, exportModule, expandModule, buttonModule,
updateModule, graphModule, routingModule, edgeEditModule, edgeLayoutModule, labelEditModule,
modelSourceModule, integrationGaphModule);
const layoutRegistry = container.get<LayoutRegistry>(TYPES.LayoutRegistry);
layoutRegistry.deregister(VBoxLayouter.KIND);
layoutRegistry.register(VBoxLayouter.KIND, new MyVBoxLayouter());
layoutRegistry.deregister(HBoxLayouter.KIND);
layoutRegistry.register(HBoxLayouter.KIND, new MyHBoxLayouter());
return container;
};

View File

@@ -0,0 +1,187 @@
/********************************************************************************
* Copyright (c) 2017-2018 TypeFox and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Bounds,
Point,
isValidDimension,
SParentElement,
SChildElement,
LayoutContainer,
isLayoutableChild,
StatefulLayouter } from 'sprotty';
import {AbstractLayoutOptions, HAlignment, VAlignment} from "sprotty/lib/features/bounds/layout-options";
import {AbstractLayout} from "sprotty/lib/features/bounds/abstract-layout";
import {BoundsData} from "sprotty/lib/features/bounds/hidden-bounds-updater";
export interface VBoxLayoutOptions extends AbstractLayoutOptions {
vGap: number
hAlign: HAlignment
}
/**
* Layouts children of a container in vertical (top->bottom) direction.
*/
export class MyVBoxLayouter extends AbstractLayout<VBoxLayoutOptions> {
protected getChildrenSize(container: SParentElement & LayoutContainer,
containerOptions: VBoxLayoutOptions,
layouter: StatefulLayouter) {
let maxWidth = containerOptions.minWidth;
let maxHeight = 0;
let isFirst = true;
container.children.forEach(
child => {
if (isLayoutableChild(child)) {
const bounds = layouter.getBoundsData(child).bounds;
if (bounds !== undefined && isValidDimension(bounds)) {
maxHeight += bounds.height;
if (isFirst)
isFirst = false;
else
maxHeight += containerOptions.vGap;
maxWidth = Math.max(maxWidth, bounds.width);
}
}
}
);
return {
width: maxWidth,
height: maxHeight
};
}
protected layoutChild(child: SChildElement,
boundsData: BoundsData,
bounds: Bounds,
childOptions: VBoxLayoutOptions,
containerOptions: VBoxLayoutOptions,
currentOffset: Point,
maxWidth: number,
maxHeight: number) {
const dx = this.getDx(childOptions.hAlign, bounds, maxWidth);
boundsData.bounds = {
x: containerOptions.paddingLeft + (child as any).bounds.x - bounds.x + dx,
y: currentOffset.y + (child as any).bounds.y - bounds.y,
width: bounds.width,
height: bounds.height
};
boundsData.boundsChanged = true;
return {
x: currentOffset.x,
y: currentOffset.y + bounds.height + containerOptions.vGap
};
}
protected getDefaultLayoutOptions(): VBoxLayoutOptions {
return {
resizeContainer: true,
paddingTop: 5,
paddingBottom: 5,
paddingLeft: 5,
paddingRight: 5,
paddingFactor: 1,
vGap: 1,
hAlign: 'center',
minWidth: 0,
minHeight: 0
};
}
protected spread(a: VBoxLayoutOptions, b: VBoxLayoutOptions): VBoxLayoutOptions {
return { ...a, ...b };
}
}
export interface HBoxLayoutOptions extends AbstractLayoutOptions {
hGap: number
vAlign: VAlignment
}
/**
* Layouts children of a container in horizontal (left->right) direction.
*/
export class MyHBoxLayouter extends AbstractLayout<HBoxLayoutOptions> {
protected getChildrenSize(container: SParentElement & LayoutContainer,
containerOptions: HBoxLayoutOptions,
layouter: StatefulLayouter) {
let maxWidth = 0;
let maxHeight = containerOptions.minHeight;
let isFirst = true;
container.children.forEach(
child => {
if (isLayoutableChild(child)) {
const bounds = layouter.getBoundsData(child).bounds;
if (bounds !== undefined && isValidDimension(bounds)) {
if (isFirst)
isFirst = false;
else
maxWidth += containerOptions.hGap;
maxWidth += bounds.width;
maxHeight = Math.max(maxHeight, bounds.height);
}
}
}
);
return {
width: maxWidth,
height: maxHeight
};
}
protected layoutChild(child: SChildElement,
boundsData: BoundsData,
bounds: Bounds,
childOptions: HBoxLayoutOptions,
containerOptions: HBoxLayoutOptions,
currentOffset: Point,
maxWidth: number,
maxHeight: number): Point {
const dy = this.getDy(childOptions.vAlign, bounds, maxHeight);
boundsData.bounds = {
x: currentOffset.x + (child as any).bounds.x - bounds.x,
y: containerOptions.paddingTop + (child as any).bounds.y - bounds.y + dy,
width: bounds.width,
height: bounds.height
};
boundsData.boundsChanged = true;
return {
x: currentOffset.x + bounds.width + containerOptions.hGap,
y: currentOffset.y
};
}
protected getDefaultLayoutOptions(): HBoxLayoutOptions {
return {
resizeContainer: true,
paddingTop: 5,
paddingBottom: 5,
paddingLeft: 5,
paddingRight: 5,
paddingFactor: 1,
hGap: 1,
vAlign: 'center',
minWidth: 0,
minHeight: 0
};
}
protected spread(a: HBoxLayoutOptions, b: HBoxLayoutOptions): HBoxLayoutOptions {
return { ...a, ...b };
}
}

View File

@@ -51,9 +51,12 @@ export default function runStandalone() {
}
// Button features
document.getElementById('refresh')!.addEventListener('click', () => {
dispatcher.dispatch(requestModelAction());
});
const refreshButton = document.getElementById('refresh');
if (refreshButton) {
refreshButton.addEventListener('click', () => {
dispatcher.dispatch(requestModelAction());
});
}
function getOptionFromDom(att: string) : string | null {
const appDiv = document.getElementById('sprotty-app');
@@ -66,7 +69,7 @@ export default function runStandalone() {
function getTarget() : string {
const input = <HTMLInputElement>document.getElementById('target-url');
const target = input && input.value;
return target || 'target-missing';
return target || /*'target-missing'*/'http://localhost:8080/integration';
}
function requestModelAction() : RequestModelAction {

View File

@@ -11,7 +11,6 @@ import org.eclipse.sprotty.EdgePlacement.Side;
import org.eclipse.sprotty.LayoutOptions;
import org.eclipse.sprotty.Point;
import org.eclipse.sprotty.RequestModelAction;
import org.eclipse.sprotty.SCompartment;
import org.eclipse.sprotty.SEdge;
import org.eclipse.sprotty.SGraph;
import org.eclipse.sprotty.SLabel;
@@ -40,12 +39,10 @@ import com.google.gson.JsonObject;
@Component
public class SIDiagramGenerator implements DiagramGenerator {
private static final double INTEGRATION_NODE_VERTICAL_PADDING = 20.0;
static final String TYPE_INTEGRATION_GRAPH = "graph";
private static final double CHANNEL_HEIGHT = 40D;
private static final double NODE_MIN_HEIGHT = 80D;
private static final double MIN_WIDTH = 120D;
private static final Logger log = LoggerFactory.getLogger(SIDiagramGenerator.class);
@@ -113,20 +110,9 @@ public class SIDiagramGenerator implements DiagramGenerator {
String sourceId = link.getFrom()+"";
String targetId = link.getTo()+"";
SEdge e = createEdge(id, sourceId, targetId, getEdgeLabel(nodesById.get(sourceId)), link.getType());
children.add(e);
}
//
// LiveBeansModel beansModel = app.getBeans();
// for (String targetBeanId : beansModel.getBeanNames()) {
// for (LiveBean bean : beansModel.getBeansOfName(targetBeanId)) {
// graphChildren.add(createBean(bean.getId(), bean.getShortName(), new Point(), new Dimension()));
// }
// for (LiveBean sourceBean : beansModel.getBeansDependingOn(targetBeanId)) {
// graphChildren.add(createEdge(sourceBean.getId() + " " + targetBeanId, sourceBean.getId(), targetBeanId));
// }
// }
return graph;
}
@@ -152,37 +138,19 @@ public class SIDiagramGenerator implements DiagramGenerator {
SNode node = new SNode();
node.setId(id);
node.setType("node:"+type);
node.setLayout("hbox");
node.setPosition(new Point(Math.random() * 1024, Math.random() * 768));
node.setLayout("vbox");
node.setSize(new Dimension(80, 80));
node.setChildren(new ArrayList<>());
centerNode(node);
SCompartment compartment = new SCompartment();
node.getChildren().add(compartment);
compartment.setId(id + "-comp");
compartment.setType("compartment");
compartment.setLayout("vbox");
compartment.setChildren(new ArrayList<>());
centerNode(compartment);
{
SLabel label = new SLabel();
label.setId(id + "-label");
label.setType("node:label");
label.setText(labelText);
centerNode(label);
compartment.getChildren().add(label);
node.getChildren().add(label);
}
{
SLabel label = new SLabel();
label.setId(id + "-label-test");
label.setType("node:label");
label.setText("s");
centerNode(label);
compartment.getChildren().add(label);
}
SPort outputPort = new SPort();
outputPort.setType("output-port");
@@ -208,12 +176,13 @@ public class SIDiagramGenerator implements DiagramGenerator {
options.setHAlign("center");
options.setVAlign("center");
}
private static SNode createIntegrationNode(String id, String labelText) {
SNode node = createNode(id, labelText, "integration_node");
LayoutOptions layoutOptions = new LayoutOptions();
layoutOptions.setMinHeight(NODE_MIN_HEIGHT);
layoutOptions.setMinWidth(MIN_WIDTH);
layoutOptions.setPaddingBottom(INTEGRATION_NODE_VERTICAL_PADDING);
layoutOptions.setPaddingTop(20.0);
node.setLayoutOptions(layoutOptions);
SPort errorPort = new SPort();

View File

@@ -1,5 +1,6 @@
package org.springframework.ide.si.view;
import org.eclipse.elk.alg.layered.options.FixedAlignment;
import org.eclipse.elk.alg.layered.options.LayeredOptions;
import org.eclipse.elk.core.options.PortConstraints;
import org.eclipse.elk.core.options.PortSide;
@@ -8,7 +9,6 @@ import org.eclipse.sprotty.layout.SprottyLayoutConfigurator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.ide.si.view.json.SpringIntegrationGraphJson;
@SpringBootApplication
public class SprottySiViewApplication {
@@ -26,7 +26,8 @@ public class SprottySiViewApplication {
IPropertyHolder holder = configurator.configureByType(SIDiagramGenerator.TYPE_INTEGRATION_GRAPH);
holder.setProperty(LayeredOptions.SPACING_COMPONENT_COMPONENT, 60.0);
holder.setProperty(LayeredOptions.SPACING_NODE_NODE_BETWEEN_LAYERS, 60.0);
holder.setProperty(LayeredOptions.NODE_PLACEMENT_BK_FIXED_ALIGNMENT, FixedAlignment.BALANCED);
holder = configurator.configureByType("output-port");
holder.setProperty(LayeredOptions.PORT_SIDE, PortSide.EAST);