diff --git a/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/runtime/properties/ProjectPropertiesModelTest.java b/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/runtime/properties/ProjectPropertiesModelTest.java index 21a2e56c..28cb48c7 100644 --- a/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/runtime/properties/ProjectPropertiesModelTest.java +++ b/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/runtime/properties/ProjectPropertiesModelTest.java @@ -9,6 +9,7 @@ import java.io.File; import java.io.InputStream; import java.io.PrintStream; +import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URL; import java.net.URLClassLoader; @@ -201,13 +202,13 @@ public void testPmdEnabledTRUE() throws CoreException, PropertiesException { * */ @Test - public void testProjectRuleSet() throws PropertiesException { + public void testProjectRuleSet() throws PropertiesException, UnsupportedEncodingException { final IProjectPropertiesManager mgr = PMDPlugin.getDefault().getPropertiesManager(); final IProjectProperties model = mgr.loadProjectProperties(this.testProject); final IPreferencesManager pmgr = PMDPlugin.getDefault().getPreferencesManager(); ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); - PrintStream out = new PrintStream(byteStream); + PrintStream out = new PrintStream(byteStream, false, StandardCharsets.UTF_8.name()); Assert.assertTrue("A new project is not created with the default plugin ruleset", EclipseUtils .assertRuleSetEquals(model.getProjectRuleSet().getRules(), pmgr.getRuleSet().getRules(), out)); diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java index 5f613158..b7d13502 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java @@ -351,9 +351,8 @@ public static String markerTypeFor(RuleViolation violation) { return PMDRuntimeConstants.PMD_MARKER_4; case LOW: return PMDRuntimeConstants.PMD_MARKER_5; - default: - return PMDRuntimeConstants.PMD_MARKER; } + return PMDRuntimeConstants.PMD_MARKER; } private void prepareMarkerAccumulator(IFile file) { @@ -418,7 +417,7 @@ private List findReviewedViolations(final IFile file) { boolean findLine = false; boolean comment = false; final Deque pendingReviews = new ArrayDeque<>(); - try (BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()))) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents(), file.getCharset()))) { while (reader.ready()) { String line = reader.readLine(); if (line != null) { @@ -491,7 +490,6 @@ private MarkerInfo2 getMarkerInfo(RuleViolation violation, String type) throws P break; case LOW: - default: info.add(IMarker.SEVERITY, IMarker.SEVERITY_INFO); break; } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/DetectCutAndPasteCmd.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/DetectCutAndPasteCmd.java index 533df35a..e9350396 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/DetectCutAndPasteCmd.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/DetectCutAndPasteCmd.java @@ -12,6 +12,7 @@ import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -273,7 +274,7 @@ private void renderReport(CPDReport cpdResult) { byte[] data = new byte[0]; try (ByteArrayOutputStream renderedReport = new ByteArrayOutputStream(); - Writer writer = new OutputStreamWriter(renderedReport);) { + Writer writer = new OutputStreamWriter(renderedReport, StandardCharsets.UTF_8);) { renderer.render(cpdResult, writer); writer.flush(); data = renderedReport.toByteArray(); @@ -286,6 +287,7 @@ private void renderReport(CPDReport cpdResult) { if (reportFile.exists()) { LOG.debug(" Overwriting report file"); reportFile.setContents(contentsStream, true, false, getMonitor()); + reportFile.setCharset(StandardCharsets.UTF_8.name(), getMonitor()); } else { LOG.debug(" Creating report file"); reportFile.create(contentsStream, true, getMonitor()); diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/RenderReportsCmd.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/RenderReportsCmd.java index 74f131e0..1c199b16 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/RenderReportsCmd.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/RenderReportsCmd.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -107,12 +108,13 @@ private void render(Report report, IFolder folder, String reportName, Renderer r LOG.debug(" Creating the report file"); IFile reportFile = folder.getFile(reportName); - try (InputStream contentsStream = new ByteArrayInputStream(reportString.getBytes())) { + try (InputStream contentsStream = new ByteArrayInputStream(reportString.getBytes(StandardCharsets.UTF_8))) { if (reportFile.exists()) { reportFile.setContents(contentsStream, true, false, getMonitor()); } else { reportFile.create(contentsStream, true, getMonitor()); } + reportFile.setCharset(StandardCharsets.UTF_8.name(), getMonitor()); } reportFile.refreshLocal(IResource.DEPTH_INFINITE, getMonitor()); } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesManagerImpl.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesManagerImpl.java index bc75a814..8777e8cc 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesManagerImpl.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesManagerImpl.java @@ -317,10 +317,11 @@ private void writeProjectProperties(final IProject project, final ProjectPropert final IFile propertiesFile = project.getFile(ProjectPropertiesTimestampTupel.PROPERTIES_FILE); if (propertiesFile.exists() && propertiesFile.isAccessible()) { - propertiesFile.setContents(new ByteArrayInputStream(writer.getBytes()), false, false, null); + propertiesFile.setContents(new ByteArrayInputStream(writer.getBytes(StandardCharsets.UTF_8)), false, false, null); } else { - propertiesFile.create(new ByteArrayInputStream(writer.getBytes()), false, null); + propertiesFile.create(new ByteArrayInputStream(writer.getBytes(StandardCharsets.UTF_8)), false, null); } + propertiesFile.setCharset(StandardCharsets.UTF_8.name(), null); } catch (CoreException e) { throw new PropertiesException("Error while writing project properties file for project " + project.getName(), e); } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/IndexedString.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/IndexedString.java index 2f036aca..a2790a3d 100755 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/IndexedString.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/IndexedString.java @@ -6,6 +6,7 @@ import java.util.Collections; import java.util.List; +import java.util.Objects; /** * A string that maintains a set of interesting indicies about itself. @@ -35,4 +36,23 @@ public int compareTo(IndexedString other) { return deltaLength == 0 ? other.string.compareTo(string) : deltaLength; } + @Override + public int hashCode() { + return Objects.hash(string); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + IndexedString other = (IndexedString) obj; + return compareTo(other) == 0; + } } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleGroup.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleGroup.java index 07c8393d..17ba292e 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleGroup.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleGroup.java @@ -8,6 +8,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.Objects; import org.apache.commons.lang3.StringUtils; @@ -143,4 +144,24 @@ public int compareTo(RuleGroup otherGroup) { return id.compareTo(otherGroup.id()); } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RuleGroup other = (RuleGroup) obj; + return Objects.equals(id, other.id); + } } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleTableManager.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleTableManager.java index 23126495..1a0827d7 100755 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleTableManager.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleTableManager.java @@ -830,23 +830,6 @@ public void populateRuleTable() { updateCheckControls(); } - // private void popupRuleSelectionMenu(Event event) { - // - // // have to do it here or else the ruleset var is null in the menu setup - - // timing issue - //// if (rulesetMenusByName == null) { - // // addRulesetMenuOptions(ruleListMenu); - // // new MenuItem(ruleListMenu, SWT.SEPARATOR); - // // addColumnSelectionOptions(ruleListMenu); - //// } - // - // // adjustMenuPrioritySettings(); - //// adjustMenuRulesetSettings(); - //// adjustMenuUseDefaultsOption(); - //// ruleListMenu.setLocation(event.x, event.y); - //// ruleListMenu.setVisible(true); - // } - @Override protected void redrawTable(String sortColumnLabel, int sortDir) { groupBy(groupingColumn); diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/RulePanelManager.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/RulePanelManager.java index fbdbfc15..8975f716 100755 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/RulePanelManager.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/RulePanelManager.java @@ -445,10 +445,6 @@ private void implementationType(ImplementationType type) { implementationTypeCombo.deselectAll(); break; } - - default: { - throw new IllegalStateException(); - } } validateRuleParams(); } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/quickfix/PMDResolution.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/quickfix/PMDResolution.java index fa53502d..c212fed2 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/quickfix/PMDResolution.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/quickfix/PMDResolution.java @@ -92,7 +92,7 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException, Inte monitor.worked(1); String fixCode = this.fix.fix(sw.toString(), this.lineNumber); - file.setContents(new ByteArrayInputStream(fixCode.getBytes()), false, true, monitor); + file.setContents(new ByteArrayInputStream(fixCode.getBytes(file.getCharset())), false, true, monitor); monitor.worked(1); } catch (CoreException e) { diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewContentProvider.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewContentProvider.java index 63a91e30..c9cd117e 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewContentProvider.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewContentProvider.java @@ -293,208 +293,6 @@ public void run() { }); } - // public void resourceChanged(IResourceChangeEvent event) { - // - // LOG.debug("resource changed event"); - // - // List markerDeltas = MarkerUtil.markerDeltasIn(event); - // - // // first we get a List of changes to Files and Projects - // // so we won't need updating everything - // List changedFiles = new ArrayList(); - // List changedProjects = new ArrayList(); - // for (IMarkerDelta markerDelta : markerDeltas) { - // IResource resource = markerDelta.getResource(); - // IProject project = resource.getProject(); - // - // // the lists should not contain Projects or Resources twice - // - // if (!changedFiles.contains(resource)) { - // changedFiles.add(resource); - // LOG.debug("Resource " + resource.getName() + " has changed"); - // } - // - // if (!changedProjects.contains(project)) { - // changedProjects.add(project); - // LOG.debug("Project " + project.getName() + " has changed"); - // } - // } - // - // // we can add, change or remove Resources - // // all this changes are given to the viewer later - // final List additions = new ArrayList(); - // final List removals = new ArrayList(); - // final List changes = new ArrayList(); - // - // // we go through the changed Projects - // for (IProject project : changedProjects) { - // LOG.debug("Processing changes for project " + project.getName()); - // ProjectRecord projectRec = (ProjectRecord) root.findResource(project); - // - // // if the Project is closed or deleted, - // // we also delete it from the Model and go on - // if (!(project.isOpen() && project.isAccessible())) { - // LOG.debug("The project is not open or not accessible. Remove it"); - // List[] array = updateFiles(project, changedFiles); - // removals.addAll(array[1]); - // root.removeResource(project); - // } - // - // // if we couldn't find the Project - // // then it has to be new - // else if (projectRec == null) { - // LOG.debug("Cannot find a project record for it. Add it."); - // projectRec = (ProjectRecord) root.addResource(project); - // } - // - // // then we can update the Files for the new or updated Project - // List[] array = updateFiles(project, changedFiles); - // additions.addAll(array[0]); - // removals.addAll(array[1]); - // changes.addAll(array[2]); - // } - // - // // the additions, removals and changes are given to the viewer - // // so that it can update itself - // // updating the table MUST be in sync - // treeViewer.getControl().getDisplay().syncExec(new Runnable() { - // public void run() { - // updateViewer(additions, removals, changes); - // } - // }); - // } - - /** - * Updates the Files for a given Project - * - * @param project - * @param changedFiles, - * a List of all changed Files - * @return an List of Lists containing additions [0], removals [1] and changes [2] (Array-Position in Brackets) - */ - // protected List[] updateFiles(IProject project, List changedFiles) { - // - // final List additions = new ArrayList(); - // final List removals = new ArrayList(); - // final List changes = new ArrayList(); - // List[] updatedFiles = new List[] { additions, removals, changes }; - // - // // we search for the ProjectRecord to the Project - // // if it doesn't exist, we return nothing - // final ProjectRecord projectRec = (ProjectRecord) root.findResource(project); - // - // // we got through all files - // if (projectRec != null && project.isAccessible()) { - // updatedFiles = ChangeEvaluator.searchProjectForModifications(projectRec, changedFiles); - // } - // - // // if the project is deleted or closed - // else if (projectRec != null) { - // final List packages = projectRec.getChildrenAsList(); - // // ... we add all Packages to the removals - // // so they are not shown anymore - // removals.addAll(packages); - // for (int k = 0; k < packages.size(); k++) { - // final PackageRecord packageRec = (PackageRecord) packages.get(k); - // removals.addAll(packageRec.getChildrenAsList()); - // } - // updatedFiles = new List[] { additions, removals, changes }; - // } - // - // return updatedFiles; - // } - - // /** - // * Analyzes the modification inside a single project and compute the list of additions, updates and removals. - // * - // * @param projectRec - // * @param changedFiles - // * @return - // */ - // private List[] searchProjectForModifications(ProjectRecord projectRec, List - // changedFiles) { - // final List additions = new ArrayList(); - // final List removals = new ArrayList(); - // final List changes = new ArrayList(); - // final IProject project = (IProject) projectRec.getResource(); - // - // LOG.debug("Analyses project " + project.getName()); - // - // for (IResource resource : changedFiles) { - // LOG.debug("Analyses resource " + resource.getName()); - // - // // ... and first check, if the project is the right one - // if (project.equals(resource.getProject())) { - // final AbstractPMDRecord rec = projectRec.findResource(resource); - // if (rec != null && rec.getResourceType() == IResource.FILE) { - // final FileRecord fileRec = (FileRecord) rec; - // fileRec.updateChildren(); - // if (fileRec.getResource().isAccessible() && fileRec.hasMarkers()) { - // LOG.debug("The file has changed"); - // changes.add(fileRec); - // } else { - // LOG.debug("The file has been removed"); - // projectRec.removeResource(fileRec.getResource()); - // removals.add(fileRec); - // - // // remove parent if no more markers - // final PackageRecord packageRec = (PackageRecord) fileRec.getParent(); - // if (!packageRec.hasMarkers()) { - // projectRec.removeResource(fileRec.getParent().getResource()); - // removals.add(packageRec); - // } - // } - // } else if (rec == null) { - // LOG.debug("This is a new file."); - // final AbstractPMDRecord fileRec = projectRec.addResource(resource); - // additions.add(fileRec); - // } else { - // LOG.debug("The resource found is not a file! type found : " + rec.getResourceType()); - // } - // } else { - // LOG.debug("The project resource is not the same! (" + resource.getProject().getName() + ')'); - // } - // } - // - // return new List[] { additions, removals, changes }; - // } - - /** - * Applies found updates on the table, adapted from Philippe Herlin - * - * @param additions - * @param removals - * @param changes - */ - // protected void updateViewer(List additions, List removals, - // List changes) { - // - // // perform removals - // if (removals.size() > 0) { - // treeViewer.cancelEditing(); - // treeViewer.remove(removals.toArray()); - // } - // - // // perform additions - // if (additions.size() > 0) { - // for (int i = 0; i < additions.size(); i++) { - // final AbstractPMDRecord addedRec = additions.get(i); - // if (addedRec instanceof FileRecord) { - // treeViewer.add(addedRec.getParent(), addedRec); - // } else { - // treeViewer.add(root, addedRec); - // } - // } - // } - // - // // perform changes - // if (changes.size() > 0) { - // treeViewer.update(changes.toArray(), null); - // } - // - // violationView.refresh(); - // } - protected void updateViewer(ChangeRecord changes) { // perform removals diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/ASTViewPage.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/ASTViewPage.java index 1f43d5e0..2b16af00 100755 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/ASTViewPage.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/ASTViewPage.java @@ -338,47 +338,6 @@ protected void showMethod(ASTMethodDeclaration pmdMethod) { astViewer.expandAll(); } - /** - * Shows the DataflowGraph (and Dataflow-Anomalies) for a Method. - * - * @param pmdMethod - * Method to show in the graph - */ - // protected void showMethod(final ASTMethodDeclaration pmdMethod) { - // if (pmdMethod != null) { - // - // final String resourceString = getDocument().get(); - // give the Data to the GraphViewer - // astViewer.setVisible(true); - // astViewer.setData(pmdMethod, resourceString); - // astViewer.addMouseListener(new MouseAdapter() { - // - // @Override - // public void mouseDown(MouseEvent e) { - // if (textEditor != null) { - // final int row = (int)((double)e.y / DataflowGraphViewer.ROW_HEIGHT); - // astViewer.getGraph().demark(); - // astViewer.getGraph().markNode(row); - // final int startLine = - // pmdMethod.getDataFlowNode().getFlow().get(row).getLine()-1; - // int offset = 0; - // int length = 0; - // try { - // offset = getDocument().getLineOffset(startLine); - // length = getDocument().getLineLength(startLine); - // } catch (BadLocationException ble) { - // logError(StringKeys.MSGKEY_ERROR_RUNTIME_EXCEPTION + "Exception when - // selecting a line in the editor" , ble); - // } - // textEditor.selectAndReveal(offset, length); - // astViewer.getTree().deselectAll(); - // } - // } - // }); - // showTableArea(isTableShown); - // } - // } - /** * Refreshes the page with a new resource. * diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/dataflow/DataflowGraph.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/dataflow/DataflowGraph.java index d49e07b5..95cd0aad 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/dataflow/DataflowGraph.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/dataflow/DataflowGraph.java @@ -426,7 +426,7 @@ public DataflowGraph(Composite parent, Node node, int radius, int length, int he setSize(parent.getSize()); setBackground(bgColor); - createDataflowGraph(/*node*/); + //createDataflowGraph(/*node*/); } @Override @@ -462,39 +462,6 @@ public void setGraphData(int radius, int length) { redraw(); } - /** - * Builds the DataflowGraph out of the given SimpleNode - * - * @param node - */ - private void createDataflowGraph(/*Node node*/) { - //List flow = node.getDataFlowNode().getFlow(); - // - //// the Data-Flow gives us all the Nodes - //// every Node has children, for which we can build Paths - //for (int i = 0; i < flow.size(); i++) { - // DataFlowNode inode = flow.get(i); - // - // // create a new Node and add it to the List - // Point location = new Point((getSize().x - 2 * nodeRadius) / 2, i * rowHeight + lineLength / 2); - // NodeCanvas nod = new NodeCanvas(this, inode, location, nodeRadius); - // nodes.add(nod); - // - // // get the Nodes children and build Paths between them - // List children = inode.getChildren(); - // for (DataFlowNode dfNode : children) { - // - // // create a new Path and add it to the List - // int x = (getSize().x - 2 * nodeRadius) / 2; - // int y1 = inode.getIndex() * rowHeight + lineLength / 2; - // int y2 = dfNode.getIndex() * rowHeight + lineLength / 2; - // - // PathCanvas path = new PathCanvas(this, inode.getIndex(), dfNode.getIndex(), x, y1, y2, nodeRadius); - // paths.add(path); - // } - //} - } - /** * Returns the graphical Node of the given Index * @@ -515,27 +482,6 @@ private NodeCanvas getNode(int index) { return null; } - /** - * Returns the Path between the given Indexes - * - * @param index1 - * @param index2 - * @return the Path - */ - //private PathCanvas getPath(int index1, int index2) { - // if (paths == null) { - // return null; - // } - // - // for (PathCanvas path : paths) { - // if (path.getIndex1() == index1 && path.getIndex2() == index2) { - // return path; - // } - // } - // - // return null; - //} - /** * Checks, if a Path in the Graph has been marked * @@ -662,59 +608,4 @@ public void markPath(int line1, int line2, String varName) { redraw(); marked = true; } - - /** - * Recursively finds a Path from the starting Node to the ending Node, the - * visited-List contains Paths, that already have been visited, so the - * Function does not produce Loops, the List should be a new ArrayList() - * when calling this Function. - * - * @param start - * @param end - * @param visited - * @return an List of PathCanvas, that build up the path from Start-Node to - * End-Node or null, if there no such path could be found - */ - //protected List findPath(DataFlowNode start, DataFlowNode end, List visited) { - // - // // this is the break-Condition for the Recursion - // // if the Node's direct children contain the ending Node - // // we return the Path from the current Node to the End - // if (start.getChildren().contains(end)) { - // List found = new ArrayList<>(); - // PathCanvas path = getPath(start.getIndex(), end.getIndex()); - // if (path != null) { - // found.add(path); - // return found; - // } - // } else { - // // this is the Search - // for (DataFlowNode node : start.getChildren()) { - // // here we avoid Loops by checking the visited nodes - // if (visited.contains(node)) { - // continue; - // } - // // ... and adding the current Node - // visited.add(node); - // - // // the Recursion: find the Path from - // // the current Node's children to the End - // List isFound = findPath(node, end, visited); - // if (isFound.isEmpty()) { - // continue; - // } else { - // // if a Path (from child to end) is found - // // we can add the Path from this Node to the child - // PathCanvas path2 = isFound.get(0); - // PathCanvas path1 = getPath(start.getIndex(), path2.getIndex1()); - // if (path1 != null) { - // isFound.add(0, path1); - // return isFound; - // } - // } - // } - // } - // - // return Collections.emptyList(); - //} } diff --git a/pom.xml b/pom.xml index d6134d05..a9704cbe 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 4.0.10 UTF-8 7.17.0 - 34 + 35 12.0.1 3.6.0 3.28.0