Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

Commit

Permalink
[PT-#150812522] Beans tab for Boot Dash
Browse files Browse the repository at this point in the history
  • Loading branch information
BoykoAlex committed Oct 3, 2017
1 parent cf439bb commit 633381f
Show file tree
Hide file tree
Showing 80 changed files with 1,573 additions and 591 deletions.
@@ -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>
28 changes: 28 additions & 0 deletions plugins/org.springframework.ide.eclipse.beans.ui.live/.project
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.springframework.ide.eclipse.beans.ui.live</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>
@@ -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
@@ -0,0 +1,22 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Live Beans Tree
Bundle-SymbolicName: org.springframework.ide.eclipse.beans.ui.live;singleton:=true
Bundle-Version: 3.9.1.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.springframework.ide.eclipse.beans.ui.live,
org.springframework.ide.eclipse.beans.ui.live.actions,
org.springframework.ide.eclipse.beans.ui.live.model,
org.springframework.ide.eclipse.beans.ui.live.tree
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui.views,
org.json,
org.eclipse.core.resources,
org.apache.commons.lang,
org.eclipse.jface,
org.eclipse.ui.workbench,
org.eclipse.jdt.core,
org.springsource.ide.eclipse.commons.ui
Bundle-ActivationPolicy: lazy
Bundle-Vendor: Spring IDE Developers
Bundle-Activator: org.springframework.ide.eclipse.beans.ui.live.LiveBeansUiPlugin
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
68 changes: 68 additions & 0 deletions plugins/org.springframework.ide.eclipse.beans.ui.live/pom.xml
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.ide.eclipse</groupId>
<artifactId>org.springframework.ide.eclipse.parent</artifactId>
<version>3.9.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>org.springframework.ide.eclipse</groupId>
<artifactId>org.springframework.ide.eclipse.beans.ui.live</artifactId>

<packaging>eclipse-plugin</packaging>

<build>
<plugins>

<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<resolver>p2</resolver>
<pomDependencies>ignore</pomDependencies>
</configuration>
</plugin>

<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho-version}</version>
</plugin>

<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>plugin-source</id>
<phase>generate-sources</phase>
<goals>
<goal>plugin-source</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>second-generate-p2-metadata</id>
<goals>
<goal>p2-metadata</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
@@ -0,0 +1,64 @@
/*******************************************************************************
* Copyright (c) 2017 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.eclipse.beans.ui.live;

import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
* Live Beans plugin
*
* @author Alex Boyko
*
*/
public class LiveBeansUiPlugin extends AbstractUIPlugin {

// The plug-in ID
public static final String PLUGIN_ID = "org.springframework.ide.eclipse.beans.ui.live"; //$NON-NLS-1$

private static final String ICON_PATH_PREFIX = "icons/";
private static final String NAME_PREFIX = PLUGIN_ID + '.';
private static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length();

public static final String IMG_OBJS_BEAN = NAME_PREFIX + "bean_obj.gif";
public static final String IMG_OBJS_BEAN_REF = NAME_PREFIX + "beanref_obj.gif";
public static final String IMG_OBJS_CONFIG = NAME_PREFIX + "config_obj.gif";

private static LiveBeansUiPlugin plugin;


@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}

@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}

public static LiveBeansUiPlugin getDefault() {
return plugin;
}

