public static void main(String[] args) throws IOException, ClassNotFoundException { File f = new File("objects2.dat"); if (!f.exists()) { System.out.println("Creating objects and writing them to file:"); SC c = new SC(); SO o1 = new SO(1, c), o2 = new SO(2, c); o1.c.ci = 3; o2.c.ci = 4; // update the shared c twice o1.cprint(); o2.cprint(); // prints i1c4 i2c4 OutputStream os = new FileOutputStream(f); ObjectOutputStream oos1 = new ObjectOutputStream(os); oos1.writeObject(o1); oos1.flush(); ObjectOutputStream oos2 = new ObjectOutputStream(os); oos2.writeObject(o2); oos2.close(); System.out.println("\nRun the example again to read objects from file"); } else { System.out.println("Reading objects from file (non-shared c):"); InputStream is = new FileInputStream(f); ObjectInputStream ois1 = new ObjectInputStream(is); SO o1i = (SO) (ois1.readObject()); ObjectInputStream ois2 = new ObjectInputStream(is); SO o2i = (SO) (ois2.readObject()); o1i.cprint(); o2i.cprint(); // prints i1c4 i2c4 o1i.c.ci = 5; o2i.c.ci = 6; // update two different c's o1i.cprint(); o2i.cprint(); // prints i1c5 i2c6 f.delete(); } System.out.println(); }
public void clearFinishedScans() { // Remove via controller int count = controller.removeFinishedScans(); if (count > 0) { // Some were removed - remove all and add back the remaining ones progressModel.removeAllElements(); progressModel.addElement(Constant.messages.getString(prefix + ".toolbar.progress.select")); for (GS scan : controller.getAllScans()) { progressModel.addElement(nameForScanner(scan)); } updateScannerUI(); } clearScansButton.setEnabled(false); }
private JLabel getActiveScansValueLabel() { if (foundCountNameLabel == null) { foundCountNameLabel = new javax.swing.JLabel(); foundCountNameLabel.setText(String.valueOf(controller.getActiveScans().size())); } return foundCountNameLabel; }
private void setActiveScanLabelsEventHandler() { List<GS> ascans = controller.getActiveScans(); getActiveScansValueLabel().setText(String.valueOf(ascans.size())); StringBuilder sb = new StringBuilder(); sb.append("<html>"); for (GS ascan : ascans) { sb.append(ascan.getDisplayName()); sb.append("<br>"); } sb.append("</html>"); final String toolTip = sb.toString(); getActiveScansNameLabel().setToolTipText(toolTip); getActiveScansValueLabel().setToolTipText(toolTip); scanStatus.setScanCount(ascans.size()); this.getClearScansButton().setEnabled(controller.getAllScans().size() - ascans.size() > 0); }
public void trimProgressList() { /* * We only trim scans that have completed, so if the user kicks off a load of scans then * we could have a lot more in the list than the 'maximum' */ if (this.progressModel.getSize() > this.getNumberOfScansToShow() + 1) { // Trim past results - the +1 is for the initial 'select scan' message for (int i = 1; i < this.progressModel.getSize(); i++) { int id = this.idForScannerName((String) this.progressModel.getElementAt(i)); GS scan = controller.getScan(id); if (scan != null && scan.isStopped()) { controller.removeScan(id); this.progressModel.removeElementAt(i); if (this.progressModel.getSize() <= this.getNumberOfScansToShow() + 1) { // Have removed enough break; } // Need to remove more, but the indexes will have changed so go back 1 i--; } } } }
public GS getSelectedScanner() { return controller.getScan( this.idForScannerName((String) this.getProgressSelect().getSelectedItem())); }
@Override public void actionPerformed(ActionEvent AE) { String ActionCommand = AE.getActionCommand(); if (ActionCommand.contains(".menu.")) { String[] description = ActionCommand.split("\\."); if (RB.getString("file").equals(description[0])) { if (description[2].equals(RB.getString("file.Options"))) { ColorUtility.O = new Options(); } } else if (RB.getString("edit").equals(description[0])) { if (description[2].equals(RB.getString("edit.cHex"))) { copytoClipboard(Easyview.hex); if (dologging) Logger.getLogger(ActionHandler.class).info("Copied Hex Color " + Easyview.hex); } else if (description[2].equals(RB.getString("edit.cAHex"))) { copytoClipboard("0x" + Easyview.ahex); if (dologging) Logger.getLogger(ActionHandler.class).info("Copied AHex Color " + "0x" + Easyview.ahex); } else if (description[2].equals(RB.getString("edit.cRGB"))) { copytoClipboard(Easyview.rgb); if (dologging) Logger.getLogger(ActionHandler.class).info("Copied RGB Color " + Easyview.rgb); } else if (description[2].equals(RB.getString("edit.cRGBA"))) { copytoClipboard(Easyview.rgba); if (dologging) Logger.getLogger(ActionHandler.class).info("Copied RGBA Color " + Easyview.rgba); } else if (description[2].equals(RB.getString("edit.pHex"))) { String phex = pastefromClipboard(); if (!phex.startsWith("#")) phex = "#".concat(phex); cc.setColor(Color.decode(phex)); if (dologging) Logger.getLogger(ActionHandler.class).info("Pasted Hex Color " + phex); } else if (description[2].equals(RB.getString("edit.pAHex"))) { String pahex = pastefromClipboard(); if (pahex.startsWith("0x")) pahex = pahex.substring(2); String apahex = pahex.substring(0, 2); // Do something with alpha data pahex = pahex.substring(2); Color C = new Color(Integer.parseInt(pahex, 16)); cc.setColor(C); if (dologging) Logger.getLogger(ActionHandler.class).info("Pasted AHex Color " + pahex); } else if (description[2].equals(RB.getString("edit.pRGB"))) { if (dologging) Logger.getLogger(ActionHandler.class).info("Pasted RGB Color "); } else if (description[2].equals(RB.getString("edit.pRGBA"))) { String prgba = pastefromClipboard(); cc.setColor(new Color(Integer.parseInt(prgba))); if (dologging) Logger.getLogger(ActionHandler.class).info("Pasted RGBA Color " + prgba); } else if (description[2].equals(RB.getString("edit.undo"))) { } else if (description[2].equals(RB.getString("edit.redo"))) { } else if (description[2].equals(RB.getString("IC.invert"))) { IC.actionPerformed( new ActionEvent((Object) this, ActionEvent.ACTION_PERFORMED, "invert")); } else if (description[2].equals(RB.getString("IC.rinvert"))) { IC.actionPerformed( new ActionEvent((Object) this, ActionEvent.ACTION_PERFORMED, "rinvert")); } else if (description[2].equals(RB.getString("IC.ginvert"))) { IC.actionPerformed( new ActionEvent((Object) this, ActionEvent.ACTION_PERFORMED, "ginvert")); } else if (description[2].equals(RB.getString("IC.binvert"))) { IC.actionPerformed( new ActionEvent((Object) this, ActionEvent.ACTION_PERFORMED, "binvert")); } else if (description[2].equals(RB.getString("edit.b"))) { TC.actionPerformed( new ActionEvent((Object) this, ActionEvent.ACTION_PERFORMED, "lighten")); } else if (description[2].equals(RB.getString("edit.d"))) { TC.actionPerformed( new ActionEvent((Object) this, ActionEvent.ACTION_PERFORMED, "darken")); } } else if (RB.getString("modules").equals(description[0])) { if (description[2].equals(AC.getDisplayName())) { AC.actionPerformed(new ActionEvent((Object) this, ActionEvent.ACTION_PERFORMED, "A")); } else if (description[2].equals(DEyed.getDisplayName())) { DEyed.deyedstart.setSelected(!DEyed.deyedstart.isSelected()); DEyed.actionPerformed( new ActionEvent((Object) this, ActionEvent.ACTION_PERFORMED, "DEyed")); } else if (description[2].equals(RC.getDisplayName())) { RC.actionPerformed( new ActionEvent((Object) this, ActionEvent.ACTION_PERFORMED, "random")); } else if (description[2].equals(SC.getDisplayName())) { SC.scroll.setSelected(!SC.scroll.isSelected()); SC.actionPerformed( new ActionEvent((Object) this, ActionEvent.ACTION_PERFORMED, "hscroll")); } } else if (RB.getString("help").equals(description[0])) { if (description[2].equals(RB.getString("help.a"))) { A = new About(); } } } }