Cleaned up the code a little
All checks were successful
Locusworks Team/lsproject/pipeline/head This commit looks good
All checks were successful
Locusworks Team/lsproject/pipeline/head This commit looks good
This commit is contained in:
21
pom.xml
21
pom.xml
@ -22,6 +22,27 @@
|
|||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<finalName>LSProject</finalName>
|
||||||
|
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||||
|
<transformers>
|
||||||
|
<transformer
|
||||||
|
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
|
<mainClass>net.locusworks.lsproject.driver.Program</mainClass>
|
||||||
|
</transformer>
|
||||||
|
</transformers>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@ -28,17 +28,6 @@ public class Program {
|
|||||||
* and System.err are sent instead to a designated console window.
|
* and System.err are sent instead to a designated console window.
|
||||||
*/
|
*/
|
||||||
public static void setupStreams() {
|
public static void setupStreams() {
|
||||||
PrintStream errorStream = new PrintStream(new OutputStream() {
|
|
||||||
@Override
|
|
||||||
public void write(int c) throws IOException {
|
|
||||||
write(new byte[] { Byte.parseByte(Integer.toString(c)) });
|
|
||||||
}
|
|
||||||
|
|
||||||
public void write(byte[] b) {
|
|
||||||
console.writeError(new String(b));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
PrintStream outputStream = new PrintStream(new OutputStream() {
|
PrintStream outputStream = new PrintStream(new OutputStream() {
|
||||||
@Override
|
@Override
|
||||||
public void write(int c) throws IOException {
|
public void write(int c) throws IOException {
|
||||||
@ -50,7 +39,6 @@ public class Program {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//System.setErr(errorStream);
|
|
||||||
System.setOut(outputStream);
|
System.setOut(outputStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@ package net.locusworks.lsproject.gui;
|
|||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.GridLayout;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
@ -12,7 +10,6 @@ import javax.swing.event.TableModelEvent;
|
|||||||
import javax.swing.event.TableModelListener;
|
import javax.swing.event.TableModelListener;
|
||||||
import javax.swing.table.TableModel;
|
import javax.swing.table.TableModel;
|
||||||
|
|
||||||
import net.locusworks.lsproject.driver.Program;
|
|
||||||
import net.locusworks.lsproject.object.Network;
|
import net.locusworks.lsproject.object.Network;
|
||||||
import net.locusworks.lsproject.object.Router;
|
import net.locusworks.lsproject.object.Router;
|
||||||
|
|
||||||
@ -22,7 +19,6 @@ public class CostViewerWindow extends JPanel implements TableModelListener{
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 8571350255455457432L;
|
private static final long serialVersionUID = 8571350255455457432L;
|
||||||
private boolean DEBUG = false;
|
|
||||||
private Router router = null;
|
private Router router = null;
|
||||||
|
|
||||||
|
|
||||||
@ -31,8 +27,7 @@ public class CostViewerWindow extends JPanel implements TableModelListener{
|
|||||||
|
|
||||||
router = _router;
|
router = _router;
|
||||||
|
|
||||||
String[] columnNames = {"Connection",
|
String[] columnNames = {"Connection", "Cost"};
|
||||||
"Cost"};
|
|
||||||
|
|
||||||
int numberOfConnections = router.getConnections().size();
|
int numberOfConnections = router.getConnections().size();
|
||||||
|
|
||||||
@ -102,13 +97,10 @@ public class CostViewerWindow extends JPanel implements TableModelListener{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
router.getConnectionByParticipant(
|
router.getConnectionByParticipant(router.getIpAddress(), otherRouterIp).setCost(newCost);
|
||||||
router.getIpAddress(), otherRouterIp).setCost(newCost);
|
|
||||||
Router otherRouter = Network.getInstance().getRouterByIp(otherRouterIp);
|
Router otherRouter = Network.getInstance().getRouterByIp(otherRouterIp);
|
||||||
otherRouter.getConnectionByParticipant(
|
otherRouter.getConnectionByParticipant(router.getIpAddress(), otherRouterIp).setCost(newCost);
|
||||||
router.getIpAddress(), otherRouterIp).setCost(newCost);
|
} catch (NumberFormatException ex) {
|
||||||
}
|
|
||||||
catch (NumberFormatException ex) {
|
|
||||||
System.out.println("Invalid cost.");
|
System.out.println("Invalid cost.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,9 +360,7 @@ public class RouterViewerWindow extends JFrame implements MouseListener,
|
|||||||
@Override public void keyPressed(KeyEvent e) {
|
@Override public void keyPressed(KeyEvent e) {
|
||||||
keys[e.getKeyCode()] = true;
|
keys[e.getKeyCode()] = true;
|
||||||
|
|
||||||
if (highlightedRouter != null &&
|
if (highlightedRouter != null && !highlightedRouter.equals("") && keys[KeyEvent.VK_DELETE]) {
|
||||||
!highlightedRouter.equals("") &&
|
|
||||||
keys[KeyEvent.VK_DELETE]) {
|
|
||||||
Network.getInstance().removeRouterByIp(highlightedRouter);
|
Network.getInstance().removeRouterByIp(highlightedRouter);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -375,7 +373,7 @@ public class RouterViewerWindow extends JFrame implements MouseListener,
|
|||||||
updateAllRouters();
|
updateAllRouters();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (keys[KeyEvent.VK_S] && ((e.getModifiers() & KeyEvent.VK_CONTROL) == 0)) {
|
else if (keys[KeyEvent.VK_S] && ((e.getModifiersEx() & KeyEvent.VK_CONTROL) == 0)) {
|
||||||
try {
|
try {
|
||||||
Utility.saveNetwork();
|
Utility.saveNetwork();
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
|
|
||||||
import net.locusworks.lsproject.driver.Program;
|
|
||||||
import net.locusworks.lsproject.object.Network;
|
import net.locusworks.lsproject.object.Network;
|
||||||
import net.locusworks.lsproject.object.Router;
|
import net.locusworks.lsproject.object.Router;
|
||||||
import net.locusworks.lsproject.object.helper.DijkstraCallback;
|
import net.locusworks.lsproject.object.helper.DijkstraCallback;
|
||||||
@ -155,15 +154,6 @@ public class RoutingTableWindow extends JFrame implements WindowListener {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRowByFirstCellName(String cellName) {
|
|
||||||
for (int i = 1; i < getRowCount(); i++) {
|
|
||||||
if (columnNames.get(i).endsWith(cellName)) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public int getColumnCount() {
|
@Override public int getColumnCount() {
|
||||||
return columnNames.size();
|
return columnNames.size();
|
||||||
|
@ -2,16 +2,11 @@ package net.locusworks.lsproject.gui;
|
|||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
|
||||||
import net.locusworks.lsproject.driver.Program;
|
|
||||||
import net.locusworks.lsproject.gui.helper.ImageHelper;
|
import net.locusworks.lsproject.gui.helper.ImageHelper;
|
||||||
import net.locusworks.lsproject.object.Network;
|
import net.locusworks.lsproject.object.Network;
|
||||||
import net.locusworks.lsproject.util.Utility;
|
import net.locusworks.lsproject.util.Utility;
|
||||||
|
@ -7,7 +7,6 @@ import org.junit.Before;
|
|||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.locusworks.lsproject.driver.Program;
|
|
||||||
import net.locusworks.lsproject.object.Connection;
|
import net.locusworks.lsproject.object.Connection;
|
||||||
import net.locusworks.lsproject.object.DijkstraEngine;
|
import net.locusworks.lsproject.object.DijkstraEngine;
|
||||||
import net.locusworks.lsproject.object.Network;
|
import net.locusworks.lsproject.object.Network;
|
||||||
|
Reference in New Issue
Block a user