@Override
protected void initializeImageRegistry(ImageRegistry reg) {
super.initializeImageRegistry(reg);
reg.put(IMG_OBJS_BEAN, imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH_PREFIX + IMG_OBJS_BEAN.substring(NAME_PREFIX_LENGTH)));
reg.put(IMG_OBJS_BEAN_REF, imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH_PREFIX + IMG_OBJS_BEAN_REF.substring(NAME_PREFIX_LENGTH)));
reg.put(IMG_OBJS_CONFIG, imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH_PREFIX + IMG_OBJS_CONFIG.substring(NAME_PREFIX_LENGTH)));
}


}
@@ -0,0 +1,60 @@
/*******************************************************************************
* Copyright (c) 2013, 2017 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.eclipse.beans.ui.live.actions;

import org.eclipse.jdt.core.IType;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
import org.springframework.ide.eclipse.beans.ui.live.model.TypeLookup;
import org.springsource.ide.eclipse.commons.ui.SpringUIUtils;

/**
* @author Leo Dos Santos
* @author Alex Boyko
*/
public abstract class AbstractOpenResourceAction extends BaseSelectionListenerAction {

protected AbstractOpenResourceAction(String text) {
super(text);
}

protected String extractClassName(String resourcePath) {
int index = resourcePath.lastIndexOf("/WEB-INF/classes/");
int length = "/WEB-INF/classes/".length();
if (index >= 0) {
resourcePath = resourcePath.substring(index + length);
}
resourcePath = resourcePath.substring(0, resourcePath.lastIndexOf(".class"));
resourcePath = resourcePath.replaceAll("\\\\|\\/", "."); //Tolerate both '/' and '\'.
return resourcePath;
}

protected String extractResourcePath(String resourceStr) {
// Extract the resource path out of the descriptive text
int indexStart = resourceStr.indexOf("[");
int indexEnd = resourceStr.indexOf("]");
if (indexStart > -1 && indexEnd > -1 && indexStart < indexEnd) {
resourceStr = resourceStr.substring(indexStart + 1, indexEnd);
}
return resourceStr;
}

protected boolean hasTypeInProject(TypeLookup workspaceContext, String className) {
return workspaceContext.findType(className) != null;
}

protected void openInEditor(TypeLookup workspaceContext, String className) {
IType type = workspaceContext.findType(className);
if (type != null) {
SpringUIUtils.openInEditor(type);
}
}

}
@@ -1,38 +1,39 @@
/*******************************************************************************
* Copyright (c) 2012 - 2013 VMware, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* Copyright (c) 2012, 2017 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* VMware, Inc. - initial API and implementation
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.eclipse.beans.ui.livegraph.actions;
package org.springframework.ide.eclipse.beans.ui.live.actions;

import java.util.List;

import org.eclipse.jface.viewers.IStructuredSelection;
import org.springframework.ide.eclipse.beans.ui.livegraph.model.LiveBean;
import org.springframework.ide.eclipse.beans.ui.livegraph.model.LiveBeansSession;
import org.springframework.ide.eclipse.beans.ui.live.model.LiveBean;
import org.springframework.ide.eclipse.beans.ui.live.model.TypeLookup;

/**
* @author Leo Dos Santos
* @author Alex Boyko
*/
public class OpenBeanClassAction extends AbstractOpenResourceAction {

public OpenBeanClassAction() {
super("Open Bean Class");
}

@Override
public void run() {
IStructuredSelection selection = getStructuredSelection();
List<?> elements = selection.toList();
for (Object obj : elements) {
if (obj instanceof LiveBean) {
LiveBean bean = (LiveBean) obj;
LiveBeansSession appName = bean.getSession();
TypeLookup appName = bean.getTypeLookup();
String beanClass = bean.getBeanType();
if (appName != null) {
if (beanClass != null && beanClass.trim().length() > 0) {
Expand Down Expand Up @@ -72,7 +73,7 @@ protected boolean updateSelection(IStructuredSelection selection) {
return true;
}
else {
return hasTypeInProject(bean.getSession(), bean.getId());
return hasTypeInProject(bean.getTypeLookup(), bean.getId());
}
}
}
Expand Down
@@ -0,0 +1,65 @@
/*******************************************************************************
* Copyright (c) 2012, 2017 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.eclipse.beans.ui.live.actions;

import java.util.List;

import org.eclipse.jface.viewers.IStructuredSelection;
import org.springframework.ide.eclipse.beans.ui.live.model.LiveBean;
import org.springframework.ide.eclipse.beans.ui.live.model.TypeLookup;

/**
* @author Leo Dos Santos
* @author Alex Boyko
*/
public class OpenBeanDefinitionAction extends AbstractOpenResourceAction {

public OpenBeanDefinitionAction() {
super("Open Bean Definition File");
}

@Override
public void run() {
IStructuredSelection selection = getStructuredSelection();
List<?> elements = selection.toList();
for (Object obj : elements) {
if (obj instanceof LiveBean) {
LiveBean bean = (LiveBean) obj;
TypeLookup session = bean.getTypeLookup();
String resource = bean.getResource();
if (resource != null && resource.trim().length() > 0 && !resource.equalsIgnoreCase("null")) {
String resourcePath = extractResourcePath(resource);
if (resourcePath.endsWith(".class")) {
openInEditor(session, extractClassName(resourcePath));
}
}
}
}
}

@Override
protected boolean updateSelection(IStructuredSelection selection) {
if (!selection.isEmpty()) {
List<?> elements = selection.toList();
for (Object obj : elements) {
if (obj instanceof LiveBean) {
LiveBean bean = (LiveBean) obj;
String resource = bean.getResource();
if (resource != null && resource.trim().length() > 0 && !resource.equalsIgnoreCase("null")) {
return true;
}
}
}
}
return false;
}

}

0 comments on commit 633381f

Please sign in to comment.