diff --git a/Kieker.WebGUI/lib/kieker-1.6-SNAPSHOT_emf.jar b/Kieker.WebGUI/lib/kieker-1.6-SNAPSHOT_emf.jar index 177ced9bf680c39239073c4a3ba63fbd87e65ac1..f0843203d315bb79a3cb532099ccad9ba42a78a3 100644 Binary files a/Kieker.WebGUI/lib/kieker-1.6-SNAPSHOT_emf.jar and b/Kieker.WebGUI/lib/kieker-1.6-SNAPSHOT_emf.jar differ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java index 9f4e7f69908be5b3e76ed830089a426460fdd00c..f3930baa4d48a7741444233915331913014dc827 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java @@ -25,9 +25,9 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.MalformedURLException; +import java.net.URL; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -46,7 +46,6 @@ import kieker.analysis.model.analysisMetaModel.MIFilter; import kieker.analysis.model.analysisMetaModel.MIInputPort; import kieker.analysis.model.analysisMetaModel.MIOutputPort; import kieker.analysis.model.analysisMetaModel.MIPlugin; -import kieker.analysis.model.analysisMetaModel.MIPort; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIProperty; import kieker.analysis.model.analysisMetaModel.MIReader; @@ -66,12 +65,8 @@ import kieker.analysis.repository.annotation.Repository; import kieker.common.configuration.Configuration; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; -import kieker.monitoring.core.registry.Registry; import kieker.webgui.beans.application.ProjectsBean; -import kieker.webgui.common.ConnectionFilterToFilter; -import kieker.webgui.common.ConnectionFilterToRepository; import kieker.webgui.common.FSManager; -import kieker.webgui.common.Global; import kieker.webgui.common.Pair; import kieker.webgui.common.PluginFinder; import kieker.webgui.common.exception.LibraryAlreadyExistingException; @@ -79,8 +74,6 @@ import kieker.webgui.common.exception.NewerProjectException; import org.primefaces.context.RequestContext; import org.primefaces.event.FileUploadEvent; -import org.primefaces.model.DefaultTreeNode; -import org.primefaces.model.TreeNode; import org.primefaces.model.UploadedFile; import org.eclipse.emf.common.util.EList; @@ -98,42 +91,6 @@ import org.eclipse.emf.ecore.EObject; @ManagedBean @ViewScoped public final class CurrentAnalysisEditorBean { - /** - * This is the javascript command to initialize the visual graph. - */ - private static final String JS_CMD_INIT_GRAPH = "var graph = GraphFlow(); graph.initGraph(null);"; - /** - * This is the javascript command for a node object. - */ - private static final String JS_CMD_NODE = "{\"id\":\"%s\", \"name\":\"%s\", \"nodeClass\":\"%s\", \"tooltip\":\"%s\"}"; - /** - * This is the javascript command for a port object. - */ - private static final String JS_CMD_PORT = "{\"name\":\"%s\",\"id\":\"%s\", \"tooltip\":\"%s\"}"; - /** - * This is the javascript type name for an input port. - */ - private static final String JS_CMD_PORT_TYPE_INPUT = "inputPort"; - /** - * This is the javascript command to add a filter to the graph. - */ - private static final String JS_CMD_ADD_FILTER = "graph.addFilter(%d, %d, %s,[%s],[%s],[%s]);"; - /** - * This is the javascript command to add a reader to the graph. - */ - private static final String JS_CMD_ADD_READER = "graph.addReader(%d, %d, %s,[%s],[%s]);"; - /** - * This is the javascript command to add a repository to the graph. - */ - private static final String JS_CMD_ADD_REPOSITORY = "graph.addRepository(%d, %d, %s,%s);"; - /** - * This is the javascript command to add an edge to the graph. - */ - private static final String JS_CMD_ADD_EDGE = "graph.addEdge(\"%s\", \"%s\");"; - /** - * This is the javascript command to redraw the command. - */ - private static final String JS_CMD_REFRESH_GRAPH = "graph.refresh();"; /** * This is the log for errors, exceptions etc. */ @@ -150,6 +107,10 @@ public final class CurrentAnalysisEditorBean { * This is the corresponding class loader to the project. It contains always the libraries within the lib-folder of the project. */ private ClassLoader classLoader; + /** + * This is the corresponding class loader to the project. It contains always the correct class loader. + */ + private PluginFinder pluginFinder; /** * This is the name of the stored project. It can be used as an identifier within the FS-Manager */ @@ -174,37 +135,16 @@ public final class CurrentAnalysisEditorBean { */ private final List<Class<?>> availableReaders = Collections.synchronizedList(new ArrayList<Class<?>>()); /** - * This map contains the mapping between the plugins and their ID. - */ - private Registry<MIPlugin> pluginMap = new Registry<MIPlugin>(); - /** - * This map contains the mapping between the ports and their ID. - */ - private Registry<MIPort> portMap = new Registry<MIPort>(); - /** - * This map contains the mapping between the repositories and their ID. - */ - private Registry<MIRepository> repositoryMap = new Registry<MIRepository>(); - /** - * This field contains the currently selected plugin. - */ - private MIPlugin selectedPlugin; - /** - * The currently selected repository. - */ - private MIRepository selectedRepository; - /** - * This list contains the currently available connections between filters. - */ - private final List<ConnectionFilterToFilter> filter2filterConnections = new ArrayList<ConnectionFilterToFilter>(); - /** - * This list contains the currently available connections between filters and repositories. + * This field contains the currently selected node (this can either be a plugin or a repository). */ - private final List<ConnectionFilterToRepository> filter2repositoryConnections = new ArrayList<ConnectionFilterToRepository>(); + private EObject selectedNode; @ManagedProperty(value = "#{projectsBean}") private ProjectsBean projectsBean; + @ManagedProperty(value = "#{currentAnalysisEditorGraphBean}") + private CurrentAnalysisEditorGraphBean currentAnalysisEditorGraphBean; + /** * Creates a new instance of this class. */ @@ -212,6 +152,25 @@ public final class CurrentAnalysisEditorBean { // No code necessary } + /** + * Getter for the attribute {@link CurrentAnalysisEditorBean#currentAnalysisEditorGraphBean}. + * + * @return Delivers the value of the attribute. + */ + public CurrentAnalysisEditorGraphBean getCurrentAnalysisEditorGraphBean() { + return this.currentAnalysisEditorGraphBean; + } + + /** + * Setter for the attribute {@link CurrentAnalysisEditorBean#currentAnalysisEditorGraphBean}. + * + * @param currentAnalysisEditorGraphBean + * The new value of the attribute. + */ + public void setCurrentAnalysisEditorGraphBean(final CurrentAnalysisEditorGraphBean currentAnalysisEditorGraphBean) { + this.currentAnalysisEditorGraphBean = currentAnalysisEditorGraphBean; + } + /** * Getter for the attribute {@link CurrentAnalysisEditorBean#projectsBean}. * @@ -264,7 +223,6 @@ public final class CurrentAnalysisEditorBean { // Make sure that the initialization will only be done for the init request. if (!FacesContext.getCurrentInstance().isPostback()) { this.project = this.projectsBean.openProject(this.projectName); - this.getConnectionsFromProject(); if (this.project != null) { // Remember the current time! This is important for the later comparison of the time stamps. @@ -275,102 +233,11 @@ public final class CurrentAnalysisEditorBean { this.addLibrariesToModel(); // Load the available readers, filters and repositories this.loadToolPalette(); - // Load the hashmaps to get the plugins and ports - this.intializeHashMaps(); } } } } - /** - * Assembles and returns the available components as a primefaces tree. Keep in mind that the tree is currently assembled every time this method is called. - * - * @return The tree with all available filters, readers and repositories. - */ - public TreeNode getAvailableComponentsAsRoot() { - synchronized (this) { - // Create the necessary roots - final TreeNode root = new DefaultTreeNode("Root", null); - final TreeNode readerRoot = new DefaultTreeNode("Reader", root); - final TreeNode filterRoot = new DefaultTreeNode("Filter", root); - final TreeNode repositoryRoot = new DefaultTreeNode("Repository", root); - - // Fill the tree - CurrentAnalysisEditorBean.assembleTree(readerRoot, this.availableReaders, "readerLeaf"); - CurrentAnalysisEditorBean.assembleTree(filterRoot, this.availableFilters, "filterLeaf"); - CurrentAnalysisEditorBean.assembleTree(repositoryRoot, this.availableRepositories, "repositoryLeaf"); - - return root; - } - } - - /** - * This method is used to "assemble" the tree containing the available components based on the given parameters. - * - * @param root - * The root-node used for the tree. - * @param clazzList - * The list of available classes which will be used to fill the tree. - * @param leafName - * The typename of the leaf-nodes. - */ - private static void assembleTree(final TreeNode root, final List<Class<?>> clazzList, final String leafName) { - final Map<String, TreeNode> map = new HashMap<String, TreeNode>(); // NOPMD (No concurrent access) - - for (final Class<?> clazz : clazzList) { - // Get the single components of the class name - final String className = clazz.getName(); - final String[] nameComponents = className.split("\\."); - final int compLen = nameComponents.length; - final StringBuilder fullQualifiedName = new StringBuilder(); - - TreeNode parent = root; - for (int i = 0; i < (compLen - 1); i++) { - fullQualifiedName.append(nameComponents[i]); - // Get the correct node if it exists already or create it if necessary - TreeNode node = map.get(fullQualifiedName.toString()); - - if (node == null) { - node = new DefaultTreeNode(nameComponents[i], parent); - map.put(fullQualifiedName.toString(), node); - } - - parent = node; - } - new DefaultTreeNode(leafName, clazz, parent); - } - } - - /** - * This method initializes the hash maps of the plugins, the ports and the repositories. The maps are cleaned beforehand. - */ - private void intializeHashMaps() { - synchronized (this) { - // Clear all maps - this.pluginMap = new Registry<MIPlugin>(); - this.portMap = new Registry<MIPort>(); - this.repositoryMap = new Registry<MIRepository>(); - - // Initialize the plugin map... - for (final MIPlugin plugin : this.project.getPlugins()) { - this.pluginMap.get(plugin); - // ..and the port map - for (final MIPort port : plugin.getOutputPorts()) { - this.portMap.get(port); - } - if (plugin instanceof MIFilter) { - for (final MIPort port : ((MIFilter) plugin).getInputPorts()) { - this.portMap.get(port); - } - } - } - // Now initialize the repository map - for (final MIRepository repository : this.project.getRepositories()) { - this.repositoryMap.get(repository); - } - } - } - /** * This method loads the list of available readers, filters and repositories, using the current libraries within the model. */ @@ -387,10 +254,17 @@ public final class CurrentAnalysisEditorBean { for (final MIDependency lib : this.project.getDependencies()) { this.addToToolPalette(lib); } + this.addKiekerToToolPalette(); } } } + private void addKiekerToToolPalette() { + synchronized (this) { + this.addToToolPalette(FSManager.getInstance().getKiekerURL()); + } + } + /** * This method adds all available readers, filters and repositories within the given library to the lists of this bean. * @@ -400,34 +274,52 @@ public final class CurrentAnalysisEditorBean { private void addToToolPalette(final MIDependency lib) { synchronized (this) { try { - final List<Class<AbstractRepository>> repositories = PluginFinder.getAllRepositoriesWithinJar(FSManager.getInstance().getURL(lib, this.projectName), - this.classLoader); - final List<Class<AbstractPlugin>> plugins = PluginFinder.getAllPluginsWithinJar(FSManager.getInstance().getURL(lib, this.projectName), - this.classLoader); - // Now run through the available classes and add all non-abstract classes to our lists - for (final Class<AbstractRepository> repository : repositories) { - if (!Modifier.isAbstract(repository.getModifiers())) { - this.availableRepositories.add(repository); - } - } - for (final Class<? extends AbstractPlugin> plugin : plugins) { - if (!Modifier.isAbstract(plugin.getModifiers())) { - // The following cast results in the unchecked-cast-warnings, but we know that the cast should be correct. - if (AbstractFilterPlugin.class.isAssignableFrom(plugin)) { - this.availableFilters.add(plugin); - } else { - if (AbstractReaderPlugin.class.isAssignableFrom(plugin)) { - this.availableReaders.add(plugin); - } - } - } - } + this.addToToolPalette(FSManager.getInstance().getURL(lib, this.projectName)); } catch (final MalformedURLException ex) { ex.printStackTrace(); } } } + /** + * This method adds all available readers, filters and repositories within the given library to the lists of this bean. + * + * @param url + * The library url used to load the plugins and repositories. + */ + private void addToToolPalette(final URL url) { + final Class<?> abstractFilterPluginClass; + final Class<?> abstractReaderPluginClass; + try { + abstractFilterPluginClass = this.classLoader.loadClass(AbstractFilterPlugin.class.getCanonicalName()); + abstractReaderPluginClass = this.classLoader.loadClass(AbstractReaderPlugin.class.getCanonicalName()); + } catch (final ClassNotFoundException ex) { + CurrentAnalysisEditorBean.LOG.error("Could not load class", ex); + return; + } + + final List<Class<AbstractRepository>> repositories = this.pluginFinder.getAllRepositoriesWithinJar(url); + final List<Class<AbstractPlugin>> plugins = this.pluginFinder.getAllPluginsWithinJar(url); + // Now run through the available classes and add all non-abstract classes to our lists + for (final Class<AbstractRepository> repository : repositories) { + if (!Modifier.isAbstract(repository.getModifiers())) { + this.availableRepositories.add(repository); + } + } + for (final Class<? extends AbstractPlugin> plugin : plugins) { + if (!Modifier.isAbstract(plugin.getModifiers())) { + // The following cast results in the unchecked-cast-warnings, but we know that the cast should be correct. + if (abstractFilterPluginClass.isAssignableFrom(plugin)) { + this.availableFilters.add(plugin); + } else { + if (abstractReaderPluginClass.isAssignableFrom(plugin)) { + this.availableReaders.add(plugin); + } + } + } + } + } + /** * This method takes all libraries from the lib-folder and adds them to the in-memory-model. */ @@ -448,6 +340,14 @@ public final class CurrentAnalysisEditorBean { private void reloadClassLoader() { synchronized (this) { this.classLoader = FSManager.getInstance().getClassLoader(this.projectName); + try { + this.pluginFinder = new PluginFinder(this.classLoader); + } catch (final ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (final NullPointerException ex) { + ex.printStackTrace(); + } } } @@ -482,32 +382,6 @@ public final class CurrentAnalysisEditorBean { } } - /** - * This method clears the bean. In other words: The stored project is set to null and it will return the page of the project overview for navigation purposes. - * - * @return The name of the page of the project overview. - */ - public String clearProject() { - synchronized (this) { - this.project = null; // NOPMD - this.projectName = null; // NOPMD - this.classLoader = null; // NOPMD - this.selectedPlugin = null; // NOPMD - this.selectedRepository = null; // NOPMD - this.timeStamp = 0; - this.availableFilters.clear(); - this.availableReaders.clear(); - this.availableRepositories.clear(); - this.pluginMap = new Registry<MIPlugin>(); - this.portMap = new Registry<MIPort>(); - this.repositoryMap = new Registry<MIRepository>(); - this.filter2filterConnections.clear(); - this.filter2repositoryConnections.clear(); - } - - return Global.PAGE_PROJECT_OVERVIEW; - } - /** * This method can be used to get the description of an {@link AbstractPlugin}- or an {@link AbstractRepository}-class. The description is read via the * annotation. @@ -971,18 +845,10 @@ public final class CurrentAnalysisEditorBean { // Make sure that everything has been loaded correctly. If something went wrong, we don't add the component to our model if (check) { synchronized (this) { - // Add it to the project + // Add it to the project - and to the graph this.project.getRepositories().add(repository); - this.repositoryMap.get(repository); - - // Add the element to the graph - final RequestContext context = RequestContext.getCurrentInstance(); - - final int pos = ((this.project.getRepositories().size() - 1) * 100) - 250; - final String repoPort = String.format(CurrentAnalysisEditorBean.JS_CMD_PORT, CurrentAnalysisEditorBean.JS_CMD_PORT_TYPE_INPUT, "ip1", "N/A"); - context.execute(String.format(CurrentAnalysisEditorBean.JS_CMD_ADD_REPOSITORY, 0, pos, this.assembleGraphString(repository), repoPort)); - - context.execute(CurrentAnalysisEditorBean.JS_CMD_REFRESH_GRAPH); + this.currentAnalysisEditorGraphBean.addRepository(repository); + this.currentAnalysisEditorGraphBean.refreshGraph(); } } } @@ -1012,143 +878,16 @@ public final class CurrentAnalysisEditorBean { // Make sure that everything has been loaded correctly. If something went wrong, we don't add the component to our model if (check) { synchronized (this) { - // Add it to the project and don't forget to add the ports. + // Add it to the project this.project.getPlugins().add(plugin); - this.pluginMap.get(plugin); - for (final MIPort port : plugin.getOutputPorts()) { - this.portMap.get(port); - } - if (plugin instanceof MIFilter) { - for (final MIPort port : ((MIFilter) plugin).getInputPorts()) { - this.portMap.get(port); - } - } - - // Make sure the user can edit the repository connections. - final EList<MIRepositoryConnector> mConnectors = plugin.getRepositories(); - for (final MIRepositoryConnector mConnector : mConnectors) { - this.filter2repositoryConnections.add(new ConnectionFilterToRepository(plugin, mConnector.getRepository(), mConnector)); - } // Add the element to the graph - final RequestContext context = RequestContext.getCurrentInstance(); - - final int pos = (this.project.getPlugins().size() - 1) * 100; if (plugin instanceof MIReader) { - context.execute(String.format(CurrentAnalysisEditorBean.JS_CMD_ADD_READER, pos, pos, this.assembleGraphString(plugin), - this.assembleGraphRepositoryPortString(plugin), this.assembleGraphOuputPortString(plugin))); + this.currentAnalysisEditorGraphBean.addReader((MIReader) plugin); } else { - context.execute(String.format(CurrentAnalysisEditorBean.JS_CMD_ADD_FILTER, pos, pos, this.assembleGraphString(plugin), - this.assembleGraphRepositoryPortString(plugin), this.assembleGraphInputPortString((MIFilter) plugin), - this.assembleGraphOuputPortString(plugin))); - } - - context.execute(CurrentAnalysisEditorBean.JS_CMD_REFRESH_GRAPH); - } - } - } - - /** - * This method removes the given repository from the project. If it is also the currently selected repository, it will be deselected. - * - * @param repository - * The repository to be removed from the project. - */ - public void removeRepository(final MIRepository repository) { - synchronized (this) { - this.project.getRepositories().remove(repository); - - // Remove the corresponding repositories from the connections - final List<ConnectionFilterToRepository> fRDelList = new ArrayList<ConnectionFilterToRepository>(); - for (final ConnectionFilterToRepository conn : this.filter2repositoryConnections) { - if (conn.getDestination() == repository) { - fRDelList.add(conn); + this.currentAnalysisEditorGraphBean.addFilter((MIFilter) plugin); } - } - - // Remove them from the project as well - for (final ConnectionFilterToRepository conn : fRDelList) { - conn.getOutputPort().setRepository(null); - } - - this.repositoryMap.remove(repository); - - if (this.selectedRepository == repository) { - this.selectedRepository = null; // NOPMD - } - } - } - - /** - * Uses the given plugin to remove the corresponding connections (to other plugins or repositories) from the current project. - * - * @param plugin - * The plugin whose connections have to be removed. - */ - private void removeCorrespondingConnections(final MIPlugin plugin) { - synchronized (this) { - final List<ConnectionFilterToFilter> ffDelList = new ArrayList<ConnectionFilterToFilter>(); - for (final ConnectionFilterToFilter conn : this.filter2filterConnections) { - if ((conn.getSource() == plugin) || (conn.getDestination() == plugin)) { - ffDelList.add(conn); - } - } - this.filter2filterConnections.removeAll(ffDelList); - - // Remove them from the project as well - for (final ConnectionFilterToFilter conn : ffDelList) { - if (conn.getDestination() == plugin) { - conn.getOutputPort().getSubscribers().remove(conn.getInputPort()); - } - } - - final List<ConnectionFilterToRepository> fRDelList = new ArrayList<ConnectionFilterToRepository>(); - for (final ConnectionFilterToRepository conn : this.filter2repositoryConnections) { - if (conn.getSource() == plugin) { - fRDelList.add(conn); - } - } - this.filter2repositoryConnections.removeAll(fRDelList); - } - } - - /** - * Uses the given plugin to remove the corresponding ports from the current project. - * - * @param plugin - * The plugin whose ports have to be removed. - */ - private void removeCorrespondingPorts(final MIPlugin plugin) { - synchronized (this) { - // Remove the ports from the registry - for (final MIPort mPort : plugin.getOutputPorts()) { - this.portMap.remove(mPort); - } - // Remove the ports from the project - if (plugin instanceof MIFilter) { - for (final MIPort mPort : ((MIFilter) plugin).getInputPorts()) { - this.portMap.remove(mPort); - } - } - } - } - - /** - * This method removes the given plugin from the project. If it is also the currently selected plugin, it will be deselected. - * - * @param plugin - * The plugin to be removed from the project. - */ - public void removePlugin(final MIPlugin plugin) { - synchronized (this) { - this.project.getPlugins().remove(plugin); - this.pluginMap.remove(plugin); - - this.removeCorrespondingConnections(plugin); - this.removeCorrespondingPorts(plugin); - - if (this.selectedPlugin == plugin) { - this.selectedPlugin = null; // NOPMD + this.currentAnalysisEditorGraphBean.refreshGraph(); } } } @@ -1160,37 +899,7 @@ public final class CurrentAnalysisEditorBean { */ public EObject getSelectedPlugin() { synchronized (this) { - if (this.selectedPlugin != null) { - return this.selectedPlugin; - } else { - return this.selectedRepository; - } - } - } - - /** - * This method sets the currently selected plugin. The selected repository is set automatically to null. - * - * @param selectedPlugin - * The new selection. - */ - public void setSelectedPlugin(final MIPlugin selectedPlugin) { - synchronized (this) { - this.selectedPlugin = selectedPlugin; - this.selectedRepository = null; // NOPMD - } - } - - /** - * This method sets the currently selected repository. The selected plugin is set automatically to null. - * - * @param selectedRepository - * The new selection. - */ - public void setSelectedRepository(final MIRepository selectedRepository) { - synchronized (this) { - this.selectedRepository = selectedRepository; - this.selectedPlugin = null; // NOPMD + return this.selectedNode; } } @@ -1210,10 +919,10 @@ public final class CurrentAnalysisEditorBean { result.add("ClassName"); // Get the original properties of the plugin - if (this.selectedPlugin != null) { - result.addAll(this.selectedPlugin.getProperties()); + if (this.selectedNode instanceof MIPlugin) { + result.addAll(((MIPlugin) this.selectedNode).getProperties()); } else { - result.addAll(this.selectedRepository.getProperties()); + result.addAll(((MIRepository) this.selectedNode).getProperties()); } return result; @@ -1241,72 +950,6 @@ public final class CurrentAnalysisEditorBean { } } - /** - * This method extracts the connections between the filters from the current main project. - */ - private void getConnectionsFromProject() { - synchronized (this) { - this.filter2filterConnections.clear(); - this.filter2repositoryConnections.clear(); - - if (this.project != null) { - final EList<MIPlugin> mPlugins = this.project.getPlugins(); - - for (final MIPlugin mPlugin : mPlugins) { - final EList<MIOutputPort> mOutputPorts = mPlugin.getOutputPorts(); - for (final MIOutputPort mOutputPort : mOutputPorts) { - final EList<MIInputPort> mInputPorts = mOutputPort.getSubscribers(); - for (final MIInputPort mInputPort : mInputPorts) { - this.filter2filterConnections.add(new ConnectionFilterToFilter(mPlugin, mInputPort.getParent(), mInputPort, mOutputPort)); - } - } - - final EList<MIRepositoryConnector> mConnectors = mPlugin.getRepositories(); - for (final MIRepositoryConnector mConnector : mConnectors) { - this.filter2repositoryConnections.add(new ConnectionFilterToRepository(mPlugin, mConnector.getRepository(), mConnector)); - } - } - } - } - } - - /** - * Delivers the connections (between the filters) within the current main project. - * - * @return A list containing all available connections. - */ - public List<ConnectionFilterToFilter> getFilterConnections() { - return this.filter2filterConnections; - } - - /** - * Delivers the connections (between filters and repositories) within the current main project. - * - * @return A list containing all available connections. - */ - public List<ConnectionFilterToRepository> getRepoConnections() { - return this.filter2repositoryConnections; - } - - /** - * Delivers the <b>valid</b> connections (between filters and repositories) within the current main project. - * - * @return A list containing all available and valid connections. - */ - public List<ConnectionFilterToRepository> getValidRepoConnections() { - final List<ConnectionFilterToRepository> list = new ArrayList<ConnectionFilterToRepository>(); - - synchronized (this) { - for (final ConnectionFilterToRepository conn : this.filter2repositoryConnections) { - if (conn.isValid()) { - list.add(conn); - } - } - } - - return list; - } - /** * Delivers all available repositories. * @@ -1325,56 +968,14 @@ public final class CurrentAnalysisEditorBean { */ public String getCurrentPluginName() { synchronized (this) { - if (this.selectedPlugin != null) { - return this.selectedPlugin.getName(); - } else { - return this.selectedRepository.getName(); - } - } - } - - /** - * Delivers the valid connections (between the filters) within the current main project. - * - * @return A list containing all available and valid connections. - */ - public List<ConnectionFilterToFilter> getValidConnections() { - synchronized (this) { - final List<ConnectionFilterToFilter> validConnections = new ArrayList<ConnectionFilterToFilter>(); - final List<ConnectionFilterToFilter> availableConnections = this.getFilterConnections(); - - for (final ConnectionFilterToFilter connection : availableConnections) { - if (connection.isValid()) { - validConnections.add(connection); - } - } - - return validConnections; - } - } - - /** - * This method adds an empty connection to the current main project. - */ - public void addConnection() { - this.filter2filterConnections.add(new ConnectionFilterToFilter(null, null, null, null)); - } - - /** - * This method "submits" the current connections to the main project (In other words: The connections will be stored within the main project). - */ - public void submitConnections() { - synchronized (this) { - for (final ConnectionFilterToFilter connection : this.filter2filterConnections) { - if (connection.isValid()) { - connection.getOutputPort().getSubscribers().add(connection.getInputPort()); - } - } - - for (final ConnectionFilterToRepository connection : this.filter2repositoryConnections) { - if (connection.isValid()) { - connection.getOutputPort().setRepository(connection.getDestination()); + if (this.selectedNode != null) { + if (this.selectedNode instanceof MIPlugin) { + return ((MIPlugin) this.selectedNode).getName(); + } else { + return ((MIRepository) this.selectedNode).getName(); } + } else { + return ""; } } } @@ -1391,265 +992,46 @@ public final class CurrentAnalysisEditorBean { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, "", msg)); } - /** - * Delivers the id which the plugin has in the plugin map of this bean. - * - * @param plugin - * The plugin whose id should be delivered. - * @return The id of the plugin. - */ - public int getPluginID(final MIPlugin plugin) { - return this.pluginMap.get(plugin); - } - - /** - * Delivers the id which the repository has in the repository map of this bean. - * - * @param repository - * The repository whose id should be delivered. - * @return The id of the repository. - */ - public int getRepositoryID(final MIRepository repository) { - return this.repositoryMap.get(repository); - } - - /** - * Delivers the id which the port has in the port map of this bean. - * - * @param port - * The port whose id should be delivered. - * @return The id of the port. - */ - public int getPortID(final MIPort port) { - return this.portMap.get(port); - } - - /** - * This method searches a plugin by name (the name should be delivered using the toString-method of the object). - * - * @param string - * The name of the plugin. - * @return The plugin with the given name if it exists, null otherwise. - */ - public MIPlugin getPluginByID(final String string) { - return this.pluginMap.get(Integer.parseInt(string)); - } - - /** - * This method searches a port by name (the name should be delivered using the toString-method of the object). - * - * @param string - * The name of the port. - * @return The port with the given name if it exists, null otherwise. - */ - public MIPort getPortByID(final String string) { - return this.portMap.get(Integer.parseInt(string)); - } - - /** - * This method searches a repository by name (the name should be delivered using the toString-method of the object). - * - * @param string - * The name of the repository. - * @return The plugin with the given name if it exists, null otherwise. - */ - public MIRepository getRepositoryByID(final String string) { - return this.repositoryMap.get(Integer.parseInt(string)); - } - /** * This method initializes the modified jit-graph by delivering the necessary javascript commands to the client. It prints all current existing plugins, * repositories and their connections. All further components will be added mostly by other methods. */ public void initializeGraph() { - final RequestContext context = RequestContext.getCurrentInstance(); - // Make sure that the graph exists in the first place - context.execute(CurrentAnalysisEditorBean.JS_CMD_INIT_GRAPH); - // Initialize the listener for the clicks on the components - context.execute("graph.addListener(\"onClick\", nodeClickListener);"); - - // Paint all necessary components - this.initializeGraphPlugins(); - this.initializeGraphRepositories(); - this.initializeGraphConnections(); - - // Repaint the whole graph to make sure that everything will be shown. - context.execute(CurrentAnalysisEditorBean.JS_CMD_REFRESH_GRAPH); - } + // Make sure that the currentAnalysisEditorGraphBean knows "this" as well. + this.currentAnalysisEditorGraphBean.setCurrentAnalysisEditorBean(this); - /** - * This method initializes the modified jit-grpah by delivering the necessary javascript commands to paint the connections between the components. - */ - private void initializeGraphConnections() { - final RequestContext context = RequestContext.getCurrentInstance(); - - // First the connections between the filters - for (final ConnectionFilterToFilter connection : this.filter2filterConnections) { - context.execute(String.format(CurrentAnalysisEditorBean.JS_CMD_ADD_EDGE, this.assembleGraphPortID(connection.getSource(), connection.getOutputPort()), - this.assembleGraphPortID(connection.getDestination(), connection.getInputPort()))); - } + // Initialize the graph + this.currentAnalysisEditorGraphBean.initGraph(); - // TODO Now the connections between filters and repositories - } - - public void nodeClicked() { - final Map<String, String> paramMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); - final String clickedNodeType = paramMap.get("type"); - final String clickedNodeID = paramMap.get("ID"); - - // Select the correct plugin/repository, based on type and ID - if ("Filter".equalsIgnoreCase(clickedNodeType) || "Reader".equalsIgnoreCase(clickedNodeType)) { - // Try to find the ID as a filter/reader - this.setSelectedPlugin(this.pluginMap.get(Integer.parseInt(clickedNodeID))); - } else { - // Try to find the ID as a repository - this.setSelectedRepository(this.repositoryMap.get(Integer.parseInt(clickedNodeID))); - } - } - - /** - * This method initializes the modified jit-graph by delivering the necessary javascript commands to paint the repository components. - */ - private void initializeGraphRepositories() { - final RequestContext context = RequestContext.getCurrentInstance(); - - int posCounter = 0; - for (final MIRepository repository : this.project.getRepositories()) { - final int pos = (posCounter * 100) - 250; - final String repoPort = String.format(CurrentAnalysisEditorBean.JS_CMD_PORT, CurrentAnalysisEditorBean.JS_CMD_PORT_TYPE_INPUT, "ip1", "N/A"); - context.execute(String.format(CurrentAnalysisEditorBean.JS_CMD_ADD_REPOSITORY, 0, pos, this.assembleGraphString(repository), repoPort)); - posCounter++; - } - } - - /** - * This method initializes the modified jit-graph by delivering the necessary javascript commands to paint the plugin components. - */ - private void initializeGraphPlugins() { - final RequestContext context = RequestContext.getCurrentInstance(); - - int posCounter = 0; + // Initialize the reader, filter and repositories for (final MIPlugin plugin : this.project.getPlugins()) { - final int pos = posCounter * 100; if (plugin instanceof MIReader) { - context.execute(String.format(CurrentAnalysisEditorBean.JS_CMD_ADD_READER, pos, pos, this.assembleGraphString(plugin), - this.assembleGraphRepositoryPortString(plugin), this.assembleGraphOuputPortString(plugin))); + this.currentAnalysisEditorGraphBean.addReader((MIReader) plugin); } else { - context.execute(String.format(CurrentAnalysisEditorBean.JS_CMD_ADD_FILTER, pos, pos, this.assembleGraphString(plugin), - this.assembleGraphRepositoryPortString(plugin), this.assembleGraphInputPortString((MIFilter) plugin), - this.assembleGraphOuputPortString(plugin))); + this.currentAnalysisEditorGraphBean.addFilter((MIFilter) plugin); } - posCounter++; } - } - - /** - * This method assembles the string containing the given ports. - * - * @param ports - * The ports to be used within the string command. - * @return A string containing the JS commands to create the ports. - */ - private String assembleGraphPortString(final EList<? extends MIPort> ports) { - final StringBuilder builder = new StringBuilder(); - final int len = ports.size(); - - for (int i = 0; i < len; i++) { - final MIPort port = ports.get(i); - - if (i != 0) { - builder.append(','); - } - - builder.append(String.format(CurrentAnalysisEditorBean.JS_CMD_PORT, port.getName(), this.portMap.get(port), port.getName())); + for (final MIRepository repository : this.project.getRepositories()) { + this.currentAnalysisEditorGraphBean.addRepository(repository); } - return builder.toString(); - } - - /** - * This method assembles the string containing the available repository ports of the given plugin. - * - * @param plugin - * The plugin whose repository ports will be used. - * @return A string containing the JS commands to create the repository ports. - */ - private String assembleGraphRepositoryPortString(final MIPlugin plugin) { - final StringBuilder builder = new StringBuilder(); - final int len = plugin.getRepositories().size(); - - for (int i = 0; i < len; i++) { - final MIRepositoryConnector port = plugin.getRepositories().get(i); - - if (i != 0) { - builder.append(','); + // Now initialize the connections between filters + for (final MIPlugin plugin : this.project.getPlugins()) { + for (final MIOutputPort oPort : plugin.getOutputPorts()) { + for (final MIInputPort iPort : oPort.getSubscribers()) { + this.currentAnalysisEditorGraphBean.addConnection(plugin, iPort.getParent(), oPort, iPort); + } } - - builder.append(String.format(CurrentAnalysisEditorBean.JS_CMD_PORT, port.getName(), port.getName(), port.getName())); } - return builder.toString(); + // Repaint the graph + this.currentAnalysisEditorGraphBean.refreshGraph(); } - /** - * This method assembles the string containing the available input ports of the given filter. - * - * @param filter - * The filter whose input ports will be used. - * @return A string containing the JS commands to create the input ports. - */ - private String assembleGraphInputPortString(final MIFilter filter) { - return this.assembleGraphPortString(filter.getInputPorts()); - } - - /** - * This method assembles the string containing the available output ports of the given plugin. - * - * @param plugin - * The plugin whose output ports will be used. - * @return A string containing the JS commands to create the output ports. - */ - private String assembleGraphOuputPortString(final MIPlugin plugin) { - return this.assembleGraphPortString(plugin.getOutputPorts()); - } - - /** - * This method assembles the ID of the port for the graph based on the given parameters. - * - * @param plugin - * The parent plugin of the port. - * @param port - * The port itself. - * @return The ID for the port within the graph - */ - private String assembleGraphPortID(final MIPlugin plugin, final MIPort port) { - return this.pluginMap.get(plugin) + "_" + this.portMap.get(port); - } - - /** - * Assembles a human-readable string of the given repository, which can also be used as a graph ID. - * - * @param repository - * The repository whose ID should be delivered. - * @return A human readable ID. - */ - private String assembleGraphString(final MIRepository repository) { - final String className = repository.getClassname(); - final String shortName = className.substring(className.lastIndexOf('.') + 1); - return String.format(CurrentAnalysisEditorBean.JS_CMD_NODE, this.repositoryMap.get(repository), repository.getName(), shortName, className); - } - - /** - * Assembles a human-readable string of the given plugin, which can also be used as a graph ID. - * - * @param plugin - * The plugin whose ID should be delivered. - * @return A human readable ID. - */ - private String assembleGraphString(final MIPlugin plugin) { - final String className = plugin.getClassname(); - final String shortName = className.substring(className.lastIndexOf('.') + 1); - return String.format(CurrentAnalysisEditorBean.JS_CMD_NODE, this.pluginMap.get(plugin), plugin.getName(), shortName, className); + public void nodeSelected(final EObject selectedNode) { + synchronized (this) { + this.selectedNode = selectedNode; + } } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorGraphBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorGraphBean.java new file mode 100644 index 0000000000000000000000000000000000000000..3f676a8ef3f077c5333f2a73373f9258eac55680 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorGraphBean.java @@ -0,0 +1,316 @@ +/*************************************************************************** + * Copyright 2012 by + * + Christian-Albrechts-University of Kiel + * + Department of Computer Science + * + Software Engineering Group + * and others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + +package kieker.webgui.beans.view; + +import java.util.Map; + +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ViewScoped; +import javax.faces.context.FacesContext; + +import kieker.analysis.model.analysisMetaModel.MIFilter; +import kieker.analysis.model.analysisMetaModel.MIInputPort; +import kieker.analysis.model.analysisMetaModel.MIOutputPort; +import kieker.analysis.model.analysisMetaModel.MIPlugin; +import kieker.analysis.model.analysisMetaModel.MIPort; +import kieker.analysis.model.analysisMetaModel.MIReader; +import kieker.analysis.model.analysisMetaModel.MIRepository; +import kieker.analysis.model.analysisMetaModel.MIRepositoryConnector; +import kieker.monitoring.core.registry.Registry; + +import org.primefaces.context.RequestContext; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; + +/** + * The {@link CurrentAnalysisEditorGraphBean} contains the necessary data behind an graph of the analysis editor. It provides various methods to manipulate the + * current graph.<br> + * The class is a JSF managed bean with view scope to make sure that one user (even in one session) can open multiple projects at a time without causing any + * problems. + * + * @author Nils Christian Ehmke + * @version 1.0 + */ +@ManagedBean +@ViewScoped +public class CurrentAnalysisEditorGraphBean { + /** + * This is the javascript code to initialize the visual graph. + */ + private static final String JS_CMD_INIT_GRAPH = "var graph = GraphFlow(); graph.initGraph(null);"; + /** + * This is the javasscript code to add the click listener to the graph. + */ + private static final String JS_CMD_ADD_CLICK_LISTENER = "graph.addListener(\"onClick\", nodeClickListener);"; + /** + * This is the javascript code for a node object. + */ + private static final String JS_CMD_NODE = "{\"id\":\"%s\", \"name\":\"%s\", \"nodeClass\":\"%s\", \"tooltip\":\"%s\"}"; + /** + * This is the javascript code for a port object. + */ + private static final String JS_CMD_PORT = "{\"name\":\"%s\",\"id\":\"%s\", \"tooltip\":\"%s\"}"; + /** + * This is the javascript type name for an input port. + */ + private static final String JS_CMD_PORT_TYPE_INPUT = "inputPort"; + /** + * This is the javascript code to add a filter to the graph. + */ + private static final String JS_CMD_ADD_FILTER = "graph.addFilter(%d, %d, %s,[%s],[%s],[%s]);"; + /** + * This is the javascript code to add a reader to the graph. + */ + private static final String JS_CMD_ADD_READER = "graph.addReader(%d, %d, %s,[%s],[%s]);"; + /** + * This is the javascript code to add a repository to the graph. + */ + private static final String JS_CMD_ADD_REPOSITORY = "graph.addRepository(%d, %d, %s,%s);"; + /** + * This is the javascript code to add an edge to the graph. + */ + private static final String JS_CMD_ADD_EDGE = "graph.addEdge(\"%s\", \"%s\");"; + /** + * This is the javascript code to redraw the command. + */ + private static final String JS_CMD_REFRESH_GRAPH = "graph.refresh();"; + /** + * This map contains all components (plugins, repositories and ports) within the graph to identify them with a unique ID. + */ + private final Registry<EObject> componentMap = new Registry<EObject>(); + + private CurrentAnalysisEditorBean currentAnalysisEditorBean; + + /** + * Creates a new instance of this class. + */ + public CurrentAnalysisEditorGraphBean() { + // No code necessary + } + + /** + * Initializes the graph. + */ + public void initGraph() { + RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_INIT_GRAPH); + RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_CLICK_LISTENER); + } + + /** + * Refreshes the graph after changes have been made. + */ + public void refreshGraph() { + RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_REFRESH_GRAPH); + } + + /** + * This method adds a filter to the current graph. + * + * @param filter + * The filter which should be added to the graph. + */ + public void addFilter(final MIFilter filter) { + RequestContext.getCurrentInstance().execute(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_FILTER, 0, 0, this.assembleGraphString(filter), + this.assembleGraphRepositoryPortString(filter), this.assembleGraphInputPortString(filter), this.assembleGraphOuputPortString(filter))); + } + + /** + * This method adds a reader to the current graph. + * + * @param reader + * The reader which should be added to the graph. + */ + public void addReader(final MIReader reader) { + RequestContext.getCurrentInstance().execute(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_READER, 0, 0, this.assembleGraphString(reader), + this.assembleGraphRepositoryPortString(reader), this.assembleGraphOuputPortString(reader))); + } + + /** + * This method adds a repository to the current graph. + * + * @param repository + * The repository which should be added to the graph. + */ + public void addRepository(final MIRepository repository) { + final String repoPort = String.format(CurrentAnalysisEditorGraphBean.JS_CMD_PORT, CurrentAnalysisEditorGraphBean.JS_CMD_PORT_TYPE_INPUT, "ip1", "N/A"); + RequestContext.getCurrentInstance().execute(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_REPOSITORY, 0, 0, this.assembleGraphString(repository), + repoPort)); + } + + /** + * This method adds a connection between two filters to the graph. + * + * @param source + * The source plugin. + * @param destination + * The destination plugin. + * @param outputPort + * The output port. + * @param inputPort + * The input port. + */ + public void addConnection(final MIPlugin source, final MIPlugin destination, final MIOutputPort outputPort, final MIInputPort inputPort) { + RequestContext.getCurrentInstance().execute(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_EDGE, this.assembleGraphPortID(source, outputPort), + this.assembleGraphPortID(destination, inputPort))); + } + + /** + * This method assembles the string containing the given ports. + * + * @param ports + * The ports to be used within the string command. + * @return A string containing the JS commands to create the ports. + */ + private String assembleGraphPortString(final EList<? extends MIPort> ports) { + + final StringBuilder builder = new StringBuilder(); + final int len = ports.size(); + + for (int i = 0; i < len; i++) { + final MIPort port = ports.get(i); + + if (i != 0) { + builder.append(','); + } + + builder.append(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_PORT, port.getName(), this.componentMap.get(port), port.getName())); + } + + return builder.toString(); + + } + + /** + * This method assembles the string containing the available repository ports of the given plugin. + * + * @param plugin + * The plugin whose repository ports will be used. + * @return A string containing the JS commands to create the repository ports. + */ + private String assembleGraphRepositoryPortString(final MIPlugin plugin) { + + final StringBuilder builder = new StringBuilder(); + final int len = plugin.getRepositories().size(); + + for (int i = 0; i < len; i++) { + final MIRepositoryConnector port = plugin.getRepositories().get(i); + + if (i != 0) { + builder.append(','); + } + + builder.append(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_PORT, port.getName(), port.getName(), port.getName())); + } + + return builder.toString(); + } + + /** + * This method assembles the string containing the available input ports of the given filter. + * + * @param filter + * The filter whose input ports will be used. + * @return A string containing the JS commands to create the input ports. + */ + private String assembleGraphInputPortString(final MIFilter filter) { + return this.assembleGraphPortString(filter.getInputPorts()); + } + + /** + * This method assembles the string containing the available output ports of the given plugin. + * + * @param plugin + * The plugin whose output ports will be used. + * @return A string containing the JS commands to create the output ports. + */ + private String assembleGraphOuputPortString(final MIPlugin plugin) { + return this.assembleGraphPortString(plugin.getOutputPorts()); + } + + /** + * This method assembles the ID of the port for the graph based on the given parameters. + * + * @param plugin + * The parent plugin of the port. + * @param port + * The port itself. + * @return The ID for the port within the graph + */ + private String assembleGraphPortID(final MIPlugin plugin, final MIPort port) { + return this.componentMap.get(plugin) + "_" + this.componentMap.get(port); + } + + /** + * Assembles a human-readable string of the given repository, which can also be used as a graph ID. + * + * @param repository + * The repository whose ID should be delivered. + * @return A human readable ID. + */ + private String assembleGraphString(final MIRepository repository) { + final String className = repository.getClassname(); + final String shortName = className.substring(className.lastIndexOf('.') + 1); + return String.format(CurrentAnalysisEditorGraphBean.JS_CMD_NODE, this.componentMap.get(repository), repository.getName(), shortName, className); + } + + /** + * Assembles a human-readable string of the given plugin, which can also be used as a graph ID. + * + * @param plugin + * The plugin whose ID should be delivered. + * @return A human readable ID. + */ + private String assembleGraphString(final MIPlugin plugin) { + final String className = plugin.getClassname(); + final String shortName = className.substring(className.lastIndexOf('.') + 1); + return String.format(CurrentAnalysisEditorGraphBean.JS_CMD_NODE, this.componentMap.get(plugin), plugin.getName(), shortName, className); + } + + /** + * This is the action which can be called from the javascript code to show that a node has been clicked. It informs the connected + * {@link CurrentAnalysisEditorBean} about this. + */ + public void nodeClicked() { + // Get the parameters + final Map<String, String> paramMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); + final String clickedNodeID = paramMap.get("ID"); + + // Now search the correct node + final EObject selectedNode = this.componentMap.get(Integer.parseInt(clickedNodeID)); + this.currentAnalysisEditorBean.nodeSelected(selectedNode); + } + + public void nodeRemoved() { + + } + + /** + * The setter for the field {@link CurrentAnalysisEditorGraphBean#currentAnalysisEditorBean}. + * + * @param currentAnalysisEditorBean + * The new value for this field. + */ + public void setCurrentAnalysisEditorBean(final CurrentAnalysisEditorBean currentAnalysisEditorBean) { + this.currentAnalysisEditorBean = currentAnalysisEditorBean; + } + +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ConnectionFilterToFilter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ConnectionFilterToFilter.java deleted file mode 100644 index 271179985fe9f31501c52ac77670548c9ab7ba4e..0000000000000000000000000000000000000000 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ConnectionFilterToFilter.java +++ /dev/null @@ -1,167 +0,0 @@ -/*************************************************************************** - * Copyright 2012 by - * + Christian-Albrechts-University of Kiel - * + Department of Computer Science - * + Software Engineering Group - * and others. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package kieker.webgui.common; - -import kieker.analysis.model.analysisMetaModel.MIInputPort; -import kieker.analysis.model.analysisMetaModel.MIOutputPort; -import kieker.analysis.model.analysisMetaModel.MIPlugin; - -/** - * This class is a helper class containing a connection between two filters. - * - * @author Nils Christian Ehmke - * @version 1.0 - */ -public class ConnectionFilterToFilter { - /** - * The source filter. - */ - private MIPlugin source; - /** - * The destination filter. - */ - private MIPlugin destination; - /** - * The input port which will be used from the destination. - */ - private MIInputPort inputPort; - /** - * The output port which will be used from the source. - */ - private MIOutputPort outputPort; - - /** - * Creates a new instance of this class using the given parameters. - * - * @param source - * The source filter. - * @param destination - * The destination filter. - * @param inputPort - * The input port which will be used from the destination. - * @param outputPort - * The output port which will be used from the source. - */ - public ConnectionFilterToFilter(final MIPlugin source, final MIPlugin destination, final MIInputPort inputPort, final MIOutputPort outputPort) { - this.source = source; - this.destination = destination; - this.inputPort = inputPort; - this.outputPort = outputPort; - } - - /** - * Delivers the current destination. - * - * @return The destination filter. - */ - public MIPlugin getDestination() { - return this.destination; - } - - /** - * Sets the new destination. - * - * @param destination - * The new destination filter. - */ - public void setDestination(final MIPlugin destination) { - this.destination = destination; - // Make sure that the output port is always valid - if necessary even null. - if (this.destination == null) { - this.outputPort = null; // NOPMD - } - } - - /** - * Delivers the current input port. - * - * @return The input port which will be used from the destination. - */ - public MIInputPort getInputPort() { - return this.inputPort; - } - - /** - * Sets the input port to a new value. - * - * @param inputPort - * The new input port which will be used from the destination. - */ - public void setInputPort(final MIInputPort inputPort) { - this.inputPort = inputPort; - } - - /** - * Delivers the current output port. - * - * @return The output port which will be used from the source. - */ - public MIOutputPort getOutputPort() { - return this.outputPort; - } - - /** - * Sets the new output port. - * - * @param outputPort - * The new output port which will be used from the source. - */ - public void setOutputPort(final MIOutputPort outputPort) { - this.outputPort = outputPort; - } - - /** - * Delivers the source filter. - * - * @return The source filter. - */ - public MIPlugin getSource() { - return this.source; - } - - /** - * Sets the source filter to a new value. - * - * @param source - * The new source filter. - */ - public void setSource(final MIPlugin source) { - this.source = source; - // Make sure that the input port is always valid - if necessary even null. - if (this.source == null) { - this.inputPort = null; // NOPMD - } - } - - /** - * Checks whether the current configuration is valid. The configuration is valid if and only if: All four components are not null, the ports exist and are - * compatible. - * - * @return true if and only if all four components are not null, the ports exist and are compatible. - */ - public boolean isValid() { - if ((this.source == null) || (this.destination == null) || (this.inputPort == null) || (this.outputPort == null)) { - return false; - } - // TODO: This is currently not necessarily valid - return true; - } -} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ConnectionFilterToRepository.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ConnectionFilterToRepository.java deleted file mode 100644 index ac7185b2eb3e76366f8d684f30650f5cb39e86d7..0000000000000000000000000000000000000000 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ConnectionFilterToRepository.java +++ /dev/null @@ -1,138 +0,0 @@ -/*************************************************************************** - * Copyright 2012 by - * + Christian-Albrechts-University of Kiel - * + Department of Computer Science - * + Software Engineering Group - * and others. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package kieker.webgui.common; - -import kieker.analysis.model.analysisMetaModel.MIPlugin; -import kieker.analysis.model.analysisMetaModel.MIRepository; -import kieker.analysis.model.analysisMetaModel.MIRepositoryConnector; - -/** - * This class is a helper class containing a connection between a filter and a repository. - * - * @author Nils Christian Ehmke - * @version 1.0 - */ -public class ConnectionFilterToRepository { - - /** - * The source filter. - */ - private MIPlugin source; - /** - * The destination repository. - */ - private MIRepository destination; - /** - * The repository port which will be used from the source. - */ - private MIRepositoryConnector outputPort; - - /** - * Creates a new instance of this class using the given parameters. - * - * @param source - * The source filter. - * @param destination - * The destination repository. - * @param outputPort - * The repository port which will be used from the source. - */ - public ConnectionFilterToRepository(final MIPlugin source, final MIRepository destination, final MIRepositoryConnector outputPort) { - this.source = source; - this.destination = destination; - this.outputPort = outputPort; - } - - /** - * Delivers the current destination. - * - * @return The destination filter. - */ - public MIRepository getDestination() { - return this.destination; - } - - /** - * Sets the new destination. - * - * @param destination - * The new destination filter. - */ - public void setDestination(final MIRepository destination) { - this.destination = destination; - } - - /** - * Delivers the current output port. - * - * @return The output port which will be used from the source. - */ - public MIRepositoryConnector getOutputPort() { - return this.outputPort; - } - - /** - * Sets the new output port. - * - * @param outputPort - * The new output port which will be used from the source. - */ - public void setOutputPort(final MIRepositoryConnector outputPort) { - this.outputPort = outputPort; - } - - /** - * Delivers the source filter. - * - * @return The source filter. - */ - public MIPlugin getSource() { - return this.source; - } - - /** - * Sets the source filter to a new value. - * - * @param source - * The new source filter. - */ - public void setSource(final MIPlugin source) { - this.source = source; - // Make sure that the input port is always valid - if necessary even null. - if (this.source == null) { - this.outputPort = null; // NOPMD - } - } - - /** - * Checks whether the current configuration is valid. The configuration is valid if and only if: All four components are not null, the ports exist and are - * compatible. - * - * @return true if and only if all four components are not null, the ports exist and are compatible. - */ - public boolean isValid() { - if ((this.source == null) || (this.destination == null) || (this.outputPort == null)) { - return false; - } - // TODO: This is currently not necessarily valid - return true; - } -} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java index 3b50267b2b2e643330882bb98036114281be5288..7d1675b21ba5b84dc78137741fcf425798ad2b58 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java @@ -662,6 +662,10 @@ public final class FSManager { // NOCS (Class Data Abstraction Coupling, Class F } } + // Add the kieker lib! + final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + libs.add(contextClassLoader.getResource(Global.KIEKER_LIB)); + // Now assemble the URL class loader final PrivilegedClassLoaderAction action = new PrivilegedClassLoaderAction(libs); return AccessController.doPrivileged(action); @@ -744,8 +748,13 @@ public final class FSManager { // NOCS (Class Data Abstraction Coupling, Class F */ @Override public URLClassLoader run() { - return new URLClassLoader(this.libs.toArray(new URL[this.libs.size()]), AnalysisController.class.getClassLoader()); + // We use "null" as an explicit parent to make sure that the class loader is completely independent from the web gui class loader. + return new URLClassLoader(this.libs.toArray(new URL[this.libs.size()]), null); } } + public URL getKiekerURL() { + return Thread.currentThread().getContextClassLoader().getResource(Global.KIEKER_LIB); + } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Global.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/Global.java index d7dfb7b14ccf38bb513aa8dc8c51020b0c9396b9..f95d34500921678ef5e49f44a5d222da6a098c32 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Global.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/Global.java @@ -28,26 +28,12 @@ package kieker.webgui.common; * @version 1.0 */ public final class Global { - /** - * This is the name of the page for the analysis controller. The page name has been modified to use a redirect of the browser. - */ - public static final String PAGE_ANALYSIS_CONTROLLER = "Controller.xhtml?faces-redirect=true"; /** * This is the name of the page for the project overview. The page name has been modified to use a redirect of the browser. */ public static final String PAGE_PROJECT_OVERVIEW = "ProjectOverview.xhtml?faces-redirect=true"; - /** - * This is the name of the page for the cockpit. The page name has been modified to use a redirect of the browser. - */ - public static final String PAGE_ANALYSIS_COCKPIT = "Cockpit.xhtml?faces-redirect=true"; - /** - * This is the name of the page for the cockpit editor. The page name has been modified to use a redirect of the browser. - */ - public static final String PAGE_ANALYSIS_VIEW_WORK_SPACE = "CockpitEditor.xhtml?faces-redirect=true"; - /** - * This is the name of the page for the analysis editor. The page name has been modified to use a redirect of the browser. - */ - public static final String PAGE_PROJECT_WORK_SPACE = "AnalysisEditor.xhtml?faces-redirect=true"; + + public static final String KIEKER_LIB = "kieker-1.6-SNAPSHOT_emf.jar"; /** * Default constructor. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java index 69282df63d1fa047bc251b235a51de3117908b4f..61bfd759c46625af4c9d100646cd7ab09aaded45 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java @@ -19,14 +19,13 @@ ***************************************************************************/ package kieker.webgui.common; -import java.io.File; import java.io.IOException; +import java.lang.annotation.Annotation; import java.net.URL; import java.util.ArrayList; -import java.util.Enumeration; import java.util.List; import java.util.jar.JarEntry; -import java.util.jar.JarFile; +import java.util.jar.JarInputStream; import kieker.analysis.plugin.AbstractPlugin; import kieker.analysis.plugin.annotation.Plugin; @@ -41,11 +40,28 @@ import kieker.analysis.repository.annotation.Repository; */ public final class PluginFinder { + private final ClassLoader classLoader; + private final Class<? extends Annotation> repositoryAnnotationClass; + private final Class<?> abstractRepositoryClass; + private final Class<? extends Annotation> pluginAnnotationClass; + private final Class<?> abstractPluginClass; + /** - * Creates a new instance of this class. + * Creates a new instance of this class, using the given class loader. + * + * @param classLoader + * The {@link ClassLoader} which will be used to load the classes. + * @throws ClassNotFoundException */ - private PluginFinder() { - // No code necessary. + @SuppressWarnings("unchecked") + public PluginFinder(final ClassLoader classLoader) throws ClassNotFoundException { + this.classLoader = classLoader; + + // Load the necessary classes and annotations for a correct comparison + this.repositoryAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Repository.class.getCanonicalName()); + this.abstractRepositoryClass = classLoader.loadClass(AbstractRepository.class.getCanonicalName()); + this.pluginAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Plugin.class.getCanonicalName()); + this.abstractPluginClass = classLoader.loadClass(AbstractPlugin.class.getCanonicalName()); } /** @@ -53,20 +69,20 @@ public final class PluginFinder { * * @param url * The url for the jar. - * @param classLoader - * The class loader used to load the classes. * @return A list containing all available repository-classes or null, if an exception occurred. */ @SuppressWarnings("unchecked") - public static List<Class<AbstractRepository>> getAllRepositoriesWithinJar(final URL url, final ClassLoader classLoader) { - final List<Class<?>> clazzes = PluginFinder.getAllClassesWithinJar(url, classLoader); + public List<Class<AbstractRepository>> getAllRepositoriesWithinJar(final URL url) { + // Get a list containing all available classes within the given jar + final List<Class<?>> clazzes = this.getAllClassesWithinJar(url); + List<Class<AbstractRepository>> result = null; if (clazzes != null) { result = new ArrayList<Class<AbstractRepository>>(); for (final Class<?> clazz : clazzes) { // This is the cast resulting in an unchecked cast warning. - if (clazz.isAnnotationPresent(Repository.class) && AbstractRepository.class.isAssignableFrom(clazz)) { + if (clazz.isAnnotationPresent(this.repositoryAnnotationClass) && this.abstractRepositoryClass.isAssignableFrom(clazz)) { result.add((Class<AbstractRepository>) clazz); } } @@ -86,15 +102,15 @@ public final class PluginFinder { * @return A list containing all available plugin-classes or null, if an exception occurred. */ @SuppressWarnings("unchecked") - public static List<Class<AbstractPlugin>> getAllPluginsWithinJar(final URL url, final ClassLoader classLoader) { - final List<Class<?>> clazzes = PluginFinder.getAllClassesWithinJar(url, classLoader); + public List<Class<AbstractPlugin>> getAllPluginsWithinJar(final URL url) { + final List<Class<?>> clazzes = this.getAllClassesWithinJar(url); List<Class<AbstractPlugin>> result = null; if (clazzes != null) { result = new ArrayList<Class<AbstractPlugin>>(); for (final Class<?> clazz : clazzes) { // This is the cast resulting in an unchecked cast warning. - if (clazz.isAnnotationPresent(Plugin.class) && AbstractPlugin.class.isAssignableFrom(clazz)) { + if (clazz.isAnnotationPresent(this.pluginAnnotationClass) && this.abstractPluginClass.isAssignableFrom(clazz)) { result.add((Class<AbstractPlugin>) clazz); } } @@ -112,28 +128,28 @@ public final class PluginFinder { * The class loader used to load the classes. * @return A list containing all available classes or null, if an exception occurred. */ - private static List<Class<?>> getAllClassesWithinJar(final URL url, final ClassLoader classLoader) { + private List<Class<?>> getAllClassesWithinJar(final URL url) { try { - // Open the jar file and run through all entries within this file. - final JarFile jarFile = new JarFile(new File(url.getPath())); final List<Class<?>> result = new ArrayList<Class<?>>(); - final Enumeration<JarEntry> jarEntries = jarFile.entries(); - while (jarEntries.hasMoreElements()) { - final JarEntry jarEntry = jarEntries.nextElement(); + // Open the jar as a stream and run through all entries within this file + final JarInputStream stream = new JarInputStream(url.openStream()); + + JarEntry jarEntry; + while ((jarEntry = stream.getNextJarEntry()) != null) { try { // Assemble the correct name String name = jarEntry.toString(); name = name.replace('/', '.'); name = name.replace(".class", ""); // Try to find a class with the same name and put it into our list - final Class<?> c = classLoader.loadClass(name); + final Class<?> c = this.classLoader.loadClass(name); result.add(c); } catch (final Throwable ex) { // NOPMD (Generic throwable and empty catch block) NOCS (IllegalCatchCheck) // Ignore error. } } // Don't forget to close the jar file again. - jarFile.close(); + stream.close(); return result; } catch (final IOException ex) { ex.printStackTrace(); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginStringConverter.java deleted file mode 100644 index 0d93faa54cce667f45b3c377a61cd1cb68f2446e..0000000000000000000000000000000000000000 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginStringConverter.java +++ /dev/null @@ -1,95 +0,0 @@ -/*************************************************************************** - * Copyright 2012 by - * + Christian-Albrechts-University of Kiel - * + Department of Computer Science - * + Software Engineering Group - * and others. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package kieker.webgui.converter; - -import javax.faces.bean.ManagedBean; -import javax.faces.bean.ManagedProperty; -import javax.faces.bean.ViewScoped; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.convert.Converter; -import javax.faces.convert.FacesConverter; - -import kieker.analysis.model.analysisMetaModel.MIPlugin; -import kieker.webgui.beans.view.CurrentAnalysisEditorBean; - -/** - * This converter can be used to convert a given plugin model instance to a string and vice versa (It uses the object's toString-method). - * - * @author Nils Christian Ehmke - * @version 1.0 - */ -@ViewScoped -@ManagedBean -@FacesConverter(value = MIPluginStringConverter.NAME) -public class MIPluginStringConverter implements Converter { - /** - * This is the name of this converter. - */ - public static final String NAME = "kieker.webgui.converter.MIPluginStringConverter"; - - @ManagedProperty(value = "#{currentAnalysisEditorBean}") - private CurrentAnalysisEditorBean bean; - - /** - * Creates a new instance of this class. - */ - public MIPluginStringConverter() { - /* No code necessary. */ - } - - /** - * The getter for the {@link #bean}-property. - * - * @return {@link #bean} - */ - public CurrentAnalysisEditorBean getBean() { - return this.bean; - } - - /** - * The setter for the {@link #bean}-property. - * - * @param bean - * The new value for {@link #bean}. - */ - public void setBean(final CurrentAnalysisEditorBean bean) { - this.bean = bean; - } - - @Override - public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) { - if (this.bean != null) { - return this.bean.getPluginByID(string); - } else { - return null; - } - } - - @Override - public String getAsString(final FacesContext fc, final UIComponent uic, final Object o) { - if ((this.bean == null) || (o == null)) { - return ""; - } else { - return Integer.toString(this.bean.getPluginID((MIPlugin) o)); - } - } -} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPortStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPortStringConverter.java deleted file mode 100644 index c4c6d2aab86736b43910bc108dd2374c12a6da02..0000000000000000000000000000000000000000 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPortStringConverter.java +++ /dev/null @@ -1,95 +0,0 @@ -/*************************************************************************** - * Copyright 2012 by - * + Christian-Albrechts-University of Kiel - * + Department of Computer Science - * + Software Engineering Group - * and others. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package kieker.webgui.converter; - -import javax.faces.bean.ManagedBean; -import javax.faces.bean.ManagedProperty; -import javax.faces.bean.ViewScoped; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.convert.Converter; -import javax.faces.convert.FacesConverter; - -import kieker.analysis.model.analysisMetaModel.MIPort; -import kieker.webgui.beans.view.CurrentAnalysisEditorBean; - -/** - * This converter can be used to convert a given port model instance to a string and vice versa (It uses the object's toString-method). - * - * @author Nils Christian Ehmke - * @version 1.0 - */ -@ViewScoped -@ManagedBean -@FacesConverter(value = MIPortStringConverter.NAME) -public class MIPortStringConverter implements Converter { - /** - * This is the name of this converter. - */ - public static final String NAME = "kieker.webgui.converter.MIPortStringConverter"; - - @ManagedProperty(value = "#{currentAnalysisEditorBean}") - private CurrentAnalysisEditorBean bean; - - /** - * Creates a new instance of this class. - */ - public MIPortStringConverter() { - /* No code necessary. */ - } - - /** - * The getter for the {@link #bean}-property. - * - * @return {@link #bean} - */ - public CurrentAnalysisEditorBean getBean() { - return this.bean; - } - - /** - * The setter for the {@link #bean}-property. - * - * @param bean - * The new value for {@link #bean}. - */ - public void setBean(final CurrentAnalysisEditorBean bean) { - this.bean = bean; - } - - @Override - public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) { - if (this.bean != null) { - return this.bean.getPortByID(string); - } else { - return null; - } - } - - @Override - public String getAsString(final FacesContext fc, final UIComponent uic, final Object o) { - if ((o == null) || (this.bean == null)) { - return ""; - } else { - return Integer.toString(this.bean.getPortID((MIPort) o)); - } - } -} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIRepositoryStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIRepositoryStringConverter.java deleted file mode 100644 index 74b709d0d5ed2176818ea46f57aca4cdad31ba18..0000000000000000000000000000000000000000 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIRepositoryStringConverter.java +++ /dev/null @@ -1,95 +0,0 @@ -/*************************************************************************** - * Copyright 2012 by - * + Christian-Albrechts-University of Kiel - * + Department of Computer Science - * + Software Engineering Group - * and others. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package kieker.webgui.converter; - -import javax.faces.bean.ManagedBean; -import javax.faces.bean.ManagedProperty; -import javax.faces.bean.ViewScoped; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.convert.Converter; -import javax.faces.convert.FacesConverter; - -import kieker.analysis.model.analysisMetaModel.MIRepository; -import kieker.webgui.beans.view.CurrentAnalysisEditorBean; - -/** - * This converter can be used to convert a given repository model instance to a string and vice versa (It uses the object's toString-method). - * - * @author Nils Christian Ehmke - * @version 1.0 - */ -@ViewScoped -@ManagedBean -@FacesConverter(value = MIRepositoryStringConverter.NAME) -public class MIRepositoryStringConverter implements Converter { - /** - * This is the name of this converter. - */ - public static final String NAME = "kieker.webgui.converter.MIRepositoryStringConverter"; - - @ManagedProperty(value = "#{currentAnalysisEditorBean}") - private CurrentAnalysisEditorBean bean; - - /** - * Creates a new instance of this class. - */ - public MIRepositoryStringConverter() { - /* No code necessary. */ - } - - /** - * The getter for the {@link #bean}-property. - * - * @return {@link #bean} - */ - public CurrentAnalysisEditorBean getBean() { - return this.bean; - } - - /** - * The setter for the {@link #bean}-property. - * - * @param bean - * The new value for {@link #bean}. - */ - public void setBean(final CurrentAnalysisEditorBean bean) { - this.bean = bean; - } - - @Override - public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) { - if (this.bean != null) { - return this.bean.getRepositoryByID(string); - } else { - return null; - } - } - - @Override - public String getAsString(final FacesContext fc, final UIComponent uic, final Object o) { - if ((o == null) || (this.bean == null)) { - return ""; - } else { - return Integer.toString(this.bean.getRepositoryID((MIRepository) o)); - } - } -} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/package-info.java deleted file mode 100644 index fcfc7bfd311476924c6500b85168e01187e05e94..0000000000000000000000000000000000000000 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * Copyright 2012 by - * + Christian-Albrechts-University of Kiel - * + Department of Computer Science - * + Software Engineering Group - * and others. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -/** - * This package contains JSF converters. - * - * @author Nils Christian Ehmke - */ -package kieker.webgui.converter; \ No newline at end of file diff --git a/Kieker.WebGUI/bin/data/Bookstore-Example/lib/kieker-1.6-SNAPSHOT_emf.jar b/Kieker.WebGUI/src/main/resources/kieker-1.6-SNAPSHOT_emf.jar similarity index 74% rename from Kieker.WebGUI/bin/data/Bookstore-Example/lib/kieker-1.6-SNAPSHOT_emf.jar rename to Kieker.WebGUI/src/main/resources/kieker-1.6-SNAPSHOT_emf.jar index cc37c36997b46247562a736d8e1268d68a6a8101..f0843203d315bb79a3cb532099ccad9ba42a78a3 100644 Binary files a/Kieker.WebGUI/bin/data/Bookstore-Example/lib/kieker-1.6-SNAPSHOT_emf.jar and b/Kieker.WebGUI/src/main/resources/kieker-1.6-SNAPSHOT_emf.jar differ diff --git a/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml b/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml index 75e76745660ef3d730c458efa4de72833f192231..446a671d4126a3e7bf1635fc324eb9c32e6ac79e 100644 --- a/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml +++ b/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml @@ -55,8 +55,8 @@ <p:remoteCommand autoRun="true" name="init" action="#{currentAnalysisEditorBean.initializeGraph()}" /> </h:form> <h:form id="hiddenNodeProperties" style="display:none"> - <p:remoteCommand name="nodeClickCommand" action="#{currentAnalysisEditorBean.nodeClicked()}" update=":propertiesForm"/> - <p:remoteCommand name="nodeRemoveCommand" action="#{currentAnalysisEditorBean.nodeRemoved()}" update=":propertiesForm"/> + <p:remoteCommand name="nodeClickCommand" action="#{currentAnalysisEditorGraphBean.nodeClicked()}" update=":propertiesForm"/> + <p:remoteCommand name="nodeRemoveCommand" action="#{currentAnalysisEditorGraphBean.nodeRemoved()}" update=":propertiesForm"/> </h:form> <p:layout fullPage="true"> @@ -94,11 +94,10 @@ <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-refresh" value=" Reload Project" ajax="false" url="analysisEditor?projectName=#{currentAnalysisEditorBean.projectName}" disabled="#{empty currentAnalysisEditorBean.project}" /> <p:separator/> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-bookmark" value=" Manage Libraries" onclick="manageLibrariesDialog.show()" ajax="true" disabled="#{empty currentAnalysisEditorBean.project}"/> - <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-shuffle" ajax="true" value=" Edit Connections" update=":connectionDialogForm" onclick="connectionDialog.show();" disabled="#{empty currentAnalysisEditorBean.project}"/> <p:separator /> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-gear" value=" Settings" onclick="settingsDlg.show()" ajax="true"/> <p:separator /> - <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-circle-close" value=" Close Project" action="#{currentAnalysisEditorBean.clearProject()}" ajax="false"/> + <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-circle-close" value=" Close Project" action="ProjectOverview.xhtml" ajax="false"/> </p:submenu> <p:submenu label="Help"> @@ -241,9 +240,6 @@ <!-- Include the about-dialog. --> <ui:include src="dialogs/aboutDialog.xhtml" /> - <!-- Include the dialog to handle the connections. --> - <ui:include src="dialogs/connectionDialog.xhtml" /> - <!-- Include the dialog the manage the libraries. --> <ui:include src="dialogs/manageLibrariesDialog.xhtml" /> diff --git a/Kieker.WebGUI/src/main/webapp/Cockpit.xhtml b/Kieker.WebGUI/src/main/webapp/Cockpit.xhtml index 31ecb088b06ba45d2da2370e7b55ebe2bb5e91e6..4de136caac0468d85c7566672eb9bc75392e67e8 100644 --- a/Kieker.WebGUI/src/main/webapp/Cockpit.xhtml +++ b/Kieker.WebGUI/src/main/webapp/Cockpit.xhtml @@ -50,7 +50,7 @@ <p:submenu label="File"> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-gear" value=" Settings" onclick="settingsDlg.show()" ajax="true"/> <p:separator/> - <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-circle-close" value=" Close Project" action="#{currentCockpitBean.clearProject()}" ajax="false"/> + <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-circle-close" value=" Close Project" action="#{ProjectOverview.xhtml}" ajax="false"/> </p:submenu> <p:submenu label="Help"> diff --git a/Kieker.WebGUI/src/main/webapp/CockpitEditor.xhtml b/Kieker.WebGUI/src/main/webapp/CockpitEditor.xhtml index d0782ba6da1b6764012fdc1ad79453f833710d6a..748b0e60d602373c0e3df3ed5a7d648e8480e74f 100644 --- a/Kieker.WebGUI/src/main/webapp/CockpitEditor.xhtml +++ b/Kieker.WebGUI/src/main/webapp/CockpitEditor.xhtml @@ -55,7 +55,7 @@ <p:separator/> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-gear" value=" Settings" onclick="settingsDlg.show()" ajax="true"/> <p:separator/> - <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-circle-close" value=" Close Project" action="#{currentCockpitEditorBean.clearProject()}" ajax="false"/> + <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-circle-close" value=" Close Project" action="#{ProjectOverview.xhtml}" ajax="false"/> </p:submenu> <p:submenu label="Help"> diff --git a/Kieker.WebGUI/src/main/webapp/Controller.xhtml b/Kieker.WebGUI/src/main/webapp/Controller.xhtml index 9c54e90650b4044d5e795a145960e84ebd6ffccf..cbc4197613a59cf8f3970292a73e287883846e8b 100644 --- a/Kieker.WebGUI/src/main/webapp/Controller.xhtml +++ b/Kieker.WebGUI/src/main/webapp/Controller.xhtml @@ -51,7 +51,7 @@ <p:submenu label="File"> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-gear" value=" Settings" onclick="settingsDlg.show()" ajax="true"/> <p:separator/> - <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-circle-close" value=" Close Controller" action="#{currentControllerBean.clearProject()}" ajax="false"/> + <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-circle-close" value=" Close Controller" action="#{ProjectOverview.xhtml}" ajax="false"/> </p:submenu> <p:submenu label="Help"> diff --git a/Kieker.WebGUI/src/main/webapp/dialogs/connectionDialog.xhtml b/Kieker.WebGUI/src/main/webapp/dialogs/connectionDialog.xhtml deleted file mode 100644 index 6eb68694dd6d4dd83f57ea992af91e5298593f27..0000000000000000000000000000000000000000 --- a/Kieker.WebGUI/src/main/webapp/dialogs/connectionDialog.xhtml +++ /dev/null @@ -1,165 +0,0 @@ -<ui:composition xmlns="http://www.w3.org/1999/xhtml" - xmlns:h="http://java.sun.com/jsf/html" - xmlns:ui="http://java.sun.com/jsf/facelets" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:p="http://primefaces.org/ui" - xmlns:c="http://java.sun.com/jsp/jstl/core"> - - <p:dialog id="connectionDlg" header="Manage Connections" - resizable="false" modal="true" widgetVar="connectionDialog"> - <h:form id="connectionDialogForm" - rendered="#{not empty currentAnalysisEditorBean.project}"> - - <p:tabView> - <p:tab title="Plugin -> Plugin Connections"> - <p:commandButton value="Add Connection" ajax="true" - action="#{currentAnalysisEditorBean.addConnection()}" - update=":connectionDialogForm" /> - <br /> - <br /> - <p:dataTable editable="true" - value="#{currentAnalysisEditorBean.filterConnections}" - var="connection" paginator="true" rows="10" - paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"> - - <p:column headerText="Source" style="width:125px"> - <p:cellEditor> - <f:facet name="output"> - <h:outputText - value="#{empty connection.source ? 'N/A' : connection.source.name}" /> - </f:facet> - <f:facet name="input"> - <p:selectOneMenu converter="#{mIPluginStringConverter}" - value="#{connection.source}" effectDuration="100"> - <f:selectItem value="#{null}" itemLabel="N/A" itemValue="#{null}" /> - <f:selectItems - value="#{currentAnalysisEditorBean.project.plugins}" - var="plugin" itemLabel="#{plugin.name}" itemValue="#{plugin}" /> - <p:ajax event="change" update="outputPortsList" /> - </p:selectOneMenu> - </f:facet> - </p:cellEditor> - </p:column> - - <p:column headerText="Output Port" style="width:125px"> - <p:cellEditor> - <f:facet name="output"> - <h:outputText - value="#{empty connection.outputPort ? 'N/A' : connection.outputPort.name}" /> - </f:facet> - <f:facet name="input"> - <h:form id="outputPortsList"> - <p:selectOneMenu rendered="#{not empty connection.source}" converter="#{mIPortStringConverter}" - value="#{connection.outputPort}" effectDuration="100"> - <f:selectItem value="#{null}" itemLabel="N/A" - itemValue="#{null}" /> - <f:selectItems value="#{connection.source.outputPorts}" - var="port" itemLabel="#{port.name}" itemValue="#{port}" /> - <p:ajax event="change" /> - </p:selectOneMenu> - </h:form> - </f:facet> - </p:cellEditor> - </p:column> - - <p:column headerText="Destination" style="width:125px"> - <p:cellEditor> - <f:facet name="output"> - <h:outputText - value="#{empty connection.destination ? 'N/A' : connection.destination.name}" /> - </f:facet> - <f:facet name="input"> - <p:selectOneMenu converter="#{mIPluginStringConverter}" - value="#{connection.destination}" effectDuration="100"> - <f:selectItem value="#{null}" itemLabel="N/A" - itemValue="#{null}" /> - <f:selectItems value="#{currentAnalysisEditorBean.filters}" - var="plugin" itemLabel="#{plugin.name}" itemValue="#{plugin}" /> - <p:ajax event="change" update="inputPortsList" /> - </p:selectOneMenu> - </f:facet> - </p:cellEditor> - </p:column> - - <p:column headerText="Input Port" style="width:125px"> - <p:cellEditor> - <f:facet name="output"> - <h:outputText - value="#{empty connection.inputPort ? 'N/A' : connection.inputPort.name}" /> - </f:facet> - <f:facet name="input"> - <h:form id="inputPortsList"> - <p:selectOneMenu rendered="#{not empty connection.destination}" converter="#{mIPortStringConverter}" - value="#{connection.inputPort}" effectDuration="100"> - <f:selectItem value="#{null}" itemLabel="N/A" - itemValue="#{null}" /> - <f:selectItems value="#{connection.destination.inputPorts}" - var="port" itemLabel="#{port.name}" itemValue="#{port}" /> - <p:ajax event="change" /> - </p:selectOneMenu> - </h:form> - </f:facet> - </p:cellEditor> - </p:column> - - <p:column id="validColumn" headerText="Valid" style="width:50px"> - <h:outputText value="#{connection.valid ? 'True' : 'False'}" /> - </p:column> - - <p:column headerText="Options" style="width:50px"> - <p:rowEditor /> - </p:column> - </p:dataTable> - </p:tab> - - <p:tab title="Plugin -> Repository Connections"> - <p:dataTable editable="true" - value="#{currentAnalysisEditorBean.repoConnections}" - var="connection" paginator="true" rows="10" - paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"> - - <p:column headerText="Source" style="width:125px"> - <h:outputText value="#{connection.source.name}"/> - </p:column> - - <p:column headerText="Repository Port" style="width:125px"> - <h:outputText value="#{connection.outputPort.name}"/> - </p:column> - - <p:column headerText="Destination" style="width:125px"> - <p:cellEditor> - <f:facet name="output"> - <h:outputText value="#{empty connection.destination ? 'N/A' : connection.destination.name}" /> - </f:facet> - <f:facet name="input"> - <p:selectOneMenu converter="#{mIRepositoryStringConverter}" - value="#{connection.destination}" effectDuration="100"> - <f:selectItem value="#{null}" itemLabel="N/A" - itemValue="#{null}" /> - <f:selectItems value="#{currentAnalysisEditorBean.repositories}" - var="repo" itemLabel="#{repo.name}" itemValue="#{repo}" /> - <p:ajax event="change" /> - </p:selectOneMenu> - </f:facet> - </p:cellEditor> - </p:column> - - <p:column id="validColumn" headerText="Valid" style="width:50px"> - <h:outputText value="#{connection.valid ? 'True' : 'False'}" /> - </p:column> - - <p:column headerText="Options" style="width:50px"> - <p:rowEditor /> - </p:column> - </p:dataTable> - </p:tab> - </p:tabView> - <br /> - <hr /> - <div style="text-align: right"> - <p:commandButton value="Ok" action="#{currentAnalysisEditorBean.submitConnections()}" oncomplete="connectionDialog.hide();" /> - </div> - </h:form> - </p:dialog> - <!-- ******************************************************************************** --> -</ui:composition>