public void run() { WindowBlocker blocker = new WindowBlocker(NearInfinity.getInstance()); blocker.setBlocked(true); List<ResourceEntry> files = new ArrayList<ResourceEntry>(); for (final String fileType : FILETYPES) files.addAll(ResourceFactory.getInstance().getResources(fileType)); ProgressMonitor progress = new ProgressMonitor(NearInfinity.getInstance(), "Searching...", null, 0, files.size()); table = new SortableTable( new String[] {"String", "StrRef"}, new Class[] {Object.class, Integer.class}, new int[] {450, 20}); StringResource.getStringRef(0); strUsed = new boolean[StringResource.getMaxIndex() + 1]; for (int i = 0; i < files.size(); i++) { ResourceEntry entry = files.get(i); Resource resource = ResourceFactory.getResource(entry); if (resource instanceof DlgResource) checkDialog((DlgResource) resource); else if (resource instanceof BcsResource) checkScript((BcsResource) resource); else if (resource instanceof PlainTextResource) checkTextfile((PlainTextResource) resource); else if (resource != null) checkStruct((AbstractStruct) resource); progress.setProgress(i + 1); if (progress.isCanceled()) { JOptionPane.showMessageDialog( NearInfinity.getInstance(), "Operation canceled", "Info", JOptionPane.INFORMATION_MESSAGE); blocker.setBlocked(false); return; } } for (int i = 0; i < strUsed.length; i++) if (!strUsed[i]) table.addTableItem(new UnusedStringTableItem(new Integer(i))); if (table.getRowCount() == 0) JOptionPane.showMessageDialog( NearInfinity.getInstance(), "No unused strings found", "Info", JOptionPane.INFORMATION_MESSAGE); else { table.tableComplete(1); textArea = new JTextArea(10, 40); textArea.setEditable(false); textArea.setWrapStyleWord(true); textArea.setLineWrap(true); JScrollPane scrollText = new JScrollPane(textArea); resultFrame = new ChildFrame("Result", true); save = new JMenuItem("Save"); save.addActionListener(this); JMenu fileMenu = new JMenu("File"); fileMenu.add(save); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); resultFrame.setJMenuBar(menuBar); resultFrame.setIconImage(Icons.getIcon("Find16.gif").getImage()); JLabel count = new JLabel(table.getRowCount() + " unused string(s) found", JLabel.CENTER); count.setFont(count.getFont().deriveFont((float) count.getFont().getSize() + 2.0f)); JScrollPane scrollTable = new JScrollPane(table); scrollTable.getViewport().setBackground(table.getBackground()); JPanel pane = (JPanel) resultFrame.getContentPane(); pane.setLayout(new BorderLayout(0, 3)); pane.add(count, BorderLayout.NORTH); pane.add(scrollTable, BorderLayout.CENTER); JPanel bottomPanel = new JPanel(new BorderLayout()); JPanel searchPanel = SearchMaster.createAsPanel(this, resultFrame); bottomPanel.add(scrollText, BorderLayout.CENTER); bottomPanel.add(searchPanel, BorderLayout.EAST); pane.add(bottomPanel, BorderLayout.SOUTH); table.setFont(BrowserMenuBar.getInstance().getScriptFont()); pane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); table.getSelectionModel().addListSelectionListener(this); resultFrame.pack(); Center.center(resultFrame, NearInfinity.getInstance().getBounds()); resultFrame.setVisible(true); } blocker.setBlocked(false); }
public void hitFound(int nr) { table.getSelectionModel().addSelectionInterval(nr, nr); table.scrollRectToVisible( table.getCellRect(table.getSelectionModel().getMinSelectionIndex(), 0, true)); }