private void changeCurrentNode() { boolean hasMatchSelectedName = false; FileObject[] children = null; try { children = currentFileObject.getChildren(); } catch (Exception e) { e.printStackTrace(); } if (children == null) return; sortFiles(children); String selectedName = historyManager.getSelectedItem(currentFileObject.getName().getPath()); table.removeAll(); TableItem item; for (int i = 0; i < children.length; i++) { FileName fileName = children[i].getName(); if (fileName.getBaseName().equals(selectedName)) { currentRow = i; hasMatchSelectedName = true; } item = new TableItem(table, SWT.NONE); item.setData("fileObject", children[i]); item.setText(fileName.getBaseName()); try { FileType fileType = children[i].getType(); FileContent fileContent = children[i].getContent(); if (fileType.equals(FileType.FOLDER)) { item.setImage(folderImage); item.setText(1, "--"); item.setText(2, StringUtil.formatDate(fileContent.getLastModifiedTime())); } else { item.setImage(fileImage); item.setText(1, StringUtil.formatSize(fileContent.getSize())); item.setText(2, StringUtil.formatDate(fileContent.getLastModifiedTime())); } } catch (Exception e) { e.printStackTrace(); } } if (!hasMatchSelectedName) currentRow = 0; table.setSelection(currentRow); table.setFocus(); }
public void enterPath() { FileObject fileObject = (FileObject) table.getItem(currentRow).getData("fileObject"); try { if (fileObject.getType().equals(FileType.FOLDER)) { historyManager.setSelectedItem( currentFileObject.getName().getPath(), fileObject.getName().getBaseName()); currentFileObject = currentFileObject.getChild(fileObject.getName().getBaseName()); changeCurrentNode(); textLocation.setText(currentFileObject.getName().getPath()); } else { editFile(fileObject); } } catch (Exception e) { e.printStackTrace(); } }
public void upOneDir() { try { // if the currentFileObject is the root of the archive file, do // nothing. if (currentFileObject.getName().getPath().equals("/")) return; FileObject parentFO = currentFileObject.getParent(); if (parentFO != null) { if (table.getItemCount() > 0) { TableItem item = table.getItem(currentRow); FileObject selectFO = (FileObject) item.getData("fileObject"); historyManager.setSelectedItem( currentFileObject.getName().getPath(), selectFO.getName().getBaseName()); } currentFileObject = parentFO; changeCurrentNode(); textLocation.setText(currentFileObject.getName().getPath()); } } catch (Exception e) { e.printStackTrace(); } }