Commit 45a76bf4 by Nepxion

增加console-desktop模块

parent fc630c5e
<?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/xsd/maven-4.0.0.xsd">
<artifactId>discovery-console-desktop</artifactId>
<name>Nepxion Discovery Console Desktop</name>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
<description>Nepxion Discovery is an enhancement for Spring Cloud Discovery</description>
<url>http://www.nepxion.com</url>
<parent>
<groupId>com.nepxion</groupId>
<artifactId>discovery</artifactId>
<version>4.0.2</version>
</parent>
<properties>
<commons.configuration.version>1.10</commons.configuration.version>
<swing.worker.version>1.2</swing.worker.version>
<swingx.version>1.0</swingx.version>
<jide.version>2.9.7</jide.version>
<l2fprod.version>7.3</l2fprod.version>
<jcalendar.version>1.3.4.200905090658</jcalendar.version>
<nepxion.swing.version>1.0.0</nepxion.swing.version>
<nepxion.util.version>1.0.0</nepxion.util.version>
<nepxion.cots.version>1.0.0</nepxion.cots.version>
<twaver.version>3.7</twaver.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>${commons.configuration.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>${disruptor.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>jdesktop</groupId>
<artifactId>swing-worker</artifactId>
<version>${swing.worker.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jdesktop-swing-worker-${swing.worker.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>jdesktop</groupId>
<artifactId>swingx</artifactId>
<version>${swingx.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jdesktop-swingx-${swingx.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>jide</groupId>
<artifactId>oss</artifactId>
<version>${jide.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jide-oss-${jide.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>l2fprod</groupId>
<artifactId>common-all</artifactId>
<version>${l2fprod.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/l2fprod-common-all-${l2fprod.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>jcalendar</groupId>
<artifactId>jcalendar</artifactId>
<version>${jcalendar.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jcalendar-${jcalendar.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>com.nepxion</groupId>
<artifactId>swing</artifactId>
<version>${nepxion.swing.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/nepxion-swing-${nepxion.swing.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>com.nepxion</groupId>
<artifactId>util</artifactId>
<version>${nepxion.util.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/nepxion-util-${nepxion.util.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>com.nepxion</groupId>
<artifactId>cots</artifactId>
<version>${nepxion.cots.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/nepxion-cots-${nepxion.cots.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>twaver</groupId>
<artifactId>twaver</artifactId>
<version>${twaver.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/twaver-${twaver.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>twaver</groupId>
<artifactId>twaver-gis</artifactId>
<version>${twaver.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/twaver-gis-${twaver.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>twaver</groupId>
<artifactId>twaver-layouter</artifactId>
<version>${twaver.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/twaver-layouter-${twaver.version}.jar</systemPath>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/assembly/dist.xml</descriptor>
</descriptors>
<encoding>${project.build.sourceEncoding}</encoding>
<testFailureIgnore>true</testFailureIgnore>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
执行maven clean install,将会在target目录下创建discovery-console-desktop-[version]-release和discovery-console-desktop-[version]-release.zip,点里面的bat运行即可
\ No newline at end of file
@echo on
@echo on
@echo =============================================================
@echo $ $
@echo $ Nepxion Discovery $
@echo $ $
@echo $ $
@echo $ $
@echo $ Nepxion Studio All Right Reserved $
@echo $ Copyright (C) 2017-2050 $
@echo $ $
@echo =============================================================
@echo.
@echo off
@title Nepxion Discovery
@color 0a
@set CLASSPATH=./conf/;./lib/*
@set PATH=
call:JAVA_HOME_CHECK
:JAVA_HOME_CHECK
if "%JAVA_HOME%"=="" goto ECHO_JAVA_HOME_CHECK_EXIT
@rem echo Found Java Home=%JAVA_HOME%
echo JAVA_HOME=%JAVA_HOME%
goto SET_CLASSPATH_AND_RUN
:ECHO_JAVA_HOME_CHECK_EXIT
@rem echo Please set JAVA_HOME
echo JAVA_HOME
goto EXIT
:SET_CLASSPATH_AND_RUN
"%JAVA_HOME%\bin\java" -Dfile.encoding=GBK -Ddefault.client.encoding=GBK -Duser.language=zh -Duser.region=CN -Djava.security.policy=java.policy -Djava.library.path=%PATH% -Xms128m -Xmx512m -classpath %CLASSPATH% com.nepxion.discovery.console.desktop.ConsoleLauncher
:PAUSE
pause;
:EXIT
exit;
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<id>release</id>
<formats>
<format>zip</format>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<unpack>false</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>src/assembly</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.bat</include>
</includes>
<fileMode>0744</fileMode>
</fileSet>
<fileSet>
<directory>src/main/resources</directory>
<outputDirectory>/conf</outputDirectory>
<includes>
<include>*.properties</include>
</includes>
<fileMode>0744</fileMode>
</fileSet>
<fileSet>
<directory>lib</directory>
<outputDirectory>/lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
\ No newline at end of file
package com.nepxion.discovery.console.desktop;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import java.awt.Dimension;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import com.nepxion.discovery.console.desktop.icon.ConsoleIconFactory;
import com.nepxion.discovery.console.desktop.locale.ConsoleLocale;
import com.nepxion.swing.frame.JBasicFrame;
import com.nepxion.swing.framework.reflection.JReflectionHierarchy;
import com.nepxion.swing.style.texture.shrink.JBlackHeaderTextureStyle;
import com.nepxion.swing.style.texture.shrink.JGreenOutlookTextureStyle;
public class ConsoleFrame extends JBasicFrame {
private static final long serialVersionUID = 1L;
public ConsoleFrame() {
super(ConsoleLocale.getString("title"), ConsoleIconFactory.getSwingIcon("ribbon/navigator_nepxion.png"), new Dimension(1280, 900));
}
public void launch() {
ConsoleHierarchy deployHierarchy = new ConsoleHierarchy(new JBlackHeaderTextureStyle(), new JGreenOutlookTextureStyle());
JReflectionHierarchy reflectionHierarchy = new JReflectionHierarchy(20, 20);
reflectionHierarchy.setContentPane(deployHierarchy);
getContentPane().add(reflectionHierarchy);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
}
});
setTitle(ConsoleLocale.getString("title"));
setExtendedState(ConsoleFrame.MAXIMIZED_BOTH);
setVisible(true);
toFront();
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import com.nepxion.discovery.console.desktop.context.UIContext;
import com.nepxion.discovery.console.desktop.icon.ConsoleIconFactory;
import com.nepxion.discovery.console.desktop.locale.ConsoleLocale;
import com.nepxion.discovery.console.desktop.toggle.ConsoleToggleConstants;
import com.nepxion.discovery.console.desktop.toggle.ConsoleToggleListener;
import com.nepxion.swing.element.ElementNode;
import com.nepxion.swing.list.toggle.JToggleList;
import com.nepxion.swing.shrinkbar.JShrinkBar;
import com.nepxion.swing.shrinkbar.JShrinkOutlook;
import com.nepxion.swing.shrinkbar.JShrinkOutlookBar;
import com.nepxion.swing.shrinkbar.ShrinkListCellRenderer;
import com.nepxion.swing.shrinkbar.ShrinkOutlookSelectionListener;
import com.nepxion.swing.style.texture.shrink.IHeaderTextureStyle;
import com.nepxion.swing.style.texture.shrink.IOutlookTextureStyle;
import com.nepxion.util.data.CollectionUtil;
public class ConsoleHierarchy extends JPanel {
private static final long serialVersionUID = 1L;
private JShrinkBar shrinkContentBar;
private JShrinkOutlookBar shrinkOutlookBar;
public ConsoleHierarchy(IHeaderTextureStyle headerTextureStyle, IOutlookTextureStyle outlookTextureStyle) {
shrinkContentBar = new JShrinkBar(JShrinkBar.PLACEMENT_EAST, JShrinkBar.CONTENT_PANE_TYPE_LABEL, headerTextureStyle);
shrinkContentBar.setShrinkable(false);
shrinkContentBar.setTitle(ConsoleLocale.getString("content_bar"));
shrinkContentBar.setToolTipText(ConsoleLocale.getString("content_bar"));
shrinkContentBar.setIcon(ConsoleIconFactory.getSwingIcon("paste.png"));
shrinkContentBar.setTitleFont(new Font(UIContext.getFontName(), Font.BOLD, UIContext.getLargeFontSize()));
shrinkContentBar.getShrinkHeader().getLabel().addMouseListener(new ShrinkContentBarMouseListener());
shrinkOutlookBar = new JShrinkOutlookBar(JShrinkBar.PLACEMENT_WEST, JShrinkBar.CONTENT_PANE_TYPE_LABEL, headerTextureStyle, outlookTextureStyle);
shrinkOutlookBar.setTitle(ConsoleLocale.getString("navigator_bar"));
shrinkOutlookBar.setToolTipText(ConsoleLocale.getString("navigator_bar"));
shrinkOutlookBar.setIcon(ConsoleIconFactory.getSwingIcon("hierarchy.png"));
shrinkOutlookBar.setTitleFont(new Font(UIContext.getFontName(), Font.BOLD, UIContext.getLargeFontSize()));
shrinkOutlookBar.setPreferredSize(new Dimension(210, shrinkOutlookBar.getPreferredSize().height));
createServiceControlShrinkOutlook(shrinkOutlookBar);
shrinkOutlookBar.getShrinkOutlook(0).setSelected(true);
setLayout(new BorderLayout(5, 5));
add(shrinkContentBar, BorderLayout.CENTER);
add(shrinkOutlookBar, BorderLayout.WEST);
}
private JShrinkOutlook createServiceControlShrinkOutlook(JShrinkOutlookBar shrinkOutlookBar) {
List<ElementNode> elementNodes = new ArrayList<ElementNode>();
elementNodes.add(new ElementNode(ConsoleToggleConstants.SERVICE_TOPOLOGY, ConsoleLocale.getString(ConsoleToggleConstants.SERVICE_TOPOLOGY), ConsoleIconFactory.getSwingIcon("component/ui_16.png"), ConsoleLocale.getString(ConsoleToggleConstants.SERVICE_TOPOLOGY)));
JToggleList list = createList(elementNodes);
list.setSelectedIndex(0);
JShrinkOutlook shrinkOutlook = shrinkOutlookBar.addShrinkOutlook(ConsoleLocale.getString("service_control"), ConsoleIconFactory.getSwingIcon("stereo/favorite_16.png"), ConsoleIconFactory.getSwingIcon("stereo/favorite_add_16.png"), ConsoleLocale.getString("service_control"), new Font(UIContext.getFontName(), Font.BOLD, UIContext.getMiddleFontSize()));
shrinkOutlook.setContentPane(list);
shrinkOutlook.addPropertyChangeListener(new OutlookSelectionListener());
return shrinkOutlook;
}
@SuppressWarnings("unchecked")
private JToggleList createList(List<ElementNode> elementNodes) {
JToggleList list = new JToggleList(CollectionUtil.parseVector(elementNodes));
list.setSelectionMode(JToggleList.SINGLE_SELECTION);
list.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
list.setCellRenderer(new ShrinkListCellRenderer(list, BorderFactory.createEmptyBorder(0, 10, 0, 0), 22));
list.setToggleContentPanel(shrinkContentBar);
list.setToggleAdapter(new ConsoleToggleListener(list));
return list;
}
private class ShrinkContentBarMouseListener extends MouseAdapter {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
boolean isShrinked = !shrinkOutlookBar.isShrinked();
shrinkOutlookBar.setShrinked(isShrinked);
}
}
}
private class OutlookSelectionListener extends ShrinkOutlookSelectionListener {
public void selectionStateChanged(JShrinkOutlook shrinkOutlook) {
JToggleList toggleList = (JToggleList) shrinkOutlook.getContentPane();
toggleList.executeSelection(-1, toggleList.getSelectedIndex());
}
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import javax.swing.SwingUtilities;
import com.nepxion.discovery.console.desktop.context.ContextInitializer;
public class ConsoleLauncher {
public static void main(String[] args) {
ContextInitializer.initialize();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ConsoleFrame consoleFrame = new ConsoleFrame();
consoleFrame.launch();
}
});
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.context;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
public class ContextInitializer {
public static void initialize() {
PropertiesContext.initialize();
DataContext.initialize();
UIContext.initialize();
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.context;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import com.nepxion.swing.exception.ExceptionTracerContext;
import com.nepxion.util.encoder.EncoderContext;
import com.nepxion.util.locale.LocaleContext;
public class DataContext {
public static final String CHARSET = "UTF-8";
public static final String LOCALE = "zh_CN";
public static void initialize() {
initializeEncoder();
initializeLocale();
initializeTracer();
}
private static void initializeEncoder() {
EncoderContext.registerIOCharset(CHARSET);
}
private static void initializeLocale() {
LocaleContext.registerLocale(LOCALE);
}
private static void initializeTracer() {
ExceptionTracerContext.register(true);
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.context;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import java.io.File;
import java.net.URL;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
public class PropertiesContext extends PropertiesConfiguration {
private static final String PATH = "config/console.properties";
private static PropertiesContext propertiesContext;
public static void initialize() {
try {
propertiesContext = new PropertiesContext(PATH);
} catch (ConfigurationException e) {
e.printStackTrace();
}
}
public static PropertiesContext getProperties() {
return propertiesContext;
}
public PropertiesContext(String path) throws ConfigurationException {
super(path);
}
public PropertiesContext(File file) throws ConfigurationException {
super(file);
}
public PropertiesContext(URL url) throws ConfigurationException {
super(url);
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.context;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import java.awt.Font;
import com.nepxion.swing.font.FontContext;
import com.nepxion.swing.lookandfeel.LookAndFeelManager;
import com.nepxion.util.locale.LocaleContext;
public class UIContext {
private static final String FONT_NAME_YAHEI = "\u5fae\u8f6f\u96c5\u9ed1"; // 微软雅黑
private static final int FONT_SMALL_SIZE_YAHEI = 12; // 11
private static final int FONT_MIDDLE_SIZE_YAHEI = FONT_SMALL_SIZE_YAHEI + 1;
private static final int FONT_LARGE_SIZE_YAHEI = FONT_SMALL_SIZE_YAHEI + 2;
private static final String FONT_NAME_CALIBRI = "Calibri";
private static final int FONT_SMALL_SIZE_CALIBRI = 12;
private static final int FONT_MIDDLE_SIZE_CALIBRI = FONT_SMALL_SIZE_CALIBRI + 1;
private static final int FONT_LARGE_SIZE_CALIBRI = FONT_SMALL_SIZE_CALIBRI + 2;
public static void initialize() {
FontContext.registerFont(getFontName(), Font.PLAIN, getDefaultFontSize());
LookAndFeelManager.setNimbusLookAndFeel();
}
public static String getFontName() {
if (LocaleContext.getLocale() == LocaleContext.LOCALE_ZH_CN) {
return FONT_NAME_YAHEI;
}
return FONT_NAME_CALIBRI;
}
public static int getDefaultFontSize() {
String fontName = getFontName();
if (fontName.equals(FONT_NAME_YAHEI)) {
return FONT_MIDDLE_SIZE_YAHEI;
} else {
return FONT_MIDDLE_SIZE_CALIBRI;
}
}
public static int getSmallFontSize() {
String fontName = getFontName();
if (fontName.equals(FONT_NAME_YAHEI)) {
return FONT_SMALL_SIZE_YAHEI;
} else {
return FONT_SMALL_SIZE_CALIBRI;
}
}
public static int getMiddleFontSize() {
String fontName = getFontName();
if (fontName.equals(FONT_NAME_YAHEI)) {
return FONT_MIDDLE_SIZE_YAHEI;
} else {
return FONT_MIDDLE_SIZE_CALIBRI;
}
}
public static int getLargeFontSize() {
String fontName = getFontName();
if (fontName.equals(FONT_NAME_YAHEI)) {
return FONT_LARGE_SIZE_YAHEI;
} else {
return FONT_LARGE_SIZE_CALIBRI;
}
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.controller;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import java.util.List;
import java.util.Map;
import org.springframework.web.client.RestTemplate;
import com.fasterxml.jackson.core.type.TypeReference;
import com.nepxion.discovery.console.desktop.context.PropertiesContext;
import com.nepxion.discovery.console.desktop.entity.InstanceEntity;
import com.nepxion.discovery.console.desktop.serializer.JacksonSerializer;
public class ServiceController {
public static RestTemplate restTemplate;
static {
restTemplate = new RestTemplate();
}
public static Map<String, List<InstanceEntity>> getInstanceMap() {
String url = getUrl() + "/console/instance-map";
String json = restTemplate.getForEntity(url, String.class).getBody();
return JacksonSerializer.fromJson(json, new TypeReference<Map<String, List<InstanceEntity>>>() {
});
}
public static String getUrl() {
String url = PropertiesContext.getProperties().getString("url");
if (!url.endsWith("/")) {
url += "/";
}
return url;
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.entity;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import java.io.Serializable;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
public class InstanceEntity implements Serializable {
private static final long serialVersionUID = -3001191508072178378L;
private String serviceId;
private String version;
private String host;
private int port;
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.icon;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import javax.swing.ImageIcon;
import com.nepxion.swing.icon.IconFactory;
public class ConsoleIconFactory extends IconFactory {
public static final String ICON_FOLDER = "com/nepxion/discovery/console/desktop/icon/";
public static ImageIcon getContextIcon(String iconName) {
return getIcon(ICON_FOLDER + iconName);
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.locale;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import java.util.Locale;
import com.nepxion.util.locale.LocaleManager;
public class ConsoleLocale {
public static final Class<?> BUNDLE_CLASS = ConsoleLocale.class;
public static String getString(String key) {
return LocaleManager.getString(BUNDLE_CLASS, key);
}
public static String getString(String key, Locale locale) {
return LocaleManager.getString(BUNDLE_CLASS, key, locale);
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.serializer;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import java.text.SimpleDateFormat;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JacksonSerializer {
private static ObjectMapper objectMapper;
static {
objectMapper = new ObjectMapper();
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"));
}
public static <T> String toJson(T object) {
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> T fromJson(String json, Class<T> clazz) {
if (StringUtils.isEmpty(json)) {
throw new IllegalArgumentException("Json is null or empty");
}
try {
return objectMapper.readValue(json, clazz);
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> T fromJson(String json, TypeReference<T> typeReference) {
if (StringUtils.isEmpty(json)) {
throw new IllegalArgumentException("Json is null or empty");
}
try {
return objectMapper.readValue(json, typeReference);
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static ObjectMapper getObjectMapper() {
return objectMapper;
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.toggle;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
public class ConsoleToggleConstants {
public static final String SERVICE_TOPOLOGY = "service_topology";
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.toggle;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import com.nepxion.swing.element.IElementNode;
import com.nepxion.swing.list.toggle.AbstractToggleAdapter;
import com.nepxion.swing.list.toggle.JToggleList;
import com.nepxion.swing.toggle.ITogglePanel;
public class ConsoleToggleListener extends AbstractToggleAdapter {
public ConsoleToggleListener(JToggleList list) {
super(list);
}
public ITogglePanel getTogglePanel(IElementNode elementNode) {
Object userObject = elementNode.getUserObject();
if (userObject == null) {
userObject = new ConsoleTogglePanel(elementNode);
elementNode.setUserObject(userObject);
}
return (ITogglePanel) userObject;
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.toggle;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import java.awt.BorderLayout;
import java.awt.Component;
import com.nepxion.discovery.console.desktop.icon.ConsoleIconFactory;
import com.nepxion.discovery.console.desktop.locale.ConsoleLocale;
import com.nepxion.swing.element.IElementNode;
import com.nepxion.swing.locale.SwingLocale;
import com.nepxion.swing.toggle.JThreadTogglePanel;
public class ConsoleTogglePanel extends JThreadTogglePanel {
private static final long serialVersionUID = 1L;
private IElementNode listElementNode;
private ConsoleToggleSpace toggleSpace;
public ConsoleTogglePanel(IElementNode listElementNode) {
super(SwingLocale.getString("initialize_and_wait"));
this.listElementNode = listElementNode;
setToggleBannerIcon(ConsoleIconFactory.getSwingIcon("banner/edit.png"));
setInformationText(ConsoleLocale.getString("initialize_component"));
setInformationIcon(ConsoleIconFactory.getSwingIcon("banner/query_128.png"));
setErrorText(ConsoleLocale.getString("initialize_component_failure"));
setErrorIcon(ConsoleIconFactory.getSwingIcon("banner/error_128.png"));
setThreadPanelWidth(300);
showInformation();
setLayout(new BorderLayout());
}
public Component getContentPane() {
return toggleSpace;
}
public boolean isLoadCache() {
return toggleSpace != null;
}
protected void loadForeground(Object data) throws Exception {
if (toggleSpace == null) {
toggleSpace = new ConsoleToggleSpace(listElementNode);
add(toggleSpace, BorderLayout.CENTER);
}
}
protected Object loadBackground() throws Exception {
return null;
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.toggle;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import java.awt.BorderLayout;
import javax.swing.JComponent;
import javax.swing.JPanel;
import com.nepxion.discovery.console.desktop.workspace.ServiceTopology;
import com.nepxion.swing.element.IElementNode;
public class ConsoleToggleSpace extends JPanel {
private static final long serialVersionUID = 1L;
private IElementNode listElementNode;
private JPanel blankPane = new JPanel();
public ConsoleToggleSpace(IElementNode listElementNode) {
this.listElementNode = listElementNode;
setLayout(new BorderLayout());
add(createContentPane(), BorderLayout.CENTER);
}
private JComponent createContentPane() {
JComponent contentPane = null;
String name = listElementNode.getName();
if (name.equals(ConsoleToggleConstants.SERVICE_TOPOLOGY)) {
contentPane = new ServiceTopology();
} else {
contentPane = blankPane;
}
return contentPane;
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.workspace;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.Box;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import com.nepxion.cots.twaver.element.TElementManager;
import com.nepxion.cots.twaver.element.TGroup;
import com.nepxion.cots.twaver.element.TGroupType;
import com.nepxion.cots.twaver.element.TNode;
import com.nepxion.cots.twaver.graph.TGraphManager;
import com.nepxion.discovery.console.desktop.controller.ServiceController;
import com.nepxion.discovery.console.desktop.entity.InstanceEntity;
import com.nepxion.discovery.console.desktop.icon.ConsoleIconFactory;
import com.nepxion.discovery.console.desktop.locale.ConsoleLocale;
import com.nepxion.discovery.console.desktop.workspace.common.UIUtil;
import com.nepxion.discovery.console.desktop.workspace.topology.AbstractTopology;
import com.nepxion.discovery.console.desktop.workspace.topology.TopologyEntity;
import com.nepxion.discovery.console.desktop.workspace.topology.TopologyEntityType;
import com.nepxion.swing.action.JSecurityAction;
import com.nepxion.swing.button.ButtonManager;
import com.nepxion.swing.button.JClassicButton;
import com.nepxion.swing.dialog.JOptionDialog;
import com.nepxion.swing.handle.HandleManager;
import com.nepxion.swing.icon.IconFactory;
import com.nepxion.swing.label.JBasicLabel;
import com.nepxion.swing.layout.filed.FiledLayout;
import com.nepxion.swing.layout.table.TableLayout;
import com.nepxion.swing.locale.SwingLocale;
import com.nepxion.swing.textfield.number.JNumberTextField;
public class ServiceTopology extends AbstractTopology {
private static final long serialVersionUID = 1L;
private int groupStartX = 120;
private int groupStartY = 200;
private int groupHorizontalGap = 280;
private int groupVerticalGap = 0;
private int nodeStartX = 0;
private int nodeStartY = 0;
private int nodeHorizontalGap = 110;
private int nodeVerticalGap = 80;
private TopologyEntity serviceGroupEntity = new TopologyEntity(TopologyEntityType.SERVICE, true, true);
private TopologyEntity serviceNodeEntity = new TopologyEntity(TopologyEntityType.SERVICE, false, false);
private Map<String, Point> groupLocationMap = new HashMap<String, Point>();
private LayoutDialog layoutDialog;
private Map<String, List<InstanceEntity>> instanceMap;
public ServiceTopology() {
initializeToolBar();
}
private void initializeToolBar() {
JToolBar toolBar = getGraph().getToolbar();
toolBar.addSeparator();
toolBar.add(Box.createHorizontalStrut(5));
toolBar.add(new JClassicButton(createShowTopologyAction()));
toolBar.addSeparator();
toolBar.add(createConfigButton(true));
ButtonManager.updateUI(toolBar);
setGroupAutoExpand(true);
setLinkAutoHide(true);
}
private void addServices(Map<String, List<InstanceEntity>> instanceMap) {
for (Map.Entry<String, List<InstanceEntity>> entry : instanceMap.entrySet()) {
addService(entry.getKey(), entry.getValue());
}
}
private void addService(String serviceId, List<InstanceEntity> instances) {
int count = groupLocationMap.size();
TGroup registryGroup = createGroup(serviceId, serviceGroupEntity, count, groupStartX, groupStartY, groupHorizontalGap, groupVerticalGap);
registryGroup.setGroupType(TGroupType.ELLIPSE_GROUP_TYPE.getType());
addGroup(registryGroup, serviceGroupEntity, serviceNodeEntity, instances);
}
private void addGroup(TGroup group, TopologyEntity groupEntity, TopologyEntity nodeEntity, List<InstanceEntity> instances) {
int count = 0;
if (CollectionUtils.isNotEmpty(instances)) {
for (int i = 0; i < instances.size(); i++) {
InstanceEntity instance = instances.get(i);
TNode node = createNode(ButtonManager.getHtmlText(instance.getHost() + ":" + instance.getPort() + (StringUtils.isNotEmpty(instance.getVersion()) ? "\n [V" + instance.getVersion() + " -> V2.0]" : "")), nodeEntity, i, nodeStartX, nodeStartY, nodeHorizontalGap, nodeVerticalGap);
node.setUserObject(instance);
group.addChild(node);
}
count = instances.size();
}
String groupName = group.getName();
group.setUserObject(groupName);
group.setDisplayName(ButtonManager.getHtmlText(groupName + " [" + count + "]"));
groupLocationMap.put(groupName, group.getLocation());
dataBox.addElement(group);
TElementManager.addGroupChildren(dataBox, group);
}
@SuppressWarnings("unchecked")
private void locateGroups() {
List<TGroup> groups = TElementManager.getGroups(dataBox);
for (TGroup group : groups) {
String groupName = group.getName();
if (groupLocationMap.containsKey(groupName)) {
group.setLocation(groupLocationMap.get(groupName));
}
}
}
private void showTopology(boolean reloaded) {
dataBox.clear();
groupLocationMap.clear();
if (reloaded) {
Map<String, List<InstanceEntity>> instanceMap = ServiceController.getInstanceMap();
this.instanceMap = instanceMap;
}
addServices(instanceMap);
locateGroups();
TGraphManager.setGroupExpand(graph, isGroupAutoExpand());
TGraphManager.setLinkVisible(graph, !isLinkAutoHide());
}
@Override
public void showLayout() {
if (layoutDialog == null) {
layoutDialog = new LayoutDialog();
}
layoutDialog.setToUI();
layoutDialog.setVisible(true);
boolean confirmed = layoutDialog.isConfirmed();
if (confirmed && !dataBox.isEmpty()) {
showTopology(false);
}
}
private JSecurityAction createShowTopologyAction() {
JSecurityAction action = new JSecurityAction(ConsoleLocale.getString("show_topology"), ConsoleIconFactory.getSwingIcon("component/ui_16.png"), ConsoleLocale.getString("show_topology")) {
private static final long serialVersionUID = 1L;
public void execute(ActionEvent e) {
showTopology(true);
}
};
return action;
}
private class LayoutDialog extends JOptionDialog {
private static final long serialVersionUID = 1L;
private JNumberTextField groupStartXTextField;
private JNumberTextField groupStartYTextField;
private JNumberTextField groupHorizontalGapTextField;
private JNumberTextField groupVerticalGapTextField;
private JNumberTextField nodeStartXTextField;
private JNumberTextField nodeStartYTextField;
private JNumberTextField nodeHorizontalGapTextField;
private JNumberTextField nodeVerticalGapTextField;
public LayoutDialog() {
super(HandleManager.getFrame(ServiceTopology.this), SwingLocale.getString("layout"), new Dimension(500, 330), true, false, true);
groupStartXTextField = new JNumberTextField(4, 0, 0, 10000);
groupStartYTextField = new JNumberTextField(4, 0, 0, 10000);
groupHorizontalGapTextField = new JNumberTextField(4, 0, 0, 10000);
groupVerticalGapTextField = new JNumberTextField(4, 0, 0, 10000);
nodeStartXTextField = new JNumberTextField(4, 0, 0, 10000);
nodeStartYTextField = new JNumberTextField(4, 0, 0, 10000);
nodeHorizontalGapTextField = new JNumberTextField(4, 0, 0, 10000);
nodeVerticalGapTextField = new JNumberTextField(4, 0, 0, 10000);
double[][] size = {
{ 100, TableLayout.FILL, 100, TableLayout.FILL },
{ TableLayout.PREFERRED, TableLayout.PREFERRED }
};
TableLayout tableLayout = new TableLayout(size);
tableLayout.setHGap(5);
tableLayout.setVGap(5);
JPanel groupPanel = new JPanel();
groupPanel.setLayout(tableLayout);
groupPanel.setBorder(UIUtil.createTitledBorder(ConsoleLocale.getString("group_layout")));
groupPanel.add(new JBasicLabel(ConsoleLocale.getString("start_x")), "0, 0");
groupPanel.add(groupStartXTextField, "1, 0");
groupPanel.add(new JBasicLabel(ConsoleLocale.getString("start_y")), "2, 0");
groupPanel.add(groupStartYTextField, "3, 0");
groupPanel.add(new JBasicLabel(ConsoleLocale.getString("horizontal_gap")), "0, 1");
groupPanel.add(groupHorizontalGapTextField, "1, 1");
groupPanel.add(new JBasicLabel(ConsoleLocale.getString("vertical_gap")), "2, 1");
groupPanel.add(groupVerticalGapTextField, "3, 1");
JPanel nodePanel = new JPanel();
nodePanel.setLayout(tableLayout);
nodePanel.setBorder(UIUtil.createTitledBorder(ConsoleLocale.getString("node_layout")));
nodePanel.add(new JBasicLabel(ConsoleLocale.getString("start_x")), "0, 0");
nodePanel.add(nodeStartXTextField, "1, 0");
nodePanel.add(new JBasicLabel(ConsoleLocale.getString("start_y")), "2, 0");
nodePanel.add(nodeStartYTextField, "3, 0");
nodePanel.add(new JBasicLabel(ConsoleLocale.getString("horizontal_gap")), "0, 1");
nodePanel.add(nodeHorizontalGapTextField, "1, 1");
nodePanel.add(new JBasicLabel(ConsoleLocale.getString("vertical_gap")), "2, 1");
nodePanel.add(nodeVerticalGapTextField, "3, 1");
JPanel panel = new JPanel();
panel.setLayout(new FiledLayout(FiledLayout.COLUMN, FiledLayout.FULL, 5));
panel.add(groupPanel);
panel.add(nodePanel);
setOption(YES_NO_OPTION);
setIcon(IconFactory.getSwingIcon("banner/navigator.png"));
setContent(panel);
}
@Override
public boolean confirm() {
return setFromUI();
}
@Override
public boolean cancel() {
return true;
}
public void setToUI() {
groupStartXTextField.setText(groupStartX + "");
groupStartYTextField.setText(groupStartY + "");
groupHorizontalGapTextField.setText(groupHorizontalGap + "");
groupVerticalGapTextField.setText(groupVerticalGap + "");
nodeStartXTextField.setText(nodeStartX + "");
nodeStartYTextField.setText(nodeStartY + "");
nodeHorizontalGapTextField.setText(nodeHorizontalGap + "");
nodeVerticalGapTextField.setText(nodeVerticalGap + "");
}
public boolean setFromUI() {
int groupStartX = 0;
int groupStartY = 0;
int groupHorizontalGap = 0;
int groupVerticalGap = 0;
int nodeStartX = 0;
int nodeStartY = 0;
int nodeHorizontalGap = 0;
int nodeVerticalGap = 0;
try {
groupStartX = Integer.parseInt(groupStartXTextField.getText());
groupStartY = Integer.parseInt(groupStartYTextField.getText());
groupHorizontalGap = Integer.parseInt(groupHorizontalGapTextField.getText());
groupVerticalGap = Integer.parseInt(groupVerticalGapTextField.getText());
nodeStartX = Integer.parseInt(nodeStartXTextField.getText());
nodeStartY = Integer.parseInt(nodeStartYTextField.getText());
nodeHorizontalGap = Integer.parseInt(nodeHorizontalGapTextField.getText());
nodeVerticalGap = Integer.parseInt(nodeVerticalGapTextField.getText());
} catch (NumberFormatException e) {
return false;
}
ServiceTopology.this.groupStartX = groupStartX;
ServiceTopology.this.groupStartY = groupStartY;
ServiceTopology.this.groupHorizontalGap = groupHorizontalGap;
ServiceTopology.this.groupVerticalGap = groupVerticalGap;
ServiceTopology.this.nodeStartX = nodeStartX;
ServiceTopology.this.nodeStartY = nodeStartY;
ServiceTopology.this.nodeHorizontalGap = nodeHorizontalGap;
ServiceTopology.this.nodeVerticalGap = nodeVerticalGap;
return true;
}
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.workspace.common;
/**
* <p>Title: Nepxion Thunder</p>
* <p>Description: Nepxion Thunder For Distribution</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import java.awt.Color;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import com.nepxion.discovery.console.desktop.context.UIContext;
import com.nepxion.swing.separator.JBasicSeparator;
public class UIUtil {
public static JBasicSeparator createSeparator() {
JBasicSeparator separator = new JBasicSeparator(JBasicSeparator.HORIZONTAL, JBasicSeparator.LOWERED_STYLE, -1);
separator.setBrightColor(new Color(197, 196, 198));
separator.setDarkColor(new Color(153, 152, 154));
return separator;
}
public static Border createTitledBorder(String title) {
return BorderFactory.createTitledBorder(null, title, TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, new Font(UIContext.getFontName(), Font.PLAIN, UIContext.getLargeFontSize()), new Color(64, 0, 0));
}
}
package com.nepxion.discovery.console.desktop.workspace.topology;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import twaver.GeoCoordinate;
import twaver.Node;
import twaver.TDataBox;
import twaver.TView;
import twaver.gis.GeographyMap;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import com.nepxion.cots.twaver.element.TElementManager;
import com.nepxion.cots.twaver.element.TGroup;
import com.nepxion.cots.twaver.element.TLink;
import com.nepxion.cots.twaver.element.TNode;
import com.nepxion.cots.twaver.gis.TGisGraph;
import com.nepxion.cots.twaver.graph.TGraph;
import com.nepxion.cots.twaver.graph.TGraphBackground;
import com.nepxion.cots.twaver.graph.TGraphController;
import com.nepxion.cots.twaver.graph.TGraphPointBackground;
import com.nepxion.cots.twaver.graph.TGraphPopupMenuGenerator;
import com.nepxion.cots.twaver.locale.TLocale;
import com.nepxion.discovery.console.desktop.context.UIContext;
import com.nepxion.discovery.console.desktop.icon.ConsoleIconFactory;
import com.nepxion.swing.action.JSecurityAction;
import com.nepxion.swing.button.JClassicMenuButton;
import com.nepxion.swing.locale.SwingLocale;
import com.nepxion.swing.menuitem.JBasicMenuItem;
import com.nepxion.swing.menuitem.JBasicRadioButtonMenuItem;
import com.nepxion.swing.popupmenu.JBasicPopupMenu;
public abstract class AbstractTopology extends JPanel {
private static final long serialVersionUID = 1L;
public static final String IMAGE_FOLDER = "/" + ConsoleIconFactory.ICON_FOLDER;
protected TGraph graph;
protected TDataBox dataBox = new TDataBox();
protected JBasicPopupMenu popupMenu;
protected JBasicMenuItem pinSelectedGroupMenuItem;
protected JBasicMenuItem pinSelectedNodeMenuItem;
protected JBasicRadioButtonMenuItem groupAutoExpandRadioButtonMenuItem;
protected JBasicRadioButtonMenuItem linkAutoHideRadioButtonMenuItem;
public AbstractTopology() {
setLayout(new BorderLayout());
add(createGraph());
// add(createGisGraph());
initializePopupMenu();
}
protected TGraph createGraph() {
if (graph == null) {
graph = new TGraph();
graph.setDataBox(dataBox);
graph.setGraphBackground(createBackground());
graph.getControlBarInternalFrame().setVisible(false);
}
return graph;
}
protected TGraph createGisGraph() {
if (graph == null) {
graph = new TGisGraph();
graph.setDataBox(dataBox);
graph.getControlBarInternalFrame().setVisible(false);
final TGisGraph gisGraph = (TGisGraph) graph;
GeographyMap map = gisGraph.getMap();
map.setZoom(16);
map.setCenterPoint(new GeoCoordinate(118.795896, 32.088683));
}
return graph;
}
protected TGraph getGraph() {
return graph;
}
protected TGraphBackground createBackground() {
return createBackground(null);
}
protected TGraphBackground createBackground(String title) {
TGraphBackground background = new TGraphBackground(Color.white, TGraphBackground.BLUE_STYLE_COLOR);
// TGraphBackground background = new TGraphBackground(Color.cyan, Color.black);
// background.setGradientFactory(TWaverConst.GRADIENT_LINE_S);
background.setTitleAlignment(TGraphPointBackground.TOP);
background.setTitle(title);
return background;
}
protected void initializePopupMenu() {
popupMenu = new JBasicPopupMenu();
pinSelectedGroupMenuItem = new JBasicMenuItem(TGraphController.getPinSelectedGroupAction(dataBox));
popupMenu.add(pinSelectedGroupMenuItem);
pinSelectedNodeMenuItem = new JBasicMenuItem(TGraphController.getPinSelectedNodeAction(dataBox));
popupMenu.add(pinSelectedNodeMenuItem);
new TGraphPopupMenuGenerator(graph) {
@Override
public JPopupMenu generate(TView view, MouseEvent event) {
return popupMenuGenerate();
}
};
}
protected JBasicPopupMenu popupMenuGenerate() {
TGroup group = TElementManager.getSelectedGroup(dataBox);
pinSelectedGroupMenuItem.setVisible(group != null);
TNode node = TElementManager.getSelectedNode(dataBox);
pinSelectedNodeMenuItem.setVisible(node != null);
if (group != null || node != null) {
return popupMenu;
}
return null;
}
protected JClassicMenuButton createConfigButton(boolean linkConfig) {
JBasicPopupMenu popupMenu = new JBasicPopupMenu();
JSecurityAction showLayoutAction = createShowLayoutAction();
popupMenu.add(new JBasicMenuItem(showLayoutAction));
popupMenu.addSeparator();
JSecurityAction groupExpandAction = TGraphController.getGroupExpandAction(graph);
groupExpandAction.setIcon(ConsoleIconFactory.getSwingIcon("rectangle_multi.png"));
popupMenu.add(new JBasicMenuItem(groupExpandAction));
JSecurityAction groupCollapseAction = TGraphController.getGroupCollapseAction(graph);
groupCollapseAction.setIcon(ConsoleIconFactory.getSwingIcon("rectangle_single.png"));
popupMenu.add(new JBasicMenuItem(groupCollapseAction));
groupAutoExpandRadioButtonMenuItem = new JBasicRadioButtonMenuItem(TLocale.getString("group_expand_auto"), TLocale.getString("group_expand_auto"));
popupMenu.add(groupAutoExpandRadioButtonMenuItem);
if (linkConfig) {
popupMenu.addSeparator();
JSecurityAction linkShowAction = TGraphController.getLinkShowAction(graph);
linkShowAction.setIcon(ConsoleIconFactory.getSwingIcon("netbean/arc_16.png"));
popupMenu.add(new JBasicMenuItem(linkShowAction));
JSecurityAction linkHideAction = TGraphController.getLinkHideAction(graph);
linkHideAction.setIcon(ConsoleIconFactory.getSwingIcon("netbean/arc_to_16.png"));
popupMenu.add(new JBasicMenuItem(linkHideAction));
linkAutoHideRadioButtonMenuItem = new JBasicRadioButtonMenuItem(TLocale.getString("link_hide_auto"), TLocale.getString("link_hide_auto"));
popupMenu.add(linkAutoHideRadioButtonMenuItem);
}
JClassicMenuButton button = new JClassicMenuButton(SwingLocale.getString("setting"), ConsoleIconFactory.getSwingIcon("property.png"), SwingLocale.getString("setting"));
button.setPopupMenu(popupMenu);
return button;
}
private JSecurityAction createShowLayoutAction() {
JSecurityAction action = new JSecurityAction(SwingLocale.getString("layout"), ConsoleIconFactory.getSwingIcon("netbean/clip_view_16.png"), SwingLocale.getString("layout")) {
private static final long serialVersionUID = 1L;
public void execute(ActionEvent e) {
showLayout();
}
};
return action;
}
protected void showLayout() {
}
protected boolean isGroupAutoExpand() {
if (groupAutoExpandRadioButtonMenuItem == null) {
return false;
}
return groupAutoExpandRadioButtonMenuItem.isSelected();
}
protected void setGroupAutoExpand(boolean expand) {
if (groupAutoExpandRadioButtonMenuItem == null) {
return;
}
groupAutoExpandRadioButtonMenuItem.setSelected(expand);
}
protected boolean isLinkAutoHide() {
if (linkAutoHideRadioButtonMenuItem == null) {
return false;
}
return linkAutoHideRadioButtonMenuItem.isSelected();
}
protected void setLinkAutoHide(boolean hide) {
if (linkAutoHideRadioButtonMenuItem == null) {
return;
}
linkAutoHideRadioButtonMenuItem.setSelected(hide);
}
protected TGroup createGroup(String name, TopologyEntity entity, int index, int startX, int startY, int horizontalGap, int verticalGap) {
String image = entity.getImage();
Point location = new Point(entity.isHorizontalPile() ? startX + index * horizontalGap : startX, entity.isHorizontalPile() ? startY : startY + index * verticalGap);
return createGroup(name, image, location);
}
protected TGroup createGroup(String name, TopologyEntity entity) {
String image = entity.getImage();
Point location = entity.getLocation();
return createGroup(name, image, location);
}
protected TGroup createGroup(String name, String image, Point location) {
TGroup group = new TGroup();
group.setName(name);
group.setImage(IMAGE_FOLDER + image);
group.putLabelFont(new Font(UIContext.getFontName(), Font.PLAIN, UIContext.getDefaultFontSize()));
group.setLocation(location);
return group;
}
protected TNode createNode(String name, TopologyEntity entity, int index, int startX, int startY, int horizontalGap, int verticalGap) {
String image = entity.getImage();
Point location = new Point(entity.isHorizontalPile() ? startX + index * horizontalGap : startX, entity.isHorizontalPile() ? startY : startY + index * verticalGap);
return createNode(name, image, location);
}
protected TNode createNode(String name, TopologyEntity entity) {
String image = entity.getImage();
Point location = entity.getLocation();
return createNode(name, image, location);
}
protected TNode createNode(String name, String image, Point location) {
TNode node = new TNode();
node.setName(name);
node.setImage(IMAGE_FOLDER + image);
node.putLabelFont(new Font(UIContext.getFontName(), Font.PLAIN, UIContext.getSmallFontSize()));
node.setLocation(location);
return node;
}
protected TLink createLink(Node fromNode, Node toNode) {
return createLink(fromNode, toNode, false);
}
protected TLink createLink(Node fromNode, Node toNode, boolean toArrow) {
TLink link = new TLink(fromNode, toNode);
link.putLinkToArrow(toArrow);
link.putLabelYOffset(-2);
link.putLabelFont(new Font(UIContext.getFontName(), Font.PLAIN, UIContext.getSmallFontSize()));
return link;
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.workspace.topology;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import java.awt.Point;
public class TopologyEntity {
public static final String REGISTRY_LARGE_IMAGE = "registry_48.png";
public static final String MQ_LARGE_IMAGE = "mq_48.png";
public static final String CACHE_LARGE_IMAGE = "cache_48.png";
public static final String LOGGER_LARGE_IMAGE = "logger_48.png";
public static final String SERVICE_LARGE_IMAGE = "service_48.png";
public static final String REFERENCE_LARGE_IMAGE = "reference_48.png";
public static final String REGISTRY_SMALL_IMAGE = "registry_32.png";
public static final String MQ_SMALL_IMAGE = "mq_32.png";
public static final String CACHE_SMALL_IMAGE = "cache_32.png";
public static final String LOGGER_SMALL_IMAGE = "logger_32.png";
public static final String SERVICE_SMALL_IMAGE = "service_32.png";
public static final String REFERENCE_SMALL_IMAGE = "reference_32.png";
private TopologyEntityType type;
private String image;
private Point location;
private boolean horizontalPile;
public TopologyEntity(TopologyEntityType type, boolean largeStyle, Point location) {
initialize(type, largeStyle);
this.location = location;
}
public TopologyEntity(TopologyEntityType type, boolean largeStyle, boolean horizontalPile) {
initialize(type, largeStyle);
this.horizontalPile = horizontalPile;
}
private void initialize(TopologyEntityType type, boolean largeStyle) {
this.type = type;
switch (type) {
case REGISTRY:
image = largeStyle ? REGISTRY_LARGE_IMAGE : REGISTRY_SMALL_IMAGE;
break;
case MQ:
image = largeStyle ? MQ_LARGE_IMAGE : MQ_SMALL_IMAGE;
break;
case CACHE:
image = largeStyle ? CACHE_LARGE_IMAGE : CACHE_SMALL_IMAGE;
break;
case LOGGER:
image = largeStyle ? LOGGER_LARGE_IMAGE : LOGGER_SMALL_IMAGE;
break;
case SERVICE:
image = largeStyle ? SERVICE_LARGE_IMAGE : SERVICE_SMALL_IMAGE;
break;
case REFERENCE:
image = largeStyle ? REFERENCE_LARGE_IMAGE : REFERENCE_SMALL_IMAGE;
break;
}
}
public TopologyEntityType getType() {
return type;
}
public String getImage() {
return image;
}
public Point getLocation() {
return location;
}
public boolean isHorizontalPile() {
return horizontalPile;
}
}
\ No newline at end of file
package com.nepxion.discovery.console.desktop.workspace.topology;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
public enum TopologyEntityType {
REGISTRY,
MQ,
CACHE,
LOGGER,
SERVICE,
REFERENCE
}
\ No newline at end of file
@echo on
@echo =============================================================
@echo $ $
@echo $ Encoding localizer $
@echo $ $
@echo $ $
@echo $ $
@echo $ Nepxion Technologies All Right Reserved $
@echo $ Copyright(C) 2015 $
@echo $ $
@echo =============================================================
@echo.
@echo off
@rem ======================================
@rem DOS Batch file to invoke the Swing UI
@rem ======================================
@title Encoding localizer
@color 0a
rem if "%JAVA_HOME%"=="" goto noJava
if "%JAVA_HOME%"=="" set JAVA_HOME=D:\JDK1.6.0
%JAVA_HOME%\bin\native2ascii -encoding gbk Locale.properties Locale_zh_CN.properties
\ No newline at end of file
title=Discovery服务治理控制台
navigator_bar=导航区
content_bar=工作区
service_control=服务治理
service_topology=服务拓扑
show_topology=显示拓扑图
group_layout=组布局
node_layout=节点布局
start_x=起始点X坐标
start_y=起始点Y坐标
horizontal_gap=水平间距
vertical_gap=垂直间距
initialize_component=初始化界面
initialize_component_failure=初始化界面失败
\ No newline at end of file
title=Discovery\u670d\u52a1\u6cbb\u7406\u63a7\u5236\u53f0
navigator_bar=\u5bfc\u822a\u533a
content_bar=\u5de5\u4f5c\u533a
service_control=\u670d\u52a1\u6cbb\u7406
service_topology=\u670d\u52a1\u62d3\u6251
show_topology=\u663e\u793a\u62d3\u6251\u56fe
group_layout=\u7ec4\u5e03\u5c40
node_layout=\u8282\u70b9\u5e03\u5c40
start_x=\u8d77\u59cb\u70b9X\u5750\u6807
start_y=\u8d77\u59cb\u70b9Y\u5750\u6807
horizontal_gap=\u6c34\u5e73\u95f4\u8ddd
vertical_gap=\u5782\u76f4\u95f4\u8ddd
initialize_component=\u521d\u59cb\u5316\u754c\u9762
initialize_component_failure=\u521d\u59cb\u5316\u754c\u9762\u5931\u8d25
url=http://localhost:2222/
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" monitorInterval="30">
<Appenders>
<Console name="stdout" target="SYSTEM_OUT">
<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%class:%line] - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<AsyncLogger name="com.nepxion.discovery.console.desktop" level="info" additivity="false" includeLocation="true">
<AppenderRef ref="stdout"/>
</AsyncLogger>
<AsyncRoot level="info" includeLocation="true">
<AppenderRef ref="stdout"/>
</AsyncRoot>
</Loggers>
</Configuration>
\ No newline at end of file
......@@ -18,6 +18,7 @@
<module>discovery-plugin-config-center</module>
<module>discovery-plugin-admin-center</module>
<module>discovery-console</module>
<module>discovery-console-desktop</module>
<module>discovery-plugin-starter-eureka</module>
<module>discovery-plugin-starter-consul</module>
<module>discovery-plugin-starter-zookeeper</module>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment